SPARQL构造。如何将RDF属性的值分配给实际的RDF变量

时间:2018-05-24 13:33:17

标签: sparql rdf ontology

我的查询(摘录)大致是这个。

CONSTRUCT {
?publication fb:type ?type;
fb:publicationType ?publicationType;
}
WHERE 
{
?publication a bibo:Document .
?publication vitro:mostSpecificType ?publicationType .
}

它返回类似于......的输出

<rdf:Description rdf:about="https://abcd.fgh/individual/publication12345">
    <fb:publication>Example pub title</fb:publication>
    <fb:publicationType rdf:resource="http://purl.org/ontology/bibo/AcademicArticle"/>
</rdf:Description>

也许是一个初学者式的问题,但我如何调整查询以使输出为:

<rdf:Description rdf:about="https://abcd.fgh/individual/publication12345">
    <fb:publication>Example pub title</fb:publication>
    <fb:publicationType>Academic Article</fb:publicationType>
</rdf:Description>

由于

1 个答案:

答案 0 :(得分:3)

假设bibo ontology位于您要查询的商店中,您可以在property path中使用其rdfs:label属性:

CONSTRUCT {
  ?publication fb:type ?type;
    fb:publicationType ?publicationType;
} WHERE {
  ?publication a bibo:Document ;
    vitro:mostSpecificType/rdfs:label ?publicationType .
  FILTER (LANG(?publicationType) = "en")
}

?a vitro:mostSpecificType/rdfs:label ?b?a vitro:mostSpecificType ?something. ?something rdfs:label ?b的简写,没有约束中间词。