I recently ran into the same problem and wrote a few blog notes on using OpenNLP 1.5.x tools. This is a little tight to copy in full, so here is a link with more details .
At a high level, you need to download the appropriate OpenNLP coreference model libraries, as well as the WordNet 3.0 dictionary . Given these dependencies, initializing the linker object is quite simple:
// LinkerMode should be TEST //Note: I tried LinkerMode.EVAL before realizing that this was the problem Linker _linker = new DefaultLinker("lib/opennlp/coref", LinkerMode.TEST);
The use of the linker, however, is slightly less obvious. You need:
- Break content into offers and associated tokens
- Create a Parse Object for Each Offer
Wrap each Parse sentence in such a way as to indicate the order of the sentences:
final DefaultParse parseWrapper = new DefaultParse (parse, idx);
Iterate over each sentence parsing and use the linker to get the Mention objects from each analysis:
final Mention [] extents =
_linker.getMentionFinder (). getMentions (parseWrapper);
Finally, use the linker to identify the various objects in all Mention objects:
DiscourseEntity [] entities = _linker.getEntities (arrayOfAllMentions);
dpdearing
source share