问题描述
<http://www.co-ode.org/ontologies/ont.owl#myCar>
a owl:Namedindividual,first:Car .
<http://www.co-ode.org/ontologies/ont.owl#Car> a owl:Class .
<http://www.co-ode.org/ontologies/ont.owl#myAutomobile>
a owl:Namedindividual,first:Automobile .
<http://www.co-ode.org/ontologies/ont.owl#Automobile> a owl:Class ;
owl:equivalentClass first:Car .
我要检索所有汽车和汽车个人。现在我使用这个查询:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX saref: <https://saref.etsi.org/core/>
PREFIX so: <http://purl.org/ontology/symbolic-music/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix cars: <http://www.w3.org/2002/03owlt/equivalentClass/premises001#>
SELECT disTINCT ?s ?type Where {
{
SELECT ?s ?type WHERE
{
?type owl:equivalentClass cars:Car .
?s rdf:type ?type
}
} UNION {
SELECT ?s ?type WHERE
{
?s rdf:type cars:Car .
?s rdf:type ?type
}
}
FILTER(?type != <http://www.w3.org/2002/07/owl#Namedindividual>)
}
结果是:
<http://www.co-ode.org/ontologies/ont.owl#myAutomobile> cars:Automobile
<http://www.co-ode.org/ontologies/ont.owl#myCar> cars:Car
没关系。如果我使用这个查询,显然会有不同的结果:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX saref: <https://saref.etsi.org/core/>
PREFIX so: <http://purl.org/ontology/symbolic-music/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix cars: <http://www.w3.org/2002/03owlt/equivalentClass/premises001#>
SELECT disTINCT ?s ?type Where {
{
SELECT ?s ?type WHERE
{
?type owl:equivalentClass cars:Automobile .
?s rdf:type ?type
}
} UNION {
SELECT ?s ?type WHERE
{
?s rdf:type cars:Automobile .
?s rdf:type ?type
}
}
FILTER(?type != <http://www.w3.org/2002/07/owl#Namedindividual>)
}
在这种情况下,只返回 http://www.co-ode.org/ontologies/ont.owl#myAutomobile 汽车:汽车。 我在 TDB2 数据集之上使用 OWLFBRulereasoner 和 Genericrulereasoner,如下所示:
:modelInf rdf:type ja:InfModel;
ja:baseModel :modelInfOwl ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/Genericrulereasoner>
] ;
.
:modelInfOwl rdf:type ja:InfModel;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRulereasoner>
] ;
.
:tdbGraph rdf:type tdb2:GraphTDB ;
tdb2:dataset siot:dataset .
我到底有什么地方可以做错或做得更好?
提前致谢, 约翰,
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)