def opinion_lexicon_features(phrase):

    features = {}

    # TODO - Maybe do % positive, rather than num_positive
    # Count number of positive, negative, and neutral labels there are
    Opi_sentiments = defaultdict(lambda:0)
    for word in phrase:
        label = lexOpi.lookup(word)
        Opi_sentiments[label] += 1
    for sentiment,count in Opi_sentiments.items():
        if sentiment ==        '': continue
        features[ 'Opi-%s_count' % sentiment ] = count

    return features
def opinion_lexicon_features(phrase):

    features = {}

    # TODO - Maybe do % positive, rather than num_positive
    # Count number of positive, negative, and neutral labels there are
    Opi_sentiments = defaultdict(lambda: 0)
    for word in phrase:
        label = lexOpi.lookup(word)
        Opi_sentiments[label] += 1
    for sentiment, count in Opi_sentiments.items():
        if sentiment == '': continue
        features['Opi-%s_count' % sentiment] = count

    return features
def opinion_lexicon_features(phrase):

    features = {}

    # Count number of positive, negative, and neutral labels there are
    Opi_sentiments = defaultdict(lambda: 0)
    for word in phrase:
        negated = ('_neg' in word)
        if negated: word = word[:-4]
        label = lexOpi.lookup(word)
        if label != 'neutral':
            if negated:
                if label == 'positive':
                    label = 'negative'
                else:
                    label = 'positive'
            Opi_sentiments[label] += 1

    for sentiment, count in Opi_sentiments.items():
        if sentiment == '': continue
        features[('Opi-count', sentiment)] = count

    return features
def opinion_lexicon_features(phrase):

    features = {}

    # Count number of positive, negative, and neutral labels there are
    Opi_sentiments = defaultdict(lambda:0)
    for word in phrase:
        negated = ('_neg' in word)
        if negated: word = word[:-4]
        label = lexOpi.lookup(word)
        if label != 'neutral':
            if negated:
                if label == 'positive':
                    label = 'negative'
                else:
                    label = 'positive'
            Opi_sentiments[label] += 1

    for sentiment,count in Opi_sentiments.items():
        if sentiment == '': continue
        features[ ('Opi-count', sentiment) ] = count

    return features