Hi guys. Got another question.
Is there a way to control the order of rules firing? What if I create a variable in one rule and need it another rule - will Stardog be able to handle that?
Hi guys. Got another question.
Is there a way to control the order of rules firing? What if I create a variable in one rule and need it another rule - will Stardog be able to handle that?
Can you provide a simple example of the behavior you want to see?
I asked this question earlier and it is related to my question:
This is the behaviour I would like to see:
I have 3 rulesets, where 1 and 2 gives a literal value to two objects and no 3 needs these strings to CONCAT a new variable. This is how the rules look:
Rule 1
[] a rule:SPARQLRule ;
rule:content “”“
IF {
?window a ifcowl:IfcWindow .
}
THEN {
?window ccs:ProductID “QQA” .
}”"".
Rule 2
[] a rule:SPARQLRule ;
rule:content “”“
IF {
?wall a ifcowl:IfcWallStandardCase .
}
THEN {
?wall ccs:ProductID “B” .
}”"".
Rule 3
[] a rule:SPARQLRule ;
rule:content “”"
IF {
?ifcrelfill a ifcowl:IfcRelFillsElement ;
ifcowl:relatingOpeningElement_IfcRelFillsElement ?openingelement ;
ifcowl:relatedBuilstrong textdingElement_IfcRelFillsElement ?window .
?window a ifcowl:IfcWindow ;
ccs:ProductID ?windowID .
?voidelement a ifcowl:IfcRelVoidsElement ;
ifcowl:relatedOpeningElement_IfcRelVoidsElement ?openingelement ;
ifcowl:relatingBuildingElement_IfcRelVoidsElement ?wall .
?wall a ifcowl:IfcWallStandardCase .
ccs:ProductID ?wallID .
BIND (CONCAT(-?wallID.?windowID) AS ?wallwindowID)
}
THEN {
?window ccs:combinedProductId ?wallwindowID .
}""".
However when I make a SPARQL query in Stardog with:
SELECT ?window ?ID
WHERE {
?window a ifcowl:IfcWindow .
?window ccs:combinedProductId ?ID .
}
I get no results
Here is the initial silly question: Do you have reasoning enabled when running the query?
Yes reasoning is enabled.
However what I am curious about is the process of reasoning in Stardog, since first it should find results for 1 and 2, and then in 3 the results from 1 and 2 will yield the results in 3. Hope this makes sense
Hi Arbaz,
I deleted your other topic as this one pretty much covers everything you asked over there.
I believe the problem here is simply a malformed Rule 3. You have right above the BIND:
?wall a ifcowl:IfcWallStandardCase .
ccs:ProductID ?wallID . # This is not a complete BGP
What I think you’re looking for is:
?wall a ifcowl:IfcWallStandardCase ; # Semicolon instead of period
ccs:ProductID ?wallID .
Additionally, the parser did not seem to like BIND (CONCAT(-?wallID.?windowID) AS ?wallwindowID)
, but when I changed it to BIND (CONCAT(?wallID,?windowID) AS ?wallwindowID)
(No - sign, and comma instead of period), things seemed to work just fine. We wouldn’t have caught it when inserting the rule, since it’s all in a big string and not being parsed as SPARQL as insert time.
If I run the query on some data that I made up, I get what looks like the answer you are wanting:
Stephens-iMac:community stephen$ stardog query -r myDb "select * {?subj ccs:ProductID ?productId }"
+----------+-----------+
| subj | productId |
+----------+-----------+
| :Wall1 | "B" |
| :Wall2 | "B" |
| :Window1 | "QQA" |
| :Window2 | "QQA" |
+----------+-----------+
Query returned 4 results in 00:00:00.051
Stephens-iMac:community stephen$ stardog query -r myDb "select * {?subj ccs:combinedProductId ?combinedProductId }"
+----------+-------------------+
| subj | combinedProductId |
+----------+-------------------+
| :Window1 | "BQQA" |
| :Window2 | "BQQA" |
+----------+-------------------+
Query returned 2 results in 00:00:00.070
Thanks a lot Stephen! Stupid mistake on my part. What if the “-” and punctuation are necessary for my end product - is there a way to write this in a Stardog rule?
Ah, you would just have to alter your CONCAT a little bit: CONCAT("-", ?wallID, ".", ?windowID)
Stephens-iMac:community stephen$ stardog query -r myDb "select * {?subj ccs:combinedProductId ?combinedProductId }"
+----------+-------------------+
| subj | combinedProductId |
+----------+-------------------+
| :Window1 | "-B.QQA" |
| :Window2 | "-B.QQA" |
+----------+-------------------+
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.