Skip to content

Instantly share code, notes, and snippets.

@cxtadment
Created April 18, 2016 00:13
Show Gist options
  • Save cxtadment/5ac38704c0c3b5d0c27d78cd4a0e30bc to your computer and use it in GitHub Desktop.
Save cxtadment/5ac38704c0c3b5d0c27d78cd4a0e30bc to your computer and use it in GitHub Desktop.
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