get_properties() not working

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

get_properties() not working

Shadow
Hi there,

I am trying to get all properties of individual with the use of get_properties(), but I always get the following error message: AttributeError: 'World' object has no attribute '_get_obj_triples_o_p'.

I am using a jupyter notebook to access the ontology.
The code looks like this:
person = onto.Human('test')
person.hasWeight = [80]
person.hasHeight = [1.92]
onto.test.get_properties()

I have tested onto.person.get_properties() but there I get: AttributeError: 'NoneType' object has no attribute 'get_properties'

Where is my problem?

Thank you in advance,
Shadow
Reply | Threaded
Open this post in threaded view
|

Re: get_properties() not working

Jiba
Administrator
Hi,

I tested the code below successfully, both in plain Python and jupyter.
Could you send me a full example demonstrating the problem?

Jiba

-------8<-------------------

from owlready2 import *

#onto = get_ontology("/home/jiba/telechargements/hermit/project/examples/ontologies/pizza.owl").load()
#onto = get_ontology("/tmp/pizza.owl").load()

# onto = get_ontology("http://test.org/rules.owl")
# with onto:
#   class LetterOccurrence(Thing): pass
# onto.save('/tmp/rules.owl')
# oerpe

onto = get_ontology("http://test.org/t.owl")

with onto:
  class Human(Thing): pass
  class hasWeight(Thing >> int):   pass
  class hasHeight(Thing >> float): pass
 
person = onto.Human('test')
person.hasWeight = [80]
person.hasHeight = [1.92]
print(onto.test.get_properties())
Reply | Threaded
Open this post in threaded view
|

Re: get_properties() not working

Shadow
Hey Jiba,

thank you very much for your time.
I honestly can not explain what happend.
I stopped working yesterday after countless tries of getting it to run.
When I restarted it today to send you the full problem, it just worked.
I dont not know why. I have not changed anything, but for some reason now it works as intended.

So I am sorry to have wasted your time, but I am glad it finally works.

Best regards,
Shadow