def subjectivity_lexicon_features(phrase): features = {} # FIXME - MUST disambiguate POS # Feature Subjectivity Classification Subj_sentiments = defaultdict(lambda: 0) for word in phrase: negated = ('_neg' in word) if negated: word = word[:-4] entry = lexSubj.lookup(word) if entry.prior != '': label = (entry.type, entry.prior) # ex. ('strongsub','positive') if negated: if label[1] == 'positive': label = ('weaksubj', 'negative') elif label[1] == 'negative': label = ('weaksubj', 'positive') Subj_sentiments[label] += 1 for sentiment, count in Subj_sentiments.items(): features[('Subj-%s-%s_count' % sentiment)] = count return features
def subjectivity_lexicon_features(phrase): features = {} # FIXME - MUST disambiguate POS # Feature Subjectivity Classification Subj_sentiments = defaultdict(lambda:0) for word in phrase: negated = ('_neg' in word) if negated: word = word[:-4] entry = lexSubj.lookup(word) if entry.prior != '': label = (entry.type, entry.prior) # ex. ('strongsub','positive') if negated: if label[1] == 'positive': label = ('weaksubj','negative') elif label[1] == 'negative': label = ('weaksubj','positive') Subj_sentiments[label] += 1 for sentiment,count in Subj_sentiments.items(): features[ ('Subj-%s-%s_count' % sentiment) ] = count return features
def subjectivity_lexicon_features(phrase): features = {} # FIXME - MUST disambiguate POS # Feature Subjectivity Classification # print '\n\n' # print phrase Subj_sentiments = defaultdict(lambda: 0) for word in phrase: entry = lexSubj.lookup(word) # print '\t', word, '\t\t\t', entry if entry.prior != "": label = (entry.type, entry.prior) # ex. ('strongsub','positive') Subj_sentiments[label] += 1 for sentiment, count in Subj_sentiments.items(): # print 'feat: ', 'Subj-%s-%s_count' % sentiment, '\t\t', count features["Subj-%s-%s_count" % sentiment] = count return features
def subjectivity_lexicon_features(phrase): features = {} # FIXME - MUST disambiguate POS # Feature Subjectivity Classification #print '\n\n' #print phrase Subj_sentiments = defaultdict(lambda: 0) for word in phrase: entry = lexSubj.lookup(word) #print '\t', word, '\t\t\t', entry if entry.prior != '': label = (entry.type, entry.prior) # ex. ('strongsub','positive') Subj_sentiments[label] += 1 for sentiment, count in Subj_sentiments.items(): #print 'feat: ', 'Subj-%s-%s_count' % sentiment, '\t\t', count features['Subj-%s-%s_count' % sentiment] = count return features