-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic.py
executable file
·46 lines (40 loc) · 1.02 KB
/
topic.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
41
42
43
44
45
46
#economyTopics = [['income', 'job','employ'], ['tax'], ['budget', 'deficit']]
#healthTopics = ['medi', 'cover', 'heal', 'hosp']
#safetyTopics = []
def extractTopic(text):
# economy
if 'income' in text \
or 'job' in text \
or 'employ' in text \
or 'hire' in text \
or 'business' in text \
or 'bankrupt' in text:
return 'IJ' #income and jobs
elif 'tax' in text \
or 'ira' in text:
return 'T' # tax
elif 'budget' in text \
or 'debt' in text \
or 'deficit' in text:
return 'B' # budget
elif 'hous' in text \
or 'liv' in text \
or 'Fannie Mae' in text \
or 'Freddie Mac' in text \
or 'loan' in text \
or 'mortgag' in text \
or 'welfar' in text:
return 'P' # peopleliving and housing
elif 'wallstreet' in text \
or 'stock' in text \
or 'market' in text \
or 'trad' in text \
or 'exchange rat' in text \
or 'stimulu' in text \
or 'rescue plan' in text \
or 'infrastructur' in text \
or 'econom' in text:
return 'G' #great economy related
else:
return None
#end def extractTopic