以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  求助,sparql查询owl问题!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=59625)


--  作者:zfsrt
--  发布时间:3/9/2008 2:19:00 PM

--  求助,sparql查询owl问题!
下面是一个owl文件,我要查询出这个文件中的Year=2001,month>1的类SST中的实例应该怎么写?
通过朋友指教,我想应该是这样写:
select ?s
where {
    ?s tp:type ?SST
    ?? pro:property ?month filter(month>2).
    ?s pro:property ?Year filter(Year=2001).
}
但是对于命名空间等东西,我不太懂,因此我不知道上面写法中的tp:type以及 pro:property在下面的这个具体例子中应该怎么写?
请各位高手多多指教!在下不尽感谢!


<?xml version="1.0"?>
<rdf:RDF
    xmlns="http://www.owl-ontologies.com/OceanOntology#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
  xml:base="http://www.owl-ontologies.com/OceanOntology" >
  <rdf:Description rdf:about="#SST">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A0">
    <rdf:first rdf:resource="#RAIN"/>
    <rdf:rest rdf:nodeID="A1"/>
  </rdf:Description>
  <rdf:Description rdf:about="">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
  </rdf:Description>
  <rdf:Description rdf:about="#ERST_10">
    <Latitude rdf:datatype="http://www.w3.org/2001/XMLSchema#float">120.0</Latitude>
    <Month rdf:datatype="http://www.w3.org/2001/XMLSchema#int">3</Month>
    <rdf:type rdf:resource="#ERST"/>
    <Year rdf:datatype="http://www.w3.org/2001/XMLSchema#int">2001</Year>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A2">
    <rdf:rest rdf:nodeID="A3"/>
    <rdf:first rdf:resource="#RAIN"/>
  </rdf:Description>
  <rdf:Description rdf:about="#RAIN">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:about="#ERST_9">
    <rdf:type rdf:resource="#ERST"/>
    <Year rdf:datatype="http://www.w3.org/2001/XMLSchema#int">2000</Year>
    <Month rdf:datatype="http://www.w3.org/2001/XMLSchema#int">2</Month>
    <Latitude rdf:datatype="http://www.w3.org/2001/XMLSchema#float">100.0</Latitude>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A3">
    <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
    <rdf:first rdf:resource="#SST"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A1">
    <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
    <rdf:first rdf:resource="#SST"/>
  </rdf:Description>
  <rdf:Description rdf:about="#Month">
    <rdfs:domain rdf:nodeID="A4"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A5">
    <rdf:rest rdf:nodeID="A6"/>
    <rdf:first rdf:resource="#RAIN"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A7">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
    <owl:unionOf rdf:nodeID="A5"/>
  </rdf:Description>
  <rdf:Description rdf:about="#Latitude">
    <rdfs:domain rdf:nodeID="A8"/>
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
  </rdf:Description>
  <rdf:Description rdf:about="#MSLA">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
    <rdfs:subClassOf rdf:resource="#SST"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A6">
    <rdf:first rdf:resource="#SST"/>
    <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
  </rdf:Description>
  <rdf:Description rdf:about="#Year">
    <rdfs:domain rdf:nodeID="A7"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
  </rdf:Description>
  <rdf:Description rdf:about="#ERST">
    <rdfs:subClassOf rdf:resource="#SST"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A4">
    <owl:unionOf rdf:nodeID="A2"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A8">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
    <owl:unionOf rdf:nodeID="A0"/>
  </rdf:Description>
</rdf:RDF>

<!-- Created with Protege (with OWL Plugin 3.3, Build 390)  http://protege.stanford.edu -->

[此贴子已经被作者于2008-3-10 8:59:03编辑过]

--  作者:zfsrt
--  发布时间:3/9/2008 5:34:00 PM

--  
是不是大致是这个样子呢?但是准确的写应该怎样写呢?
请多指教啊

SELECT ?s
WHERE {
    ?s tp:type ?SST.
    ?s pro:latitude ?latitude . FILTER {latitude >100}
    ?s pro:month ?month. FILTER {month =2}.
}


--  作者:l.hongjun
--  发布时间:3/9/2008 7:16:00 PM

--  
关系表达式应该是小括号吧。
--  作者:zfsrt
--  发布时间:3/10/2008 8:28:00 AM

--  
多谢指教!
那其中的命名空间应该怎么用呢?
上面我是随便写的
?s tp:type ?SST.
    ?s pro:latitude ?latitude . FILTER (latitude >100)
    ?s pro:month ?month. FILTER (month =2).
在这里面的 tp:type和pro:latitude以及pro:month,这三个具体到这个例子应该怎么写呢?
我不是做计算机方面的,对计算机方面的东西不懂,但是又要写着方面的论文,真是着急。

--  作者:zfsrt
--  发布时间:3/11/2008 9:55:00 AM

--  
继续求助!请指教!
--  作者:lark
--  发布时间:3/11/2008 10:38:00 PM

--  
PREFIX my: <http://www.owl-ontologies.com/OceanOntology#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?s
WHERE {
    ?s rdf:type ?SST.
    ?s my:latitude ?latitude . FILTER (?latitude >100)
    ?s my:month ?month. FILTER (?month =2).
}


--  作者:zfsrt
--  发布时间:3/12/2008 12:46:00 PM

--  
非常感谢!
--  作者:bzbc
--  发布时间:4/11/2008 1:31:00 PM

--  
我试了怎么不行呢?

W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
93.750ms