/** * Adds lemmas to the given list of CoreLabels, using the given * Morphology object. The input list must already have tags set. */ public static void lemmatize(List<CoreLabel> sentence, Morphology morpha) { for (CoreLabel label : sentence) { morpha.stem(label); } }
/** * Adds the LemmaAnnotation to the given CoreLabel. */ public void stem(CoreLabel label) { stem(label, CoreAnnotations.LemmaAnnotation.class); }
public Word stem(Word w) { return new Word(stem(w.value())); }
private static void addLemma(Morphology morpha, Class<? extends CoreAnnotation<String>> ann, CoreMap map, String word, String tag) { if ( ! tag.isEmpty()) { String phrasalVerb = phrasalVerb(morpha, word, tag); if (phrasalVerb == null) { map.set(ann, morpha.lemma(word, tag)); } else { map.set(ann, phrasalVerb); } } else { map.set(ann, morpha.stem(word)); } }
@Override public Object apply(Object in) { if (in instanceof WordTag) { WordTag wt = (WordTag) in; String tag = wt.tag(); return new WordTag(lemmatize(wt.word(), tag, lexer, lexer.option(1)), tag); } if (in instanceof Word) { return stem((Word) in); } return in; }
/** * Only works on English, as it is hard coded for using the * Morphology class, which is English-only */ public List<CoreLabel> lemmatize(List<? extends HasWord> tokens) { List<TaggedWord> tagged; if (getOp().testOptions.preTag) { Function<List<? extends HasWord>, List<TaggedWord>> tagger = loadTagger(); tagged = tagger.apply(tokens); } else { Tree tree = parse(tokens); tagged = tree.taggedYield(); } Morphology morpha = new Morphology(); List<CoreLabel> lemmas = Generics.newArrayList(); for (TaggedWord token : tagged) { CoreLabel label = new CoreLabel(); label.setWord(token.word()); label.setTag(token.tag()); morpha.stem(label); lemmas.add(label); } return lemmas; }
/** * Adds lemmas to the given list of CoreLabels, using the given * Morphology object. The input list must already have tags set. */ public static void lemmatize(List<CoreLabel> sentence, Morphology morpha) { for (CoreLabel label : sentence) { morpha.stem(label); } }
/** * Adds the LemmaAnnotation to the given CoreLabel. */ public void stem(CoreLabel label) { stem(label, CoreAnnotations.LemmaAnnotation.class); }
/** * Adds lemmas to the given list of CoreLabels, using the given * Morphology object. The input list must already have tags set. */ public static void lemmatize(List<CoreLabel> sentence, Morphology morpha) { for (CoreLabel label : sentence) { morpha.stem(label); } }
/** * Adds the LemmaAnnotation to the given CoreLabel. */ public void stem(CoreLabel label) { stem(label, CoreAnnotations.LemmaAnnotation.class); }
public String[] lemmatizeText(String[] words) { final String[] stems = new String[words.length]; for (int word = 0; word < words.length; word++) { stems[word] = analyzer.stem(words[word]); } return stems; }
/** * Adds lemmas to the given list of CoreLabels, using the given * Morphology object. The input list must already have tags set. */ public static void lemmatize(List<CoreLabel> sentence, Morphology morpha) { for (CoreLabel label : sentence) { morpha.stem(label); } }
/** * Adds the LemmaAnnotation to the given CoreLabel. */ public void stem(CoreLabel label) { stem(label, CoreAnnotations.LemmaAnnotation.class); }
/** * Adds the LemmaAnnotation to the given CoreLabel. */ public void stem(CoreLabel label) { stem(label, LemmaAnnotation.class); }
public String lemmatizeWord(String word) { return analyzer.stem(word); }
public List<WordTag> lemmatizeText(String tokenizedText) { final List<WordTag> lemmatized = new ArrayList<WordTag>(); final String[] tokens = tokenizedText.split("\\s+"); for (String token : tokens) { final String lemma = analyzer.stem(token); lemmatized.add(new WordTag(token, lemma)); } return lemmatized; }
public Object apply(Object in) { if (in instanceof WordTag) { WordTag wt = (WordTag) in; String tag = wt.tag(); return new WordTag(lemmatize(wt.word(), tag, lexer, lexer.option(1)), tag); } if (in instanceof Word) { return stem((Word) in); } return in; }
@Override public Object apply(Object in) { if (in instanceof WordTag) { WordTag wt = (WordTag) in; String tag = wt.tag(); return new WordTag(lemmatize(wt.word(), tag, lexer, lexer.option(1)), tag); } if (in instanceof Word) { return stem((Word) in); } return in; }
@Override public Object apply(Object in) { if (in instanceof WordTag) { WordTag wt = (WordTag) in; String tag = wt.tag(); return new WordTag(lemmatize(wt.word(), tag, lexer, lexer.option(1)), tag); } if (in instanceof Word) { return stem((Word) in); } return in; }
public Object apply(Object in) { if (in instanceof WordTag) { WordTag wt = (WordTag) in; String tag = wt.tag(); return new WordTag(lemmatize(wt.word(), tag, lexer, lexer.option(1)), tag); } if (in instanceof Word) { return stem((Word) in); } return in; }