本文整理汇总了Python中helper.Helper.get_text_from_corpus方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.get_text_from_corpus方法的具体用法?Python Helper.get_text_from_corpus怎么用?Python Helper.get_text_from_corpus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.Helper
的用法示例。
在下文中一共展示了Helper.get_text_from_corpus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import get_text_from_corpus [as 别名]
classifier = nltk.NaiveBayesClassifier.train(training_set)
# classifier = nltk.MaxentClassifier.train(training_set)
# helper.save_model('maxent.mdl', classifier)
#ini mah cuma ngeprint yang didalem file question.txt
print helper.question_text
# classifier = helper.load_model('naivebayes.mdl')
# classifier2 = helper.load_model('sentiment-maxent.mdl')
#mecah kalimat jadi kata2
print helper.replace_two_or_more_liat(tweet.split())
#corpus = data uji
corpus_tag = helper.get_tag_from_corpus("tweets.dat")
corpus_text = helper.get_text_from_corpus("tweets.dat")
test_tag = []
#untuk nguji
corpus_text = ["Aku ga suka sama kamu"]
for text in corpus_text:
#untuk klasifikasi si "text" di corpus
result = classifier.classify(helper.extract_features(text.split()))
print result
# if result == '1':
# result = classifier2.classify(helper.extract_features(text.split()))
test_tag.append(result)
corpus_tag.reverse()
test_tag.reverse()
# print corpus_tag
# print test_tag
示例2: Helper
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import get_text_from_corpus [as 别名]
helper = Helper()
# helper.setFilteredTweet('opinion.dat')
# training_set = nltk.classify.apply_features(helper.extract_features, helper.filtered_tweet)
# print helper.positive_value
# print helper.negative_value
# classifier = nltk.NaiveBayesClassifier.train(training_set)
# helper.setFilteredTweet('sentiment.dat')
# training_set = nltk.classify.apply_features(helper.extract_features, helper.filtered_tweet)
# classifier2 = nltk.NaiveBayesClassifier.train(training_set)
# helper.save_model('opinion-naivebayes.mdl', classifier)
classifier = helper.load_model('opinion-naivebayes.mdl')
classifier2 = helper.load_model('sentiment-naivebayes.mdl')
# helper.setFilteredTweet('tweets.dat')
classic = helper.extract_features(tweet.split())
corpus_tag = helper.get_tag_from_corpus()
corpus_text = helper.get_text_from_corpus()
test_tag = []
for text in corpus_text:
result = classifier.classify(helper.extract_features_opinion(text.split()))
if result == '1':
result = classifier2.classify(helper.extract_features(text.split()))
test_tag.append(result)
corpus_tag.reverse()
print corpus_tag
test_tag.reverse()
print test_tag
# print corpus_tag
# print test_tag
cm = nltk.ConfusionMatrix(corpus_tag, test_tag)
print cm.pp(sort_by_count=True, show_percents=True, truncate=9)
print classic
示例3: Helper
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import get_text_from_corpus [as 别名]
import nltk
from helper import Helper
tweet = 'tono gendut jelek'
# print classifier.classify(extract_features(tweet.split()))
helper = Helper()
helper.setFilteredTweet('sentiment.dat')
training_set = nltk.classify.apply_features(helper.extract_features, helper.filtered_tweet)
# print helper.positive_value
# print helper.negative_value
# classifier = SvmClassifier.train(training_set)
classifier = nltk.NaiveBayesClassifier.train(training_set)
helper.save_model('sentiment-naivebayes.mdl', classifier)
# helper.save_model('sentiment-svm.mdl', classifier)
# classifier = helper.load_model('sentiment-naivebayes.mdl')
classic = helper.extract_features(tweet.split())
corpus_tag = helper.get_tag_from_corpus('sentiment.dat')
corpus_text = helper.get_text_from_corpus('sentiment.dat')
test_tag = []
for text in corpus_text:
result = classifier.classify(helper.extract_features(text.split()))
test_tag.append(result)
corpus_tag.reverse()
test_tag.reverse()
cm = nltk.ConfusionMatrix(corpus_tag, test_tag)
print cm.pp(sort_by_count=True, show_percents=True, truncate=9)
print classic
print classifier.classify(classic)
示例4: Helper
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import get_text_from_corpus [as 别名]
import nltk
from helper import Helper
tweet = 'tono asik'
# print classifier.classify(extract_features(tweet.split()))
helper = Helper()
helper.setFilteredTweet('opinion.dat')
training_set = nltk.classify.apply_features(helper.extract_features_opinion, helper.filtered_tweet)
# print helper.positive_value
# print helper.negative_value
classifier = nltk.NaiveBayesClassifier.train(training_set)
# classifier = nltk.MaxentClassifier.train(training_set)
helper.save_model('opinion-naivebayes.mdl', classifier)
# helper.save_model('opinion-maxent.mdl', classifier)
# classifier = helper.load_model('opinion-maxent.mdl')
classic = helper.extract_features_opinion(tweet.split())
corpus_tag = helper.get_tag_from_corpus('opinion.dat')
corpus_text = helper.get_text_from_corpus('opinion.dat')
test_tag = []
for text in corpus_text:
result = classifier.classify(helper.extract_features_opinion(text.split()))
test_tag.append(result)
corpus_tag.reverse()
test_tag.reverse()
cm = nltk.ConfusionMatrix(corpus_tag, test_tag)
print cm.pp(sort_by_count=True, show_percents=True, truncate=9)
print classic
print classifier.classify(classic)