Example usage for edu.stanford.nlp.pipeline Annotation containsKey

List of usage examples for edu.stanford.nlp.pipeline Annotation containsKey

Introduction

In this page you can find the example usage for edu.stanford.nlp.pipeline Annotation containsKey.

Prototype

@Override
public <VALUE> boolean containsKey(Class<? extends Key<VALUE>> key) 

Source Link

Usage

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
    }
}