このような問題の解決策は、推論(This Pellet fork)を使用することです。
考えられるのは、「確認する範囲のデータプロパティを持つ個体」と「プロパティ/リテラルを持つ個体」を表すクラスを作成することです。その後、推論を使用して、2つのクラスが交差していないかどうかをチェックします。
import java.util.function.BiFunction;
import org.semanticweb.owlapi.model.*;
import openllet.owlapi.*;
public class RangeInclusionTest
{
public static void main(final String[] args)
{
try (final OWLManagerGroup group = new OWLManagerGroup())
{
final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create("http://test.org#entail-class-restrict-to-some-range"), 1.0);
final OWLHelper owl = new OWLGenericTools(group, ontId, true);
// This declaration is vital since this reasoner have problems with pure anonymous reasoning.
// You can remove this property after yours tests, (or better use one of your already existing properties).
final OWLDataProperty prop = OWL.DataProperty("http://test.org#dummyProp");
owl.addAxiom(OWL.declaration(prop));
final OWLLiteral un = OWL.constant(1);
final OWLLiteral deux = OWL.constant(2);
final OWLLiteral trois = OWL.constant(3);
final OWLLiteral quatre = OWL.constant(4);
final OWLDataRange dataRange = OWL.dataOr(OWL.oneOf(un), OWL.oneOf(deux), OWL.oneOf(trois));
final BiFunction<OWLDataRange, OWLLiteral, Boolean> isIncludeInRange = //
(range, literal) -> owl.getReasoner().isSatisfiable(//
OWL.and(// You must be of all the following class
OWL.some(prop, OWL.oneOf(literal)), // The class of the 'literal'
OWL.some(prop, range), // The class of the range.
OWL.max(prop, 1))// But you can have the property only once.
);
System.out.println("[A] " + (isIncludeInRange.apply(dataRange, un)));
System.out.println("[B] " + (isIncludeInRange.apply(dataRange, deux)));
System.out.println("[C] " + (isIncludeInRange.apply(dataRange, trois)));
System.out.println("[D] " + (isIncludeInRange.apply(dataRange, quatre)));
} catch (final Exception e)
{
e.printStackTrace();
}
}
}
まず、あなたがあなたの範囲を定義する必要がありますいくつかのトリックが、それはここで正常に動作を取得することがあるので
は私の完全なソリューションです。次に、reasonerの 'isSatisfiable'メソッドを使用します。 1つのトリックは、交差クラスに「OWL.max(prop、1)」という制限を追加することによって、プロパティのインスタンスを1つだけ使用するように強制することです。
出力は
[A] true
[B] true
[C] true
[D] false
リテラル 'キャトルは' 'dataRange' 答え '[D]' が含まれていませんので
がfalseである必要があります。 この解決策を見ても分かるように、ある範囲の包含物を別のものに簡単に含めることができます。
オントロジで変更を要求しない解決策は、特別なswrlルールを作成し、オントロジ(空であっても)がルールを伴うかどうかを確認することでしたが、現在はswlに対してdl-reasonerサポートの含意はありません。
docs(http://owlapi.sourceforge.net/javadoc/org/semanticweb/owlapi/model/OWLDataRange.html)から見ることができるように、複数の種類のデータ範囲があります。あなたのケースでは、 2つの「DATA_ONE_OF」を含む「DATA_UNION_OF」。したがって、IF-ELSE(SWITCH-CASE)ブランチ、または対応するビジター(http://owlapi.sourceforge.net/javadoc/org/semanticweb/owlapi/model)の実装によって、これらのケースを処理する必要があります。 /OWLDataRangeVisitor.html) – AKSW
'OWLDataRangeVisitor'インターフェースを実装した例はどこで読むことができますか? – enzom83
これはインターフェイスを実装するのが簡単です。あなたの場合、ブール値のメソッドを実装するには十分だと思います。つまり、交差、結合、補完、そして最後に、値を含む構造体の1つの部分についてです。 – AKSW