简体   繁体   English

SWRL-使用课堂知识

[英]SWRL - using knowledge from classes

I want to use knowledge, which is modelled between classes. 我想使用在类之间建模的知识。 Eg I have modelled a car and a bus have 4 wheels, a bike 2 wheels. 例如,我模拟了一辆汽车,一辆公共汽车有4个轮子,自行车有2个轮子。 Now, I want to express that bike can tip (if you don't keep them in balance - incompetent driver). 现在,我想表达的是,自行车可能会翻倒(如果您不能保持平衡-无能的驾驶员)。 If I add an instance "CB450", subClassOf Bike, a rule should enable reasoning: can(CB450,Tip) . 如果添加实例“ CB450”(自行车的子类),则规则应启用推理: can(CB450,Tip) Way: 方式:

Type(Cb450,Bike) and has(Bike,TwoWheels) and can(TwoWheels,Tip) -> can (CB450,Tip)

I did not find any way to express this rule in SWRL, or Jena rules. 我找不到任何方法可以在SWRL或Jena规则中表达此规则。 Is there a possibility? 有可能吗?

I know that it can be modelled differently, but I need to use class relations for rules in instances. 我知道可以对其建模,但是我需要在实例中为规则使用类关系。

I use Protege 5.16 with pellet 2.3.1. 我将Protege 5.16与颗粒2.3.1一起使用。 See the example ontology below 请参阅下面的示例本体

Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>

Ontology: <http://www.semanticweb.org/vehicle>
ObjectProperty: <http://www.semanticweb.org/vehicle#has>
ObjectProperty: <http://www.semanticweb.org/vehicle#can>

Class: <http://www.semanticweb.org/vehicle#Car>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Vehicle>,
    <http://www.semanticweb.org/vehicle#has> some <http://www.semanticweb.org/vehicle#FourWheels>

Class: <http://www.semanticweb.org/vehicle#Vehicle>
Class: <http://www.semanticweb.org/vehicle#Bike>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Vehicle>,
    <http://www.semanticweb.org/vehicle#has> some     <http://www.semanticweb.org/vehicle#TwoWheels>

Class: <http://www.semanticweb.org/vehicle#FourWheels>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#TwoWheels>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#can> some        <http://www.semanticweb.org/vehicle#Tip>,
    <http://www.semanticweb.org/vehicle#Property>

Class: <http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#Tip>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Property>

Individual: <http://www.semanticweb.org/vehicle#CB450>

Types: 
    <http://www.semanticweb.org/vehicle#Bike>

Individual: <http://www.semanticweb.org/vehicle#Tip>

Types: 
    <http://www.semanticweb.org/vehicle#Tip>

Based on the way you have explained the problem it looks like "CB40" isn't a subclass of Bike but rather an individual of type Bike. 根据您解释问题的方式,看起来“ CB40”不是Bike的子类,而是Bike类型的个人。 So say you have a class Vehicle, a data property hasWheels on Vehicle and a boolean property canTip on Vehicle, you can write a SWRL rule as 因此,假设您有一个Vehicle类,在Vehicle上有一个data属性hasWheels,在Vehicle上有一个布尔属性canTip,则可以将SWRL规则写为

Vehicle(?x) ^ hasWheels(?x, 2) -> canTip(?x, true)

which translates as "A vehicle with two wheels can tip over" . 意思是“带两个轮子的车辆可以翻倒”。 The ?x is any individual of the specified type. ?x是指定类型的任何个体。 So if you create a class Bike as a subclass of Vehicle and an individual CB40 of that class and set all the relevant data properties a reasoner will assign the canTip property to true for CB40 因此,如果您将“自行车”类创建为“车辆”的子类,并创建该类的单个CB40并设置所有相关数据属性,则推理程序将为CB40分配canTip属性为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM