JAPE and Gazetteers
1. Check that a word has a certain suffix
We assume that the relevant suffixes are first placed in a gazetteer list with the wholeWordsOnly parameter unchecked.
Rule: CheckSuffix ( {Token.category == JJ} ):tag --> { gate.AnnotationSet tagSet = (gate.AnnotationSet)bindings.get("tag"); gate.Annotation tagAnn = (gate.Annotation)tagSet.iterator().next(); // create a temporary variable for the Lookup value we want to check gate.FeatureMap suffixFM = gate.Factory.newFeatureMap(); suffixFM.put("majorType", "suffix_us"); // check if tag has the suffix we're interested in // AnnotationSet.get(...).get(...).size() > 0 is a useful // pattern for checking overlap. if (inputAS.get(tagAnn.getStartNode().getOffset(), tagAnn.getEndNode().getOffset() ). get("Lookup", suffixFM).size() > 0 ) { gate.FeatureMap features = Factory.newFeatureMap(); features.put("rule", "Suffix_us"); annotations.add(tagAnn.getStartNode(),tagAnn.getEndNode(), "LatinAdj", features); } }