Reputation: 41
I am in need of creating an ontology dynamically.
for classes I am creating them using below method.
with onto:
NewClass = types.new_class(class_name, tuple(SuperClasses))
But for creating properties(object/data etc..) I am unable to find a way to create them dynamically. Right now what I can do is :
with onto:
class has_grouping(Bacterium >> Grouping):
pass
where "has_grouping" is the property name. I wish to be able to create the property where the property name can be induced from a variable.
Upvotes: 2
Views: 940
Reputation: 547
Adding on to the answer posted by @Zenmate, here is a solution that includes assignment of domain and range.
with onto:
prop = types.new_class(property_name, (ObjectProperty, FunctionalProperty))
prop.domain = [domain]
prop.range = [range]
Upvotes: 0
Reputation: 41
OWL properties are actually “classes of relationship”. Properties are created by defining a class that inherits from DataProperty, ObjectProperty, or AnnotationProperty. In addition, the classes FunctionalProperty, InverseFunctionalProperty, TransitiveProperty, SymmetricProperty, AsymmetricProperty, ReflexiveProperty, and IrreflexiveProperty can be used as additional superclasses (using multiple inheritance) in order to create functional, inverse functional, transitive, and other properties.
Hence you can create a property dynamically in a similar manner of that of classes.
with onto:
NewProperty= types.new_class(property_name, (ObjectProperty, FunctionalProperty))
Upvotes: 1