-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetarticles.py
40 lines (36 loc) · 1.21 KB
/
getarticles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import app.parser.getData as importArticles
import app.parser.articleRetrieval.getArticles as getContent
import app.parser.sentences as sent
import app.parser.getChunks as gc
import app.analytics.tag as tag
def getArticle(article):
article = article.split(',')
singleSets = []
try:
chunks = gc.getChunks(article[1])
print chunks
tags = tag.getTags(article[1],chunks)
#if tags == []:
# continue # check this is right. go to next itteration
"""The Stanford Open IE tags"""
subject = tags['subject']
relation = tags['relation']
objects = tags['object']
objects = objects.split()
content = wp.getArticle(subject)
rawSentences = sent.getSentences(content)
sentences = []
for sentence in rawSentences:
if(hd.hasDate(sentence) != []):
sentences.append(sentence)
listOfYears.append(article[0])
SS = {'title':article[1], 'sentences':sentences, 'year':article[0]}
singleSets.append(SS)
except:
pass
return singleSets
data = open('data/todayinhistory.txt').readlines()
print getArticle(data[0])