public static Annotation getHeadVerb( Annotation verb, Map<String, AnnotationSet> annotations, String text) { AnnotationSet verbs = annotations.get(Constants.POS).getContained(verb); if (verbs == null || verbs.size() < 1) return verb; Annotation result = verbs.getFirst(); for (Annotation v : verbs) { if (!SyntaxUtils.isPreposition(v.getType())) { result = v; } } return result; }
public static ArticleTypeEnum articleType(Annotation np, Document doc) { String[] indefs = {"a", "an", "one"}; // String[] defs = { "the", "this", "that", "these", "those" }; String[] quans = {"every", "all", "some", "most", "few", "many", "much"}; String[] words = doc.getWords(np); String first = words[0]; if (ProperName.getValue(np, doc)) return ArticleTypeEnum.DEFINITE; if (isPronoun(np, doc)) return ArticleTypeEnum.DEFINITE; if (memberArray(first, indefs)) return ArticleTypeEnum.INDEFINITE; if (memberArray(first, quans)) { if (words.length < 2 || !words[1].equalsIgnoreCase("of")) return ArticleTypeEnum.QUANTIFIED; else return ArticleTypeEnum.DEFINITE; } AnnotationSet pos = doc.getAnnotationSet(Constants.POS); pos = pos.getContained(np); if (pos != null && pos.size() > 0) { if (isCardinalNumber(pos.getFirst()) || isPredeterminer(pos.getFirst())) return ArticleTypeEnum.QUANTIFIED; if (isPossesivePronoun(pos.getFirst()) || isProperNoun(pos.getLast())) return ArticleTypeEnum.DEFINITE; } return ArticleTypeEnum.INDEFINITE; }