将freebase数据转储仅限于英语实体

时间:2014-09-16 13:39:35

标签: go rdf semantic-web freebase linked-data

我有一个压缩的freebase数据转储,其中包含所有实体。我如何使用grep或其他东西来修剪数据转储只包含英文实体?

以下是我试图让rdf转储看起来像:http://play.golang.org/p/-WwSysL3y3

<card>
    <title></title>
    <image></image>
    <text></text>
    <facts>
        <fact></fact>
        <fact></fact>
        <fact></fact>
    </fact>
</card>

其中card是每个实体,其中包含所有子元素中的内容。标题是/ type / object / name。文本是"https://usercontent.googleapis.com/freebase/v1/image"%s"\n", id完成主题中间的图像。 Text是实体的/ 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 个答案:

答案 0 :(得分:0)

我同意Joshua Taylor的观点,这个问题很难解读,因为 entity 通常是Freebase对象的同义词,它可能有多种语言的标签(或根本没有标签/文本)。

如果我们将问题重新定义为“如何从压缩的Freebase转储中过滤所有非英语文本?”,那么它就会成为我们实际可以回答的内容。

在RDF中,所有字符串都标有其语言,因此如果我们看到类似

的内容
ns:award.award_winner   rdfs:label      "Lauréat"@fr.

我们可以告诉Lauréat是英语中名为Award Winner的Freebase类型的法语名称。

要过滤掉非英文标签,请使用zgrep过滤那些匹配“@ ...但不是”的行。 这将为您提供所有类型,属性,数字和英文标签/说明,但不会排除那些没有至少一个英文标签的对象(对您的问题的另一种可能的解释)。要进行这种级别的过滤,您可能需要比grep更强大的功能。