Stardog raises ConcurrentModificationException upon reasoned query on graph with SWRL Rules - swrl
When trying to execute a query with reasoning in a model, I get this error: 000012: com.complexible.stardog.plan.eval.operator.OperatorException: Uncaught error during query evaluation: ConcurrentModificationException
Ontology model has 2 SWRL rules and is consistent, as it runs fine in Protege (with built-in pellet reasoner). Model has been imported into a stardog rdf model and the query
SELECT ?tse
FROM <urn:test_graph>
{
?tse a :TaperedShaftEnd
}
fails with the above error message.
By deleting the SWRL rules the query runs fine, but of course the model does no longer represent the desired domain. By translating the SWRL rules into stardog native rules, the error appears again.
Reasoning level is set to DL, as SL would imply too high processing times for the target application.
Changing the sameAs flag in the reasoner options does not change the behavior.
Setting the reasoning level to SL, as advised generally in Stardog documentation would solve the problem on this simplified model, but as said would result impractical for the use on the final target application.
May you help me in identifying the root cause and the possible solution?
Did anyone experienced the same issue when dealing with SWRL rules?
Here below the concerned model in turtle format, to easily replicate the issue on a test graph.
Heartful thanks to anyone who may help me with this.
#prefix : <http://api.stardog.com/> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix stardog: <tag:stardog:api:> .
#prefix test: <urn:test_graph#> .
<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> a owl:AnnotationProperty .
<urn:test> a owl:Ontology .
:hasTorqueTransmissionConnectionWith a owl:ObjectProperty , owl:FunctionalProperty , owl:InverseFunctionalProperty , owl:SymmetricProperty , owl:IrreflexiveProperty .
:CouplingConnection a owl:Class ;
owl:disjointWith :ShaftEnd .
:ShaftEnd a owl:Class ;
owl:disjointWith :ShaftEnd .
:LeftCouplingConnection a owl:Class ;
rdfs:subClassOf :CouplingConnection ;
owl:disjointWith :RightCouplingConnection .
:RightCouplingConnection a owl:Class ;
rdfs:subClassOf :CouplingConnection .
:LeftShaftEnd a owl:Class ;
rdfs:subClassOf :ShaftEnd ;
owl:disjointWith :RightShaftEnd .
:RightShaftEnd a owl:Class ;
rdfs:subClassOf :ShaftEnd .
:TaperedCouplingConnection a owl:Class , <tag:stardog:api:rule:SPARQLRule> ;
rdfs:subClassOf :CouplingConnection ;
<tag:stardog:api:rule:content> """IF {
?tse a :TaperedShaftEnd .
?tse :hasTorqueTransmissionConnectionWith ?cc .
?cc a :CouplingConnection .
}
THEN {
?cc a :TaperedCouplingConnection .
}
""" .
:TaperedShaftEnd a owl:Class , <tag:stardog:api:rule:SPARQLRule> ;
rdfs:subClassOf :ShaftEnd ;
<tag:stardog:api:rule:content> """IF {
?tcc a :TaperedCouplingConnection .
?tcc :hasTorqueTransmissionConnectionWith ?se .
?se a :ShaftEnd .
}
THEN {
?se a :TaperedShaftEnd .
}
""" .
:lcc1 a :LeftCouplingConnection , owl:NamedIndividual .
:lse2 a :LeftShaftEnd , owl:NamedIndividual .
:rcc2 a :RightCouplingConnection , :TaperedCouplingConnection , owl:NamedIndividual ;
:hasTorqueTransmissionConnectionWith :lse2 .
:rse1 a :RightShaftEnd , owl:NamedIndividual ;
:hasTorqueTransmissionConnectionWith :lcc1 .
Related
SPARQL - Filter all instances that only contain a condition
I have recipes with ingredients that have a category. #prefix schema: <http://schema.org/> . #prefix ex: <http://example.org> . ex:recipe1 a schema:Recipe ; schema:recipeIngredient ex:ingredient1 , ex:ingredient3 . ex:recipe2 a schema:Recipe ; schema:recipeIngredient ex:ingredient1, ex:ingredient2 . ex:ingredient1 ex:category ex:plant . ex:ingredient2 ex:category ex:spice . ex:ingredient3 ex:category ex:meat . ex:ingredient4 ex:category ex:fish . I want to filter all recipes that only contain ingredients from the category ex:plants or ex:spice. I tried: SELECT ?recipes WHERE { ?recipes a schema:Recipe; schema:recipeIngredient ?ingredient. ?ingredient ex:category ?category. FILTER(?category NOT IN (ex:meat && ex:fish)) } This returns both recipes, I guess because ex:recipe1 also includes a ex:plant. However, my desired output is only ex:recipe2 because it does not contain any ex:meat or ex:fish. If any ex:meat or ex:fish is included in the recipes, I want it to be excluded from the result set.
how to create a stand-alone swi-plog executable file?
i'm new to Prolog. i have a .pl like this male(philip). male(charles). male(andrew). male(edward) . male(mark) . male(peter) . male(mike) . male(timothy) . male(william) . male(harry) . male(geogre) . male(louis) . male(archie) . male(james) . female(elizabeth). female(anne) . female(zara) . female(autumn) . female(sophie) . female(louise) . female(sarah) . female(diana) . female(camilla) . female(eugenie) . female(beatrice) . female(kate) . female(meghan) . female(charlotte) . married(philip, elizabeth). married(peter, autumn) . married(zara, mike) . married(anne, timothy) . married(edward, sophie) . married(andrew, sarah) . married(charles, camilla) . married(william, kate). married(harry, meghan). parent(philip, charles) . parent(elizabeth, charles) . parent(philip, andrew) . parent(alizabeth, andrew) . parent(philip, anne) . parent(elizabeth, anne) . parent(philip, edward) . parent(elizabeth, edward) . parent(mark, peter) . parent(anne, peter) . parent(mark, zara) . parent(anne, zara) . parent(edward, louise) . parent(sophie, louise) . parent(edward, james) . parent(sophie, james) . parent(andrew, eugenie) . parent(andrew, beatrice) . parent(sarah, eugenie) . parent(sarah, beatrice) . parent(charles, william) . parent(diana, william) . parent(charles, harry) . parent(diana, harry) . parent(kate, geogre) . parent(kate, charlotte) . parent(kate, louis) . parent(william, geogre) . parent(william, charlotte) . parent(william, louis) . parent(harry, archie) . parent(meghan, archie) . divorced(anne, mark) . divorced(charles, diana) . father(Parent,Child):-male(Parent), parent(Parent,Child). mother(Parent,Child):-female(Parent), parent(Parent,Child). child(Child,Parent):-father(Parent,Child); mother(Parent,Child). son(Child,Parent):-male(Child), child(Child,Parent). daughter(Child,Parent):-female(Child), child(Child,Parent). grandparent(GP,GC):-parent(GP,Parent),parent(Parent,GC). grandmother(GM,GC):-mother(GM,Parent),mother(Parent,GC). grandfather(GF,GC):-father(GF,Parent),father(Parent,GC). grandchild(GC,GP):-parent(Parent,GC), parent(GP,Parent). grandson(GS,GP):-male(GS), parent(GP,Parent),parent(Parent,GS). granddaughter(GD,GP):-female(GD), parent(GP,Parent),parent(Parent,GD). spouse(Husband,Wife):-married(Husband,Wife). husband(Person,Wife):-male(Person),married(Person,Wife). wife(Person,Husband):-female(Person),married(Husband,Person). sibling(Person1,Person2):-parent(P,Person1), parent(P,Person2). brother(Person,Sibling):-male(Person), parent(P,Person), parent(P,Sibling), Person \=Sibling. sister(Person,Sibling):-female(Person), parent(P,Person), parent(P,Sibling), Person \=Sibling. aunt1(Aunt, Person):- parent(Parent, Person), sister(Aunt, Parent). aunt2(Aunt, Person):- parent(Parent, Person), sibling(Parent, Sib), married(Sib, Aunt). aunt3(Aunt, Person):- married(P, Person), (aunt1(Aunt, P); aunt2(Aunt, P)). aunt(Aunt, Person):- (aunt1(Aunt,Person); aunt2(Aunt, Person); aunt3(Aunt, Person)). uncle1(Uncle, Person):- parent(Parent, Person), brother(Uncle, Parent). uncle2(Uncle, Person):- parent(Parent, Person), sibling(Parent, Sib), married(Sib, Uncle). uncle3(Uncle, Person):- married(P, Person), (uncle1(Uncle, P); uncle2(Uncle, P)). uncle(Uncle, Person):- (uncle1(Uncle,Person); uncle2(Uncle, Person); uncle3(Uncle, Person)). nephew(Person, Uncle):- male(Person), uncle(Uncle, Person). niece(Person, Aunt):- female(Person), aunt(Aunt, Person). firstCousin(Person, Cousin):- child(Cousin, AC), (aunt(AC, Person);uncle(AC, Person)). After i use the command "swipl.exe -o 1812057_18127064_18127205.exe -c 1812057_18127064_18127205.pl --goal=main", i got 1812057_18127064_18127205.exe file in same directory. Then i use "1812057_18127064_18127205.exe" to cmd prompt to run the file but seem like it open and end immediately. What i want is to use this file like a program which you can ask using "?-". Can anyone help me? Thanks alot.
Seems that you forgot to define the "main" predicate in your code !
Get latitude and longitude given name and address
I have a CSV file with name,area,city fieds and I'm expecting that CSV with following fields name,area,city,latitude,longitude Can any one suggest which API is best for these, I already tried Google API's Textsearch: this is giving overall city wise. Not particular eg: kfc, in jp nagar 1st phase, bangalore it throws all over bangalore kfc list I want exactly echo $url = "https://maps.googleapis.com/maps/api/geocode/json?address=" . $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key; Which API will fulfill my requirement? I tried this also $url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=". $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
SPARQL INSERT query in Protege
I'm trying to map my Data Properties in Protege to owl:Class with Sparql but it doesn't work. If any one has an example, please don't hesitate to give me an answer. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX myOnto: <http://imis/SNI/9.4.3#> INSERT DATA { ?s rdf:type owl:Class } WHERE { ?s ?o owl:DatatypeProperty} When i was running it i got this message . Please help me to resolve this problem. Error 61 Logged at Wed Oct 15 23:11:26 CEST 2014 SparqlReasonerException: org.openrdf.query.MalformedQueryException: Encountered " "insert" "INSERT "" at line 7, column 1. Was expecting one of: "base" ... "prefix" ... "select" ... "construct" ... "describe" ... "ask" ...
can I do this in AllegroGraph prolog?
I have an RDF file and I need to extract some information from it in a single line. Now, I'm using AllegroGraph with Prolog query engin : (select (?result) (q ?a !rdfs:label ?alabel) (q ?b !rdfs:label ?blabel) (lisp ?result (string+ ?alabel " AND " ?blabel))) to get the results in a single line: "{a1} AND {b1}" "{a1} AND {b2}" "{a2} AND {b1}" "{a2} AND {b2}" Now, I need to group all the rows of ?result in a single line with the string "OR". so i get: "{a1} AND {b1} OR {a1} AND {b2} OR {a2} AND {b1} OR {a2} AND {b2}" Is there any function in prolog to do this?
The fact that you've only got a* on the left and b* on the right means that you've got some other selection condition than just having a label. Given data like this: #prefix : <http://example.org/>. #prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. :a1 a :ClassA ; rdfs:label "a1" . :a2 a :ClassA ; rdfs:label "a2" . :b1 a :ClassB ; rdfs:label "b1" . :b2 a :ClassB ; rdfs:label "b2" . you can select ?a and ?b by their classes (:ClassA and :ClassB), and then extract their labels as well, with a pattern like: ?a a :ClassA ; rdfs:label ?alabel . ?b a :ClassB ; rdfs:label ?blabel . Then you can get the {alabel} AND {blabel} with a bind and a concat: bind( concat( "{", ?alabel, "} AND {", ?blabel, "}" ) as ?AandB ) Using these, a query like prefix : <http://example.org/> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> select ?AandB { ?a a :ClassA ; rdfs:label ?alabel . ?b a :ClassB ; rdfs:label ?blabel . bind( concat( "{", ?alabel, "} AND {", ?blabel, "}" ) as ?AandB ) } will get you the kind of results that you can already get: ------------------- | AandB | =================== | "{a2} AND {b2}" | | "{a2} AND {b1}" | | "{a1} AND {b2}" | | "{a1} AND {b1}" | ------------------- The trick now is to use group_concat and an implicit group to combine all these into a string, with a separator of " OR ": prefix : <http://example.org/> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> select ( group_concat( ?AandB ; separator=" OR ") as ?string ) where { ?a a :ClassA ; rdfs:label ?alabel . ?b a :ClassB ; rdfs:label ?blabel . bind( concat( "{", ?alabel, "} AND {", ?blabel, "}" ) as ?AandB ) } to get a result: ---------------------------------------------------------------------- | string | ====================================================================== | "{a2} AND {b2} OR {a2} AND {b1} OR {a1} AND {b2} OR {a1} AND {b1}" | ---------------------------------------------------------------------- If you like, you can even get rid of the bind, and just put the concat expression right into the group_concat. You might find that easier to read (less jumping around) or harder to read (big one-liner), but at least it's good to have options: prefix : <http://example.org/> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> select ( group_concat( concat( "{",?alabel,"} AND {",?blabel,"}" ) ; separator=" OR ") as ?string ) where { ?a a :ClassA ; rdfs:label ?alabel . ?b a :ClassB ; rdfs:label ?blabel . } There are some other examples of group_concat floating around on StackOverflow that might be useful to you as well: Aggregating results from SPARQL query RDF list subjects with their objects in a single line (this is actually another question that you asked, and that I answered, and in that answer, I also pointed out the previous question) obtain the matrix in protege (this does some pretty fancy string manipulation) SPARQL query to get all parent of a node