简体   繁体   English

使用SPARQL和SPIN对数据进行RDF处理

[英]RDFising data with SPARQL and SPIN

I want to RDFising data, I need construct with a SPARQL query (I'm using SPIN) an object (Book) with two properties (Title and Author). 我想对数据进行RDF处理,我需要使用SPARQL查询(我正在使用SPIN)构造具有两个属性(标题和作者)的对象(书)。 All books have "Title" but sometime haven't "Author". 所有书籍都有“标题”,但有时没有“作者”。

When this happens, it doesn't create this "Book", and I want create it with "Title". 发生这种情况时,它不会创建此“书”,而我想使用“标题”来创建它。

I'm using GraphDB and this is the query: 我正在使用GraphDB,这是查询:

prefix spif: <http://spinrdf.org/spif#>
prefix pres: <http://example.com/pruebardf/>

CONSTRUCT {
    ?rdfIRI a           pres:Book ;
            pres:Author ?author   .
}
WHERE {
     SERVICE <http://localhost:7200/rdf-bridge/1683716393221> {
         ?bookRow a                <urn:Row> ;
                  <urn:col:Author> ?author   ;
                  <urn:col:Title>  ?title    .
     }
     BIND(IRI(CONCAT("http://example.com/", spif:encodeURL(?title))) AS ?rdfIRI)
}

Is there a solution? 有解决方案吗? I can use other SPARQL syntax. 我可以使用其他SPARQL语法。

Use OPTIONAL in the SERVICE part to make the pattern not fail when <urn:col:Author> is missing. 在缺少<urn:col:Author>时,在SERVICE部分中使用OPTIONAL可使模式不失败。

The CONSTRUCT will then simply not put in the ?rdfIRI pres:Author ?author triple but will include ?rdfIRI a pres:Book . 这样, CONSTRUCT将不会简单地将“ ?rdfIRI pres:Author ?author放到三元组中,而是将?rdfIRI a pres:Book包括?rdfIRI a pres:Book

If you want to set ?author when it is missing in the data, look at using COALESCE . 如果您想在数据中缺少?author时设置它,请考虑使用COALESCE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM