本文整理汇总了Python中stream.Stream.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.filter方法的具体用法?Python Stream.filter怎么用?Python Stream.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream.Stream
的用法示例。
在下文中一共展示了Stream.filter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import filter [as 别名]
def main(self):
#twitter authorization
auth = OAuthHandler(AuthDetails.consumer_key, AuthDetails.consumer_secret)
auth.set_access_token(AuthDetails.access_token, AuthDetails.access_token_secret)
language = 'en'
pt = ProcessTweet()
searchTerm = pt.unicodetostring(self.searchTerm)
stopAt = pt.unicodetostring(self.stopAt)
#calls method to train the classfier
tr = Training()
(priors, likelihood) = tr.starttraining()
#stream tweets from twitter
twitterStream = Stream(auth, Listener(searchTerm, stopAt))
twitterStream.filter(track=[searchTerm], languages=[language])
sen = Sentiment()
sentiment_tally = Counter()
(sentiment_tally, tweet_list) = sen.gettweetstoanalyse(priors, likelihood, searchTerm)
tr = Training()
sen = Sentiment()
(neutral, positive, negative) = sen.analyse(sentiment_tally)
tweet_list = self.edittweetlists(tweet_list)
#truncate streamtweets table
self.removetweetsfromdatabase()
#save training data
tr.savetrainingdatatodb(priors, likelihood)
return (neutral, positive, negative, tweet_list)