本文整理汇总了Python中corpus.Corpus.getTweets方法的典型用法代码示例。如果您正苦于以下问题:Python Corpus.getTweets方法的具体用法?Python Corpus.getTweets怎么用?Python Corpus.getTweets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corpus.Corpus
的用法示例。
在下文中一共展示了Corpus.getTweets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateCorpus
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import getTweets [as 别名]
def generateCorpus(self, c_type = 'not'):
corpus = Corpus(password='', db='project_major')
if c_type == 'not':
corpus.getTweetsWithNot()
else:
corpus.getTweets()
self.corpus = corpus.dataSet
self.negatives = corpus.negatives
self.stopWords = corpus.stopWords
corpus.close()
示例2: scoring
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import getTweets [as 别名]
def scoring(self, method='zagibolov'):
# Supply argument in Corpus to connect to databse. user, password and db.
corpus = Corpus(password='', db='project_major')
corpus.getTweets()
dataset = corpus.dataSet
preprocess = Preprocess('zagibolov', self.lexicons, self.negatives, self.stopWords)
scoring = Scoring(method, self.lexicons, self.negatives, self.stopWords, self.seeds)
j = 0
for data in dataset:
preprocess.preprocessScoring(data)
processed = preprocess.processed_data
for data in processed:
scoring.count(data['tweet'])
## print self.seeds
preprocess.seeds = scoring.lexicon_count
preprocess.processLexicon()
scoring.lexicons = preprocess.lexicons
## print scoring.lexicon_count
last_score = {}
i = 0
for i in range(0,3):
total = 0
j = 0
negative = 0
positive = 0
scoring.resetLexiconCount()
## print self.lexicons
for data in processed:
if j == 50:
break
j += 1
score = scoring.score(data)
if score != 0:
total += 1
if score < 0:
negative += 1
else:
positive += 1
scoring.adjustScoring()
if last_score == {}:
last_score = scoring.lexicons
this_score = last_score
else:
this_score = scoring.lexicons
if this_score == last_score:
break
else:
last_score = this_score
print this_score
print "Total scored: " + str(total), "Negative: ", negative, "Positive: ", positive
print this_score
print "Total scored: " + str(total), "Negative: ", negative, "Positive: ", positive