根据RDF

时间:2017-09-17 22:56:29

标签: java apache sparql rdf jena

我正在努力通过智能手机数据从我的RDF基础获取文字设备名称。示例数据:

<rdf:Description rdf:about="https://lukasgorny.pro/devices#GioneeX1">
    <feature:device-name>Gionee X1</feature:device-name>
    <feature:screen-size>big</feature:screen-size>
    <feature:internal-memory-size>small</feature:internal-memory-size>
 </rdf:Description>
 <rdf:Description rdf:about="https://lukasgorny.pro/devices#SharpAquosS3">
    <feature:device-name>Sharp Aquos S3</feature:device-name>
    <feature:screen-size>big</feature:screen-size>
    <feature:internal-memory-size>big</feature:internal-memory-size>
 </rdf:Description>

查询:

PREFIX feature: <https://lukasgorny.pro/devices#>

SELECT ?device WHERE 
{ 
    ?device feature:device-name ?deviceName .
    OPTIONAL { ?x feature:screen-size ?screenSize . } 
    OPTIONAL { ?y feature:internal-memory-size ?memorySize . }
}

我想提取所有屏幕大小为&#34; big&#34;内部存储器大小是小的&#34; (这些在我的应用程序中是参数化的,但我在这里给你一个例子)。你能指点我正确的方向吗?我似乎无法找到解决方案。

1 个答案:

答案 0 :(得分:1)

您可以使用FILTER条件,如下所示:

 WHERE 
 { 
    ?x feature:screen-size ?screenSize . 
    FILTER(str(?screenSize) = "big") 
 }