Exemplo n.º 1
0
 def addTeachedTweets(tweets):
     """ добавляет информацию о вручную определённых твиттах в базу. обновляет индексы для слов """
     print tweets
     connection = pymongo.Connection(TweetsAnalysis.connection_string,
                                     safe=True)
     results = connection.twitterAnalytic.results
     for post in tweets:
         if results.find_one("_id") is not None:
             continue
         tweet = TwitterStuff.getTweet(post)
         words = TweetsAnalysis.parseTweet(tweet['text'])
         results.save({"_id": int(post), "happy": tweets[post]})
         for word in words:
             print word
 def addTeachedTweets(self, tweets):
     """ добавляет информацию о вручную определённых твиттах в базу. обновляет индексы для слов """
     for tweetId in tweets:
         if self.tweetsColl.find_one({"_id": int(tweetId)}) is not None:
             continue
         tweet = TwitterStuff.getTweet(tweetId)
         if tweet is None:
             continue
         words = Parser().parseTweet(tweet['text'])
         words.append("@" + tweet['user']['screen_name'])
         self.tweetsColl.save({"_id": int(tweetId), "happy": tweets[tweetId]})
         for word in words:
             if len(word) < 4:
                 continue
             self.saveWord(word, tweets[tweetId])
Exemplo n.º 3
0
 def addTeachedTweets(self, tweets):
     """ добавляет информацию о вручную определённых твиттах в базу. обновляет индексы для слов """
     for tweetId in tweets:
         if self.tweetsColl.find_one({"_id": int(tweetId)}) is not None:
             continue
         tweet = TwitterStuff.getTweet(tweetId)
         if tweet is None:
             continue
         words = Parser().parseTweet(tweet['text'])
         words.append("@" + tweet['user']['screen_name'])
         self.tweetsColl.save({
             "_id": int(tweetId),
             "happy": tweets[tweetId]
         })
         for word in words:
             if len(word) < 4:
                 continue
             self.saveWord(word, tweets[tweetId])