Adding Individuals to Existing Ontology and Store Indivudals
For a given ontology created in Protege, for example, with all classes and properties as will as restrictions already defined between them in Protege. How to load such ontology and create instances of those classes based on data incoming from other sources and then store those instances in knowledge base? Is it possible to do that in Owlready2 and can you please give one simple example how to do that?
Re: Adding Individuals to Existing Ontology and Store Indivudals
Hummm... Not sure to be a model to follow, but below is my own approach to peuplate my ontology with Individuals :
As I don't have resolvable namespace yet like http://mydomain/.../myonto/, I use a base ontology using the local C:/path/to/local/ontologies/myonto.owl (and I'm using Stanford Protégé to describe the logic)
onto = get_ontology('file://C:/path/to/local/ontologies/myonto.owl').load()
skos = get_ontology("http://www.w3.org/2004/02/skos/core#").load()
Individual1 = MyClass('MyClass/1') # thus creating http://mydomain/.../myonto/MyClass/1 Individual
Individual1.label = 'My Class Individual 1' # giving a label to it
Individual1.prefLabel = 'a preferred label' # remember that skos:prefLabel id defined in SKOS !
Individual1.other = [something] # assuming namespace:other is not functional and already defined in myonto.owl or any imported ontology
Individual1.other.append(something else to add to other) # wanted to add another value to other property
#... and so on
# and saving the result as RDF/XML file (to open/inspect using Stanford Protégé for example)
But things could be different if you are more interested in creating the classes using owlready2