How to give the same number to each subject belonging to a certain group

Hi guys,

I want to accomplish the following:

I have certain subjects of rdf:type ifc:IfcWindow.

If each of the subjects belongs to a certain type (i.e. in a physical sense like the same window type e.g. 200x200 fixed window or 430x200 sliding window) then they should be given a type number “1”, “2” etc.

So for instance if I have three windows in my graph:

:window1 :objecttype “200x200 fixed window”
:window2 :objecttype “200x200 fixed window”
:window3 :objecttype “430x200 sliding window”

then :window1 and :window2 should have the following relation:

:window1 ccs:typeID “QQA1”

:window2 ccs:typeID “QQA1”

:window3 ccs:typeID “QQA2”

I wanted to accomplish this in a Stardog rule, but I do know that this could be difficult.

Any ideas would be appreciated :slight_smile: !!


Do you have any control over this data, such that you would be able to store the window types as entities/IRIs instead of string literals? E.g.,

:window1 :objecttype :fixedWindow1 .

:fixedWindow1 a :Window ;
    rdfs:label "200x200 fixed window";
    ccs:typeID "QQA1" .

Well I have a Tbox, where my classes and properties are stored and a Abox with instance data.

The Abox is generated automatically. For instance one of my windows are defined as:

inst:IfcWindow_10974 ifcowl:globalId_IfcRoot inst:IfcGloballyUniqueId_58661 ;
ifcowl:ownerHistory_IfcRoot inst:IfcOwnerHistory_41 ;
ifcowl:name_IfcRoot inst:IfcLabel_58649 ;
ifcowl:objectType_IfcObject inst:IfcLabel_58651 ;
ifcowl:objectPlacement_IfcProduct inst:IfcLocalPlacement_73218 ;
ifcowl:representation_IfcProduct inst:IfcProductDefinitionShape_10968 .

And the ifcowl:objectType_IfcObject property should control, which windows are of same and different types.

So for this window the range of this property is:

inst:IfcLabel_58651 rdf:type ifcowl:IfcLabel ;
express:hasString “Four-Light Vertical” .

But how to make a rule, which collects the same typed windows and gives them the same code and number ?

Is there no way you can add a property to the inst:IfcLabel_58651 entity such that you get :hasCode "some code 1"?

Is there a process or significance to generating the code/number strings? I.e., does “Four-Light Vertical” always need to resolve to the same code like “QQA1?”

I have two distinct classifications I need to give these windows.

One is a productID: QQA is for windows.
Two is a typeID: also QQA for windows.

If I have three windows the productId is just given as follows:

window_A ccs:productID "#QQA1"
window_B ccs:productID "#QQA2"
window_C ccs:productID “#QQA3
, hence it just the number of instances of the ifcowl:IfcWindow .

However for the typeID I need to look at the objecttype, and all objecttypes for windows will also be named QQA, however with the symbol % in front. Now all window objects have a distinct code such as %QQA1, %QQA2 etc. So when two or more windows are of a given type they need to have the same code: say window_A and window_C are of same type and window_B is of another class then I need to make some automatic rule that can both give the code and the number:

window_A ccs:typeID "%QQA1"
window_B ccs:typeID "%QQA2"
window_C ccs:typeID “%QQA1”

The thing is I need to make this process automatic, so if I have 100 windows in my database the productId should run from #QQA1…QQA100", but say I only have 50 object types then all my windows instances will have a corresponding typeId that could be from %QQA1…QQA50".

I know RDF is not a list-based format, but a triple relation syntax. But I was wondering if I could find all instances with the same object type then I could give them the code QQA, and then determine the numbering.

Appreciate you looking into this!

I think assigning a code without the number should be fairly easy but assigning the number, as you’ve identified, is going to be the hard part. I think you might be able implement a transaction listener that would do this. Someone else would have to confirm if you’re able to do this and if it’s a good idea. I think you only have access to the database name from within a transaction listener. You might be able to open a connection and query for the max assigned n number and modify the update to write n+1. I’m very unsure if you can do this though. The transaction listener might only have access to immutable data.

Yes, the code without number works just fine with Stardog rulesets. But the number is the issue :confused:

I was just thinking of a couple of problems that my help you with your approach. The first problem is that you’re trying to enforce a constraint that every instance of a class is assigned a unique (possibly sequential) number but that is a closed world restriction as it applies only to your particular database. There is no way you can guarantee that in the entire universe there is no other instance with this number. I think you might be able to require that every instance inserted into the database have a unique number with ICV and you might be able to require that it be the max(number) + 1 using a SPARQL ICV constraint but I don’t believe there is any way to do this automatically and it might require that you add instances one at a time to pass the ICV constraint. I’m not positive you can do this so you’d have to test it out.

The other problem is that the numbers will be somewhat like blank nodes in that they won’t be durable if the data is reloaded. If you’re just looking for an id you could always try just taking a has of the resources URI. It’s not as pretty as a sequential number but it should work although I’m not sure what a css:typeID is.

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