Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import sys
- import os
- import helpers
- from analyzer import Analyzer
- from termcolor import colored
- def main():
- if len(sys.argv) != 2:
- sys.exit("Usage: ./tweets @screen_name")
- screen_name = sys.argv[1]
- tweets = helpers.get_user_timeline(screen_name)
- # absolute paths to lists
- positives = os.path.join(sys.path[0], "positive-words.txt")
- negatives = os.path.join(sys.path[0], "negative-words.txt")
- # instantiate analyzer
- analyzer = Analyzer(positives, negatives)
- positive,negative,neutral = 0.0,0.0,0.0
- # analyze tweet
- for tweet in tweets:
- score = analyzer.analyze(tweet)
- if score > 0.0:
- print(colored(":)", "green"))
- elif score < 0.0:
- print(colored(":(", "red"))
- else:
- print(colored(":|", "yellow"))
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment