维基百科 api 似乎几乎总是把有问题的词弄错
The wikipedia api seems to almost always get the word in question wrong
我正在使用维基百科 python 库 (https://pypi.org/project/wikipedia/),在大多数情况下,它似乎会自动更正我正在使用的术语或其他内容,因此它们经常是错误的。
例如,“青蛙”改为“食物”,“皇冠”改为“十字架”:
input: wikipedia.page("frog")
output: <WikipediaPage 'Food'>
input: wikipedia.summary("Frog")
output: 'Food is any substance consumed to provide nutritional support for an organism..."
input: wikipedia.page("crown")
output: <WikipediaPage 'Cross'>
当使用wikipedia.search时,它似乎提供了一个合适的列表,但我不知道在使用.summary等时如何利用它来获得正确的页面:
input: print(wikipedia.search("frog"))
output: ['Frog', 'FROG', 'The Princess and the Frog', 'Boiling frog', 'Frog legs', 'Frogger', 'The Scorpion and the Frog', 'Pepe the Frog', 'The Frog Prince', 'Common frog']
这是因为 auto_suggest
在 summary()
上的默认设置是 True
。
根据 docs,您可以将其更改为 False
,它将正确 return frog
的摘要。
wikipedia.summary("Frog", auto_suggest=False)
#'A frog is any member of a diverse and largely carnivorous group of short-bodied, tailless amphibians composing the order Anura (literally without tail in Ancient Greek)
看起来,无论出于何种奇怪的原因,API's
suggest()
功能都……很奇怪。
最好保持 auto_suggest
到 False
..
wikipedia.suggest("Frog")
#'food'
wikipedia.suggest("Steak")
#'steam'
wikipedia.suggest("Dog")
#'do'
wikipedia.suggest("cat")
#'cats'
wikipedia.suggest("david attenborough")
#None
我正在使用维基百科 python 库 (https://pypi.org/project/wikipedia/),在大多数情况下,它似乎会自动更正我正在使用的术语或其他内容,因此它们经常是错误的。
例如,“青蛙”改为“食物”,“皇冠”改为“十字架”:
input: wikipedia.page("frog")
output: <WikipediaPage 'Food'>
input: wikipedia.summary("Frog")
output: 'Food is any substance consumed to provide nutritional support for an organism..."
input: wikipedia.page("crown")
output: <WikipediaPage 'Cross'>
当使用wikipedia.search时,它似乎提供了一个合适的列表,但我不知道在使用.summary等时如何利用它来获得正确的页面:
input: print(wikipedia.search("frog"))
output: ['Frog', 'FROG', 'The Princess and the Frog', 'Boiling frog', 'Frog legs', 'Frogger', 'The Scorpion and the Frog', 'Pepe the Frog', 'The Frog Prince', 'Common frog']
这是因为 auto_suggest
在 summary()
上的默认设置是 True
。
根据 docs,您可以将其更改为 False
,它将正确 return frog
的摘要。
wikipedia.summary("Frog", auto_suggest=False)
#'A frog is any member of a diverse and largely carnivorous group of short-bodied, tailless amphibians composing the order Anura (literally without tail in Ancient Greek)
看起来,无论出于何种奇怪的原因,API's
suggest()
功能都……很奇怪。
最好保持 auto_suggest
到 False
..
wikipedia.suggest("Frog")
#'food'
wikipedia.suggest("Steak")
#'steam'
wikipedia.suggest("Dog")
#'do'
wikipedia.suggest("cat")
#'cats'
wikipedia.suggest("david attenborough")
#None