本文整理汇总了Python中classifier.Classifier.print_probs方法的典型用法代码示例。如果您正苦于以下问题:Python Classifier.print_probs方法的具体用法?Python Classifier.print_probs怎么用?Python Classifier.print_probs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classifier.Classifier
的用法示例。
在下文中一共展示了Classifier.print_probs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import print_probs [as 别名]
def main():
global startTime, classifier
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--rootdir", type=str, default="../www.gutenberg.lib.md.us",
help="The root directory to collect txt files for training")
parser.add_argument('-fo', '--file_object_out',
help='give file path to store trained object', type=str, default="trained.pickle")
parser.add_argument('-fi', '--file_object_in',
help='give file path to store trained object', type=str, default=None)
parser.add_argument("-v", "--verbose", help="increase output verbosity",
action="store_true")
args = parser.parse_args()
if args.file_object_in != None:
classifier = load_classifier(args.file_object_in)
else:
classifier = Classifier(args.verbose)
#register the signal handler
signal.signal(signal.SIGINT, signal_handler)
#start the clock
startTime = time.time()
#parse all the files and update classifier's dictionaries (prior && joint) frequences
read_files_calculate_probs(args.rootdir, classifier)
###read_file('3.txt', classifier) ### testing
if args.verbose:
classifier.print_probs()
#Train method does num_words(in all texts) * num_bigrams(num_joints) => FORGET IT
### classifier.pre_train() ###
#classify will train the classifier for the specific word which is ok
example_classify('and')
save_classifier(args.file_object_out)
print_time_elapsed()