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

error when getting a word's summary #279

Open
karimk123 opened this issue Apr 26, 2021 · 5 comments · May be fixed by #310
Open

error when getting a word's summary #279

karimk123 opened this issue Apr 26, 2021 · 5 comments · May be fixed by #310

Comments

@karimk123
Copy link

karimk123 commented Apr 26, 2021

`
import wikipedia
print(wikipedia.summary("Ubuntu"))

    The code that caused this warning is on line 389 of the file C:\Users\karim\AppData\Local\Programs\Python\Python38-32\lib\site-packages\wikipedia\wikipedia.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.
    
      lis = BeautifulSoup(html).find_all('li')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Users\karim\AppData\Local\Programs\Python\Python38-32\lib\site-packages\wikipedia\util.py", line 28, in __call__
        ret = self._cache[key] = self.fn(*args, **kwargs)
      File "C:\Users\karim\AppData\Local\Programs\Python\Python38-32\lib\site-packages\wikipedia\wikipedia.py", line 231, in summary
        page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
      File "C:\Users\karim\AppData\Local\Programs\Python\Python38-32\lib\site-packages\wikipedia\wikipedia.py", line 276, in page
        return WikipediaPage(title, redirect=redirect, preload=preload)
      File "C:\Users\karim\AppData\Local\Programs\Python\Python38-32\lib\site-packages\wikipedia\wikipedia.py", line 299, in __init__
        self.__load(redirect=redirect, preload=preload)
      File "C:\Users\karim\AppData\Local\Programs\Python\Python38-32\lib\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`

it used to work normally before but now i just randomly get this error for some reason.

@wlerin
Copy link

wlerin commented May 3, 2021

Auto suggestion is turned on by default for summary. This is mind-boggling terrible and the fact that it ever works is frankly miraculous. Turn it off:

wikipedia.summary("Ubuntu", auto_suggest=False)

@karimk123
Copy link
Author

Thanks!

@KairaNithin
Copy link

@wlerin auto_suggest is not working in specific cases. It worked for your example by try the word "Sabrina" in case of Ubuntu, where it fails.
image

@wlerin
Copy link

wlerin commented Jul 6, 2021

@KairaNithin That looks like it's working as intended? That query is too vague so of course it throws a DisambiguationError, but at least it didn't get transformed into something completely different like with Ubuntu turning into bantu, even though there's an Ubuntu page.

@eschinei
Copy link

eschinei commented Jun 7, 2022

@KairaNithin That looks like it's working as intended? That query is too vague so of course it throws a DisambiguationError, but at least it didn't get transformed into something completely different like with Ubuntu turning into bantu, even though there's an Ubuntu page.

I believe the issue is in line 274: title = suggestion or results[0]
If there is any result, it should take it. This line will prioritize the suggestions.
This happens with 'blockchain' for instance, it will never find it.

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

Successfully merging a pull request may close this issue.

4 participants