user1717931
user1717931

Reputation: 2501

owlready2 add attributes to individual

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:

  1. A location (say Seattle) has 5 schools (with different types: Elementary, Middle and High).
  2. 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

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...

Upvotes: 0

Views: 168

Answers (1)

Jiba
Jiba

Reputation: 46

Are these attributes seen as 'properties' in owlready2?

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 :

class firstname(Staff >> str): pass

Upvotes: 1

Related Questions