从维基百科真正搜索和发现 api
True Search and Discover from Wikipedia api
我有一个字符串要搜索"founder of google"
但是 returns
{
"query-continue":{
"search":{
"sroffset":10
}
},
"query":{
"searchinfo":{
"totalhits":14577
},
"search":[
{
"ns":0,
"title":"Lars Rasmussen (software developer)"
},
{
"ns":0,
"title":"Wirth's law"
},
{
"ns":0,
"title":"Brin"
},
{
"ns":0,
"title":"H\u00e9ctor Garc\u00eda-Molina"
},
{
"ns":0,
"title":"Chris Wetherell"
},
{
"ns":0,
"title":"Forbes list of The World's Most Powerful People"
},
{
"ns":0,
"title":"Tamil American"
},
{
"ns":0,
"title":"Lars Rasmussen"
},
{
"ns":0,
"title":"List of Jewish American computer scientists"
},
{
"ns":0,
"title":"Larry"
}
]
}
}
但我只想要这两个真实结果:
{
"ns":0,
"title":"Brin"
},
{
"ns":0,
"title":"Larry"
}
维基百科页面 Lars Rasmussen (software developer) 以以下段落开头(强调 我的):
"Lars Eilstrup Rasmussen is a Danish-born[1] computer scientist, software developer, and co-founder of Google Maps."
因此,这是您的搜索查询的完全有效结果。它的所有其他页面也是如此 returns。例如Wirth's law上的文章是这样写的:
"The law was restated in 2009 and attributed to Larry Page, founder of Google."
Héctor García-Molina 上的文章包含句子:
"He was advisor to Sergey Brin, the founder of Google, from 1993 to 1997 when he was a computer science student at Stanford."
维基百科的搜索不是 AI — 它不理解 "founder of Google" 的意思。它只是为您提供恰好包含您正在搜索的短语的页面列表。这就是应该要做的。
尝试输入 "who was the founder of google" here.
一般来说,语义搜索使用 Wikidata,而不是维基百科。
(1) - https://www.wikidata.org/w/api.php?action=wbsearchentities&search= google &language=en&type=item&format=json
(2) - https://www.wikidata.org/w/api.php?action=wbsearchentities&search= founder &language=en&type=property&format=json
(3) - https://www.wikidata.org/w/api.php?action=wbgetclaims&entity={id of 1st link}&property={id of 2nd link}&format=json
(4) - https://www.wikidata.org/w/api.php?action=wbgetentities&ids={ numeric-id of 3rd link }&languages=en&format=json&props=labels|descriptions|aliases
我有一个字符串要搜索"founder of google"
但是 returns
{
"query-continue":{
"search":{
"sroffset":10
}
},
"query":{
"searchinfo":{
"totalhits":14577
},
"search":[
{
"ns":0,
"title":"Lars Rasmussen (software developer)"
},
{
"ns":0,
"title":"Wirth's law"
},
{
"ns":0,
"title":"Brin"
},
{
"ns":0,
"title":"H\u00e9ctor Garc\u00eda-Molina"
},
{
"ns":0,
"title":"Chris Wetherell"
},
{
"ns":0,
"title":"Forbes list of The World's Most Powerful People"
},
{
"ns":0,
"title":"Tamil American"
},
{
"ns":0,
"title":"Lars Rasmussen"
},
{
"ns":0,
"title":"List of Jewish American computer scientists"
},
{
"ns":0,
"title":"Larry"
}
]
}
}
但我只想要这两个真实结果:
{
"ns":0,
"title":"Brin"
},
{
"ns":0,
"title":"Larry"
}
维基百科页面 Lars Rasmussen (software developer) 以以下段落开头(强调 我的):
"Lars Eilstrup Rasmussen is a Danish-born[1] computer scientist, software developer, and co-founder of Google Maps."
因此,这是您的搜索查询的完全有效结果。它的所有其他页面也是如此 returns。例如Wirth's law上的文章是这样写的:
"The law was restated in 2009 and attributed to Larry Page, founder of Google."
Héctor García-Molina 上的文章包含句子:
"He was advisor to Sergey Brin, the founder of Google, from 1993 to 1997 when he was a computer science student at Stanford."
维基百科的搜索不是 AI — 它不理解 "founder of Google" 的意思。它只是为您提供恰好包含您正在搜索的短语的页面列表。这就是应该要做的。
尝试输入 "who was the founder of google" here.
一般来说,语义搜索使用 Wikidata,而不是维基百科。
(1) - https://www.wikidata.org/w/api.php?action=wbsearchentities&search= google &language=en&type=item&format=json
(2) - https://www.wikidata.org/w/api.php?action=wbsearchentities&search= founder &language=en&type=property&format=json
(3) - https://www.wikidata.org/w/api.php?action=wbgetclaims&entity={id of 1st link}&property={id of 2nd link}&format=json
(4) - https://www.wikidata.org/w/api.php?action=wbgetentities&ids={ numeric-id of 3rd link }&languages=en&format=json&props=labels|descriptions|aliases