在OWL类上创建正则表达式限制 [英] Creating regex restriction on OWL class
本文介绍了在OWL类上创建正则表达式限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
推荐答案
使用Openllet(2.6.2-SNAPSHOT)可以这样做:
final OWLNamedIndividual x1 = OWL.Individual("#I1");
final OWLNamedIndividual x2 = OWL.Individual("#I2");
owl.addAxiom(OWL.equivalentClasses(ClsA, OWL.some(propB, OWL.restrict(XSD.STRING, OWL._factory.getOWLFacetRestriction(OWLFacet.PATTERN, OWL.constant("A.A"))))));
owl.addAxiom(OWL.propertyAssertion(x1, propB, OWL.constant("AAA")));
owl.addAxiom(OWL.propertyAssertion(x2, propB, OWL.constant("BBB")));
owl.addAxiom(OWL.differentFrom(x1, x2));
final OpenlletReasoner r = owl.getReasoner();
assertTrue(r.isEntailed(OWL.classAssertion(x1, ClsA)));
assertFalse(r.isEntailed(OWL.classAssertion(x2, ClsA)));
如您所见:
OWL.restrict(XSD.STRING, OWL._factory.getOWLFacetRestriction(OWLFacet.PATTERN, OWL.constant("A.A"))))));
是将"regexp"添加到分类算法的那个。
此处模式为‘A.A’,模式遵循‘Java-regexp’enter link description here规则。
这篇关于在OWL类上创建正则表达式限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文