将同义词库与SPARQL(MarkLogic)结合使用

将同义词库与SPARQL(MarkLogic)结合使用,sparql,marklogic,Sparql,Marklogic,我目前正在尝试从XQuery控制台查看是否可以在SPARQL中使用同义词库。我当前使用的代码如下所示 xquery version "1.0-ml"; import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy"; import module namespace thsr="http://marklogic.com/xdmp/thesaurus"

我目前正在尝试从XQuery控制台查看是否可以在SPARQL中使用同义词库。我当前使用的代码如下所示

xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
import module namespace thsr="http://marklogic.com/xdmp/thesaurus" 
                             at "/MarkLogic/thesaurus.xqy";
sem:sparql(
'
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
PREFIX cts: <http://marklogic.com/cts#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema/>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX db: <http://dbpedia.org/resource/>
PREFIX onto: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>
PREFIX xdmp: <http://marklogic.com/xdmp#>

SELECT *
WHERE{
?question </has_comment> ?comment .
?commented_by_person </commented_by> ?comment .
#FILTER (cts:contains(fn:doc(?comment), thsr:expand( cts:element-word-query(xs:QName("text"),"go"), thsr:lookup("/myThsrDocs/wordnet.xml", "go"), (), (), () ) ) ) .

}',
(),
(),
() #thsr:expand( cts:element-word-query(xs:QName("text"),"go"), thsr:lookup("/myThsrDocs/wordnet.xml", "go"), (), (), () )
)
然而,正如所看到的那样,它的实现方式似乎不是很具有可扩展性。因此,对该解决方案的任何改进或实现这一点的其他方法都将不胜感激

for $d in $test
return (
for $x in $d
 where(cts:contains($x["comment_text"],thsr:expand(cts:word-query("go"), thsr:lookup("/myThsrDocs/wordnet.xml", "go"),(), (), () ))) or ($x["comment_text"] = "comment_text")
 return $x
)