// ================================ FEATURE EXTRACTION ================================
@Override
protected String getField(FtrToken token, DEPState state)
{
DEPNode node = state.getNode(token);
if (node == null) return null;
Matcher m;
if (token.isField(JointFtrXml.F_FORM))
{
return node.form;
}
else if (token.isField(JointFtrXml.F_SIMPLIFIED_FORM))
{
return node.simplifiedForm;
}
else if (token.isField(JointFtrXml.F_LEMMA))
{
return node.lemma;
}
else if (token.isField(JointFtrXml.F_POS))
{
return node.pos;
}
else if (token.isField(JointFtrXml.F_DEPREL))
{
return node.getLabel();
}
else if (token.isField(JointFtrXml.F_DISTANCE))
{
int dist = state.getDistance();
return (dist > 6) ? "6" : Integer.toString(dist);
}
else if (token.isField(JointFtrXml.F_LEFT_VALENCY))
{
return state.getLeftValency(node.id);
}
else if (token.isField(JointFtrXml.F_RIGHT_VALENCY))
{
return state.getRightValency(node.id);
}
else if ((m = JointFtrXml.P_BOOLEAN.matcher(token.field)).find())
{
int field = Integer.parseInt(m.group(1));
switch (field)
{
case 0: return state.isLambdaFirst() ? token.field : null;
case 1: return state.isBetaLast() ? token.field : null;
case 2: return state.isLambdaBetaAdjacent() ? token.field : null;
default: throw new IllegalArgumentException("Unsupported feature: "+field);
}
}
else if ((m = JointFtrXml.P_FEAT.matcher(token.field)).find())
{
return node.getFeat(m.group(1));
}
return null;
}