in = new BufferedReader(new InputStreamReader(System.in));
}
else {
in = new BufferedReader(new FileReader(args[ai]));
}
Linker treebankLinker = new TreebankLinker(dataDir,LinkerMode.TEST);
int sentenceNumber = 0;
List<Mention> document = new ArrayList<Mention>();
List<Parse> parses = new ArrayList<Parse>();
for (String line=in.readLine();null != line;line = in.readLine()) {
if (line.equals("")) {
DiscourseEntity[] entities = treebankLinker.getEntities((Mention[]) document.toArray(new Mention[document.size()]));
//showEntities(entities);
new CorefParse(parses,entities).show();
sentenceNumber=0;
document.clear();
parses.clear();
}
else {
Parse p = Parse.parseParse(line);
parses.add(p);
Mention[] extents = treebankLinker.getMentionFinder().getMentions(new DefaultParse(p,sentenceNumber));
//construct new parses for mentions which don't have constituents.
for (int ei=0,en=extents.length;ei<en;ei++) {
//System.err.println("PennTreebankLiner.main: "+ei+" "+extents[ei]);
if (extents[ei].getParse() == null) {
//not sure how to get head index, but its not used at this point.
Parse snp = new Parse(p.getText(),extents[ei].getSpan(),"NML",1.0,0);
p.insert(snp);
extents[ei].setParse(new DefaultParse(snp,sentenceNumber));
}
}
document.addAll(Arrays.asList(extents));
sentenceNumber++;
}
}
if (document.size() > 0) {
DiscourseEntity[] entities = treebankLinker.getEntities((Mention[]) document.toArray(new Mention[document.size()]));
//showEntities(entities);
(new CorefParse(parses,entities)).show();
}
}