Ejemplo n.º 1
0
def classifyTweets(tweetFile, history, tag, sSaveFile, offset=3):
    stopWords = getStopWords()
    tweets = []    
    for line in IO.readData_by_line(tweetFile):
        tweet = Tweet.Tweet()
        tweet.setTweet(line)
        if(tweet.containsTag("#" + tag)):
            stamp = tweet.date + timedelta(days=offset)
            if stamp.date() in history:
                tweet.label = history[stamp.date()]
                tweet.removeStopWords(stopWords)
                tweets.append(tweet)
    print len(tweets)
    tweetFile.close()
    IO.writeTweets(sSaveFile, tweets, ['label', 'trimmedMessage'])
Ejemplo n.º 2
0
def classifyTweets(tweetFile, history, tag, sSaveFile, offset=3):
    stopWords = getStopWords()
    tweets = []
    for line in IO.readData_by_line(tweetFile):
        tweet = Tweet.Tweet()
        tweet.setTweet(line)
        if (tweet.containsTag("#" + tag)):
            stamp = tweet.date + timedelta(days=offset)
            if stamp.date() in history:
                tweet.label = history[stamp.date()]
                tweet.removeStopWords(stopWords)
                tweets.append(tweet)
    print len(tweets)
    tweetFile.close()
    IO.writeTweets(sSaveFile, tweets, ['label', 'trimmedMessage'])