4

I use OpenNLP's coreference package for anaphora resolution. So basically I have this input string:

"Harry writes a letter to his brother. He told him that he met Mary in London. They had a lunch together.";

The set of mentions output are as below:

Harry, his, He, him, he, They

I need to replace the pronouns with its proper nouns. I wrote a simple algorithm for this by adding each mention into a list, then iterate the list while replacing each pronouns with the 1st mention ("Harry"). My problem is "his" will be "Harry" not "Harry's".

There aren't a lot of examples/tutorials on pronoun resolver. I have looked through the OpenNLP API. Either I'm looking in the wrong direction or there is one in the API but I don't know how to use it. Can someone please guide me in the right direction to pronoun resolving or give an example of how to do this? Maybe there's a better way that I didn't know of.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
sw2
  • 357
  • 6
  • 13

1 Answers1

2

What you want is called "co-reference resolution".

Linker _linker = null;

try {
   _linker = new DefaultLinker("lib/opennlp/coref", LinkerMode.TEST);

} catch (final IOException ioe) {
   ioe.printStackTrace();
}

Here's a perfect tutorial with code examples:

http://blog.dpdearing.com/2012/11/making-coreference-resolution-with-opennlp-1-5-0-your-bitch/

Stanford CoreNLP also provides a good model for it.

http://nlp.stanford.edu/software/dcoref.shtml

Aditya
  • 3,080
  • 24
  • 47
  • I actually use an adaption of this. I got the result like I mentioned in my post but there's no tutorial out there that actually teach how to replace the pronouns with its proper nouns. That's why I wrote my own codes to replace it but my problem is "his" is not replaced by "Harry's" as it should be. I want to know if there's a way to do this better than just a simple iteration and replace the pronouns blindly. – sw2 Jun 30 '15 at 11:32