选举数据的RDF模式

时间:2016-11-17 07:48:57

标签: rdf ontology linked-data

我设计一个本体论来代表RDF选举结果来自投票活动(选举或公投)。

我定义了以下

  • electoralList

  • 候选

  • electoralBody

以及以下属性:

  • totalVotesCasted ,域名为 electoralBody ,范围为int

  • votesReceived ,域名为选举列表 / 候选人,范围为int

  • dateOfElection ,域名选举,范围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中构造数据?

1 个答案:

答案 0 :(得分:0)

正如@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 .