List<Mention> document = new ArrayList<Mention>(1);
ArrayList<opennlp.tools.parser.Parse> parsedSentences = new ArrayList<opennlp.tools.parser.Parse>(
1);
parsedSentences.add(chosen_parse);
Linker treebankLinker = new DefaultLinker(
// LinkerMode should be TEST
//Note: I tried LinkerMode.EVAL for a long time
// before realizing that this was the problem
"models/coref", LinkerMode.TEST);
int sentenceNumber = 0;
Mention[] extents = treebankLinker.getMentionFinder().getMentions(
new DefaultParse(chosen_parse, sentenceNumber));
// construct new parses for mentions which don't have constituents.
// for (int ei = 0, en = extents.length; ei < en; ei++) {
for (final Mention mention : extents) {
// System.err.println("PennTreebankLiner.main: "+ei+" "+extents[ei]);
// if (extents[ei].getParse() == null) {
if (mention.getParse() == null) {
Parse snp = new Parse(p.getText(), mention.getSpan(), "NML",
1.0, null);
p.insert(snp);
mention.setParse(new DefaultParse(snp, sentenceNumber));
}
}
document.addAll(Arrays.asList(extents));
if (document.size() > 0) {
DiscourseEntity[] entities = treebankLinker.getEntities(document
.toArray(new Mention[0]));
// showEntities(entities);
(new CorefParse(Arrays.asList(parses), entities)).show();
}