Stanford NLP Sentiment - how to check if a word is recognized, is in the vocabulary?

624 views Asked by At

Is there a function that returns true if a word is recognized by Stanford NLP Sentiment and false if not?

For example, if I want to find the sentiment of the sentence: "I like AAA because of BBB." both the phrases (AAA) and (BBB) will not be recognized and therefore get the same phrase vector (which will effect the results). I would like to avoid that.

1

There are 1 answers

3
Jon Gauthier On BEST ANSWER

If you have a SentimentModel instance, you can inspect its public member wordVectors (not sure why this is public, but I suppose that's a different story..).

SentimentModel model = SentimentModel.loadSerialized("edu/stanford/nlp/models/sentiment/sentiment.ser.gz");
boolean knownWord = model.wordVectors.containsKey("foo");