gpt4 book ai didi

json - Freebase MQL 列出给定单词的所有公共(public)类型?

转载 作者:行者123 更新时间:2023-12-05 00:01:07 26 4
gpt4 key购买 nike

我正在尝试弄清楚如何编写 MQL 查询以获取与给定单词关联的所有类型的列表。

例如我试过:

{
"id":null,
"name":null,
"name~=": "SOME_WORD",
"type":"/type/type",
"domain": {
"id": null,
"/freebase/domain_profile/category": {
"id": "/category/commons"
}
}
}​

我发现它列出了所有 Commons 类型或类别,但还没有想出如何针对给定输入缩小范围。

[{
"id": null,
"name": null,
"type": "/freebase/domain_profile",
"category": {
"id": "/category/commons"
}
}]​

最佳答案

有几种不同的方法可以做到这一点,每种方法都有不同的权衡。

  1. 像这样使用搜索 API 进行查询

    https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28all%20name {full}:%22uss%20constitution%22%29

您将得到如下所示的 JSON 结果:

{
"status": "200 OK",
"result": [
{
"mid": "/m/07y14",
"name": "USS Constitution",
"notable": {
"name": "Ship",
"id": "/boats/ship"
},
"lang": "en",
"score": 1401.410400
},
...

您可以通过将“{full}”切换为“{phrase}”来使匹配更加自由,这将为您提供子字符串匹配而不是完全匹配。

注意事项: - 你只会得到一个“值得注意的类型”,它由 Freebase 的(未知)算法修复 - 我认为没有办法同时获得 USS Constitution 和 U.S.S.体质结果 - 您可以通过添加 &mql_output={"type":[]} 来获得所有类型的列表,但是您会丢失“值得注意的”类型。我不认为有一种方法可以在一个电话中同时获得两者。

  1. 使用 MQL

此查询返回您想要的基本信息:

[{
"name~=":"uss constitution",
"type":[],
"/common/topic/notable_types" : []
}]​

注意事项:

  • 它不会找到“uss constitution”,它是一个别名而不是主要名称(虽然在 MQL cookbook 中有一个配方)
  • 它不会找到“u.s.s. constitution”
  • “notable_types”API 是一个 MQL 扩展,新的 Freebase API 不支持 MQL 扩展,仅支持遗留的已弃用 API
  • 您与 Freebase 用于计算“知名度”的任何(未知)算法有关

根据您要完成的目标,您可能需要比这更复杂的东西(以及对 Freebase 中的内容有更深入的了解),但这应该让您了解基础知识。

关于json - Freebase MQL 列出给定单词的所有公共(public)类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9491528/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com