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 Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (!(value instanceof Annotation)) throw new RuntimeException("Invalid value in opinion list"); // System.err.println("Rendering..."+value); Annotation a = (Annotation) value; StringBuilder s = new StringBuilder(a.getType()); s.append(" - "); Map<String, String> features = a.getFeatures(); for (String k : features.keySet()) { s.append(k).append(": ").append(features.get(k)).append(" "); } setText(s.toString()); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); setOpaque(true); return this; }
public static boolean isAdverb(Annotation pos) { final String[] ADV_POS = {"RB", "RBR", "RBS"}; return memberArray(pos.getType(), ADV_POS); }
public static boolean isAdjective(Annotation pos) { final String[] ADJ_POS = {"JJ", "JJR", "JJS"}; return memberArray(pos.getType(), ADJ_POS); }
public static boolean isPossesivePronoun(Annotation pos) { return pos.getType().equals("PRP$"); }
public static boolean isPredeterminer(Annotation pos) { return pos.getType().equals("PDT"); }
public static boolean isProperNoun(Annotation pos) { return pos.getType().startsWith("NNP"); }
public static boolean isCardinalNumber(Annotation pos) { final String[] CN_POS = {"CC"}; return memberArray(pos.getType(), CN_POS); }