pretty new python, have experience in c.
does if statements work same way in c? putting if statement below if statement check false return.
there seem issue me trying use elif statement in python can 1 me figure out issue here?
#!/usr/bin/env python3 # todo #import nltk helpers import get_user_timeline analyzer import analyzer #zymayla's hints #ensure proper usage #argv def main(): if len(sys.argv) != 2: sys.exit("usage: ./smile @username") # absolute paths lists positives = os.path.join(sys.path[0], "positive-words.txt") negatives = os.path.join(sys.path[0], "negative-words.txt") #get tweets ##get_user_timeline (in helpers.py) if get_user_timeline(screen_name, count=200) false: #check if successful #if private account or not exist(unsuccessful) #error message if unsuccessful(sys.exit) sys.exit("account either private or not exist") #tokenize tweet (like did in analyzer.py "smile") #tokenizers part of natural language toolkit #use tweettokenizer split list of words #analyze tweets #initialize analyzer analyzer = analyzer(positives, negatives) #instantiate analyzer, iterate on every token scoring them pos,neg,neutral (this indicate if tweet posistive/negative/neutral) score = analyzer.tweetanalyzer(sys.argv[1]) if score > 0.0: #print score print(colored("{}".format(score), "green", end='')) #print tweet print("{}".format(tweet) elif score < 0.0: print(colored("{}".format(score), "red", end='')) #print tweet print("{}".format(tweet) else: print(colored("{}".format(score), "yellow", end='')) #print tweet print("{}".format(tweet) if __name__ == "__main__": main()
you're missing parenthesis on previous line:
print("{}".format(tweet)
this should be:
print("{}".format(tweet))
... , same goes identical print
s on lines 48 , 53.
Comments
Post a Comment