如何将两个变量连接在一起并在 SPARQL 中输出一个字符串

问题描述

我有三个变量 ?leaf 和 ?superclass,以及包含 uri 的 ?supersuperclass。现在我想得到一个有 2 列的表格,一列是叶子标签,另一列是 ?superclass 和 ?supersuperclass 的串联,中间有一个 -。

例如,一个虚构的例子: |叶?| ?超类-超超类| |:----: | :-----:| |床|卧室房子| 高分辨率照片| CLIPARTO |冰箱|厨房-房子| |餐厅|家庭街|

我尝试在查询的选择部分连接超类和超超类,但这没有用。我不确定我还能把它放在哪里。我是否需要创建一个新变量,以某种方式将每个变量的字符串值分配给该新变量,并连接起来?我知道如何访问每个 uri 的标签,这是我最终想要连接的字符串。

tldr:如何连接 2 个变量内的字符串值?

编辑:我到现在为止的查询:我希望它是可读的,删除评论可能会有所帮助,我主要是为自己写的。

 PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#>
    PREFIX : <*databaselocation*>

    SELECT disTINCT ?leaf  #?subclasslabel ?subclasslabel #?superclasslabel ? 
    supersuperclasslabel 
    WHERE {GRAPH <*insertyourgraphhere*>

    #a leaf is the lowest level class: A class that does not have a subclass
    {{
            #I want anything which is a class
            ?leaf rdf:type owl:Class.
            #i also want the subclass of any superclass if that exists
            optional {?leaf rdfs:subClassOf ?superclass .}
            
            #give me the label of that subclass
            #optional {?leaf skos:prefLabel ?subclasslabel.}

        
            #?superclass rdfs:subClassOf ?supersuperclass.
            #give me the label of the superclass
            #?superclass skos:prefLabel ?superclasslabel.

            
            #if it exists,give me also the superclass of the superclass 
            creating a supersuperclass
            # {?superclass rdfs:subClassOf ?supersuperclass.
            #give me the label of the supersuperclass
            # {?supersuperclass skos:prefLabel ?supersuperclasslabel.}
                
            
            #keep the leafs that are NOT The values whereby the subclass is 
     not empty. (double negative for remove the leafs where the subclass has a 
    subclass below it)
    FILTER NOT EXISTS
    {?subclass rdfs:subClassOf ?leaf 
                FILTER (?sublass != ?leaf && ?subclass != owl:nothing ) }}}}    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...