forked from ncollins/say_what
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (29 loc) · 1.35 KB
/
main.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
import sqlite3
import datetime
import config
from bill_search import count_matches, words, title_phrases
from wordsearch import count_phrase_for_legislator
TODAY = datetime.date.today().isoformat()
def main():
conn = sqlite3.connect(config.DATABASE)
c = conn.cursor()
c.execute("""
SELECT * FROM bills;
""")
bills = c.fetchmany(200)
for (congress, chamber, number, introduced_on, sponsor, title, file_path) in bills:
check_date = datetime.datetime.strptime(introduced_on, '%Y-%m-%d') - datetime.timedelta(90)
with open(file_path) as f:
phrases = list(title_phrases(title)) + ['obamacare', 'clinton', 'war', 'jobs', 'budget', 'weapon', 'syria', 'military']
print(file_path)
print('{0}: {1}'.format(number, title))
print('{0}: {1} other docs'.format(number, count_matches(words, f.read())))
#print('{0}: sponsored by {1}'.format(number, sponsor))
for p in phrases:
n, c = count_phrase_for_legislator(p, sponsor, check_date, TODAY)
if n not in ['Rep Gohmert', 'Sen Cruz', 'Sen Sessions', 'Rep Bachmann',
'Rep King']:
print('{0}: {1} mentioned {2} {3} times'.format(number, n, p, str(c)))
print('\n')
if __name__ == '__main__':
main()