SPARQL:基于另一个值将值绑定到变量

SPARQL:基于另一个值将值绑定到变量,sparql,rdf,Sparql,Rdf,我有一个SPARQL查询,返回附表中显示的三元组。是否有可能根据变量arg1和arg2的“位置”值将“new_arg_val”的值分配给变量arg1和arg2?该位置来自一个rdf:Seq,它应该使用任意长度的rdf:Seq 编辑: 因此,我正在研究一种方法来处理计算属性的推断,即从其他属性的值派生的属性。我正在使用,我的数据结构如下: <resourceURI> seas:fluidTemperatureDiffeence <propertyURI> . <pr

我有一个SPARQL查询,返回附表中显示的三元组。是否有可能根据变量arg1和arg2的“位置”值将“new_arg_val”的值分配给变量arg1和arg2?该位置来自一个rdf:Seq,它应该使用任意长度的rdf:Seq

编辑: 因此,我正在研究一种方法来处理计算属性的推断,即从其他属性的值派生的属性。我正在使用,我的数据结构如下:

<resourceURI> seas:fluidTemperatureDiffeence <propertyURI> .
<propertyURI> seas:evaluation <evaluationURI> .
<evaluationURI> seas:evaluatedValue "33 Cel"^^cdt:ucum ;
              prov:wasGeneratedAtTime "2017-06-13T21:51:26.706+02:00"^^xsd:dateTime ;
              seas:calculation "abs(?arg1-?arg2)"^^xsd:string ;
              prov:wasDerivedFrom _:c0 .
 _:c0 a rdf:Seq ;
      rdf:_1 <evaluationURIa> ;
      rdf:_2 <evaluationURIb> .

我想得到一个计算结果,这样我就可以构造新的三元组。

你的问题似乎很有趣,但要理解你到底想要什么并不容易。请提供一些示例数据和所需的输出。谢谢。我将把它添加到我的原始帖子中。如果你把它添加到你的问题中,而不是添加到注释中,那会更好。输入数据和预期输出会使问题描述更容易。此外,这允许人们在您的样本数据上测试他们的解决方案。我现在进行了编辑。我希望我想要达到的目标是明确的。你的问题似乎很有趣,但要理解你到底想要什么并不容易。请提供一些示例数据和所需的输出。谢谢。我将把它添加到我的原始帖子中。如果你把它添加到你的问题中,而不是添加到注释中,那会更好。输入数据和预期输出会使问题描述更容易。此外,这允许人们在您的样本数据上测试他们的解决方案。我现在进行了编辑。我希望我想要实现的目标是明确的。
SELECT  *
WHERE
  { #Get the time of the latest calculation
    { SELECT  ?calculatedProperty (MAX(?_tc) AS ?tc)
      WHERE
        { GRAPH ?g
            { ?resource seas:fluidTemperatureDifference/seas:evaluation _:b0 .
              _:b0 ^seas:evaluation ?calculatedProperty .
              _:b0  prov:wasGeneratedAtTime  ?_tc
            }
        }
      GROUP BY ?calculatedProperty
    }
    #Get calculation data
    GRAPH ?gi
      { ?calculatedProperty
                  seas:evaluation       _:b1 .
        _:b1      prov:wasGeneratedAtTime  ?tc ;
                  seas:calculation      ?calc ;
                  seas:evaluatedValue   ?old_res .
        _:b1     (prov:wasDerivedFrom)+ _:b2 .
        _:b2  ?position  ?old_arg
      }
    #Get the time of the latest input values
    { SELECT  ?old_arg (MAX(?_t) AS ?t)
      WHERE
        { GRAPH ?g
            { ?old_arg ^seas:evaluation/seas:evaluation ?arg .
              ?arg  prov:wasGeneratedAtTime  ?_t
            }
        }
      GROUP BY ?old_arg
    }
    #Get argument data
    GRAPH ?g
      { ?old_arg ^seas:evaluation/seas:evaluation ?new_arg .
        ?new_arg  prov:wasGeneratedAtTime  ?t ;
                  seas:evaluatedValue   ?new_arg_val
      }
    #Bind values to arguments (WIP)
    BIND(IF(?position = rdf:_1, ?new_arg_val, "") AS ?arg1)
    BIND(IF(?position = rdf:_2, ?new_arg_val, "") AS ?arg2)
    #Should do the calculation based on ?calc
    BIND(str("newResultHere") AS ?_res)
    #Get datatype of existing result
    BIND(datatype(?old_res) AS ?datatype)
    #Get unit of existing result
    BIND(strafter(str(?old_res), " ") AS ?unit)
    #Define datatype and unit for result
    BIND(strdt(concat(str(?_res), " ", ?unit), ?datatype) AS ?res)
    #Make a guid (struuid() bug in stardog)
    BIND(replace(str(uuid()), "urn:uuid:", "") AS ?guid)
    BIND(uri(concat("https://host/proj", "/Evaluation/", ?guid)) AS ?evaluationURI)
    BIND(now() AS ?now)
  }