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
#Source code with the blog post at http://monik.in/a-noobs-guide-to-implementing-rnn-lstm-using-tensorflow/ | |
import numpy as np | |
import random | |
from random import shuffle | |
import tensorflow as tf | |
# from tensorflow.models.rnn import rnn_cell | |
# from tensorflow.models.rnn import rnn | |
NUM_EXAMPLES = 10000 |
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: |