我有一个rdf-schema和turtle语法中的三元组(提取):
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#own, TODO change it
@prefix japany: <http://vschuberth.bplaced.net/rdfschema.ttl#> .
japany:import a rdfs:Class.
japany:food a rdfs:Class.
japany:radioactiveIngredients a rdfs:Class.
japany:imports a rdf:Property;
rdfs:range dbr:PopulatedPlace;
rdfs:domain japany:import.
japany:exports a rdf:Property;
rdfs:range dbr:PopulatedPlace;
rdfs:domain japany:import.
japany:importQuantity a rdf:Property;
rdfs:range xsd:integer;
rdfs:domain japany:import.
japany:importValue a rdf:Property;
rdfs:range xsd:integer;
rdfs:domain japany:import.
japany:year a rdf:Property;
rdfs:range xsd:gYear;
rdfs:domain japany:import.
japany:isPartOf a rdf:Property;
rdfs:range japany:import;
rdfs:domain japany:food.
japany:nameOfIng a rdf:Property;
rdfs:range rdf:Class;
rdfs:domain japany:radioactiveIngredients.
japany:amount a rdf:Property;
rdfs:range japany:bqkg;
rdfs:domain japany:radioactiveIngredients.
japany:nameOfFood a rdf:Property;
rdfs:range rdf:Class;
rdfs:domain japany:food.
japany:dateOfSampling a rdf:Property;
rdfs:range xsd:date;
rdfs:domain japany:radioactiveIngredients.
japany:isIn a rdf:Property;
rdfs:range xsd:food;
rdfs:domain japany:radioactiveIngredients.
<#Import_of_Olivenöl>
japany:imports dbr:Germany;
japany:exports dbr:Japan;
japany:importQuantity 0;
japany:importValue 36;
japany:year "2011"^^xsd:gYear.
<#Olivenöl_Class>
japany:isPartOf <#Import_of_Olivenöl>.
<#Iodine131_in_Olivenöl>
japany:nameOfIng "Iodine131";
japany:amount "< 2,3";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
<#Cesium134_in_Olivenöl>
japany:nameOfIng "Caesium134";
japany:amount "< 1,54";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
<#Cesium137_in_Olivenöl>
japany:nameOfIng "Caesium137";
japany:amount "< 1,95";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
我很困惑如何查询所有这些实体。他们彼此相关。例如:我想编写一个查询/查询来获取每年每种食物的importValue和importQuantity,并列出每个放射性成分的含量。
此查询会给我不正确的数据:
PREFIX japany: <http://vschuberth.bplaced.net/rdfschema.ttl#>
SELECT ?importValue ?importQuantity ?name ?year
WHERE {
?trade japany:importValue ?importValue;
japany:year ?year;
japany:importQuantity ?importQuantity.
?food japany:nameOfFood ?name.
}
ORDER BY ?importQuantity
任何人都可以帮忙吗?
答案 0 :(得分:0)
问题是?food
,japany:import
未与您的查询相关联。
这是一个有效的查询:
PREFIX japany: <http://vschuberth.bplaced.net/rdfschema.ttl#>
SELECT ?importValue ?importQuantity ?name ?year
WHERE {
?food japany:isPartOf ?import .
?import japany:importValue ?importValue ;
japany:importQuantity ?importQuantity ;
japany:year ?year .
?food japany:nameOfFood ?name.
}
ORDER BY ?importQuantity
但这令人毛骨悚然:
japany:nameOfFood a rdf:Property;
rdfs:range rdf:Class.
为什么不将其创建为DatatypeProperty
,因此存储Literal
?