I am trying to use the swrl tab used with protege, and I was wondering if there is any way I can assert the current time and date in a rule. Also I need to know if I can subtract 2 dataproperties (type: dateTime).
Thank-you in advance
I am trying to use the swrl tab used with protege, and I was wondering if there is any way I can assert the current time and date in a rule. Also I need to know if I can subtract 2 dataproperties (type: dateTime).
Thank-you in advance
A rule using the current date and time would very likely imply the ontology is non monotonic - the inferences being drawn from it would change with time, without any change to the ontology. This might catch some users of your ontology by surprise.
That said, I'm not aware of a way to do either mathematical operations or capture the current time in the Protege SWRL tab. You could of course create a rule with the current timestamp via code, e.g., through the OWL API, and show it in Protege.
An example rule can be built like this:
OWLOntologyManager m = create();
OWLOntology o = m.createOntology(example_iri);
// Get hold of references to class A and class B.
OWLClass clsA = df.getOWLClass(IRI.create(example_iri + "#A"));
OWLClass clsB = df.getOWLClass(IRI.create(example_iri + "#B"));
SWRLVariable var = df.getSWRLVariable(IRI.create(example_iri + "#x"));
SWRLClassAtom body = df.getSWRLClassAtom(clsA, var);
SWRLClassAtom head = df.getSWRLClassAtom(clsB, var);
SWRLRule rule = df.getSWRLRule(Collections.singleton(body), Collections.singleton(head));
m.applyChange(new AddAxiom(o, rule));
Source, examples and support for OWL API programming can be found here