如何在Python中使用词典文件(即NRC Emotion词典)进行情感分析?
答案 0 :(得分:0)
也许这会帮助http://jonathansoma.com/lede/algorithms-2017/classes/more-text-analysis/nrc-emotional-lexicon/
import pandas as pd
filepath = "NRC-Emotion-Lexicon-v0.92/NRC-emotion-lexicon-wordlevel-alphabetized-v0.92.txt"
emolex_df = pd.read_csv(filepath, names=["word", "emotion", "association"], skiprows=45, sep='\t')
emolex_df.head(12)
答案 1 :(得分:0)
我建议您看一下该存储库,该存储库为字典提供了一些接口。似乎他们也有pypi
https://github.com/metalcorebear/NRCLex
from nrclex import NRCLex
#Instantiate text object (for best results, 'text' should be unicode).
text_object = NRCLex('text')
#Return words list.
text_object.words
#Return sentences list.
text_object.sentences
#Return affect list.
text_object.affect_list
#Return affect dictionary.
text_object.affect_dict
#Return raw emotional counts.
text_object.raw_emotion_scores
#Return highest emotions.
text_object.top_emotions
#Return affect frequencies.
text_object.affect_frequencies