赞
踩
`“”"
2. 情感定位
“”"
def classifyWords(wordDict):
senList = readLines(‘BosonNLP_sentiment_score.txt’)
senDict = defaultdict()
for s in senList:
senDict[s.split(’ ‘)[0]] = s.split(’ ')[1]
notList = readLines(‘notDict.txt’)
degreeList = readLines(‘degreeDict.txt’)
degreeDict = defaultdict()
for d in degreeList:
degreeDict[d.split(‘,’)[0]] = d.split(‘,’)[1]
senWord = defaultdict()
notWord = defaultdict()
degreeWord = defaultdict()
for word in wordDict.keys():
if word in senDict.keys() and word not in notList and word not in degreeDict.keys():
senWord[wordDict[word]] = senDict[word]
elif word in notList and word not in degreeDict.keys():
notWord[wordDict[word]] = -1
elif word in degreeDict.keys():
degreeWord[wordDict[word]] = degreeDict[word]
return senWord, notWord, degreeWord`
###### 1.3.2 计算句子得分 > > 在此,简化的情感分数计算逻辑:**所有情感词语组的分数之和** > > > 定义一个**情感词语组**:两情感词之间的所有否定词和程度副词与这两情感词中的后一情感词构成一个情感词组,即`notWords + degreeWords + sentiWords`,例如`不是很交好`,其中`不是`为否定词,`很`为程度副词,`交好`为情感词,那么这个情感词语组的分数为: `finalSentiScore = (-1) ^ 1 * 1.25 * 0.747127733968` 其中`1`指的是一个否定词,`1.25`是程度副词的数值,`0.747127733968`为`交好`的情感分数。 伪代码如下: `finalSentiScore = (-1) ^ (num of notWords) * degreeNum * sentiScore` `finalScore = sum(finalSentiScore)`
`“”"
3. 情感聚合
“”"
def scoreSent(senWord, notWord, degreeWord, segResult):
W = 1
score = 0
senLoc = senWord.keys()
notLoc = notWord.keys()
degreeLoc = degreeWord.keys()
senloc = -1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。