0

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.

Alonzorz
  • 2,113
  • 4
  • 18
  • 21

1 Answers1

2

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");
Jon Gauthier
  • 25,202
  • 6
  • 63
  • 69
  • do you know who do I get the SentimentModel object given that I have a StanfordCoreNLP object that is supposed to contain it somehow? – Alonzorz Dec 01 '14 at 09:51
  • As far as I can see in the code it's not possible to access the model instance directly from `StanfordCoreNLP` (member visibility issues). But you can instantiate your own `SentimentModel` with the default model configuration — see my updated answer. – Jon Gauthier Dec 01 '14 at 17:39
  • Thank you so much. also it should be: boolean knownWord = model.wordVectors.containsKey("foo"); – Alonzorz Dec 02 '14 at 15:51