def affin_lexicon_features(phrase):
    # Add Affin Features
    scores = []
    for word in phrase:
        negated = ('_neg' in word)
        if negated: word = word[:-4]

        score = lexAff.score(word)
        if score != None:
            if negated: score = 0
            scores.append(score)

    return scores_to_features(scores, 'Affin', 'score')
def affin_lexicon_features(phrase):
    # Add Affin Features
    scores = []
    for word in phrase:
        negated = ('_neg' in word)
        if negated: word = word[:-4]

        score = lexAff.score(word)
        if score != None:
            if negated: score = 0
            scores.append(score)

    return scores_to_features(scores, 'Affin', 'score')
def affin_lexicon_features(phrase):

    features = {}

    # Add Affin Features
    affTotal = 0
    affDict = defaultdict(lambda: 0)
    affLast = 0
    for word in phrase:
        affScore = lexAff.score(word)
        if affScore != None:
            affTotal += affScore
            affDict[affScore] += 1
            affLast = affScore
    features["Affin-Sum"] = affTotal
    for key in affDict:
        features[("Aff-score", key)] = affDict[key]
    features["Aff-last"] = affLast

    return features
def affin_lexicon_features(phrase):

    features = {}

    #Add Affin Features
    affTotal = 0
    affDict = defaultdict(lambda: 0)
    affLast = 0
    for word in phrase:
        affScore = lexAff.score(word)
        if affScore != None:
            affTotal += affScore
            affDict[affScore] += 1
            affLast = affScore
    features['Affin-Sum'] = affTotal
    for key in affDict:
        features[('Aff-score', key)] = affDict[key]
    features['Aff-last'] = affLast

    return features