import wikipedia
print(wikipedia.summary("Tomato", sentences=3))
Why does this code return a disambiguation error with "tom tom" and not just a summmary/disambiguation error to the entry "tomato"? The search term is clearly not tom tom or am I missing something here? Why doesnt this work?
Searching for "Tomato"
leads to the suggestion "tom tom"
. Not sure why... In any case, you can disable auto_suggest
in wikipedia.summary
:
import wikipedia
wikipedia.summary("Tomato", sentences=3, auto_suggest=False)
The output is
'The tomato is the edible, often red, berry of the plant Solanum lycopersicum, commonly known as a tomato plant. The species originated in western South America and Central America. The Nahuatl (the language used by the Aztecs) word tomatl gave rise to the Spanish word tomate, from which the English word tomato derived.'
You can see that searching for "Tomato"
suggests "tom tom"
using the wikipedia.search
function:
results, suggestion = wikipedia.search("Tomato", suggestion=True)
The suggestion
is "tom tom"
, and results
is a list of titles that are closely related to tomato.