// Extract features between
List<TerminalTreebankNode> headList = this.extractPhraseHeadByTreenode(jCas, JCasUtil.selectCovered(jCas, TreebankNode.class, arg1.getEnd(), arg2.getBegin()));
if(headList.size() > 0) {
features.add(new Feature("PhraseChunk_Between_FirstHead", headList.get(0).getNodeValue()));
features.add(new Feature("PhraseChunk_Between_LastHead", headList.get(headList.size()-1).getNodeValue()));
if(headList.size() >= 2) {
String inBetweenValue = "";
for(int i=1;i<headList.size()-1;i++) {
if(i>1)
inBetweenValue += "_";
inBetweenValue += headList.get(i).getNodeValue();
}
features.add(new Feature("PhraseChunk_Between_BetweenHeads", inBetweenValue));
}
}
// Extract feature before M1
headList = this.extractPhraseHeadByTreenode(jCas, JCasUtil.selectPreceding(jCas, TreebankNode.class, arg1, 20));
boolean isFirst = false;
for(int i=headList.size()-1;i>=0;i--) {
if(headList.get(i).getEnd() < arg1.getBegin()) {
if(!isFirst) {
features.add(new Feature("PhraseChunk_Before_FirstHead", headList.get(i).getNodeValue()));
isFirst = true;
}
else {
features.add(new Feature("PhraseChunk_Before_SecondHead", headList.get(i).getNodeValue()));
break;
}
}
}
// Extract feature after M2
headList = this.extractPhraseHeadByTreenode(jCas, JCasUtil.selectFollowing(jCas, TreebankNode.class, arg2, 20));
isFirst = false;
for(int i=0;i<headList.size();i++) {
if(headList.get(i).getBegin() > arg2.getEnd() ) {
if(!isFirst) {
features.add(new Feature("PhraseChunk_After_FirstHead", headList.get(i).getNodeValue()));
isFirst = true;
}
else {
features.add(new Feature("PhraseChunk_After_SecondHead", headList.get(i).getNodeValue()));
break;
}
}
}