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

Wrong Output #266

Open
MS-Jahan opened this issue Jan 19, 2021 · 5 comments
Open

Wrong Output #266

MS-Jahan opened this issue Jan 19, 2021 · 5 comments

Comments

@MS-Jahan
Copy link

I tried this:

import wikipedia
print(wikipedia.search("Ubuntu"))

It gave me this:

/home/sjs/.local/lib/python3.9/site-packages/wikipedia/wikipedia.py:389: GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html5lib"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 389 of the file /home/sjs/.local/lib/python3.9/site-packages/wikipedia/wikipedia.py. To get rid of this warning, pass the additional argument 'features="html5lib"' to the BeautifulSoup constructor.

  lis = BeautifulSoup(html).find_all('li')
Traceback (most recent call last):
  File "/home/sjs/msg/fbchat/wiki.py", line 2, in <module>
    print(wikipedia.summary("Ubuntu"))
  File "/home/sjs/.local/lib/python3.9/site-packages/wikipedia/util.py", line 28, in __call__
    ret = self._cache[key] = self.fn(*args, **kwargs)
  File "/home/sjs/.local/lib/python3.9/site-packages/wikipedia/wikipedia.py", line 231, in summary
    page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
  File "/home/sjs/.local/lib/python3.9/site-packages/wikipedia/wikipedia.py", line 276, in page
    return WikipediaPage(title, redirect=redirect, preload=preload)
  File "/home/sjs/.local/lib/python3.9/site-packages/wikipedia/wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "/home/sjs/.local/lib/python3.9/site-packages/wikipedia/wikipedia.py", line 393, in __load
    raise DisambiguationError(getattr(self, 'title', page['title']), may_refer_to)
wikipedia.exceptions.DisambiguationError: "bantu" may refer to: 
Bantu languages
Bantu peoples
Bantu knots
Black Association for Nationalism Through Unity
Bantu (band)
Bantu (album)
Bantu FC
Bantu expansion
Bantustan

I installed this package from pip: pip install wikipedia
Python Version: 3.9.1

What's wrong?

@MS-Jahan
Copy link
Author

MS-Jahan commented Jan 19, 2021

I've uninstalled wikipedia from pip and cloned this repo. The output is different this time but still getting errors.

Traceback (most recent call last):
  File "/home/sjs/msg/fbchat/wiki.py", line 2, in <module>
    print(wikipedia.summary("Ubuntu"))
  File "/home/sjs/msg/fbchat/wikipedia/util.py", line 28, in __call__
    ret = self._cache[key] = self.fn(*args, **kwargs)
  File "/home/sjs/msg/fbchat/wikipedia/wikipedia.py", line 231, in summary
    page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
  File "/home/sjs/msg/fbchat/wikipedia/wikipedia.py", line 276, in page
    return WikipediaPage(title, redirect=redirect, preload=preload)
  File "/home/sjs/msg/fbchat/wikipedia/wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "/home/sjs/msg/fbchat/wikipedia/wikipedia.py", line 393, in __load
    raise DisambiguationError(getattr(self, 'title', page['title']), may_refer_to)
wikipedia.exceptions.DisambiguationError: "bantu" may refer to: 
Bantu languages
Bantu peoples
Bantu knots
Black Association for Nationalism Through Unity
Bantu (band)
Bantu (album)
Bantu FC
Bantu expansion
Bantustan

@Sgewux
Copy link

Sgewux commented Jan 27, 2021

Same bro :(

@MS-Jahan
Copy link
Author

Same bro :(

I've started using pymediawiki. Try this out.

@iamtheef
Copy link

Also, "goat" returns results for boat and "sheep" returns results about "ship" xD

@wlerin
Copy link

wlerin commented Jul 9, 2021

See #279

TL;DR: add auto_suggest=False to search and summary and page calls (maybe others too).

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

4 participants