-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw2.py
More file actions
31 lines (20 loc) · 1.04 KB
/
hw2.py
File metadata and controls
31 lines (20 loc) · 1.04 KB
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
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 20 10:37:56 2016
@author: arvil
"""
#Compares two words and outputs sentence counts for September 2016
import logging
import mediacloud, datetime
mc = mediacloud.api.MediaCloud('e0ca07461a0f1fb81d96d5584ab9ddc02bed9978581a0a770dd9b3ce75b0d82f')
def CountSentences():
phrase1 = raw_input("Enter first word: ")
phrase2 = raw_input("Enter second word: ")
logging.basicConfig(filename='example.log',level=logging.INFO)
logging.info('succes', phrase1, phrase2)
SentCount1 = mc.sentenceCount(phrase1, solr_filter=[mc.publish_date_query( datetime.date( 2016, 9, 1), datetime.date( 2016, 10, 1) ), 'tags_id_media:1' ])
SentCount2 = mc.sentenceCount(phrase2, solr_filter=[mc.publish_date_query( datetime.date( 2016, 9, 1), datetime.date( 2016, 10, 1) ), 'tags_id_media:1' ])
print SentCount1['count'] # prints the number of sentences found
print SentCount2['count'] # prints the number of sentences found
logging.info(SentCount1,SentCount2)
CountSentences()