oli666
(Oli666)
April 14, 2022, 2:45pm
1
Hi there,
I am trying to use owl:sameAs in the THEN part of a custom Stardog rule. So far, with no success:
PREFIX rule: <tag:stardog:api:rule:>
INSERT DATA {
:C1 a :Customer; :email "test@test.com"; :id 1 .
:U3 a :User; :email "test@test.com"; :income 1000 .
:D4 a :User; :email "nope@test.de"; :income 34000 .
[] a rule:SPARQLRule;
rule:content """
IF {
?x a :Customer ; :email ?email_customer .
?y a :User; :email ?email_user .
FILTER(?email_customer = ?email_user)
}
THEN {
?x owl:sameAs ?y .
}
""".
}
The following rule does work. Am I allowed to use owl:sameAs? It might be me, but I could not find it out reading User-defined Rule Reasoning | Stardog Documentation Latest
PREFIX rule: <tag:stardog:api:rule:>
INSERT DATA {
:C1 a :Customer; :email "test@test.com"; :id 1 .
:U3 a :User; :email "test@test.com"; :income 1000 .
:D4 a :User; :email "nope@test.de"; :income 34000 .
[] a rule:SPARQLRule;
rule:content """
IF {
?x a :Customer ; :email ?email_customer .
?y a :User; :email ?email_user .
FILTER(?email_customer = ?email_user)
}
THEN {
?y a :KnownCustomer .
}
""".
}
oli666
(Oli666)
April 25, 2022, 3:01pm
3
I have stumbled upon on older post regarding this issue stating:
Stardog currently does not support rules in sameAs reasoning. Only OWL axioms (FunctionaProperty, InversefunctionalProperty and HasKey) and explicit sameAs triples are used. We have a ticket to add this feature but we don’t have a specific deadline at this point.
Query Available SWRL Rules + Insert new ones - Support / Feature Request - Stardog Community
Is this still a limitation or is there another issue in the original code posted above?
oli666
(Oli666)
April 26, 2022, 9:55am
4
Yet another update ... The logic does work using the following SWRL rule within Protege/Pellet:
Customer(?x) ^ User(?y) ^ email(?x, ?m) ^ email(?y, ?m) -> sameAs(?x, ?y)
This rule is exported as
#################################################################
# Rules
#################################################################
:x rdf:type swrl:Variable .
:y rdf:type swrl:Variable .
:m rdf:type swrl:Variable .
[ swrla:isRuleEnabled "true"^^xsd:boolean ;
rdfs:comment ""^^xsd:string ;
rdfs:label "S1"^^xsd:string ;
rdf:type swrl:Imp ;
swrl:body [ rdf:type swrl:AtomList ;
rdf:first [ rdf:type swrl:ClassAtom ;
swrl:classPredicate :Customer ;
swrl:argument1 :x
] ;
rdf:rest [ rdf:type swrl:AtomList ;
rdf:first [ rdf:type swrl:ClassAtom ;
swrl:classPredicate :User ;
swrl:argument1 :y
] ;
rdf:rest [ rdf:type swrl:AtomList ;
rdf:first [ rdf:type swrl:DatavaluedPropertyAtom ;
swrl:propertyPredicate :email ;
swrl:argument1 :x ;
swrl:argument2 :m
] ;
rdf:rest [ rdf:type swrl:AtomList ;
rdf:first [ rdf:type swrl:DatavaluedPropertyAtom ;
swrl:propertyPredicate :email ;
swrl:argument1 :y ;
swrl:argument2 :m
] ;
rdf:rest rdf:nil
]
]
]
] ;
swrl:head [ rdf:type swrl:AtomList ;
rdf:first [ rdf:type swrl:SameIndividualAtom ;
swrl:argument1 :x ;
swrl:argument2 :y
] ;
rdf:rest rdf:nil
]
] .
However, trying to use this imported SWRL rule (either via a plain data import or by adding it as a schema in the model tab) does not seem to have any effect.
Any thoughts, anyone?