我有這樣的代碼,它應該將單詞的正面語料與主題文本進行比較。它一直很好,直到我發現重複的文本不被考慮。Python情緒分析(當比較單詞時,文本中的重複單詞不計算在內)
文字:這是一個非常好的電影,它是那麼好
肯定列表:好,更好等。
只有在下列實施計「好」一旦腳本:
readFile = open('test.txt','r').read()
readFileList = readFile.split('\n')
counter = 0
for eachNeg in negWords:
if eachNeg in readFile:
counter -= 1
print eachNeg
print counter
for eachPos in posWords:
if eachPos in readFile:
counter +=1
print eachPos
print counter
這都給downvote的人可以建議我的答案的修正? – 2014-10-10 20:47:54