I am new to creating ontologies using Python (owlready2) and want to load my existing data (about schools, location and staff) into it.
# Create some classes
with onto:
class Staff(Thing): pass
class Location(Thing): pass
class School(Thing): pass
# Create some relationships
class belongs_to(Staff >> School, FunctionalProperty): pass
class located_in(School >> Location, FunctionalProperty): pass
I want to add some attributes to these classes. I have some questions around attributes and adding of those attributes. For example, this is the scenario:
- A location (say Seattle) has 5 schools (with different types: Elementary, Middle and High).
- Each school has some number of teachers/staff.
Given this scenario, I have these extra info to each school in my large-dataset that I want to add. But, I do not know how to add such granular info into
- Location will have street-address, postal-code etc.
- Staff will have first-name, last-name, age, sex, teaching subjects(math, science..more than one)
- school will have name, location, type (high, middle, elem), built-date, total-area,...
I presume that I can add such attributes to instances of classes...but, I do not know how to do it in owlready2. Are these attributes seen as 'properties' in owlready2?
It would be great to see some code-examples.
Update: Upon further reading, I am thinking about three properties - DataProperties and ObjectProperties. Not sure when some relationships among entities will be an inheritance of both ObjProperty and FunctionalProperty and when some will have DataProperty...
Yes. If their values are string or numbers, they are DataProperty, and if the values is another object, they are ObjectProperty.
For example for first name :