如果我有连接cxn
到一个空的三元组存储,我说:
val CheckSparql = "select (count(?s) as ?scount) where { ?s ?p ?o . }"
val PreparedSparql = cxn.prepareTupleQuery(QueryLanguage.SPARQL, CheckSparql)
val Result = PreparedSparql.evaluate()
val ResBindSet = Result.next()
val TripleCount = ResBindSet.getValue("scount")
println(TripleCount.toString())
我明白了
"0"^^<http://www.w3.org/2001/XMLSchema#integer>
是否有 RDF4J 方法可以仅检索该文字的值?
我只想要 0 或“0”,没有数据类型
我想如果可能的话,我应该尝试在没有字符串操作/正则表达式的情况下做到这一点。
最佳答案
Literals util class是你的 friend 吗:
int scount = Literals.getIntValue(ResBindSet.getValue("scount"))
或者如果您更喜欢字符串:
String scount = Literals.getLabel(ResBindSet.getValue("scount"))
您还可以选择添加后备参数,例如,如果提供的参数不是文字。
关于scala - 将文字拆分为值和数据类型的 RDF4J 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46941167/