def test(self, input_str):
'''
4?????????????????SVM??????????????
'''
test_input = input_str
x_test = np.zeros(self.count+1) #???????
after_split = " ".join(jieba.cut(test_input)) #??
words = after_split.split(" ")
for i in words:
i = i.replace('\n','')
i = i.replace('\r','')
i = i.replace(' ','')
if self.dictionary.__contains__(i.encode('utf-8')):
x_test[self.dictionary[i.encode('utf-8')]] = 1.
# else:
# print 'Cannot find: '+i
#???0????1
if self.mySVM.predict([x_test]) == 1.:
return 1
else:
return 0
评论列表
文章目录