String corefType = (anaphor instanceof NEMarkable ? CorefConsts.NE : (anaphor instanceof DemMarkable ? CorefConsts.DEM : CorefConsts.PRON));
// String nodeStr = vec.getVector();
// int label = getLabel(nodeStr);
FSList pairList = pair.getAntecedentList();
while(pairList instanceof NonEmptyFSList){
NonEmptyFSList node = (NonEmptyFSList) pairList;
BooleanLabeledFS labeledProb = (BooleanLabeledFS) node.getHead();
int label = labeledProb.getLabel() ? 1 : 0;
if(anaphora){
if(label == 1) posAnaphInst++;
else negAnaphInst++;
anaphLabels.add(label);
svm_node[] nodes = vecCreator.createAnaphoricityVector(anaphor, jcas);
anaphNodes.add(nodes);
}
Markable antecedent = (Markable) labeledProb.getFeature();
label = (labeler.isGoldPair(anaphor, antecedent) ? 1 : 0);
if(label == 1){
numPos++;
if(corefType.equals(CorefConsts.NE)){
posNeInst++;
// neInds.add(ind);
}else if(corefType.equals(CorefConsts.DEM)){
posDemInst++;
}else if(corefType.equals(CorefConsts.PRON)){
posPronInst++;
}
}
else if(label == 0){
if(corefType.equals(CorefConsts.NE)){
negNeInst++;
// neInds.add(ind);
}else if(corefType.equals(CorefConsts.DEM)){
negDemInst++;
}else if(corefType.equals(CorefConsts.PRON)){
negPronInst++;
}
}
// corefLabels.add(label);
// corefTypes.add(corefType); // need to add it every time so the indices match...
// corefPathTrees.add(pathTree);
if(printVectors){
svm_node[] nodes = vecCreator.getNodeFeatures(anaphor, antecedent, jcas); //getNodes(nodeStr);
// corefNodes.add(nodes);
PrintWriter writer = null;
if(corefType.equals(CorefConsts.NE)){
writer = neOut;
}else if(corefType.equals(CorefConsts.PRON)){
writer = pronOut;
}else if(corefType.equals(CorefConsts.DEM)){
writer = demOut;
}
writer.print(label);
for(svm_node inst : nodes){
writer.print(" ");
writer.print(inst.index);
writer.print(":");
writer.print(inst.value);
}
writer.println();
writer.flush();
}
if(printTrees){
// Markable anaphor = vec.getAnaphor();
// Markable antecedent = vec.getAntecedent();
TreebankNode antecedentNode = MarkableTreeUtils.markableNode(jcas, antecedent.getBegin(), antecedent.getEnd());
TreebankNode anaphorNode = MarkableTreeUtils.markableNode(jcas, anaphor.getBegin(), anaphor.getEnd());
debug.println(TreeUtils.tree2str(antecedentNode));
debug.println(TreeUtils.tree2str(anaphorNode));
// TopTreebankNode pathTree = TreeExtractor.extractPathTree(antecedentNode, anaphorNode, jcas);
SimpleTree pathTree = TreeExtractor.extractPathTree(antecedentNode, anaphorNode);
SimpleTree petTree = TreeExtractor.extractPathEnclosedTree(antecedentNode, anaphorNode, jcas);
// TopTreebankNode tree = mctTree;
// String treeStr = TreeUtils.tree2str(tree);
// String treeStr = mctTree.toString();
String treeStr = pathTree.toString();
PrintWriter writer = null;
if(corefType.equals(CorefConsts.NE)){
writer = neTreeOut;
}else if(corefType.equals(CorefConsts.PRON)){
writer = pronTreeOut;
}else if(corefType.equals(CorefConsts.DEM)){
writer = demTreeOut;
}
writer.print(label == 1 ? "+1" : "-1");
writer.print(" |BT| ");
writer.print(treeStr.replaceAll("\\) \\(", ")("));
writer.println(" |ET|");
}
pairList = node.getTail();
if(label == 1) break;
}
}
if(printVectors){
neOut.close();