How to make Stardog Rules working?

i've tried to add these in to archetype schema

@prefix rule: <tag:stardog:api:rule:> .
@prefix skosextends: <http://www.w3.org/2004/02/skos/skos-extends#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

skosextends:coordinateOf a owl:ObjectProperty ;
  owl:inverseOf skosextends:hasCoordinate ;
  rdfs:subPropertyOf skos:semanticRelation ;
  rdfs:domain skos:Concept ;
  rdfs:range rdf:List .

skosextends:hasCoordinate a owl:ObjectProperty ;
  owl:inverseOf skosextends:coordinateOf ;
  rdfs:subPropertyOf skos:semanticRelation ;
  rdfs:domain skos:List ;
  rdfs:range rdf:Concept .

skosextends:hasCoordinatePart a owl:ObjectProperty ;
  rdfs:subPropertyOf skos:semanticRelation ;
  rdfs:domain skos:Concept ;
  rdfs:range rdf:Concept .

IF {
  ?concept skosextends:coordinateOf ?list .
  ?list rdf:rest*/rdf:first ?conceptIRI .
} THEN {
  ?concept skosextends:hasCoordinatePart ?conceptIRI .
}

but the rule doesn't seems to work

my reasoning type is set to SL

you can see the inverse infer "hasCoordinate" is working, but not IF THEN

Hey can you share the query plan please? (in text format, not json)

SELECT
      (stardog:functions:localname(?conceptIRI) as ?conceptId)
      ?conceptLabel
    WHERE {
      ?concept skosextends:coordinateOf ?list .
      ?list rdf:rest*/rdf:first ?conceptIRI .
      ?conceptIRI skosxl:prefLabel/skosxl:literalForm ?conceptLabel .
    }
    ORDER BY ASC(?conceptLabel)
Distinct [#1]
`─ Projection(?conceptId, ?conceptLabel) [#1]
   `─ OrderBy(ASC(?conceptLabel)) [#1]
      `─ Bind(localname(?conceptIRI) AS ?conceptId) [#1]
         `─ MergeJoin(?hfmdgnuq) [#1]
            +─ Scan[PSOC](?hfmdgnuq, <http://www.w3.org/2008/05/skos-xl#literalForm>, ?conceptLabel) [#1]
            `─ Sort(?hfmdgnuq) [#1]
               `─ MergeJoin(?conceptIRI) [#1]
                  +─ Scan[PSOC](?conceptIRI, <http://www.w3.org/2008/05/skos-xl#prefLabel>, ?hfmdgnuq) [#1]
                  `─ Sort(?conceptIRI) [#1]
                     `─ MergeJoin(?bxrkqwcl) [#1]
                        +─ Scan[PSOC](?bxrkqwcl, rdf:first, ?conceptIRI) [#1]
                        `─ Sort(?bxrkqwcl) [#3]
                           `─ MergeJoin(?list) [#3]
                              +─ Scan[PO_NOC](_, <http://www.w3.org/2004/02/skos/skos-extends#>, ?list) [#1]
                              `─ PropertyPath(?list -> ?bxrkqwcl, minLength=0, sorted by=?list) [#551]
                                 `─ Scan[PSOC](?list, rdf:rest, ?bxrkqwcl) [#1]

SELECT *
WHERE {
    ?s ?p ?o .
    FILTER (?o NOT IN (owl:Thing)) .
}
Distinct [#97K]
`─ Projection(?s, ?p, ?o) [#97K]
   `─ Filter(?o != owl:Thing) [#97K]
      `─ Property(?s, ?p, ?o)

weird

after fixing typo

the inverse infer hasCoordinate are gone

this is the archetype that used in this post

stardog-admin db create -o database.archetypes="dcterms,skos-inline,skosxl,skosthes,uneskos,skosextends" -n app
INSERT DATA {
    :otherconcept1 a skos:Concept .
    :otherconcept2 a skos:Concept .
    :someconcept a skos:Concept .
    :someconcept skosextends:coordinateOf (:otherconcept1 :otherconcept2)
}

some data

Can you share the query plan for just select * { ?s skosextends:hasCoordinatePart ?o }?

Distinct [#1]
`─ Projection(?s, ?o) [#1]
   `─ Empty [#1]

I see you have the * property path operator used in the rule which is not supported. You should see a message about this in the stardog.log.

WARN  2020-08-05 10:49:42,221 [stardog-user-5] com.complexible.stardog.reasoning.rule.RuleExtractor:parseRule(153): Ignoring invalid rule:
 IF {
   ?concept <http://www.w3.org/2004/02/skos/skos-extends#coordinateOf> ?list .
   ?list <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>*/<http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?conceptIRI .
}
THEN {
   ?concept <http://www.w3.org/2004/02/skos/skos-extends#hasCoordinatePart> ?conceptIRI .
}

Parse error was: Unsupported operator: PropertyPath

oh oh oh okay thanks @jess

and how do i fix warn like this Not a valid SL axiom

WARN  2020-08-05 10:49:42,185 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(terms:modified,rdfs:Literal) 
WARN  2020-08-05 10:49:42,186 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(terms:issued,rdfs:Literal) 
WARN  2020-08-05 10:49:42,186 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(core:member,or(core:Concept, core:Collection)) 
WARN  2020-08-05 10:49:42,187 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(ns:term_status,xsd:string) 
WARN  2020-08-05 10:49:42,188 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Domain(skos-thes:status,or(core:Concept, skos-xl:Label)) 
WARN  2020-08-05 10:49:42,188 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Domain(uneskos:memberOf,or(core:Collection, core:Concept)) 
WARN  2020-08-05 10:49:42,189 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: SubClassOf(skos-xl:Label,cardinality(skos-xl:literalForm,1,rdfs:Literal)) 
WARN  2020-08-05 10:49:42,190 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: SubClassOf(skos-thes:CompoundEquivalence,min(skos-thes:plusUse,2,skos-thes:PreferredTerm)) 
WARN  2020-08-05 10:49:42,190 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: SubClassOf(skos-thes:CompoundEquivalence,cardinality(skos-thes:plusUF,1,skos-thes:SplitNonPreferredTerm)) 

You have a couple different issues here:

I don't think Literal is specific enough to infer anything.

This is not permitted in Stardog (not sure why). Also not sure why you would require it.

"or" is not permitted for domain/range spec in OWL2 RL profile. What are you trying to infer here?

There are some restrictions on cardinality, esp on the right hand side of these expressions. What are you after here?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.