![](/img/trans.png)
[英]Google’s Freebase API: Basic MQL Query and JSON Parse Example in Java?
[英]Freebase MQL to list out all commons types for a given word?
我正在試圖弄清楚如何編寫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"
}
}]
有幾種不同的方法可以做到這一點,每種方式都有不同的權衡。
將Search 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憲法和USS憲法結果 - 你可以得到所有類型的列表通過添加&mql_output = {“type”:[]},但是你失去了“值得注意的”類型。 我認為沒有辦法在一次通話中獲得兩者。
此查詢返回所需的基本信息:
[{
"name~=":"uss constitution",
"type":[],
"/common/topic/notable_types" : []
}]
注意事項:
根據您要完成的任務,您可能需要比這更復雜的東西(以及對Freebase中的內容有更深入的了解),但這應該讓您了解基礎知識。
你試過了嗎:
[{
"name": "David Bowie",
"type": []
}]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.