How to give each instance reasoned by rule a running number

3 views
Skip to first unread message

Arbaz Hamayun

unread,
Jan 31, 2017, 11:50:02 AM1/31/17
to Stardog
Hello guys, 

So my usecase is a building model (as in construction), which has been converted into turtle triples. Thus I have windows, walls etc. represented by rdf and owl.  

Now I need to find all windows contained in walls and this can be done by the following rule in Stardog: 

# Rule to find windows in walls
[] a rule:SPARQLRule ;
    rule:content """
            IF {
                ?ifcrelfill a ifcowl:IfcRelFillsElement  ;
                    ifcowl:relatingOpeningElement_IfcRelFillsElement ?openingelement ;
                    ifcowl:relatedBuildingElement_IfcRelFillsElement ?window .
                
                ?window a ifcowl:IfcWindow . 
                
                ?voidelement a ifcowl:IfcRelVoidsElement ;
                        ifcowl:relatedOpeningElement_IfcRelVoidsElement ?openingelement ;
                        ifcowl:relatingBuildingElement_IfcRelVoidsElement ?wall .
                
                ?wall a ifcowl:IfcWallStandardCase .   
            }
            THEN {
                ?window expr:hasString "window in wall"
            }""".

Now that is fine and good. However I need to create a product-id for these windows and these id's are created on the basis of letters and a running number: QQA#runningnumber. 

The letters are the same for all resulting instances of windows from this rule. But the runningnumber is based on the order in which the windows were placed while designing the BIM model. So my question is: Is there a way to give each instance resulting from a rule a identification number, so that it would look something like this: 

inst:window_222 :id QQA1
inst:window_212 :id QQA2
inst:window_525 :id QQA3 ..

 

Zachary Whitley

unread,
Jan 31, 2017, 12:22:31 PM1/31/17
to Stardog
My intuition is that you will not be able to do this and if you can the solution will be either very clever or very hackish. I'd be interested if anyone could come up with the clever solution though. I'd probably be interested in the hackish solution as well but just less so ;).

I played around with writing a really simple user defined function to compute a running total a while ago but it isn't a "pure function" so it probably can't be used in rules and I'm not even sure if it should be used in general because it probably breaks in several use cases but it seemed to work for simple select queries. (Evren just updated the docs with a great description of rule limitations which you might be interested in reading. It hasn't been released yet so you'll have to read it from the git repo [1] under the section "Rule Limitations & Gotchas")


[1] https://github.com/stardog-union/stardog-docs/blob/develop/src/doc/owl2.ad

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+unsubscribe@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

Reply all
Reply to author
Forward
0 new messages