{"id":1444,"date":"2019-02-10T14:04:34","date_gmt":"2019-02-10T08:34:34","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=1444"},"modified":"2019-02-10T14:36:00","modified_gmt":"2019-02-10T09:06:00","slug":"coreference-resolution-in-stanford-corenlp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/","title":{"rendered":"Coreference Resolution in Stanford CoreNLP"},"content":{"rendered":"<p>In the <a href=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/03\/coreference-resolution-using-spacy\/\" target=\"_blank\" rel=\"noopener\"><em><strong>last article<\/strong><\/em><\/a>, I showed how we can use the <a href=\"https:\/\/github.com\/huggingface\/neuralcoref\" target=\"_blank\" rel=\"noopener\"><em><strong>neuralcoref<\/strong><\/em><\/a>\u00a0library along with <a href=\"https:\/\/spacy.io\" target=\"_blank\" rel=\"noopener\"><em><strong>spaCy<\/strong><\/em><\/a>\u00a0to do coreference resolution (examples involved <em><strong>anaphoric<\/strong><\/em> references). In today&#8217;s article, I want to try the same (well, almost) examples in <a href=\"https:\/\/stanfordnlp.github.io\/CoreNLP\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Stanford CoreNLP<\/strong><\/em><\/a> engine and see how they compare.<\/p>\n<p>Since <em><strong>CoreNLP<\/strong><\/em> is a <em><strong>Java<\/strong><\/em> implementation, I chose to write the test program in <em><strong>Java<\/strong><\/em>. Here is the <a href=\"http:\/\/www.rangakrish.com\/downloads\/CorefExample.java\" target=\"_blank\" rel=\"noopener\"><em><strong>program<\/strong><\/em><\/a><span class=\"Apple-converted-space\">\u00a0\u00a0<\/span>along with the examples.<\/p>\n<figure id=\"attachment_1445\" aria-describedby=\"caption-attachment-1445\" style=\"width: 618px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Program.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"1445\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/program\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Program.jpg\" data-orig-size=\"618,585\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549645616&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"CoreNLP Corereference Example\" data-image-description=\"&lt;p&gt;CoreNLP Corereference Example&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;CoreNLP Corereference Example&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Program.jpg\" class=\"size-full wp-image-1445\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Program.jpg?resize=618%2C585&#038;ssl=1\" alt=\"CoreNLP Corereference Example\" width=\"618\" height=\"585\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Program.jpg?w=618&amp;ssl=1 618w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Program.jpg?resize=300%2C284&amp;ssl=1 300w\" sizes=\"(max-width: 618px) 100vw, 618px\" \/><\/a><figcaption id=\"caption-attachment-1445\" class=\"wp-caption-text\"><strong>CoreNLP Corereference Example<\/strong><\/figcaption><\/figure>\n<p>You can download the <em><strong>CoreNLP<\/strong><\/em> library from <a href=\"https:\/\/stanfordnlp.github.io\/CoreNLP\/download.html\" target=\"_blank\" rel=\"noopener\"><em><strong>here.<\/strong><\/em><\/a><\/p>\n<p>Let us start with the first sentence:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;My sister has a dog and she loves him.&#8221;<\/span><\/p><\/blockquote>\n<p>When I run it through the program, this is the output:<\/p>\n<figure id=\"attachment_1446\" aria-describedby=\"caption-attachment-1446\" style=\"width: 242px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example1.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1446\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example1-13\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example1.jpg\" data-orig-size=\"242,56\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549645742&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-1 Output\" data-image-description=\"&lt;p&gt;Example-1 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-1 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example1.jpg\" class=\"size-full wp-image-1446\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example1.jpg?resize=242%2C56&#038;ssl=1\" alt=\"Example-1 Output\" width=\"242\" height=\"56\" \/><\/a><figcaption id=\"caption-attachment-1446\" class=\"wp-caption-text\"><strong>Example-1 Output<\/strong><\/figcaption><\/figure>\n<p>Strange. It shows that the program has identified <em><strong>&#8220;My sister&#8221;<\/strong><\/em> and <em><strong>&#8220;she&#8221;<\/strong><\/em> as pointing to the same entity, but there is no mention of <em><strong>&#8220;dog&#8221;<\/strong><\/em> and <em><strong>&#8220;him&#8221;<\/strong><\/em>. In contrast, <em><strong>neuralcoref<\/strong><\/em>\u00a0identified both the <em><strong>&#8220;mentions&#8221;<\/strong><\/em> correctly.<\/p>\n<p>Could it be because this is a compound sentence? Let us convert this into two simple sentences:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;My sister has a dog. She loves him.&#8221;<\/span><\/p><\/blockquote>\n<p>Here is the output in this case:<\/p>\n<figure id=\"attachment_1447\" aria-describedby=\"caption-attachment-1447\" style=\"width: 242px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example2.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1447\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example2-9\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example2.jpg\" data-orig-size=\"242,113\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549645661&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-2 Output\" data-image-description=\"&lt;p&gt;Example-2 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-2 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example2.jpg\" class=\"size-full wp-image-1447\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example2.jpg?resize=242%2C113&#038;ssl=1\" alt=\"Example-2 Output\" width=\"242\" height=\"113\" \/><\/a><figcaption id=\"caption-attachment-1447\" class=\"wp-caption-text\"><strong>Example-2 Output<\/strong><\/figcaption><\/figure>\n<p>OK! It is interesting that the program has identified both the <em><strong>&#8220;mentions&#8221;<\/strong><\/em> this time.<\/p>\n<p>I am using the remaining sentences as they were in <em><strong>neuralcoref<\/strong><\/em>\u00a0example. Here is the third sentence:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;My sister has a dog and she loves him. He is cute.&#8221;<\/span><\/p><\/blockquote>\n<p>The output is:<\/p>\n<figure id=\"attachment_1448\" aria-describedby=\"caption-attachment-1448\" style=\"width: 222px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example3.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1448\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example3-8\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example3.jpg\" data-orig-size=\"222,106\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549645867&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-3 Output\" data-image-description=\"&lt;p&gt;Example-3 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-3 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example3.jpg\" class=\"size-full wp-image-1448\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example3.jpg?resize=222%2C106&#038;ssl=1\" alt=\"Example-3 Output\" width=\"222\" height=\"106\" \/><\/a><figcaption id=\"caption-attachment-1448\" class=\"wp-caption-text\"><strong>Example-3 Output<\/strong><\/figcaption><\/figure>\n<p>Although the system has identified <em><strong>&#8220;him&#8221;<\/strong><\/em> and <em><strong>&#8220;he&#8221;<\/strong><\/em> as belonging together, it has omitted <em><strong>&#8220;dog&#8221;<\/strong><\/em> from the reference. Bug! Here also, <em><strong>neuralcoref<\/strong><\/em>\u00a0fared better.<\/p>\n<p>The next example is:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;My sister has a dog and she loves her.&#8221;<\/span><\/p><\/blockquote>\n<p>The output is:<\/p>\n<figure id=\"attachment_1449\" aria-describedby=\"caption-attachment-1449\" style=\"width: 222px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example4.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1449\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example4-6\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example4.jpg\" data-orig-size=\"222,77\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549645929&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-4 Output\" data-image-description=\"&lt;p&gt;Example-4 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-4 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example4.jpg\" class=\"size-full wp-image-1449\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example4.jpg?resize=222%2C77&#038;ssl=1\" alt=\"Example-4 Output\" width=\"222\" height=\"77\" \/><\/a><figcaption id=\"caption-attachment-1449\" class=\"wp-caption-text\"><strong>Example-4 Output<\/strong><\/figcaption><\/figure>\n<p>The behavior is the same as with <em><strong>neuralcoref<\/strong><\/em>. <em><strong>&#8220;dog&#8221;<\/strong><\/em> is not paired with <em><strong>&#8220;her&#8221;<\/strong><\/em>.<\/p>\n<p>Consider the following statement that uses different genders and hence should be easier to resolve:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;My brother has a dog and he loves her.&#8221;<\/span><\/p><\/blockquote>\n<p>This is what we get:<\/p>\n<figure id=\"attachment_1451\" aria-describedby=\"caption-attachment-1451\" style=\"width: 233px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example5.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1451\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example5-6\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example5.jpg\" data-orig-size=\"233,108\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549645981&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-5 Output\" data-image-description=\"&lt;p&gt;Example-5 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-5 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example5.jpg\" class=\"size-full wp-image-1451\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example5.jpg?resize=233%2C108&#038;ssl=1\" alt=\"Example-5 Output\" width=\"233\" height=\"108\" \/><\/a><figcaption id=\"caption-attachment-1451\" class=\"wp-caption-text\"><strong>Example-5 Output<\/strong><\/figcaption><\/figure>\n<p>That is nice! <em><strong>&#8220;dog&#8221;<\/strong><\/em> and <em><strong>&#8220;her&#8221;<\/strong><\/em> are correctly paired. <em><strong>neuralcoref<\/strong><\/em>\u00a0did not handle this case correctly.<\/p>\n<p>Let us look at the next sentence:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;Mary and Julie are sisters. They love chocolates.&#8221;<\/span><\/p><\/blockquote>\n<p><em><strong>neuralcoref<\/strong><\/em>\u00a0handled this case correctly. Strangely, when given this input, <em><strong>CoreNLP<\/strong><\/em> does not identify any <em><strong>&#8220;mentions&#8221;<\/strong><\/em> at all! I confess I am disappointed.<\/p>\n<p>Let us try the next one:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;John and Mary are neighbours. She admires him because he works hard.&#8221;<\/span><\/p><\/blockquote>\n<p>This looks more complex than the earlier one. How does <em><strong>CoreNLP<\/strong><\/em> fare?<\/p>\n<figure id=\"attachment_1452\" aria-describedby=\"caption-attachment-1452\" style=\"width: 201px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example7.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1452\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example7-3\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example7.jpg\" data-orig-size=\"201,124\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549646140&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-7 Output\" data-image-description=\"&lt;p&gt;Example-7 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-7 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example7.jpg\" class=\"size-full wp-image-1452\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example7.jpg?resize=201%2C124&#038;ssl=1\" alt=\"Example-7 Output\" width=\"201\" height=\"124\" \/><\/a><figcaption id=\"caption-attachment-1452\" class=\"wp-caption-text\"><strong>Example-7 Output<\/strong><\/figcaption><\/figure>\n<p>OK, this one is handled correctly. That is a relief.<\/p>\n<p>The next one is tougher:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;X and Y are neighbours. She admires him because he works hard.&#8221;<\/span><\/p><\/blockquote>\n<p>Here is the program&#8217;s output:<\/p>\n<figure id=\"attachment_1453\" aria-describedby=\"caption-attachment-1453\" style=\"width: 200px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example8.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1453\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example8-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example8.jpg\" data-orig-size=\"200,55\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549646202&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-8 Output\" data-image-description=\"&lt;p&gt;Example-8 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-8 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example8.jpg\" class=\"size-full wp-image-1453\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example8.jpg?resize=200%2C55&#038;ssl=1\" alt=\"Example-8 Output\" width=\"200\" height=\"55\" \/><\/a><figcaption id=\"caption-attachment-1453\" class=\"wp-caption-text\"><strong>Example-8 Output<\/strong><\/figcaption><\/figure>\n<p>Not surprised with the behavior. <em><strong>neuralcoref<\/strong><\/em>\u00a0wasn&#8217;t any better.<\/p>\n<p>Here is the last example:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&#8220;The dog chased the cat. But it escaped.&#8221;<\/span><\/p><\/blockquote>\n<p>This is the corresponding output:<\/p>\n<figure id=\"attachment_1454\" aria-describedby=\"caption-attachment-1454\" style=\"width: 209px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example9.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1454\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/example9-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example9.jpg\" data-orig-size=\"209,59\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549646259&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Example-9 Output\" data-image-description=\"&lt;p&gt;Example-9 Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Example-9 Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example9.jpg\" class=\"size-full wp-image-1454\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Example9.jpg?resize=209%2C59&#038;ssl=1\" alt=\"Example-9 Output\" width=\"209\" height=\"59\" \/><\/a><figcaption id=\"caption-attachment-1454\" class=\"wp-caption-text\"><strong>Example-9 Output<\/strong><\/figcaption><\/figure>\n<p>Not correct. Again, the behavior is identical to <em><strong>neuralcoref<\/strong><\/em>.<\/p>\n<p>Let me summarize and show the performance of <em><strong>CoreNLP<\/strong><\/em> and <em><strong>neuralcoref<\/strong><\/em> with respect to the examples:<\/p>\n<figure id=\"attachment_1456\" aria-describedby=\"caption-attachment-1456\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1456\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/10\/coreference-resolution-in-stanford-corenlp\/table\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg\" data-orig-size=\"986,517\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549785049&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Comparison Table\" data-image-description=\"&lt;p&gt;Comparison Table&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Comparison Table&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg\" class=\"wp-image-1456\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg?resize=650%2C341&#038;ssl=1\" alt=\"Comparison Table\" width=\"650\" height=\"341\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg?w=986&amp;ssl=1 986w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg?resize=300%2C157&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Table.jpg?resize=768%2C403&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1456\" class=\"wp-caption-text\"><strong>Comparison Table<\/strong><\/figcaption><\/figure>\n<p>You can see that among the sentences tested in both the systems, <em><strong>neuralcoref<\/strong><\/em>\u00a0got 4 out of 8 correct, whereas <em><strong>CoreNLP<\/strong><\/em> got just 2 out of 8 correct. To clarify, I have marked the output as <em><strong>&#8220;Wrong&#8221;<\/strong><\/em> if the system did not <em><strong>FULLY<\/strong><\/em> identify the <em><strong>mentions<\/strong><\/em>.<\/p>\n<p>Overall, in the case of anaphora resolution, both the popular libraries have fared poorly in my opinion. I expected more out of <em><strong>CoreNLP<\/strong><\/em>, so that was a bigger disappointment!<\/p>\n<p>Looks like there is a lot more work to do in the area of coreference resolution!<\/p>\n<p>You can download my <em><strong>Java<\/strong><\/em> program from <a href=\"http:\/\/www.rangakrish.com\/downloads\/CorefExample.java\" target=\"_blank\" rel=\"noopener\"><em><strong>here.<\/strong><\/em><\/a><\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last article, I showed how we can use the neuralcoref\u00a0library along with spaCy\u00a0to do coreference resolution (examples involved anaphoric references). In today&#8217;s article, I want to try the same (well, almost) examples in Stanford CoreNLP engine and see how they compare. Since CoreNLP is a Java implementation, I chose to write the test [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[107,17],"tags":[186,174,185,190],"class_list":["post-1444","post","type-post","status-publish","format-standard","hentry","category-natural-language-processing","category-programming","tag-coreference-resolution","tag-natural-language-processing","tag-neuralcoref","tag-stanford-corenlp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-ni","jetpack-related-posts":[{"id":1427,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/03\/coreference-resolution-using-spacy\/","url_meta":{"origin":1444,"position":0},"title":"Coreference Resolution Using spaCy","author":"admin","date":"February 3, 2019","format":false,"excerpt":"According to Stanford NLP Group, \"Coreference resolution is the task of finding all expressions that refer to the same entity in a text\".\u00a0 You can also read this Wikipedia page. For example, in the sentence \"Tom dropped the glass jar by accident and broke it\", what does \"it\" refer to?\u2026","rel":"","context":"In &quot;Machine Learning&quot;","block_context":{"text":"Machine Learning","link":"https:\/\/www.rangakrish.com\/index.php\/category\/machine-learning\/"},"img":{"alt_text":"Loading the Coreference Model","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Loading-Model.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1368,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/01\/08\/parsing-text-with-apache-opennlp\/","url_meta":{"origin":1444,"position":1},"title":"Parsing Text with Apache OpenNLP","author":"admin","date":"January 8, 2019","format":false,"excerpt":"In my earlier posts I have written about parsing text using spaCy\u00a0and MeaningCloud's parsing API. For today's article, I decided to take a look at OpenNLP, an open-source ML-based Java toolkit for parsing natural language text. OpenNLP is a fairly mature library and has been around since 2004 (source: Wikipedia).\u2026","rel":"","context":"In &quot;Natural Language Processing&quot;","block_context":{"text":"Natural Language Processing","link":"https:\/\/www.rangakrish.com\/index.php\/category\/natural-language-processing\/"},"img":{"alt_text":"Parse Tree","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/01\/Tree3.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":912,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/04\/22\/question-answering-using-dependency-trees\/","url_meta":{"origin":1444,"position":2},"title":"Question Answering\u00a0Using Dependency Trees","author":"admin","date":"April 22, 2018","format":false,"excerpt":"A few weeks ago I had written about my brief experiment with Mathematica's new feature, which provides answers to questions based on given text. After that post, I spent some time thinking about how to implement something similar. In today's post, I want to show you what I have been\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Dependency Tree","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/04\/Deptree-example.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1386,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/01\/13\/chunking-in-opennlp\/","url_meta":{"origin":1444,"position":3},"title":"Chunking in OpenNLP","author":"admin","date":"January 13, 2019","format":false,"excerpt":"In my previous post, I showed how to parse sentences using OpenNLP. Another useful feature supported by OpenNLP is \"chunking\u201d. That is the subject of today\u2019s article. Chunking stands between part-of-speech tagging and full parse in terms of the information it captures. POS tagging assigns part of speech to individual\u2026","rel":"","context":"In &quot;Natural Language Processing&quot;","block_context":{"text":"Natural Language Processing","link":"https:\/\/www.rangakrish.com\/index.php\/category\/natural-language-processing\/"},"img":{"alt_text":"Printing Chunked Tags with Probability","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/01\/Example3-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/01\/Example3-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/01\/Example3-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2506,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/08\/21\/loop-command-in-ring-programming-language\/","url_meta":{"origin":1444,"position":4},"title":"&#8220;Loop&#8221; Command in Ring Programming Language","author":"admin","date":"August 21, 2021","format":false,"excerpt":"In my last article, I had written about how easy it is to execute Ring code from within C\/C++. Today's article takes a look at the \"Loop\" command. This command is very similar to \"continue\" in many languages such as C++, Java, Python. etc. It is used to skip the\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"\"Continue\" in Java","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/08\/javacode-300x183.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1475,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/24\/emotion-detection-using-paralleldots-api\/","url_meta":{"origin":1444,"position":5},"title":"Emotion Detection using ParallelDots API","author":"admin","date":"February 24, 2019","format":false,"excerpt":"Last week, I showed how we can use IBM Natural Language Understanding API to identify emotions from given text. Today, I would like to run through the same examples, but using ParallelDots API service. There are wrappers\u00a0in Java, Python, Ruby, C#, and PHP for accessing the REST service. However, I\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"The Code","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code-1.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code-1.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code-1.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=1444"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1444\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=1444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=1444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=1444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}