我有一個壓縮的 freebase 數(shù)據(jù)轉(zhuǎn)儲,其中包含所有實體。如何使用 grep 或其他東西將數(shù)據(jù)轉(zhuǎn)儲修剪為僅包含英文實體?這是我試圖讓 rdf 轉(zhuǎn)儲看起來像的內(nèi)容:http : //play.golang.org/p/-WwSysL3y3<card> <title></title> <image></image> <text></text> <facts> <fact></fact> <fact></fact> <fact></fact> </fact></card>其中 card 是在所有子元素中具有內(nèi)容的每個實體。標題是 /type/object/name。文本是由 完成的主題中間的圖像"https://usercontent.googleapis.com/freebase/v1/image"%s"\n", id。文本是實體的 /common/document/text。和事實及其事實兒童作為事實,如年齡、出生日期、身高、在搜索中的知識面板中顯示的事實。這是我在 Go ( Golang ) 中將 rdf 解析為 xml 的嘗試。如果有人能幫我獲得這種形式的 rdf,我將不勝感激。這是我正在嘗試做的算法或邏輯:For every entity written in english: parse the `type/object/name`property's and write that to the xml file in the `<title></title>` element. parse the mid and add that to `https://usercontent.googleapis.com/freebase/v1/image`and then write the result to the xml file in the <image></image> element. parse the common/document/text property and writes its value to the <text></text> element. And lastly, for each fact about the entity, write them to the <fact></fact> elements in the XML file, which are all children of the <facts></facts> element.
1 回答

紫衣仙女
TA貢獻1839條經(jīng)驗 獲得超15個贊
我同意 Joshua Taylor 的觀點,這個問題很難破譯,因為實體通常是 Freebase 對象的同義詞,它可能有多種語言的標簽(或根本沒有標簽/文本)。
如果我們將問題改寫為“如何從壓縮的 Freebase 轉(zhuǎn)儲中過濾所有非英語文本?”,它就變成了我們可以實際回答的問題。
在 RDF 中,所有字符串都標有它們的語言,所以如果我們看到類似
ns:award.award_winner rdfs:label "Lauréat"@fr.
我們可以看出這Lauréat
是 Freebase 類型的法語名稱Award Winner
,英文名稱。
要過濾掉非英文標簽,請使用 zgrep 過濾那些匹配“@...但不匹配”@en 的行。這將為您提供所有類型、屬性、數(shù)字和英文標簽/描述,但不會排除那些沒有至少一個英文標簽的對象(對您的問題的另一種可能解釋)。要進行這種級別的過濾,您可能需要比 grep 更強大的東西。
- 1 回答
- 0 關注
- 248 瀏覽
添加回答
舉報
0/150
提交
取消