Rdf SPARQL查询限制答案

Rdf SPARQL查询限制答案,rdf,sparql,ontology,Rdf,Sparql,Ontology,我有以下疑问: PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFI

我有以下疑问:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>         
PREFIX rec:<http://www.receta.org#>
SELECT ?r (count(distinct ?Ingrediente) as ?oi)  {
?r rec:Ingrediente ?Ingrediente. 
     filter not exists {
        ?r rec:Ingrediente ?other_ingredient 
        filter( ?other_ingredient not in ( rec:Aceite, rec:Cebolla ) )  
     }
   }
GROUP BY ?r 
order by (count(distinct ?Ingrediente))
我想得到这样的东西:

 ?r         ?oi     ?PreparationMode        ?IngredientList
 Recipe1    1       First, you have to..    ing1, ing2, ing3... 
 Recipe2    2       First, you have to..    ing1, ing2, ing3... 
我试着这样做:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>         
PREFIX rec:<http://www.receta.org#>
SELECT ?r (count(distinct ?Ingrediente) as ?oi) ?mo  ?sa{
?r rec:Ingrediente ?Ingrediente. 
?m rdf:type rec:ModoPreparacion.
?m rdfs:label ?mo.
?s rdf:type rec:ListaIngredientes.
?s rdfs:label ?sa.
filter not exists {
  ?r rec:Ingrediente ?other_ingredient 
  filter( ?other_ingredient not in ( rec:Aceite, rec:Cebolla ) )    
   }
}
GROUP BY ?r ?mo ?sa
order by (count(distinct ?Ingrediente))
前缀rdf:
前缀owl:
前缀rdfs:
前缀xsd:
前缀rec:
选择?r(计数(不同的?Ingrediente)作为?oi?mo?sa{
r记录:Ingrediente?Ingrediente。
?m rdf:类型rec:ModoPreparacion。
?m rdfs:标签?mo。
?s rdf:type rec:ListaIngredientes。
?s rdfs:标签?sa。
筛选器不存在{
?r记录:Ingrediente?其他成分
过滤器(?其他成分不在(rec:Aceite,rec:Cebolla))
}
}
按r?mo?sa分组
订货人(计数(不同?不一致)
但我得到的食谱名称倍增了很多次,我不知道如何修复它。有什么想法吗?谢谢

这是DDBB结构:

每个配方都有成分和制备模式:

每个准备模式都有一个标签,标签上有说明:

每个成分列表都有一个标签,上面有其他说明:

这里还有protégéddbb:


变量?r和?m之间没有联系:

?r rec:Ingrediente ?Ingrediente. 
?m rdf:type rec:ModoPreparacion.
上面写着“找到(一个配方)?r含有成分?Ingredite,而a?m含有类型rec:ModoPreparacion。”这意味着你可以找到每一种可能的组合。与以下数据进行比较:

:John a :Person; :hasAge 30 .
:Bill a :Person; :hasAge 35 .
如果您编写一个如下的查询

select ?person ?age {
  ?person a :Person .
  ?y :hasAge ?age .
}
您将在结果中得到四行:

John 30
Bill 30
John 35
Bill 35

变量r和m之间没有联系:

?r rec:Ingrediente ?Ingrediente. 
?m rdf:type rec:ModoPreparacion.
上面写着“找到(一个配方)?r含有成分?Ingredite,而a?m含有类型rec:ModoPreparacion。”这意味着你可以找到每一种可能的组合。与以下数据进行比较:

:John a :Person; :hasAge 30 .
:Bill a :Person; :hasAge 35 .
如果您编写一个如下的查询

select ?person ?age {
  ?person a :Person .
  ?y :hasAge ?age .
}
您将在结果中得到四行:

John 30
Bill 30
John 35
Bill 35

变量r和m之间没有联系:

?r rec:Ingrediente ?Ingrediente. 
?m rdf:type rec:ModoPreparacion.
上面写着“找到(一个配方)?r含有成分?Ingredite,而a?m含有类型rec:ModoPreparacion。”这意味着你可以找到每一种可能的组合。与以下数据进行比较:

:John a :Person; :hasAge 30 .
:Bill a :Person; :hasAge 35 .
如果您编写一个如下的查询

select ?person ?age {
  ?person a :Person .
  ?y :hasAge ?age .
}
您将在结果中得到四行:

John 30
Bill 30
John 35
Bill 35

变量r和m之间没有联系:

?r rec:Ingrediente ?Ingrediente. 
?m rdf:type rec:ModoPreparacion.
上面写着“找到(一个配方)?r含有成分?Ingredite,而a?m含有类型rec:ModoPreparacion。”这意味着你可以找到每一种可能的组合。与以下数据进行比较:

:John a :Person; :hasAge 30 .
:Bill a :Person; :hasAge 35 .
如果您编写一个如下的查询

select ?person ?age {
  ?person a :Person .
  ?y :hasAge ?age .
}
您将在结果中得到四行:

John 30
Bill 30
John 35
Bill 35

现在,您已经发布了许多问题,如果您发布数据样本,其中许多问题的回答将非常简单。在评论中,您多次被要求提供数据样本。请注意,“寻求调试帮助的问题(“为什么此代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现这些问题所需的最短代码。”如果您不提供运行查询的示例数据,这个问题不是很容易重现的。你现在已经发布了很多问题,如果你发布了一个数据样本,其中很多问题的回答会非常简单。在评论中,您多次被要求提供数据样本。请注意,“寻求调试帮助的问题(“为什么此代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现这些问题所需的最短代码。”如果您不提供运行查询的示例数据,这个问题不是很容易重现的。你现在已经发布了很多问题,如果你发布了一个数据样本,其中很多问题的回答会非常简单。在评论中,您多次被要求提供数据样本。请注意,“寻求调试帮助的问题(“为什么此代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现这些问题所需的最短代码。”如果您不提供运行查询的示例数据,这个问题不是很容易重现的。你现在已经发布了很多问题,如果你发布了一个数据样本,其中很多问题的回答会非常简单。在评论中,您多次被要求提供数据样本。请注意,“寻求调试帮助的问题(“此代码为什么不起作用?”)必须包括所需的行为、特定问题或错误以及在问题本身中重现这些问题所需的最短代码。”如果您不提供运行查询所需的示例数据,则问题并不容易重现。