本文整理汇总了Python中classifier.Classifier.classify_reviews方法的典型用法代码示例。如果您正苦于以下问题:Python Classifier.classify_reviews方法的具体用法?Python Classifier.classify_reviews怎么用?Python Classifier.classify_reviews使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classifier.Classifier
的用法示例。
在下文中一共展示了Classifier.classify_reviews方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Classifier
# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import classify_reviews [as 别名]
## - December 10, 2015
## - An interactive classifier
import sys
from classifier import Classifier
print "\nPlease wait while the training data is loaded.."
myClassifier = Classifier()
myClassifier.load()
print "Ready for input"
filename = raw_input("Enter a file name or a directory (type \"quit\" to quit) > ")
while filename != "quit":
if ".txt" in filename:
with open(filename, 'r') as infile:
clsfy = myClassifier.classify(infile)
if clsfy > 0:
print "Positive! Weight = {0}".format(clsfy)
elif clsfy < 0:
print "Negative! Weight = {0}".format(clsfy)
elif clsfy == 0:
print "Undertermined"
else:
myClassifier.classify_reviews(filename + "*.txt")
filename = raw_input("Enter a file name or a directory > ")
示例2: Classifier
# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import classify_reviews [as 别名]
## - Comp 4710 - Data Mining
## - Prof: Dr. Carson K. Leung
## - Authors: Trevor Blanchard, Stefan Harris, Brett Small, Sam Peers
## - Sentiment Miner
## - December 10, 2015
from classifier import Classifier
from timer import Timer
myClassifier = Classifier()
myTimer = Timer()
myTimer.start_timer()
myClassifier.load()
folderpath = "Test/positivetestdata/*.txt"
myClassifier.classify_reviews(folderpath)
folderpath = "Test/negativetestdata/*.txt"
myClassifier.classify_reviews(folderpath)
myTimer.end_timer()
myTimer.summary()