本文整理汇总了Python中nltk.classify.NaiveBayesClassifier.classify方法的典型用法代码示例。如果您正苦于以下问题:Python NaiveBayesClassifier.classify方法的具体用法?Python NaiveBayesClassifier.classify怎么用?Python NaiveBayesClassifier.classify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.classify.NaiveBayesClassifier
的用法示例。
在下文中一共展示了NaiveBayesClassifier.classify方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: classifyTest
# 需要导入模块: from nltk.classify import NaiveBayesClassifier [as 别名]
# 或者: from nltk.classify.NaiveBayesClassifier import classify [as 别名]
def classifyTest(self,test, classifier, feature_extractor):
testClassifies = []
for doc,lbl in test:
tmpLbl = classifier.classify(feature_extractor(movie_reviews.words(fileids=[doc])))
x = (doc,tmpLbl)
testClassifies.append(x)
return testClassifies
示例2: hasNegativeSent
# 需要导入模块: from nltk.classify import NaiveBayesClassifier [as 别名]
# 或者: from nltk.classify.NaiveBayesClassifier import classify [as 别名]
def hasNegativeSent(text):
#take in raw text, not tokens
return nb_classifier.classify(word_features(text))
示例3: test
# 需要导入模块: from nltk.classify import NaiveBayesClassifier [as 别名]
# 或者: from nltk.classify.NaiveBayesClassifier import classify [as 别名]
def test(self):
testArr= self.matched[100:]
random.shuffle(testArr)
for item in testArr:
classified = NaiveBayesClassifier.classify(self.model,item)
示例4: batchClassify
# 需要导入模块: from nltk.classify import NaiveBayesClassifier [as 别名]
# 或者: from nltk.classify.NaiveBayesClassifier import classify [as 别名]
def batchClassify(self, model):
for item in self.unmatched:
classified = NaiveBayesClassifier.classify(model, item.featurize())
示例5: classify
# 需要导入模块: from nltk.classify import NaiveBayesClassifier [as 别名]
# 或者: from nltk.classify.NaiveBayesClassifier import classify [as 别名]
def classify(self, model, item):
_name = self.convertItem(item)
tokens = _name.getNameDes()
classified = NaiveBayesClassifier.classify(model, _name.input_featurize(tokens))
return classified
示例6: nameobj_classify
# 需要导入模块: from nltk.classify import NaiveBayesClassifier [as 别名]
# 或者: from nltk.classify.NaiveBayesClassifier import classify [as 别名]
def nameobj_classify(self, model, _name):
tokens = _name.name + name.brand
classified = NaiveBayesClassifier.classify(model, _name.input_featurize(tokens))
return classified