* @return A set of contextual features about this attachment.
*/
public String[] getContext(Parse[] constituents, int index, List<Parse> rightFrontier, int rfi) {
List<String> features = new ArrayList<String>(100);
int nodeDistance = rfi;
Parse fn = rightFrontier.get(rfi);
Parse fp = null;
if (rfi+1 < rightFrontier.size()) {
fp = rightFrontier.get(rfi+1);
}
Parse p_1 = null;
if (rightFrontier.size() > 0) {
p_1 = rightFrontier.get(0);
}
Parse p0 = constituents[index];
Parse p1 = null;
if (index+1 < constituents.length) {
p1 = constituents[index+1];
}
Collection<Parse> punct1s = null;
Collection<Parse> punct_1s = null;
Collection<Parse> punct_1fs = null;
punct_1fs = fn.getPreviousPunctuationSet();
punct_1s=p0.getPreviousPunctuationSet();
punct1s=p0.getNextPunctuationSet();
String consfp = cons(fp,-3);
String consf = cons(fn,-2);
String consp_1 = cons(p_1,-1);
String consp0 = cons(p0,0);
String consp1 = cons(p1,1);
String consbofp = consbo(fp,-3);
String consbof = consbo(fn,-2);
String consbop_1 = consbo(p_1,-1);
String consbop0 = consbo(p0,0);
String consbop1 = consbo(p1,1);
Cons cfp = new Cons(consfp,consbofp,-3,true);
Cons cf = new Cons(consf,consbof,-2,true);
Cons c_1 = new Cons(consp_1,consbop_1,-1,true);
Cons c0 = new Cons(consp0,consbop0,0,true);
Cons c1 = new Cons(consp1,consbop1,1,true);
//default
features.add("default");
//unigrams
features.add(consfp);
features.add(consbofp);
features.add(consf);
features.add(consbof);
features.add(consp_1);
features.add(consbop_1);
features.add(consp0);
features.add(consbop0);
features.add(consp1);
features.add(consbop1);
//productions
String prod = production(fn,false);
//String punctProd = production(fn,true,punctSet);
features.add("pn="+prod);
features.add("pd="+prod+","+p0.getType());
features.add("ps="+fn.getType()+"->"+fn.getType()+","+p0.getType());
if (punct_1s != null) {
StringBuilder punctBuf = new StringBuilder(5);
for (Iterator<Parse> pi=punct_1s.iterator();pi.hasNext();) {
Parse punct = pi.next();
punctBuf.append(punct.getType()).append(",");
}
//features.add("ppd="+punctProd+","+punctBuf.toString()+p0.getType());
//features.add("pps="+fn.getType()+"->"+fn.getType()+","+punctBuf.toString()+p0.getType());
}