Closed ghost closed 7 years ago
IIRC the sentiment analyzer object has an "annotate" method that allows you to assign polarity and subjectivity float values to a word. I think you could just use that iteratively.
If you want I can post an example.
An example post would be nice. It would be helpful to all people who currently face similar problem
polarity and subjectivity float values to a word do "stop loss" will be considered as a word
Unfortunately that may be a wrinkle in the annotation approach. I can't recall for sure though. Will post what I know later today.
Well here is the snippet from sentiment class in /text/init.py.. Sorry for any false hope I may have given. Perhaps someone who knows more can give a better answer.
def annotate(self, word, pos=None, polarity=0.0, subjectivity=0.0, intensity=1.0, label=None):
""" Annotates the given word with polarity, subjectivity and intensity scores, and optionally a semantic label (e.g., MOOD for emoticons, IRONY for "(!)"). """
w = self.setdefault(word, {})
w[pos] = w[None] = (polarity, subjectivity, intensity)
if label:
self.labeler[word] = label
Anyway if you were to use above method it could be something like:
foo_analyzer = pattern.sentiment
foo_analyzer.annotate('unsetword', pos='NN', polarity=-1.0, subjectivity=0.7, intensity=1.0)
You could always try a second or alternate pass of sentiment analysis with a classifier E.G. from TextBlob which is supposed to be Pattern-compatible. Again sorry that annotate may not be your answer.
I use polarity function to asses the sentiment of financial data; what I observed is pattern polarity function tends to give false negatives in a financial data.
A article contains this phrase tends to give negative result " .....industry is going up and stop loss should be placed at 20..."
I think pattern mis interprets stop loss as a negative meaning.
There are many financial sentiment dictionaries available in web can we use those dictionaries with pattern. If yes how can we do it?