예제 #1
0
def Pattern_Module_Twitter_Stream():

    # Start Stop Watch
    t1 = time.time()

    # Create a list to Store the Data
    List = Twitter().stream('#Fail')

    # For 10 Instances
    for second in range(10):
        # Get Stream Data
        value = List.update(bytes=1024)
        # Add Value to List if not Empty
        if len(value) == 0:
            # Pass
            continue
        else:
            # Storing Results
            List.append()
            # Print Tweet
            print('Tweet: %s') % (value.text)
            # Get Sentiment
            print('Sentiment Analysis of Tweet: %s') % (TextBlob(
                str(value.text),
                analyzer=NaiveBayesAnalyzer()).sentiment[0].upper())
        # Wait 3 Seconds between queries - Do not want to get blocked
        time.sleep(3)

    return time.time() - t1
def Pattern_Module_Twitter_Stream():

     # Start Stop Watch
    t1 = time.time()

    # Create a list to Store the Data
    List = Twitter().stream('#Fail')

    # For 10 Instances
    for second in range(10):
        # Get Stream Data
        value = List.update(bytes=1024)
        # Add Value to List if not Empty
        if len(value) == 0:
            # Pass
            continue
        else:
            # Storing Results
            List.append()
            # Print Tweet
            print('Tweet: %s') % (value.text)
            # Get Sentiment
            print('Sentiment Analysis of Tweet: %s') % (TextBlob(str(value.text),
                                                                 analyzer=NaiveBayesAnalyzer()).sentiment[0].upper())
        # Wait 3 Seconds between queries - Do not want to get blocked
        time.sleep(3)

    return time.time() - t1