SVMClass.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Chinese-ChatBot-AIML-Web.py 作者: JingLuo05 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号