synchronized Document mockLemma(Properties props) { // Cached result if (this.sentences != null && this.sentences.size() > 0 && this.sentences.get(0).rawToken(0).hasLemma()) { return this; } // Prerequisites runPOS(props); // Mock lemma with word Annotation ann = asAnnotation(true); for (int i = 0; i < sentences.size(); ++i) { sentences.get(i).updateTokens(ann.get(CoreAnnotations.SentencesAnnotation.class).get(i).get(CoreAnnotations.TokensAnnotation.class), (pair) -> pair.first.setLemma(pair.second), CoreLabel::word); } return this; }
synchronized Document runLemma(Properties props) { // Cached result if (this.sentences != null && this.sentences.size() > 0 && this.sentences.get(0).rawToken(0).hasLemma()) { return this; } // Prerequisites runPOS(props); // Run annotator Supplier<Annotator> lemma = (props == EMPTY_PROPS || props == SINGLE_SENTENCE_DOCUMENT) ? defaultLemma : getOrCreate(STANFORD_LEMMA, props, () -> backend.morpha(props, false)); Annotation ann = asAnnotation(true); lemma.get().annotate(ann); // Update data for (int i = 0; i < sentences.size(); ++i) { sentences.get(i).updateTokens(ann.get(CoreAnnotations.SentencesAnnotation.class).get(i).get(CoreAnnotations.TokensAnnotation.class), (pair) -> pair.first.setLemma(pair.second), CoreLabel::lemma); } return this; }
synchronized Document mockLemma(Properties props) { // Cached result if (this.sentences != null && this.sentences.size() > 0 && this.sentences.get(0).rawToken(0).hasLemma()) { return this; } // Prerequisites runPOS(props); // Mock lemma with word Annotation ann = asAnnotation(true); for (int i = 0; i < sentences.size(); ++i) { sentences.get(i).updateTokens(ann.get(CoreAnnotations.SentencesAnnotation.class).get(i).get(CoreAnnotations.TokensAnnotation.class), (pair) -> pair.first.setLemma(pair.second), CoreLabel::word); } return this; }
synchronized Document runLemma(Properties props) { // Cached result if (this.sentences != null && this.sentences.size() > 0 && this.sentences.get(0).rawToken(0).hasLemma()) { return this; } // Prerequisites runPOS(props); // Run annotator Supplier<Annotator> lemma = (props == EMPTY_PROPS || props == SINGLE_SENTENCE_DOCUMENT) ? defaultLemma : getOrCreate(STANFORD_LEMMA, props, () -> backend.morpha(props, false)); Annotation ann = asAnnotation(true); lemma.get().annotate(ann); // Update data for (int i = 0; i < sentences.size(); ++i) { sentences.get(i).updateTokens(ann.get(CoreAnnotations.SentencesAnnotation.class).get(i).get(CoreAnnotations.TokensAnnotation.class), (pair) -> pair.first.setLemma(pair.second), CoreLabel::lemma); } return this; }