将FILTER关键字放在SPARQL代码块中的位置是否重要?

时间:2019-07-02 06:16:57

标签: filtering sparql ontology

我试图将本体中的所有子类(子类)与它们的信息一起获取,然后从FMA本体中选择与“中央回”有关的信息:

        #selecting all sub-classes that include "precentral gyrus"
        select distinct ?parts ?name ?id ?propName ?comment
        where {

          #finding sub-classes
          ?c a ?class. 
          ?parts rdfs:subClassOf ?class.

          #getting the info
          optional {?parts rdfs:label ?name.}
          optional {?parts fma:FMAID ?id.}
          optional {?property a rdf:Property.
            optional {?property rdfs:label ?propName}}
          optional {?parts rdfs:comment ?comment.}

          #filtering related info - moved to the beginning  
          filter contains(lcase(str(?name)), "precentral gyrus").         
        }
        order by ?id
        limit 100 

问题是,如果我将FILTER关键字移到该块的开头,则仍会得到部分效果,如图所示: enter image description here 当我将过滤器放在代码的开头时,即使?name在执行其工作时,甚至尚未定义FILTER命令中使用的FILTER变量(过滤中央回)为什么会这样?

我还有一个问题。带有两个OPTIONAL块的代码部分在另一个内部正确吗?

0 个答案:

没有答案
相关问题