Created
August 31, 2017 01:00
-
-
Save monikkinom/8c0f532277a8c4eae13f8901d75d9d4d to your computer and use it in GitHub Desktop.
This gist will help to quickly annotate the text for the assignment by providing a CLI and writing results to the required format!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For Assignment 1 INFO 159/259 (NLP) Fall 2017 | |
import csv | |
fn = 'your_name_trump_tweets.txt' | |
inp = list(csv.reader(open(fn, 'rb'), delimiter='\t')) | |
out = csv.writer(open('output.txt','w'), delimiter='\t') | |
sent = {'p':'positive','n':'negative','m':'mixed','u':'unknown'} | |
out.writerow(['tweet ID', 'target', 'sentiment toward target', 'rationale']) | |
for tweet in inp: | |
print tweet[1] | |
print "Enter the target:" | |
target = raw_input() | |
sentiment = "unknown" | |
while 1: | |
print "Enter the sentiment (p,n,m,u for positive,negative,mixed,unknown respectively):" | |
try: | |
sentiment = sent[raw_input()] | |
break | |
except: | |
print "please enter p,n,m or u" | |
pass | |
print "Enter rationale:" | |
rationale = raw_input() | |
resp = [tweet[0],target,sentiment,rationale] | |
out.writerow(resp) | |
print "---------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment