@Override
public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1,
IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
List<Feature> features = new ArrayList<Feature>();
SimpleTree tree = null;
tree = new SimpleTree("BOP");
TreebankNode lca = TreeExtractor.getLCA(AnnotationTreeUtils.annotationNode(jcas, arg1),
AnnotationTreeUtils.annotationNode(jcas, arg2));
SimpleTree arg1Tree = new SimpleTree("ARG1");
SimpleTree arg2Tree = new SimpleTree("ARG2");
tree.addChild(arg1Tree);
List<BaseToken> coveredTokens = JCasUtil.selectCovered(jcas, BaseToken.class, lca);
for(BaseToken token : coveredTokens){
// create pre-terminal tree
SimpleTree tokenTree = new SimpleTree("TOK");
// tokenTree.addChild(new SimpleTree(token.getCoveredText()));
tokenTree.addChild(new SimpleTree(token.getPartOfSpeech()));
// do we add this to one of the arg trees or to the root?
if(token.getEnd() <= arg1.getEnd()){
arg1Tree.addChild(tokenTree);
}else if(token.getBegin() >= arg2.getBegin()){
arg2Tree.addChild(tokenTree);
}else{
SimpleTree termTree = new SimpleTree("TERM");
termTree.addChild(tokenTree);
tree.addChild(termTree);
}
}
tree.addChild(arg2Tree);