import wikipedia
print(wikipedia.summary("Tomato", sentences=3))
为什么此代码会返回带有“tom tom”的消歧错误,而不仅仅是条目“tomato”的摘要/消歧错误?搜索词显然不是汤姆汤姆或者我在这里遗漏了什么?为什么这不起作用?
import wikipedia
print(wikipedia.summary("Tomato", sentences=3))
为什么此代码会返回带有“tom tom”的消歧错误,而不仅仅是条目“tomato”的摘要/消歧错误?搜索词显然不是汤姆汤姆或者我在这里遗漏了什么?为什么这不起作用?
搜索"Tomato"
导致建议"tom tom"
。不知道为什么......无论如何,您可以auto_suggest
禁用wikipedia.summary
:
import wikipedia
wikipedia.summary("Tomato", sentences=3, auto_suggest=False)
输出是
'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.'
您可以看到搜索"Tomato"
建议"tom tom"
使用该wikipedia.search
功能:
results, suggestion = wikipedia.search("Tomato", suggestion=True)
suggestion
是"tom tom"
和是与番茄密切相关的results
标题列表。