I'm trying to create a simple ontology that has two classes: class1 and class2,- and two instances that have simple text data property with the same name (hasName: "string1"^^xsd:string and hasName "string2"^^xsd:string respectivly). I want to classify these instances with reasoner to the respective classes based on regular expression (for example, the restriction for class 1 would be hasName some xsd:string[pattern "string1"], and such, the reasoner should infer that instance1 belongs to class1, but instance2 is not). How can it be done?
Asked
Active
Viewed 359 times
2
-
You can use an OWL facet restriction with `xsd:pattern` as datatype – UninformedUser Jul 19 '17 at 11:20
-
In Manchester syntax: `class1 SubClassOf hasName some string[pattern "THE_PATTERN_HERE"]` – UninformedUser Jul 19 '17 at 11:24
-
1But it depends on the reasoner support indeed, you could try Pellet and HermiT - maybe one of those works with REGEX patterns. – UninformedUser Jul 19 '17 at 11:25
-
Maybe you can try the openllet (lastest unreleased on streams branch) https://github.com/Galigator/openllet/commit/eed2c6ef635c9cb882d0b84a13ad2d770da57e45 look at the testRegexRestriction() method for an example. – Galigator Jul 20 '17 at 17:56
1 Answers
0
Using Openllet(2.6.2-SNAPSHOT) you can do things like that :
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)));
As you can see the line :
OWL.restrict(XSD.STRING, OWL._factory.getOWLFacetRestriction(OWLFacet.PATTERN, OWL.constant("A.A"))))));
is the one that add the "regexp" to the classification algorithm.
Here the pattern is 'A.A', pattern follow 'java-regexp'enter link description here rules.

Galigator
- 8,957
- 2
- 25
- 39