【问题标题】:RDF schema for electoral data选举数据的 RDF 模式
【发布时间】:2016-11-17 07:48:57
【问题描述】:

我正在设计一个本体来表示来自投票事件(选举或公投)的 RDF 选举结果。

我定义了以下

  • 选举

  • 选举名单

  • 候选人

  • 选举机构

以及以下属性:

  • totalVotesCastedelectoralBody 和范围 int

  • votesReceived,域 electoralList / candidate 和范围 int

  • dateOfElection,域 election 和范围 date

我设想我的 RDF 是这样的:

<Election rdf:about="election1">
  <dateOfElection>2000-01-01</dateOfElection>
  <totalVotesCasted>60</totalVotesCasted>
  <electoralBody rdf:about="county1">
    <candidate rdf:about="Peter Parker">
     <votesReceived>12</votesReceived>
    </candidate>
    <candidate rdf:about="Clark Kent">
     <votesReceived>34</votesReceived>
    </candidate>
    <candidate rdf:about="Bruce Wayne">
     <votesReceived>14</votesReceived>
    </candidate>
  </electoralBody>
</rdf:Election>
<Election rdf:about="election2">
...
</rdf:Election>

这种嵌套结构对于在 RDF 中结构化数据是否正确和可取?

【问题讨论】:

  • 信息不足。您的类列表与无效的 RDF 不一致,例如您将选举列为一个类,将选举列为一个 XML 元素。未指定您打算在类之间建立的关系。如果您必须使用 RDF/XML 而不是更具可读性的Turtle,那么它应该是有效的 XML 和有效的 RDF/XML,然后任何人才能就适当的结构向您提供建议。
  • 不要费心尝试手动编写 RDF/XML。没有必要。写Turtle就行了,以后如果需要,可以转成RDF/XML。

标签: rdf ontology linked-data


【解决方案1】:

正如@chrisis 所说,您需要定义类之间的关系。我建议您像这样构建您的 RDF/XML(使用 rdf 集合对选举机构的候选人进行分组):

<rdf:RDF
  xmlns="http://example.org/election#" 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <Election rdf:about="election1">
    <dateOfElection rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2000-01-01</dateOfElection>
    <totalVotesCasted rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">60</totalVotesCasted>
    <hasElectoralBody>
      <ElectoralBody rdf:about="county1">
        <hasCandidates rdf:parseType="Collection">
          <Candidate rdf:about="PeterParker">
            <votesReceived rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">12</votesReceived>
          </Candidate>
          <Candidate rdf:about="ClarkKent">
            <votesReceived rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">34</votesReceived>
          </Candidate>
          <Candidate rdf:about="BruceWayne">
            <votesReceived rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">14</votesReceived>
          </Candidate>
        </hasCandidates>
      </ElectoralBody>
    </hasElectoralBody>
  </Election>
  <Election rdf:about="election2">
    ...
  </Election>
</rdf:RDF>

或者(如果在海龟中):

@prefix : <http://example.org/election#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:election1 a :Election ;
    :dateOfElection "2000-01-01"^^xsd:date ;
    :totalVotesCasted 60 ;
    :hasElectoralBody :county1 .

:county1 a :ElectoralBody ;
    hasCandidates ( :PeterParker :ClarkKent :BruceWayne )
    .
:PeterParker a :Candidate ;
    :votesReceived 12 .
:ClarkKent a :Candidate ;
    :votesReceived 34 .
:BruceWayne a :Candidate ;
    :votesReceived 14 .

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-28
    相关资源
    最近更新 更多