Week 25: 2/19 – 2/23

This week, I updated my decoder file to be able to take in 2 articles and compare every sentence in the first article to every sentence in the next article.

import pandas as pd
import numpy as np

article1 = pd.read_csv('article1.csv', names = ["Value", "Sentence"])
article2 = pd.read_csv('article2.csv', names = ["Value", "Sentence"])

combined_articles = []
for sent1 in article1["Sentence"]:
 for sent2 in article2["Sentence"]:
 combined_articles.append([sent1, sent2, 0])

article1['Value'] = 0
article2['Value'] = 0

article1['Sentence2'] = article2['Sentence']

numCols = len(article1.index)

article1['id'] = np.arange(0,numCols)

with open("test_final.tsv", 'w') as f:
 for row in combined_articles:
 sent1 = row[0]
 sent2 = row[1]
 value = row[2]
 f.write("\"%s\"\t\"%s\"\t%s\n" % (sent1, sent2, value))