【NLP】三種知識圖譜
三種知識圖譜
知識圖譜本質上是一種語義網路。其結點代表實體(entity)或者概念(concept),邊代表實體/概念之間的各種語義關係。Knowledge Graph , Freebase , Wikidata 是目前最常見的三種知識圖譜。
Knowledge Graph 是Google的一個知識庫,其使用語義檢索從多種來源收集資訊,以提高Google搜尋的質量。Knowledge Graph 2012年加入Google搜尋,2012年5月16日正式釋出,首先可在美國使用。Knowledge Graph 除了顯示其他網站的連結列表,還提供結構化及詳細的關於主題的資訊。其目標是,使用者將能夠使用此功能提供的資訊來解決他們查詢的問題,而不必導航到其他網站並自己彙總資訊。
1.搜尋api
2.搜尋結果
使用者可以指定返回的查詢結果格式,json格式的內容如下:
{ @context: { @vocab: "http://schema.org/", goog: "http://schema.googleapis.com/", EntitySearchResult: "goog:EntitySearchResult", detailedDescription: "goog:detailedDescription", resultScore: "goog:resultScore", kg: "http://g.co/kg" }, @type: "ItemList", itemListElement: [ { @type: "EntitySearchResult", result: { @id: "kg:/m/0jktd", name: "Fudan University", @type: [ "CollegeOrUniversity", "Organization", "EducationalOrganization", "Place", "Thing" ], description: "University in Shanghai, China", image: { contentUrl: "http://t3.gstatic.com/images?q=tbn:ANd9GcRL6bWR-Z8BDYVYytbMaXJiTa8l690RY2pwpAbj7EvIlRgrDb97", url: "https://commons.wikimedia.org/wiki/File:Fudan-logo.jpg", license: "http://creativecommons.org/licenses/by-sa/3.0" }, detailedDescription: { articleBody: "Fudan University, located in Shanghai, China, is one of the most prestigious and selective universities in China, and is a member in the C9 League and Universitas 21. ", url: "http://en.wikipedia.org/wiki/Fudan_University", license: "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License" }, url: "http://www.fudan.edu.cn/" }, resultScore: 40.484966 } ] }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
其中 @id 欄位為對應的entity在 Freebase 中的mid。
3.api特點
優點:
- 查詢簡單便捷
- 查詢結果可以指定以json等格式返回
- entity中的大部分資訊是直接顯示在Google相關搜尋的右側欄wiki中的,質量較高並且相對比較豐富
- 每個賬戶的免費額度為每天100,000次查詢,能夠滿足大部分使用場景
缺點:
- 不能直接得到與其相關聯的其他entity資訊
Freebase 是一個由元資料組成的大型合作知識庫,內容主要來自其社群成員的貢獻。它整合了許多網上的資源,包括部分私人wiki站點中的內容。Freebase 致力於打造一個允許全球所有人(和機器)快捷訪問的資源庫。它由美國軟體公司Metaweb開發並於2007年3月公開運營。2010年7月16日被谷歌收購。 2014年12月16日,Google宣佈將在六個月後關閉 Freebase ,並將全部資料遷移至 Wikidata 。
1.搜尋api
2.搜尋結果
典型的搜尋結果類似如下:
{
"status":"200 OK",
"result":
[
{
"mid":"/m/0jktd",
"id":"/en/fudan_university",
"name":"Fudan University",
"under":"Shanghai",
"lang":"en","score":39.771729
},
],
"cursor":20,
"cost":4,
"hits":543
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
3.api特點
優點:
- 查詢簡單便捷
- 查詢結果以json格式返回
- 每個賬戶的免費額度為每天100,000次查詢,能夠滿足大部分使用場景
缺點:
- 不能直接得到與其相關聯的其他實體資訊
- 實體中能直接利用的資訊較少
4.檢視實體詳細資訊
雖然 Freebase 的實體查詢結果中能直接利用的資訊較少,不過可以通過Freebase提供的網頁檢視相應實體的詳細資訊,只需要在首頁地址https://www.freebase.com後新增上對應的mid就能直接反問html格式的詳細資訊頁面,如 Fudan University 的mid為m/0jktd,則其詳細資訊頁面的url為https://www.freebase.com/m/0jktd。這使得利用網路爬蟲獲取實體的詳細資訊成為可能。
5.Data Dumps
另外 Freebase 還提供完整的資料庫下載,詳情參考Data Dumps。dump的資料為元組的形式,實際利用起來具有一定的挑戰性。
6.停止開放
需要注意的是,Freebase 不久將停止開放,詳情參考ShutDown。
Wikidata 是一個可協同編輯的知識庫,是繼2006年的維基學院之後,第一個新的維基媒體基金會專案。這一專案與維基共享資源的工作方式類似,將為其他維基計劃及各語種維基百科中的資訊框、列表及跨語言連結等提供統一存放的資料,該專案在2012年10月30日投入使用。
1.搜尋api
2.搜尋結果
典型的搜尋結果類似如下:
{
"batchcomplete":"",
"continue":
{
"sroffset":10,
"continue":"-||"
},
"query":
{
"searchinfo":
{
"totalhits":17
},
"search":
[
{
"ns":0,
"title":"Q495015",
"snippet":"universit\u00e9 <span class=\sity Universit\u00e0 >Fudan</span>-universiteit",
"size":17783,
"wordcount":253,
"timestamp":"2016-01-06T21:09:34Z"
},
]
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
3.api特點
優點:
- 查詢簡單便捷
- 查詢結果可以設定以json格式返回
- 沒有查詢額度限制
缺點:
- 不能直接得到與其相關聯的其他實體資訊
- 實體中能直接利用的資訊較少
4.獲取entity詳細資訊
除了提供實體查詢介面,Wikidata 還提供了專門的api用於通過實體的id獲取實體的詳細資訊,這些資訊包含與其相關聯的其他實體資訊。
此api可以將結果以多種格式返回,例如以HTTP GET的方式獲取id為Q495015的實體的詳細資訊並指定以json格式返回的url為:
https://www.wikidata.org/wiki/Special:EntityData/Q495015.json
另外還可以直接通過html方式展示實體詳細資訊,例如:
https://www.wikidata.org/wiki/Q495015
5.Database Download
對比
專案 | Knowledge Graph | Wikidata | Freebase |
---|---|---|---|
額度 | 10萬/天 | 不限 | 10萬/天 |
查詢結果中能直接利用的資訊 | 多,大部分資訊都會放在Google相關搜尋的右側wiki欄 | 很少(只有name和id) | 很少 |
資料獲取 | 線上api | 線上api + data dump | 線上api + data dump |
獲取關聯實體 | 查詢能得到實體在freebase中的mid,通過此mid獲取相關實體 | 可以直接查詢實體詳細資訊得到關聯實體 | 通過dump的資料離線分析(複雜)或者爬蟲分析實體詳情頁面 |
維護 | Wikipedia | 不久將被shut down |