1

I have an ontology-pattern that I want to use to drive a csv-to-rdf instantiation process.

The underlying datamodel consists of containers and elements, and the naming is such that element-names are only unique within their container.

So the csv file might look something like:

container, element
box_one, penny
box_one, cube
box_one, hammer
box_two, key
box_two, penny

I want to read the csv, instantiating the objects as I go as members of container and element respectively, and additionally, assign a property hasElement that links each container to the element they contain.

I can do this by calling the class-constructors and populating them with the data provided by the rows in the csv.

However, it's important that the penny in box_one is a different object to the penny in box_two. Same labels perhaps, but two distinct objects.

With my ontology, after importing into owlready2, I have Class constructors defined for Container and Element, but I want these to construct an IRI based on the context of each component being loaded - or, potentially using some unique guid type number. Otherwise, when I construct Element('penny') for the item on the first row, it ends up being the same IRI as the. Element('penny') on the final row - despite them being different things in different contexts.

I could embed this logic into the python loading the data, but I want all the config for the load process to be part of the ontology - so that should someone come along later and create a SpecialContainer subclass of Container, the python will continue to know that element-IRIs' uniqueness should take their container classes into consideration - even if they're frequently referred to using their short-hand names, where the container, whatever it may be, is an important piece of contextual information. (Or to be relatively flexible for some alternate use-case, such that only the ontology be updated to support continued loading functionality)

So, how much control do I have over IRI construction using owlready2?

Does it have inbuilt options for IRI construction or does it only use whatever text I provide when calling the Class instantiator method - appending that to the end of the base_iri?

Are there any existing tools or modules to support common csv to rdf conversion processes (informed by some owl) without me having to roll one from scratch? (Which I'll be happy to do, but want to get a view on whether anything already exists, or if there are any accepted standards/methods in this area before embarking on such a project)

Thomas Kimber
  • 10,601
  • 3
  • 25
  • 42

0 Answers0