Re: How to create Object and Data Properties dynamically ?

Posted by rahul_raj on
URL: http://owlready.306.s1.nabble.com/How-to-create-Object-and-Data-Properties-dynamically-tp244p380.html

Hello jui_guram and Jiba,
Thank you for helping me out. That inclusion of a comma was what all needed. It works perfectly fine now!

 for i in range(len(s)):
    with onto:
        onto_data_property = types.new_class(s[i],  (DataProperty,))
        onto_data_property.range = [float]
        onto_data_property.domain = [Customer]

@jui_guram: You need to remove the quotes from the class name i.e., instead of ['customers'] as domain, put [customers] as domain. When you put it as 'customers', it is taken up as a new string which is just a constant fixed string and hence, it is not recognized as an ontology class. And since, you must put an ontology class as the domain, you should put it as [customers]. Then it gets recognized as an ontology class.