【发布时间】:2019-03-05 15:56:06
【问题描述】:
这是我想以RDF/XML 格式提取的规则:
<rdf:Description rdf:about="http://www.semanticweb.org/myCompany/ontologies#x">
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable"/>
</rdf:Description>
<rdf:Description>
<swrla:isRuleEnabled rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">testing a rule</rdfs:comment>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">TEST</rdfs:label>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
<swrl:body>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate rdf:resource="http://www.semanticweb.org/myCompany/ontologies#depth"/>
<swrl:argument1 rdf:resource="http://www.semanticweb.org/myCompany/ontologies#x"/>
</rdf:Description>
</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#BuiltinAtom"/>
<swrl:builtin rdf:resource="http://www.w3.org/2003/11/swrlb#greaterThan"/>
<swrl:arguments>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#int">2</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</swrl:arguments>
</rdf:Description>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</swrl:body>
<swrl:head>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate rdf:resource="http://www.semanticweb.org/myCompany/ontologies#profondeur"/>
<swrl:argument1 rdf:resource="http://www.semanticweb.org/myCompany/ontologies#Bad"/>
</rdf:Description>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</swrl:head>
</rdf:Description>
我想知道是否可以提取语法更像:
depth(?x) ^ swrlb:greaterThan(2) -> profondeur(Bad)
另外,我不想在 protégé 或其他软件中使用我的规则,我正在寻找像 Jena 或 Pellet 这样的外部连接器
等待您的回复,
Aloïs,Sparql 用户。
【问题讨论】:
-
你现在用什么软件?您如何“提取”您引用的规则?请参考stackoverflow.com/help/how-to-ask 获取改进问题的指导,以便您获得更好的答案。
-
目前我正在使用 protégé 创建我的规则。然后我以 RDF 格式保存我的“本体”,并使用 Jena 进行 Sparql 查询。现在我想将 RDF 语法转换为我可以在算法中使用的东西(例如在 python 或 java 中)。希望能帮助您更多地了解我在寻找什么。
-
使用具有表示 SWRL 规则的本机对象的 OWL API - 实际上它们也被建模为 OWLAxiom:
Set<SWRLRule> rules = ontology.getAxioms(AxiomType.SWRL_Rule);,其中ontology是表示本体的OWLOntology对象 -
注意——您要保存的“RDF 格式”实际上是RDF 的RDF/XML 序列化。 RDF 可以以多种形式序列化,包括 RDF/XML、Turtle、N-Triples、N-Quads、TriG 等。
标签: sparql rdf owl ontology rules