public static WordTag valueOf(String s, String tagDivider) { WordTag result = new WordTag(); result.setFromString(s, tagDivider); return result; }
/** * Make a new label with this <code>String</code> as the value (word). * Any other fields of the label would normally be null. * * @param labelStr The String that will be used for value * @return The new WordTag (tag will be <code>null</code>) */ public Label newLabel(String labelStr) { return new WordTag(labelStr); }
/** * Create a new {@code WordLemmaTag}. * * @param word This word is set as the word of this Label * @param tag The {@code value()} of this Label is set as the * tag of this Label */ public WordLemmaTag(String word, String tag) { WordTag wT = new WordTag(word, tag); this.word = word; this.lemma = Morphology.stemStatic(wT).word(); setTag(tag); }
/** * Return a String representation of the label. For a multipart label, * this will return all parts. The {@code toString()} method * causes a label to spill its guts. It should always return an * empty string rather than {@code null} if there is no value. * * @return a text representation of the full label contents */ @Override public String toString() { return toString(DIVIDER); }
String getWord(History h, int position) { final int p = h.current + position; return (p >= h.start && p <= h.end) ? arr.get(p).word() : "NA"; }
String getTag(History h, int position) { final int p = h.current + position; return (p >= h.start && p <= h.end) ? arr.get(p).tag() : "NA"; }
void setWord(int pos, String word) { arr.get(pos).setWord(word); }
public String word() { return value(); }
void setTag(int pos, String tag) { arr.get(pos).setTag(tag); }
public void setWord(String word) { setValue(word); }
/** * Sets a WordTag from decoding * the {@code String} passed in. The String is divided according * to the divider character (usually, "/"). We assume that we can * always just * divide on the rightmost divider character, rather than trying to * parse up escape sequences. If the divider character isn't found * in the word, then the whole string becomes the word, and the tag * is {@code null}. * * @param wordTagString The word that will go into the {@code Word} */ @Override public void setFromString(String wordTagString) { setFromString(wordTagString, DIVIDER); }
} else if (args[0].equals("-stem")) { for (int i = 1; i < args.length; i++) { System.out.println(args[i] + " --> " + stemStatic(WordTag.valueOf(args[i], "_")));
/** * Orders first by word, then by tag. * * @param wordTag object to compare to * @return result (positive if {@code this} is greater than * {@code obj}, 0 if equal, negative otherwise) */ public int compareTo(WordTag wordTag) { int first = (word != null ? word().compareTo(wordTag.word()) : 0); if(first != 0) return first; else { if (tag() == null) { if (wordTag.tag() == null) return 0; else return -1; } return tag().compareTo(wordTag.tag()); } }
/** * Make a new label with this <code>String</code> as a value component. * Any other fields of the label would normally be null. * * @param labelStr The String that will be used for value * @param options what to make (use labelStr as word or tag) * @return The new WordTag (tag or word will be <code>null</code>) */ public Label newLabel(String labelStr, int options) { if (options == TaggedWordFactory.TAG_LABEL) { return new WordTag(null, labelStr); } else { return new WordTag(labelStr); } }
/** * Create a new {@code WordLemmaTag} from a Label. The value of * the Label corresponds to the word of the WordLemmaTag. * * @param word This word is passed to the supertype constructor * @param tag The {@code value()} of this Label is set as the * tag of this Label */ public WordLemmaTag(Label word, Label tag) { this(word); WordTag wT = new WordTag(word, tag); this.lemma = Morphology.stemStatic(wT).word(); setTag(tag.value()); }
return ((WordLemmaTag) o).toString(separator); } else if (separator != null && o instanceof WordTag) { return ((WordTag) o).toString(separator); } else { return (o.toString());