Merge pull request #1686 from MarcAbonce/wiki_infobox_fixes

Infobox fixes
This commit is contained in:
Markus Heiser 2019-12-23 12:31:31 +00:00 committed by GitHub
commit 3e14bf4d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -21,7 +21,8 @@ search_url = base_url + u'w/api.php?'\
'action=query'\ 'action=query'\
'&format=json'\ '&format=json'\
'&{query}'\ '&{query}'\
'&prop=extracts|pageimages'\ '&prop=extracts|pageimages|pageprops'\
'&ppprop=disambiguation'\
'&exintro'\ '&exintro'\
'&explaintext'\ '&explaintext'\
'&pithumbsize=300'\ '&pithumbsize=300'\
@ -87,7 +88,7 @@ def response(resp):
if int(article_id) > 0: if int(article_id) > 0:
break break
if int(article_id) < 0: if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}):
return [] return []
title = page.get('title') title = page.get('title')
@ -99,6 +100,7 @@ def response(resp):
extract = page.get('extract') extract = page.get('extract')
summary = extract_first_paragraph(extract, title, image) summary = extract_first_paragraph(extract, title, image)
summary = summary.replace('() ', '')
# link to wikipedia article # link to wikipedia article
wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \ wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \

View File

@ -606,11 +606,11 @@ def index():
# HTML output format # HTML output format
# suggestions: use RawTextQuery to get the suggestion URLs with the same bang # suggestions: use RawTextQuery to get the suggestion URLs with the same bang
suggestion_urls = map(lambda suggestion: { suggestion_urls = list(map(lambda suggestion: {
'url': raw_text_query.changeSearchQuery(suggestion).getFullQuery(), 'url': raw_text_query.changeSearchQuery(suggestion).getFullQuery(),
'title': suggestion 'title': suggestion
}, },
result_container.suggestions) result_container.suggestions))
correction_urls = list(map(lambda correction: { correction_urls = list(map(lambda correction: {
'url': raw_text_query.changeSearchQuery(correction).getFullQuery(), 'url': raw_text_query.changeSearchQuery(correction).getFullQuery(),