@@ -49,29 +49,6 @@ def request(query, params):
49 return params
49 return params
52−# get first meaningful paragraph
53−# this should filter out disambiguation pages and notes above first paragraph
54−# "magic numbers" were obtained by fine tuning
55−def extract_first_paragraph(content, title, image):
56− first_paragraph = None
59− for paragraph in content.split('\n'):
61− starts_with_title = paragraph.lower().find(title.lower(), 0, len(title) + 35)
62− length = len(paragraph)
64− if length >= 200 or (starts_with_title >= 0 and (image or length >= 150)):
65− first_paragraph = paragraph
69− if failed_attempts > 3:
72− return first_paragraph
75# get response from search-request
52# get response from search-request
76def response(resp):
53def response(resp):
77 results = []
54 results = []
@@ -97,10 +74,7 @@ def response(resp):
98 image = image.get('source')
75 image = image.get('source')
100− extract = page.get('extract')
77+ summary = page.get('extract', '').split('\n')[0].replace('()', '')
102− summary = extract_first_paragraph(extract, title, image)
103− summary = summary.replace('() ', '')
105 # link to wikipedia article
79 # link to wikipedia article
106 wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \
80 wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \