Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in a response for search mr bean suggestion is come up with a typo wikipedia #284

Open
biswajit-hub opened this issue Jun 26, 2021 · 2 comments

Comments

@biswajit-hub
Copy link

biswajit-hub commented Jun 26, 2021

in suggestion of "mr bean" it returns "me bean" which makes a page not found error
it is acctually a serverside typing mistake in wikipedia response in suggestion

when i printed out some of request parameter from wikipedia.py then i found::::

Listening....
Recognizing...
User Said :: Mr Bean Wikipedia

mr bean
title: mr bean

headers: {'User-Agent': 'wikipedia (https://github.com/goldsmith/Wikipedia/)'}

params: {'list': 'search', 'srprop': '', 'srlimit': 1, 'limit': 1, 'srsearch': 'mr bean ', 'srinfo': 'suggestion', 'format': 'json', 'action': 'query'}

Api Url:: http://en.wikipedia.org/w/api.php

r.json:: b'{"warnings":{"main":{"*":"Unrecognized parameter: limit."}},"batchcomplete":"","continue":{"sroffset":1,"continue":"-||"},"query":{"`

searchinfo":{"suggestion":"me bean","suggestionsnippet":"me bean"},"search":[{"ns":0,"title":"Mr. Bean","pageid":173863}]}}'

`
result:: ['Mr. Bean']
suggestions:: me bean
Title2: me bean

headers: {'User-Agent': 'wikipedia (https://github.com/goldsmith/Wikipedia/)'}

params: {'prop': 'info|pageprops', 'inprop': 'url', 'ppprop': 'disambiguation', 'redirects': '', 'titles': 'me bean', 'format': 'json', 'action': 'query'}

Api Url:: http://en.wikipedia.org/w/api.php

r.json:: b'{"batchcomplete":"","query":{"normalized":[{"from":"me bean","to":"Me bean"}],"pages":{"-1":{"ns":0,"title":"Me bean","missing":"","contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr","fullurl":"https://en.wikipedia.org/wiki/Me_bean","editurl":"https://en.wikipedia.org/w/index.php?title=Me_bean&action=edit","canonicalurl":"https://en.wikipedia.org/wiki/Me_bean"}}}}'
Traceback (most recent call last):
File "d:/MyProject/python/jervis/jervis.py", line 62, in
results = wikipedia.summary(query, sentences=2)
File "c:\python38\lib\site-packages\wikipedia\util.py", line 28, in call
ret = self._cache[key] = self.fn(*args, **kwargs)
File "c:\python38\lib\site-packages\wikipedia\wikipedia.py", line 232, in summary
page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
File "c:\python38\lib\site-packages\wikipedia\wikipedia.py", line 281, in page
return WikipediaPage(title, redirect=redirect, preload=preload)
File "c:\python38\lib\site-packages\wikipedia\wikipedia.py", line 304, in init
self.__load(redirect=redirect, preload=preload)
File "c:\python38\lib\site-packages\wikipedia\wikipedia.py", line 348, in __load
raise PageError(self.title)
wikipedia.exceptions.PageError: Page id "me bean" does not match any pages. Try another id!

@tamborello
Copy link

I've run into this as well. "ISO 8601" becomes "iso 860i." Notice where I specify the keyword "title," but Python throws an error about pageid.

results = wikipedia.search("ISO 8601"); results
==>
['ISO 8601',
'ISO week date',
'Year zero',
'Time zone',
'Sunday',
'Date and time representation by country',
'Week',
'24-hour clock',
'Calendar date',
'Date format by country']

iso8601 = wikipedia.page(title="ISO 8601")

iso8601.title

==>
PageError Traceback (most recent call last)
in
----> 1 iso8601 = wikipedia.page(title="ISO 8601")
2 # iso8601.title

c:\Users\ftamborello\Documents\Hopeful Brown.venv\lib\site-packages\wikipedia\wikipedia.py in page(title, pageid, auto_suggest, redirect, preload)
274 # if there is no suggestion or search results, the page doesn't exist
275 raise PageError(title)
--> 276 return WikipediaPage(title, redirect=redirect, preload=preload)
277 elif pageid is not None:
278 return WikipediaPage(pageid=pageid, preload=preload)

c:\Users\ftamborello\Documents\Hopeful Brown.venv\lib\site-packages\wikipedia\wikipedia.py in init(self, title, pageid, redirect, preload, original_title)
297 raise ValueError("Either a title or a pageid must be specified")
298
--> 299 self.__load(redirect=redirect, preload=preload)
300
301 if preload:

c:\Users\ftamborello\Documents\Hopeful Brown.venv\lib\site-packages\wikipedia\wikipedia.py in __load(self, redirect, preload)
343 if 'missing' in page:
344 if hasattr(self, 'title'):
--> 345 raise PageError(self.title)
346 else:
347 raise PageError(pageid=self.pageid)

PageError: Page id "iso 860i" does not match any pages. Try another id!

@wlerin
Copy link

wlerin commented Jul 9, 2021

See #279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants