Open tommycarstensen opened 1 year ago
Not a dev here, but I think I can help you out. The problem is with the IRI. You are loading an OBO ontology. When you check out the original ontology file you will find that the class BTO_0000042
can only be accessed through http://purl.obolibrary.org/obo/BTO_0000042
. However, when you print the variable onto
you get http://purl.obolibrary.org/obo/bto.owl#
. If you attach the class id after that, there will naturally be an error. You have to properly define the obo namespace as instructed in the "namspaces" section in the documentation. The following should work for you:
onto = get_ontology('http://purl.obolibrary.org/obo/bto.owl')
obo = get_namespace('http://purl.obolibrary.org/obo/')
print(onto.search(subclass_of = obo.BTO_0000042))
I hope I could help with your problem (if it is still relevant for you).
@tommycarstensen I got the exact same problem when I try to apply an object property to an individual. The funny thing is that it works perfectly for data properties but not for object properties. I finally figured out what happened and I think it might be useful for others that would encouter this problem. The error I made is that I forgot to declare the class of the object to be used as the object property output. Formally, instead of assigning a token to an utterance like this:
token = dialog_dict['TokenID'][current_token_index:current_token_index+n_tokens][0]
utt.containsToken = [token]
I declare that token
is of class Token
by adding an intermediate step, which gives:
token = dialog_dict['TokenID'][current_token_index:current_token_index+n_tokens][0]
tok = onto.Token(token)
utt.containsToken = [tok]
Now, the assignation works perfectly.
This code:
Gives this error:
AttributeError: 'str' object has no attribute 'storid'
It seems like a bug to me.