Dynamically create axioms between classes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamically create axioms between classes

joseph
Hello,

I created the classes in my ontology dynamically out of a csv-file. Now I want to add a relation between two classes dynamically out of my csv with the "my_class.is_a.append(my_prop.some(other_class))"-syntax.
"has_attribute" is an Object Property I did manually.

I tried the following but only got an error, that the string I got out of the list has no attribute "is_a". I also tried referencing the string to the onto with onto.i[class_one_colum] but only got " 'NoneType' object is not subscriptable"

I hope someone can help me, thanks in advance
Joseph


code:
def dynamically_add_attributes(iri, output, input_list, class_one_column, class_two_column):
    """dynamically add axioms between classes"""
    onto = get_ontology(iri).load()
    with onto:
        for i in input_list[1:]:
            i[class_one_column].is_a.append(has_attribute.some(i[class_two_column]))
    onto.save(file=output)
Reply | Threaded
Open this post in threaded view
|

Re: Dynamically create axioms between classes

Jiba
Administrator
Hi,

I think there is some problem in you code example. If the inputs list contains class name, you should use onto[class_one_colum] to obtain the class object, not onto.i[class_one_colum] nor i[class_one_colum].

Jiba