I know how I can annotate a sentence and get the lemma of each word but I don't know how to do it if I just want to lemmatize a single word. I tried
Annotation tokenAnnotation = new Annotation("wedding");
List<CoreMap> list = tokenAnnotation.get(SentencesAnnotation.class);
String tokenLemma = list
.get(0).get(TokensAnnotation.class)
.get(0).get(LemmaAnnotation.class);
but the tokenAnnotation
has only one TextAnnotation
key which means list
will be null
here.
So how can I lemmatize a single word?
There are two options: you can either annotate you
Annotation
object through aStanfordCoreNLP
pipeline:The other option is to use the SimpleCoreNLP API: