Skip to content

Commit

Permalink
fix bayes
Browse files Browse the repository at this point in the history
  • Loading branch information
isnowfy committed Mar 24, 2014
1 parent 4512349 commit 796eeeb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ s.tags # [(u'这个', u'r'), (u'东西', u'n'),
# (u'真心', u'd'), (u'很', u'd'),
# (u'赞', u'Vg')]
s.sentiments # 0.9830157237610916 positive的概率
s.sentiments # 0.9769663402895832 positive的概率
s.pinyin # [u'zhe', u'ge', u'dong', u'xi',
# u'zhen', u'xin', u'hen', u'zan']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def read(fname):

setup(
name='snownlp',
version='0.9.9',
version='0.9.10',
description='Python library for processing Chinese text',
author='isnowfy',
url='https://github.com/isnowfy/snownlp',
Expand Down
5 changes: 2 additions & 3 deletions snownlp/classification/bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ def train(self, data):
def classify(self, x):
tmp = {}
for k in self.d:
tmp[k] = 0
tmp[k] = log(self.d[k].getsum()) - log(self.total)
for word in x:
tmp[k] += log(self.d[k].getsum()) - log(self.total)\
+ log(self.d[k].freq(word))
tmp[k] += log(self.d[k].freq(word))
ret, prob = 0, 0
for k in self.d:
now = 0
Expand Down

0 comments on commit 796eeeb

Please sign in to comment.