Created
April 18, 2016 00:13
-
-
Save cxtadment/5ac38704c0c3b5d0c27d78cd4a0e30bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def polarity_count(self, microblog_text): | |
seg_list = list(jieba.cut(microblog_text)) | |
t = 0 | |
while t < len(seg_list) - 1: | |
if seg_list[t] in ESCAPE_WORDS: | |
seg_list[t + 1] = seg_list[t] + seg_list[t + 1] | |
seg_list.pop(t) | |
t += 1 | |
posCount, negCount = 0, 0 | |
for word in seg_list: | |
if word in self.posDic: | |
posCount += 1 | |
if word in self.negDic: | |
negCount += 1 | |
return posCount, negCount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment