List of usage examples for edu.stanford.nlp.pipeline Annotation containsKey
@Override public <VALUE> boolean containsKey(Class<? extends Key<VALUE>> key)
From source file:com.asimihsan.handytrowel.nlp.StopwordAnnotator.java
License:Open Source License
@Override public void annotate(Annotation annotation) { if (stopwords != null && stopwords.size() > 0 && annotation.containsKey(TokensAnnotation.class)) { List<CoreLabel> tokens = annotation.get(TokensAnnotation.class); for (CoreLabel token : tokens) { boolean isWordStopword = stopwords.contains(token.word().toLowerCase()); boolean isLemmaStopword = checkLemma ? stopwords.contains(token.lemma().toLowerCase()) : false; Pair<Boolean, Boolean> pair = Pair.makePair(isWordStopword, isLemmaStopword); token.set(StopwordAnnotator.class, pair); }//w w w. ja v a2 s.c o m } }