如何在Python中使用词典文件(即NRC情感词典)进行情感分析?
发布于 2019-10-13 04:09:18
也许这会对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)发布于 2020-07-15 23:44:09
我建议您看看这个存储库,它提供了一些到字典的接口。看起来他们也有一个皮皮人
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_frequencieshttps://stackoverflow.com/questions/56862418
复制相似问题