IdentifiedAnnotation secondArg, String prefix) {
List<Feature> feats = Lists.newArrayList();
List<TreebankNode> nodes = JCasUtil.selectCovered(TreebankNode.class, primeArg);
if(nodes.size() > 0){
TreebankNode node = nodes.get(0);
if(node.getBegin() == primeArg.getBegin() && node.getEnd() == primeArg.getEnd()){
HashSet<String> priorNPs = new HashSet<String>();
// we have a node with the exact span as the argument
// now check if it is an element of a list
// first move NNs up to their constituent
if(node.getNodeType().startsWith("NN")){
node = node.getParent();
}
TreebankNode parent = node.getParent();
if(parent == null) return feats;
int childIndex = -1;
for(int i = 0; i < parent.getChildren().size(); i++){
if(parent.getChildren(i) == node){
childIndex = i;
break;
}
priorNPs.add(getKey(parent.getChildren(i)));
}
// cnoditions for this arg being an element of a list:
// 1) is NP
// 2) Parent is NP
// 3) left neighbor is , or right neighbor is , or both neigbors are ,
boolean lcComma=false, rcComma=false, lcAnd=false;
if(node.getNodeType().equals("NP") && parent.getNodeType().equals("NP")){
if(childIndex > 0 && parent.getChildren(childIndex-1).getNodeType().equals(",")){
// left child is ","
lcComma = true;
}
if(childIndex+1 < parent.getChildren().size() && parent.getChildren(childIndex+1).getNodeType().equals(",")){
rcComma = true;
}
if(childIndex+1 == parent.getChildren().size() && childIndex > 0 && parent.getChildren(childIndex-1).getNodeType().equals("CC")){
lcAnd = true;
}
}
if(lcComma && rcComma){
feats.add(new Feature(prefix + "_midlist", true));