Annotate NPs within a list of NPs
Rule: List
(
{NP}
((AND) {NP})*
):mention
—>
{
//get the mention annotations in a list
List annList = new ArrayList((AnnotationSet)bindings.get("mention"));
//sort the list by offset
Collections.sort(annList, new OffsetComparator());
//iterate through the matched annotations
for(int i = 0; i < annList.size(); i++)
{
Annotation anAnn = (Annotation)annList.get(i);
// check that the new annotation is an NP
if ((anAnn.getType().equals("NP"))
{
FeatureMap features = Factory.newFeatureMap();
features.put("rule", "List1");
annotations.add(anAnn.getStartNode(), anAnn.getEndNode(), "SomeTag",
features);
}
}
}
page revision: 1, last edited: 24 Nov 2008 17:09