Skip to content

Commit acd8893

Browse files
authored
fix(context-generator): support rdfs:Class and sh:in IRI enumerations (#71)
The context generator only looked for owl:Class when building class term mappings, causing ontologies like OpenLABEL v1 (which uses rdfs:Class) to be missing from the generated context. Properties constrained with sh:in containing IRI members were also missing type coercion, forcing instance data to use verbose {"@id": ...} objects instead of bare term names. Changes: - Add RDFS.Class to extract_classes() type query loop - Add _sh_in_has_iris() helper to detect sh:in with URIRef members - Use @type: @vocab (not @id) for enum properties so rdflib resolves bare term names through context definitions - Prevent class term mappings from overwriting richer property definitions - Move Collection import to module level, add Node type hint - Regenerate openlabel.context.jsonld (~50 new classes, enum coercion) - Add unit tests for rdfs:Class, sh:in IRI/Literal detection Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>
1 parent ab99651 commit acd8893

3 files changed

Lines changed: 362 additions & 42 deletions

File tree

artifacts/openlabel/openlabel.context.jsonld

Lines changed: 224 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,52 @@
2525
"@type": "@id"
2626
},
2727
"BehaviourCommunication": {
28-
"@id": "openlabel:BehaviourCommunication"
28+
"@id": "openlabel:BehaviourCommunication",
29+
"@type": "@vocab"
2930
},
3031
"ConnectivityCommunication": {
31-
"@id": "openlabel:ConnectivityCommunication"
32+
"@id": "openlabel:ConnectivityCommunication",
33+
"@type": "@vocab"
3234
},
3335
"ConnectivityPositioning": {
34-
"@id": "openlabel:ConnectivityPositioning"
36+
"@id": "openlabel:ConnectivityPositioning",
37+
"@type": "@vocab"
3538
},
3639
"DaySunElevation": {
3740
"@id": "openlabel:DaySunElevation",
3841
"@type": "xsd:boolean"
3942
},
4043
"DaySunPosition": {
41-
"@id": "openlabel:DaySunPosition"
44+
"@id": "openlabel:DaySunPosition",
45+
"@type": "@vocab"
4246
},
4347
"DrivableAreaEdge": {
44-
"@id": "openlabel:DrivableAreaEdge"
48+
"@id": "openlabel:DrivableAreaEdge",
49+
"@type": "@vocab"
4550
},
4651
"DrivableAreaSurfaceCondition": {
47-
"@id": "openlabel:DrivableAreaSurfaceCondition"
52+
"@id": "openlabel:DrivableAreaSurfaceCondition",
53+
"@type": "@vocab"
4854
},
4955
"DrivableAreaSurfaceFeature": {
50-
"@id": "openlabel:DrivableAreaSurfaceFeature"
56+
"@id": "openlabel:DrivableAreaSurfaceFeature",
57+
"@type": "@vocab"
5158
},
5259
"DrivableAreaSurfaceType": {
53-
"@id": "openlabel:DrivableAreaSurfaceType"
60+
"@id": "openlabel:DrivableAreaSurfaceType",
61+
"@type": "@vocab"
5462
},
5563
"DrivableAreaType": {
56-
"@id": "openlabel:DrivableAreaType"
64+
"@id": "openlabel:DrivableAreaType",
65+
"@type": "@vocab"
5766
},
5867
"EnvironmentParticulates": {
59-
"@id": "openlabel:EnvironmentParticulates"
68+
"@id": "openlabel:EnvironmentParticulates",
69+
"@type": "@vocab"
6070
},
6171
"GeometryTransverse": {
62-
"@id": "openlabel:GeometryTransverse"
72+
"@id": "openlabel:GeometryTransverse",
73+
"@type": "@vocab"
6374
},
6475
"HorizontalCurves": {
6576
"@id": "openlabel:HorizontalCurves",
@@ -70,20 +81,24 @@
7081
"@type": "xsd:boolean"
7182
},
7283
"IlluminationArtificial": {
73-
"@id": "openlabel:IlluminationArtificial"
84+
"@id": "openlabel:IlluminationArtificial",
85+
"@type": "@vocab"
7486
},
7587
"IlluminationCloudiness": {
7688
"@id": "openlabel:IlluminationCloudiness",
7789
"@type": "xsd:boolean"
7890
},
7991
"IlluminationLowLight": {
80-
"@id": "openlabel:IlluminationLowLight"
92+
"@id": "openlabel:IlluminationLowLight",
93+
"@type": "@vocab"
8194
},
8295
"JunctionIntersection": {
83-
"@id": "openlabel:JunctionIntersection"
96+
"@id": "openlabel:JunctionIntersection",
97+
"@type": "@vocab"
8498
},
8599
"JunctionRoundabout": {
86-
"@id": "openlabel:JunctionRoundabout"
100+
"@id": "openlabel:JunctionRoundabout",
101+
"@type": "@vocab"
87102
},
88103
"LaneSpecificationDimensions": {
89104
"@id": "openlabel:LaneSpecificationDimensions",
@@ -98,10 +113,12 @@
98113
"@type": "xsd:boolean"
99114
},
100115
"LaneSpecificationTravelDirection": {
101-
"@id": "openlabel:LaneSpecificationTravelDirection"
116+
"@id": "openlabel:LaneSpecificationTravelDirection",
117+
"@type": "@vocab"
102118
},
103119
"LaneSpecificationType": {
104-
"@id": "openlabel:LaneSpecificationType"
120+
"@id": "openlabel:LaneSpecificationType",
121+
"@type": "@vocab"
105122
},
106123
"LongitudinalDownSlope": {
107124
"@id": "openlabel:LongitudinalDownSlope",
@@ -216,7 +233,8 @@
216233
"@type": "xsd:boolean"
217234
},
218235
"RainType": {
219-
"@id": "openlabel:RainType"
236+
"@id": "openlabel:RainType",
237+
"@type": "@vocab"
220238
},
221239
"RoadUser": {
222240
"@id": "openlabel:RoadUser",
@@ -227,31 +245,40 @@
227245
"@type": "xsd:boolean"
228246
},
229247
"RoadUserHuman": {
230-
"@id": "openlabel:RoadUserHuman"
248+
"@id": "openlabel:RoadUserHuman",
249+
"@type": "@vocab"
231250
},
232251
"RoadUserVehicle": {
233-
"@id": "openlabel:RoadUserVehicle"
252+
"@id": "openlabel:RoadUserVehicle",
253+
"@type": "@vocab"
234254
},
235255
"SceneryFixedStructure": {
236-
"@id": "openlabel:SceneryFixedStructure"
256+
"@id": "openlabel:SceneryFixedStructure",
257+
"@type": "@vocab"
237258
},
238259
"ScenerySpecialStructure": {
239-
"@id": "openlabel:ScenerySpecialStructure"
260+
"@id": "openlabel:ScenerySpecialStructure",
261+
"@type": "@vocab"
240262
},
241263
"SceneryTemporaryStructure": {
242-
"@id": "openlabel:SceneryTemporaryStructure"
264+
"@id": "openlabel:SceneryTemporaryStructure",
265+
"@type": "@vocab"
243266
},
244267
"SceneryZone": {
245-
"@id": "openlabel:SceneryZone"
268+
"@id": "openlabel:SceneryZone",
269+
"@type": "@vocab"
246270
},
247271
"SignsInformation": {
248-
"@id": "openlabel:SignsInformation"
272+
"@id": "openlabel:SignsInformation",
273+
"@type": "@vocab"
249274
},
250275
"SignsRegulatory": {
251-
"@id": "openlabel:SignsRegulatory"
276+
"@id": "openlabel:SignsRegulatory",
277+
"@type": "@vocab"
252278
},
253279
"SignsWarning": {
254-
"@id": "openlabel:SignsWarning"
280+
"@id": "openlabel:SignsWarning",
281+
"@type": "@vocab"
255282
},
256283
"SubjectVehicleSpeed": {
257284
"@id": "openlabel:SubjectVehicleSpeed",
@@ -408,6 +435,175 @@
408435
"weatherWindValue": {
409436
"@id": "openlabel:weatherWindValue",
410437
"@type": "xsd:decimal"
411-
}
438+
},
439+
"ArtificialStreetLighting": "openlabel:ArtificialStreetLighting",
440+
"ArtificialVehicleLighting": "openlabel:ArtificialVehicleLighting",
441+
"BehaviourMotion": "openlabel:BehaviourMotion",
442+
"CommunicationHeadlightFlash": "openlabel:CommunicationHeadlightFlash",
443+
"CommunicationHorn": "openlabel:CommunicationHorn",
444+
"CommunicationSignalEmergency": "openlabel:CommunicationSignalEmergency",
445+
"CommunicationSignalHazard": "openlabel:CommunicationSignalHazard",
446+
"CommunicationSignalLeft": "openlabel:CommunicationSignalLeft",
447+
"CommunicationSignalRight": "openlabel:CommunicationSignalRight",
448+
"CommunicationSignalSlowing": "openlabel:CommunicationSignalSlowing",
449+
"CommunicationV2i": "openlabel:CommunicationV2i",
450+
"CommunicationV2v": "openlabel:CommunicationV2v",
451+
"CommunicationWave": "openlabel:CommunicationWave",
452+
"DrivableAreaGeometry": "openlabel:DrivableAreaGeometry",
453+
"DrivableAreaLaneSpecification": "openlabel:DrivableAreaLaneSpecification",
454+
"DrivableAreaSigns": "openlabel:DrivableAreaSigns",
455+
"DrivableAreaSurface": "openlabel:DrivableAreaSurface",
456+
"DynamicElementsSubjectVehicle": "openlabel:DynamicElementsSubjectVehicle",
457+
"DynamicElementsTraffic": "openlabel:DynamicElementsTraffic",
458+
"EdgeLineMarkers": "openlabel:EdgeLineMarkers",
459+
"EdgeNone": "openlabel:EdgeNone",
460+
"EdgeShoulderGrass": "openlabel:EdgeShoulderGrass",
461+
"EdgeShoulderPavedOrGravel": "openlabel:EdgeShoulderPavedOrGravel",
462+
"EdgeSolidBarriers": "openlabel:EdgeSolidBarriers",
463+
"EdgeTemporaryLineMarkers": "openlabel:EdgeTemporaryLineMarkers",
464+
"EnvironmentConnectivity": "openlabel:EnvironmentConnectivity",
465+
"EnvironmentIllumination": "openlabel:EnvironmentIllumination",
466+
"EnvironmentWeather": "openlabel:EnvironmentWeather",
467+
"FixedStructureBuilding": "openlabel:FixedStructureBuilding",
468+
"FixedStructureStreetFurniture": "openlabel:FixedStructureStreetFurniture",
469+
"FixedStructureStreetlight": "openlabel:FixedStructureStreetlight",
470+
"FixedStructureVegetation": "openlabel:FixedStructureVegetation",
471+
"GeometryHorizontal": "openlabel:GeometryHorizontal",
472+
"GeometryLongitudinal": "openlabel:GeometryLongitudinal",
473+
"HumanAnimalRider": "openlabel:HumanAnimalRider",
474+
"HumanCyclist": "openlabel:HumanCyclist",
475+
"HumanDriver": "openlabel:HumanDriver",
476+
"HumanMotorcyclist": "openlabel:HumanMotorcyclist",
477+
"HumanPassenger": "openlabel:HumanPassenger",
478+
"HumanPedestrian": "openlabel:HumanPedestrian",
479+
"HumanWheelchairUser": "openlabel:HumanWheelchairUser",
480+
"IlluminationDay": "openlabel:IlluminationDay",
481+
"InformationSignsUniform": "openlabel:InformationSignsUniform",
482+
"InformationSignsUniformFullTime": "openlabel:InformationSignsUniformFullTime",
483+
"InformationSignsUniformTemporary": "openlabel:InformationSignsUniformTemporary",
484+
"InformationSignsVariable": "openlabel:InformationSignsVariable",
485+
"InformationSignsVariableFullTime": "openlabel:InformationSignsVariableFullTime",
486+
"InformationSignsVariableTemporary": "openlabel:InformationSignsVariableTemporary",
487+
"IntersectionCrossroad": "openlabel:IntersectionCrossroad",
488+
"IntersectionGradeSeperated": "openlabel:IntersectionGradeSeperated",
489+
"IntersectionStaggered": "openlabel:IntersectionStaggered",
490+
"IntersectionTJunction": "openlabel:IntersectionTJunction",
491+
"IntersectionYJunction": "openlabel:IntersectionYJunction",
492+
"LaneTypeBus": "openlabel:LaneTypeBus",
493+
"LaneTypeCycle": "openlabel:LaneTypeCycle",
494+
"LaneTypeEmergency": "openlabel:LaneTypeEmergency",
495+
"LaneTypeSpecial": "openlabel:LaneTypeSpecial",
496+
"LaneTypeTraffic": "openlabel:LaneTypeTraffic",
497+
"LaneTypeTram": "openlabel:LaneTypeTram",
498+
"LowLightAmbient": "openlabel:LowLightAmbient",
499+
"LowLightNight": "openlabel:LowLightNight",
500+
"MotorwayManaged": "openlabel:MotorwayManaged",
501+
"MotorwayUnmanaged": "openlabel:MotorwayUnmanaged",
502+
"OddDynamicElements": "openlabel:OddDynamicElements",
503+
"OddEnvironment": "openlabel:OddEnvironment",
504+
"OddScenery": "openlabel:OddScenery",
505+
"ParticulatesWater": "openlabel:ParticulatesWater",
506+
"PositioningGalileo": "openlabel:PositioningGalileo",
507+
"PositioningGlonass": "openlabel:PositioningGlonass",
508+
"PositioningGps": "openlabel:PositioningGps",
509+
"RainTypeConvective": "openlabel:RainTypeConvective",
510+
"RainTypeDynamic": "openlabel:RainTypeDynamic",
511+
"RainTypeOrographic": "openlabel:RainTypeOrographic",
512+
"RegulatorySignsUniform": "openlabel:RegulatorySignsUniform",
513+
"RegulatorySignsUniformFullTime": "openlabel:RegulatorySignsUniformFullTime",
514+
"RegulatorySignsUniformTemporary": "openlabel:RegulatorySignsUniformTemporary",
515+
"RegulatorySignsVariable": "openlabel:RegulatorySignsVariable",
516+
"RegulatorySignsVariableFullTime": "openlabel:RegulatorySignsVariableFullTime",
517+
"RegulatorySignsVariableTemporary": "openlabel:RegulatorySignsVariableTemporary",
518+
"RoadTypeDistributor": "openlabel:RoadTypeDistributor",
519+
"RoadTypeMinor": "openlabel:RoadTypeMinor",
520+
"RoadTypeMotorway": "openlabel:RoadTypeMotorway",
521+
"RoadTypeParking": "openlabel:RoadTypeParking",
522+
"RoadTypeRadial": "openlabel:RoadTypeRadial",
523+
"RoadTypeShared": "openlabel:RoadTypeShared",
524+
"RoadTypeSlip": "openlabel:RoadTypeSlip",
525+
"RoundaboutCompact": "openlabel:RoundaboutCompact",
526+
"RoundaboutCompactNosignal": "openlabel:RoundaboutCompactNosignal",
527+
"RoundaboutCompactSignal": "openlabel:RoundaboutCompactSignal",
528+
"RoundaboutDouble": "openlabel:RoundaboutDouble",
529+
"RoundaboutDoubleNosignal": "openlabel:RoundaboutDoubleNosignal",
530+
"RoundaboutDoubleSignal": "openlabel:RoundaboutDoubleSignal",
531+
"RoundaboutLarge": "openlabel:RoundaboutLarge",
532+
"RoundaboutLargeNosignal": "openlabel:RoundaboutLargeNosignal",
533+
"RoundaboutLargeSignal": "openlabel:RoundaboutLargeSignal",
534+
"RoundaboutMini": "openlabel:RoundaboutMini",
535+
"RoundaboutMiniNosignal": "openlabel:RoundaboutMiniNosignal",
536+
"RoundaboutMiniSignal": "openlabel:RoundaboutMiniSignal",
537+
"RoundaboutNormal": "openlabel:RoundaboutNormal",
538+
"RoundaboutNormalNosignal": "openlabel:RoundaboutNormalNosignal",
539+
"RoundaboutNormalSignal": "openlabel:RoundaboutNormalSignal",
540+
"Scenario": "openlabel:Scenario",
541+
"SceneryDrivableArea": "openlabel:SceneryDrivableArea",
542+
"SceneryJunction": "openlabel:SceneryJunction",
543+
"SpecialStructureAutoAccess": "openlabel:SpecialStructureAutoAccess",
544+
"SpecialStructureBridge": "openlabel:SpecialStructureBridge",
545+
"SpecialStructurePedestrianCrossing": "openlabel:SpecialStructurePedestrianCrossing",
546+
"SpecialStructureRailCrossing": "openlabel:SpecialStructureRailCrossing",
547+
"SpecialStructureTollPlaza": "openlabel:SpecialStructureTollPlaza",
548+
"SpecialStructureTunnel": "openlabel:SpecialStructureTunnel",
549+
"SunPositionBehind": "openlabel:SunPositionBehind",
550+
"SunPositionFront": "openlabel:SunPositionFront",
551+
"SunPositionLeft": "openlabel:SunPositionLeft",
552+
"SunPositionRight": "openlabel:SunPositionRight",
553+
"SurfaceConditionContamination": "openlabel:SurfaceConditionContamination",
554+
"SurfaceConditionFlooded": "openlabel:SurfaceConditionFlooded",
555+
"SurfaceConditionIcy": "openlabel:SurfaceConditionIcy",
556+
"SurfaceConditionMirage": "openlabel:SurfaceConditionMirage",
557+
"SurfaceConditionSnow": "openlabel:SurfaceConditionSnow",
558+
"SurfaceConditionStandingWater": "openlabel:SurfaceConditionStandingWater",
559+
"SurfaceConditionWet": "openlabel:SurfaceConditionWet",
560+
"SurfaceFeatureCrack": "openlabel:SurfaceFeatureCrack",
561+
"SurfaceFeaturePothole": "openlabel:SurfaceFeaturePothole",
562+
"SurfaceFeatureRut": "openlabel:SurfaceFeatureRut",
563+
"SurfaceFeatureSwell": "openlabel:SurfaceFeatureSwell",
564+
"SurfaceTypeLoose": "openlabel:SurfaceTypeLoose",
565+
"SurfaceTypeSegmented": "openlabel:SurfaceTypeSegmented",
566+
"SurfaceTypeUniform": "openlabel:SurfaceTypeUniform",
567+
"Tag": "openlabel:Tag",
568+
"TemporaryStructureConstructionDetour": "openlabel:TemporaryStructureConstructionDetour",
569+
"TemporaryStructureRefuseCollection": "openlabel:TemporaryStructureRefuseCollection",
570+
"TemporaryStructureRoadSignage": "openlabel:TemporaryStructureRoadSignage",
571+
"TemporaryStructureRoadWorks": "openlabel:TemporaryStructureRoadWorks",
572+
"TrafficAgentType": "openlabel:TrafficAgentType",
573+
"TransverseBarriers": "openlabel:TransverseBarriers",
574+
"TransverseDivided": "openlabel:TransverseDivided",
575+
"TransverseLanesTogether": "openlabel:TransverseLanesTogether",
576+
"TransversePavements": "openlabel:TransversePavements",
577+
"TransverseUndivided": "openlabel:TransverseUndivided",
578+
"TravelDirectionLeft": "openlabel:TravelDirectionLeft",
579+
"TravelDirectionRight": "openlabel:TravelDirectionRight",
580+
"V2iCellular": "openlabel:V2iCellular",
581+
"V2iSatellite": "openlabel:V2iSatellite",
582+
"V2iWifi": "openlabel:V2iWifi",
583+
"V2vCellular": "openlabel:V2vCellular",
584+
"V2vSatellite": "openlabel:V2vSatellite",
585+
"V2vWifi": "openlabel:V2vWifi",
586+
"VehicleAgricultural": "openlabel:VehicleAgricultural",
587+
"VehicleBus": "openlabel:VehicleBus",
588+
"VehicleCar": "openlabel:VehicleCar",
589+
"VehicleConstruction": "openlabel:VehicleConstruction",
590+
"VehicleCycle": "openlabel:VehicleCycle",
591+
"VehicleEmergency": "openlabel:VehicleEmergency",
592+
"VehicleMotorcycle": "openlabel:VehicleMotorcycle",
593+
"VehicleTrailer": "openlabel:VehicleTrailer",
594+
"VehicleTruck": "openlabel:VehicleTruck",
595+
"VehicleVan": "openlabel:VehicleVan",
596+
"VehicleWheelchair": "openlabel:VehicleWheelchair",
597+
"WarningSignsUniform": "openlabel:WarningSignsUniform",
598+
"WarningSignsUniformFullTime": "openlabel:WarningSignsUniformFullTime",
599+
"WarningSignsUniformTemporary": "openlabel:WarningSignsUniformTemporary",
600+
"WarningSignsVariable": "openlabel:WarningSignsVariable",
601+
"WarningSignsVariableFullTime": "openlabel:WarningSignsVariableFullTime",
602+
"WarningSignsVariableTemporary": "openlabel:WarningSignsVariableTemporary",
603+
"ZoneGeoFenced": "openlabel:ZoneGeoFenced",
604+
"ZoneInterference": "openlabel:ZoneInterference",
605+
"ZoneRegion": "openlabel:ZoneRegion",
606+
"ZoneSchool": "openlabel:ZoneSchool",
607+
"ZoneTrafficManagement": "openlabel:ZoneTrafficManagement"
412608
}
413609
}

0 commit comments

Comments
 (0)