代码之家  ›  专栏  ›  技术社区  ›  bmargulies

文本中实体引用的rdf表示

  •  2
  • bmargulies  · 技术社区  · 14 年前

    考虑这样一个句子:

    在一个好日子里,贴名字的人会把“约翰·史密斯”当作一个人,把“华盛顿”当作一个地方。然而,如果没有其他证据,它无法分辨世界上所有可能的“约翰·史密斯”中的哪一个,甚至也无法分辨华盛顿的各种“约翰·史密斯”中的哪一个。

    最终,一些解决过程可能会根据其他证据做出决定。然而,在此之前,用RDF表示这些引用的好做法是什么?在某个命名空间中为它们分配唯一的标识符?生成空元组(例如“文档d中引用了一个叫John Smith的人”)?还有别的选择吗?我的一本书给出了一个涉及匿名气象站的例子,但我不太明白他们的例子如何与所描述的RDF的所有其他内容相吻合。

    4 回复  |  直到 14 年前
        1
  •  3
  •   glenn mcdonald    14 年前

    在您自己的命名空间中为它们分配唯一的标识符。如果你后来发现这个“华盛顿”和 http://dbpedia.org/resource/Washington,_D.C 或者别的什么,你可以加一个owl:sameAs to 断言。

        2
  •  2
  •   nathan    14 年前

    首先,您可以使用现有的良好服务进行实体识别,例如 OpenCalais , Zemanta Alchemy

    不过,更具体地说,是的,只需为每件事“造出”自己的URI(标识符),然后讨论它们——在turtle中为这些信息提供一个表示

    @prefix : <http://yourdomain.com/data/> .
    @prefix myont: <http://yourdomain.com/ontology/> .
    @prefix dcterms: <http://purl.org/dc/terms/> .
    @prefix dbpedia-owl: <http://dbpedia.org/ontology/Place>.
    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    
    :John_Smith#d rdf:type foaf:Person ;
      foaf:name "John Smith"@en .
    
    :Washington#d rdf:type dbpedia-owl:Place ;
      rdfs:label "Washington"@en .
    
    :John_Smith#d myont:travelled_to :Washington#d .
    
    <http://yourdomain.com/some-doc#this> rdf:type foaf:Document ;
      dcterms:references :John_Smith#d, :Washington#d .
    

        3
  •  1
  •   wikier    12 年前

    您可能需要了解Apache Stanbol是如何做到这一点的: http://stanbol.apache.org/docs/trunk/components/enhancer/enhancementstructure.html

        4
  •  0
  •   Recurse    14 年前

    您可以像上面讨论的那样创建自己的URI,也可以使用空白节点。两种方法各有利弊:

    URI有一个外部标识,因此您可以在将来的查询中显式引用您的概念,这可以使某些查询更简单;但是,它们有一个外部标识,因此用于构造URI的算法成为基础结构的关键部分,并且必须保证它们既稳定又唯一。这在一开始可能很琐碎,但当您开始处理在不同时间(通常是并行地)重新处理的多个文档时,在分布式系统上,它很快就不再是直接处理了。

    在这两种情况下,尤其是当您使用空白节点时,无论如何都应该包含出处语句来描述它。

    因此,使用空白节点的示例可能是:

    @prefix my: <http://yourdomain.com/2010/07/20/conceptmap#> .
    @prefix proc: <http://yourdomain.com/2010/07/20/processing#> .
    @prefix prg: <http://yourdomain.com/processors#> .
    
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix xsd: <http://www.example.org/> .
    @prefix dcterms: <http://purl.org/dc/terms/> .
    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix doc: <http://yourdomain.com/doc-path/> .
    
    _:1 rdf:type proc:ProcessRun ; 
        proc:parser prg:tagger ;
        proc:version "1.0.2" ;
        proc:time "2010-07-03 20:35:45"^^<xsd:Timestamp> ;
        proc:host prg:hostname-of-processing-node ;
        proc:file doc:some-doc#line=1,;md5=md5_sum_goes_here,mime-charset_goes_here ;
    
    _:2 rdf:type foaf:Person ;
        foaf:name "John Smith"@en ;
        proc:identifiedBy _:1 ;
        proc:atLocation doc:some-doc#char=0,9 .
    
    
    _:3 rdf:type owl:Thing ;
        foaf:name "Washington"@en ;
        proc:identifiedBy _:1 ;
        proc:atLocation doc:some-doc#char=24,33 .
    
    <http://yourdomain.com/some-doc#this> rdf:type foaf:Document ;
                                          dcterms:references _:2, _:3 .
    

    注意使用rfc5147文本/纯片段标识符来唯一地标识正在处理的文件,这为您提供了如何标识单个运行的灵活性。另一种方法是在文档根的URI中捕获所有这些内容,或者完全放弃出处。

    @prefix : <http://yourdomain.com/ProcessRun/parser=tagger/version=1.0.2/time=2010-07-03+20:35:45/host=hostname-of-processing-node/file=http%3A%2F%2Fyourdomain.com%2Fdoc-path%2Fsome-doc%23line%3D1%2C%3Bmd5%3Dmd5_sum_goes_here%2Cmime-charset_goes_here/$gt; .
    
    @prefix my: <http://yourdomain.com/2010/07/20/conceptmap#> .
    @prefix proc: <http://yourdomain.com/2010/07/20/processing#> .
    @prefix prg: <http://yourdomain.com/processors#> .
    
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix xsd: <http://www.example.org/> .
    @prefix dcterms: <http://purl.org/dc/terms/> .
    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix doc: <http://yourdomain.com/doc-path/some-doc#> .
    
    :1 rdf:type proc:ProcessRun ; 
        proc:parser prg:tagger ;
        proc:version "1.0.2" ;
        proc:time "2010-07-03 20:35:45"^^<xsd:Timestamp> ;
        proc:host prg:hostname-of-processing-node ;
        proc:file doc:some-doc#line=1,;md5=md5_sum_goes_here,mime-charset_goes_here ;
    
    :2 rdf:type foaf:Person ;
        foaf:name "John Smith"@en ;
        proc:identifiedBy :1 ;
        proc:atLocation doc:some-doc#char=0,9 .
    
    
    :3 rdf:type owl:Thing ;
        foaf:name "Washington"@en ;
        proc:identifiedBy :1 ;
        proc:atLocation doc:some-doc#char=24,33 .
    
    <http://yourdomain.com/some-doc#this> rdf:type foaf:Document ;
                                          dcterms:references :2, :3 .
    

    最终,如果我要在图中发布出处信息以及最终的统一实体,我会倾向于使用空白节点,并将URI分配给最终统一实体的概念。

    然而,如果我不打算追踪推论的出处,而这只是管道中的一次传递,最终将丢弃中间结果,那么我只需要使用某种文档哈希、时间戳和id来创建uri,就可以了。

    @prefix : <http://yourdomain.com/entities#> .
    @prefix my: <http://yourdomain.com/2010/07/20/conceptmap#> .
    
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix dcterms: <http://purl.org/dc/terms/> .
    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    
    :filename_timestamp_1 rdf:type foaf:Person ;
                          foaf:name "John Smith"@en .
    
    :filename_timestamp_2 rdf:type owl:Thing ;
        foaf:name "Washington"@en .
    
    <http://yourdomain.com/some-doc#this> rdf:type foaf:Document ;
                                          dcterms:references :2, :3 .