Untitled

 avatar
unknown
plain_text
a year ago
334 B
5
Indexable
def load_emotion_lexicon(filename):
    lexicon = {}
    with open(filename, 'r') as file:
        for line in file:
            word, emotion, association = line.strip().split('\t')
            if word not in lexicon:
                lexicon[word] = {}
            lexicon[word][emotion] = int(association)
    return lexicon
Editor is loading...
Leave a Comment