0

私の質問は SWRL ルールに関連しており、実際には別のユーザーからすでに質問されています ( Protégé-OWL / SWRL のオントロジー プロパティ定義を参照)。それでも、それを機能させる方法に関する指示に従った後、私は成功しませんでした.

私のオントロジーでは、いくつかの複雑な時間的事実 (時間間隔などに関連するもの) を扱う必要があるため、Time Ontologyをインポートします。実際の問題に取り組む前に、簡単な例を考えて、SWRL ルールに基づいてデータ プロパティに値を割り当てる方法をテストします。簡単な例では、クラスPersonを扱います。クラスBirthYear (時間オントロジーのInstantクラスのサブクラス) もあります。ドメインPersonと範囲BirthYearを持つオブジェクト プロパティBornInYearは、個人とその誕生年を関連付けます。今年の人の年齢を計算したいので、次の SWRL ルールを作成します。

Person(?p) ∧bornInYear(?p, ?birthYear) ∧subtract(?age, 2014, ?birthYear) → age(?p, ?age)

クラスPersonの個体を作成し、彼/彼女のBirthYearの値がであるとアサートした後、Pellet は"1977"この人物の年齢が37であると計算することを期待します。これは起こりません。理由はありますか?SWRL ルールは正しいですか? 37(値がデータ プロパティageにアサートされているかどうかを知るために、個々の p の [プロパティ アサーション] ビューを確認します。また、推論設定で [オブジェクト プロパティ アサーション] チェック ボックスがオンになっていることも確認します。 .) 私のオントロジーの例は次のようになります。

Prefix(SWRLexample:=<http://www.semanticweb.org/ontologies/2014/1/SWRLexample#>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(swrlb:=<http://www.w3.org/2003/11/swrlb#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(:=<http://www.semanticweb.org/ontologies/2014/1/untitled-ontology-101#>)
Prefix(time:=<http://www.w3.org/2006/time#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(swrl:=<http://www.w3.org/2003/11/swrl#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)


Ontology(<http://www.semanticweb.org/ontologies/2014/1/SWRLexample>
Import(<http://www.w3.org/2006/time>)

Declaration(Class(SWRLexample:BirthYear))
SubClassOf(SWRLexample:BirthYear time:Instant)
Declaration(Class(SWRLexample:Person))
Declaration(ObjectProperty(SWRLexample:bornInYear))
ObjectPropertyDomain(SWRLexample:bornInYear SWRLexample:Person)
ObjectPropertyRange(SWRLexample:bornInYear SWRLexample:BirthYear)
Declaration(DataProperty(SWRLexample:age))
AnnotationAssertion(rdfs:comment SWRLexample:age "Age of a person in years")
DataPropertyDomain(SWRLexample:age SWRLexample:Person)
DataPropertyRange(SWRLexample:age xsd:int)
Declaration(NamedIndividual(SWRLexample:birthYear1))
ClassAssertion(SWRLexample:BirthYear SWRLexample:birthYear1)
DataPropertyAssertion(time:year SWRLexample:birthYear1 "1977"^^xsd:gYear)
Declaration(NamedIndividual(SWRLexample:p1))
ClassAssertion(SWRLexample:Person SWRLexample:p1)
ObjectPropertyAssertion(SWRLexample:bornInYear SWRLexample:p1 SWRLexample:birthYear1)
DLSafeRule(Body(ClassAtom(SWRLexample:Person Variable(<urn:swrl#p>)) ObjectPropertyAtom(SWRLexample:bornInYear Variable(<urn:swrl#p>) Variable(<urn:swrl#birthYear>)) BuiltInAtom(swrlb:subtract Variable(<urn:swrl#age>) "2014"^^xsd:integer Variable(<urn:swrl#birthYear>)))Head(DataPropertyAtom(SWRLexample:age Variable(<urn:swrl#p>) Variable(<urn:swrl#age>))))
)
4

2 に答える 2

0

一連の手順は次のとおりです。

  • メタデータタブに移動
  • 一時的なオントロジーをインポートし、一時的な接頭辞を付けます。
  • SWRLタブに移動

次のようにルールを記述します。

Person(?x) ^ hasDOB(?x, ?dob) ^ temporal:duration(?age, "now", ?dob, temporal:Years) -> hasAge(?x,  ?age)

Personクラス hasDOBで、hasAgeオブジェクトのプロパティは

于 2014-08-08T10:34:07.557 に答える
0

いくつか問題があります(ただし、他の回答が有用な出発点であったことを嬉しく思います):

  • ageデータプロパティであるため、「[オブジェクト プロパティ アサーション] チェック ボックスがオンになっている」ことを確認するだけでなく、探しているデータ型アサーションであるため、[データ プロパティ アサーション] も確認する必要があります。

  • BornInYearオブジェクトプロパティであるため?birthYear、inbornInYear(?p, ?birthYear)は個人でなければなりません。ただし、swrlb:subtractの引数は数値リテラルでなければなりません。swrlb:subtract を使用するには、ルールで年の整数値を取得し、それに対して演算を実行する必要があります。値を引き続き使用できるかどうかはわかりませんが、あまり問題なく実行できるはずです"1977"^^xsd:gYear。ただし、SWRL では、日付と時刻を扱ういくつかの関数が定義されています ( 8.5. Built-Ins for Date, Time and Duration を参照)。ただし、すべての推論者がそれを支持しているわけではありません (たとえば、Pellet はそうではないと思います)。ただし、yearプロパティの値はxsd:gYearである必要があります.

于 2014-02-11T13:00:48.673 に答える