-
Notifications
You must be signed in to change notification settings - Fork 0
/
requestGenerator.py
36 lines (31 loc) · 1.17 KB
/
requestGenerator.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 wikipedia
import requests
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
def get_corpus():
queries = ['meditation', 'big sur', 'vipassana', 'osho', 'krishna', 'compilers', 'mpfc', 'triune brain', 'javascript', 'http', 'burning man']
titles = [wikipedia.search(q) for q in queries]
pages = []
print len(titles)
for title in titles:
try:
pages.append(wikipedia.summary(title))
except wikipedia.exceptions.DisambiguationError:
print 'Skipping ambiguous page title: %s' % title
print len(pages)
return pages
def make_requests(pages):
results = list()
for page in pages:
parameters = { 'document_body': page }
r = requests.post('http://ssaas-1-harleykwyn.beta.tutum.io:49315/corpus', params=parameters)
results.append((r.text))
print r.text
parameters = { 'document_id': 'doc_1' }
r = requests.get('http://ssaas-1-harleykwyn.beta.tutum.io:49315/search', params=parameters)
results.append((r.text, parameters))
return results
corpus = get_corpus()
print make_requests(corpus)
r = requests.get('http://ssaas-1-harleykwyn.beta.tutum.io:49315/documents/doc_1')
print r.text