简答
简短的回答是查询的语法格式不正确,并且它不会返回您要查找的内容。查询需要用句号 ( .
) 而不是分号 ( ;
) 来终止其三元组模式。固定查询应如下所示:
PREFIX schema: <http://schema.org/>
SELECT ?description
WHERE {
?review a schema:Review ;
schema:author "Judson C." .
}
但是,这是查询中未使用SELECT
的变量?description
,因此它始终为空。您可能想要SELECT ?review
或添加到模式schema:description ?description
中。
长答案
更多细节表明这是有效的。您提供的 RDF 格式不正确,因此很难对其进行测试。我接受了您提供的内容,并将其写为 N3 以获得以下内容。(RDF/XML 也在答案的最后。)
@prefix schema: <http://schema.org/> .
[]
a schema:Rating ;
schema:ratingValue "5.0" .
[]
a schema:Review ;
schema:reviewRating [] ;
schema:description "OMG Love this place!! But glad I don't have to stand in line for an hour like back in the day to get my fix!" ;
schema:datePublished "2013-05-18" ;
schema:author "Judson C." .
[]
a schema:Review ;
schema:reviewRating [] ;
schema:description "If you're ever wondering of where to stuff your face with a good ol' sandwich, you'll definitely have to pop in at Ike's Place. Not only are the different sandwiches uniquely named, they're also uniquely flavor profiled. A wonderful experience indeed!Sandwiches I've personally ordered are the Love Triangle, Nacho girl, and the Al Bundy. For all you people out there who loved the tv show, Married with Children, I think you could appreciate the sentiment of having a sammie named after the 'No Ma'am enthusiast. I know I did. Ahhh... *tucks hand under pant waistband*All kidding aside, these sandwiches are pretty legit. You go to the counter and order whichever sandwich sounds appealing and they can either add chips or a drink to your meal. Simple. They have a wide range of sandwiches that are made to please any meat lover, vegetarian, or vegan palate alike. The huge variety is an A+ in my book. They can even individualize and customize your sandwich to your liking. This means that even the pickiest of eaters are welcome!So if you're interested in a fun place to enjoy a good sandwich, most definitely give 'em a try!" ;
schema:datePublished "2013-04-30" ;
schema:author "Ann S." .
如上所述,该查询有一些语法错误;三重模式应该以 a 结尾.
,而不是 a ;
,并且应该是:
PREFIX schema: <http://schema.org/>
SELECT ?description
WHERE {
?review a schema:Review ;
schema:author "Judson C." .
}
但是,这不会返回任何有用?description
的信息,因为查询中没有使用它。使用 Jena 的 ARQ(并将查询编写为 schema.query),我们输出一行(因为模式匹配),但带有一个未绑定的变量:
$ /usr/local/lib/apache-jena-2.10.0/bin/arq \
--query schema.query \
--data schema.n3
---------------
| description |
===============
| |
---------------
这是一个绑定的查询?description
:
PREFIX schema: <http://schema.org/>
SELECT ?description
WHERE {
?review a schema:Review ;
schema:author "Judson C." ;
schema:description ?description .
}
正如预期的那样,它给出了一些有用的结果:
$ /usr/local/lib/apache-jena-2.10.0/bin/arq \
--query schema2.query \
--data schema.n3
-------------------------------------------------------------------------------------------------------------------
| description |
===================================================================================================================
| "OMG Love this place!! But glad I don't have to stand in line for an hour like back in the day to get my fix!" |
-------------------------------------------------------------------------------------------------------------------
RDF/XML 附录
这是手头数据的 RDF/XML 序列化。
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:schema="http://schema.org/">
<schema:Review>
<schema:reviewRating rdf:parseType="Resource">
</schema:reviewRating>
<schema:description>If you're ever wondering of where to stuff your face with a good ol' sandwich, you'll definitely have to pop in at Ike's Place. Not only are the different sandwiches uniquely named, they're also uniquely flavor profiled. A wonderful experience indeed!Sandwiches I've personally ordered are the Love Triangle, Nacho girl, and the Al Bundy. For all you people out there who loved the tv show, Married with Children, I think you could appreciate the sentiment of having a sammie named after the 'No Ma'am enthusiast. I know I did. Ahhh... *tucks hand under pant waistband*All kidding aside, these sandwiches are pretty legit. You go to the counter and order whichever sandwich sounds appealing and they can either add chips or a drink to your meal. Simple. They have a wide range of sandwiches that are made to please any meat lover, vegetarian, or vegan palate alike. The huge variety is an A+ in my book. They can even individualize and customize your sandwich to your liking. This means that even the pickiest of eaters are welcome!So if you're interested in a fun place to enjoy a good sandwich, most definitely give 'em a try!</schema:description>
<schema:datePublished>2013-04-30</schema:datePublished>
<schema:author>Ann S.</schema:author>
</schema:Review>
<schema:Review>
<schema:reviewRating rdf:parseType="Resource">
</schema:reviewRating>
<schema:description>OMG Love this place!! But glad I don't have to stand in line for an hour like back in the day to get my fix!</schema:description>
<schema:datePublished>2013-05-18</schema:datePublished>
<schema:author>Judson C.</schema:author>
</schema:Review>
<schema:Rating>
<schema:ratingValue>5.0</schema:ratingValue>
</schema:Rating>
</rdf:RDF>