AttributeError: 'python_name' property is not defined

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

AttributeError: 'python_name' property is not defined

gbaesso
Bonjour Mr. Lamy,

I have created the ontology classes using owlready, and then I created the Object Properties and Data Properties using Protégé. Reasoner finds no error.

When I try to load the ontology it gives me the following error:

Traceback (most recent call last):
  File "C:/Users/GuilhermeBaesso/OneDrive/Documents/CloudStation/Mestrado IME/Dissertação/python/veris_20171116_v001_loadData.py", line 66, in <module>
    main()
  File "C:/Users/GuilhermeBaesso/OneDrive/Documents/CloudStation/Mestrado IME/Dissertação/python/veris_20171116_v001_loadData.py", line 18, in main
    onto = get_ontology("http://ds.gb.moreira.nom/VERIS_v01_20171116_manual.owl").load()
  File "C:\Users\GuilhermeBaesso\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\namespace.py", line 464, in load
    self._load_properties()
  File "C:\Users\GuilhermeBaesso\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\namespace.py", line 489, in _load_properties
    props.append(Prop.python_name)
  File "C:\Users\GuilhermeBaesso\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\entity.py", line 355, in __getattr__
    if Prop is None: raise AttributeError("'%s' property is not defined." % attr)
AttributeError: 'python_name' property is not defined.

Interestingly, from the interactive shell I got the same error, BUT, if I call onto.load() again, the ontology loads, and I can interact with the ontology normally.

Do you have any clue on that problem?

Kind Regards,
Guilherme
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

Jiba
Administrator
Bonjour,

Could you send me the ontology ? Or at least at extract of it that exhibits the same problem ?

This problem seems more complex and I need to experiment it.

Thank you,

Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13

> Bonjour Mr. Lamy,
>
> I have created the ontology classes using owlready, and then I created the
> Object Properties and Data Properties using Protégé.
>
> When I try to load the ontology it gives me the following error:
>
> Traceback (most recent call last):
>   File "C:/Users/GuilhermeBaesso/OneDrive/Documents/CloudStation/Mestrado
> IME/Dissertação/python/veris_20171116_v001_loadData.py", line 66, in
> <module>
>     main()
>   File "C:/Users/GuilhermeBaesso/OneDrive/Documents/CloudStation/Mestrado
> IME/Dissertação/python/veris_20171116_v001_loadData.py", line 18, in main
>     onto =
> get_ontology("http://ds.gb.moreira.nom/VERIS_v01_20171116_manual.owl").load()
>   File
> "C:\Users\GuilhermeBaesso\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\namespace.py",
> line 464, in load
>     self._load_properties()
>   File
> "C:\Users\GuilhermeBaesso\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\namespace.py",
> line 489, in _load_properties
>     props.append(Prop.python_name)
>   File
> "C:\Users\GuilhermeBaesso\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\entity.py",
> line 355, in __getattr__
>     if Prop is None: raise AttributeError("'%s' property is not defined." %
> attr)
> AttributeError: 'python_name' property is not defined.
>
> Interestingly, from the interactive shell I got the same error, BUT, if I
> call onto.load() again, the ontology loads, and I can interact with the
> ontology normally.
>
> Do you have any clue on that problem?
>
> Kind Regards,
> Guilherme
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/AttributeError-python-name-property-is-not-defined-tp50.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

gbaesso
Sure. I'll send the complete files to your personal e-mail.

Meanwhile, I´ll try to reproduce the steps I did in Protégé within owlready, gradually, to try to find where it breaks....

Salutations,
Guilherme

Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

Jiba
Administrator
Thank you for the file.

There is a problem in your ontology: several entities are both a class and a property. For example, incident_id is declared twice, as a property and as a class.

While some persons use this as an "advanced practice" (this is known as punning), most of the tools do not support it well, including Owlready and reasonners. For Owlready, a given entity must be a class, an individual, an object property, a data property or an annotation property, but it cannot be more that one of these types.

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

gbaesso
Merci Jiba!

It was not on purpose, just one more thing related to my inexperience in the topic.  So, I have to give them unique names, right?

Salutations,
Guilherme


Em sex, 17 de nov de 2017 às 14:11, Jiba [via Owlready] <[hidden email]> escreveu:
Thank you for the file.

There is a problem in your ontology: several entities are both a class and a property. For example, incident_id is declared twice, as a property and as a class.

While some persons use this as an "advanced practice" (this is known as punning), most of the tools do not support it well, including Owlready and reasonners. For Owlready, a given entity must be a class, an individual, an object property, a data property or an annotation property, but it cannot be more that one of these types.

Best regards,
Jiba


If you reply to this email, your message will be added to the discussion below:
http://owlready.8326.n8.nabble.com/AttributeError-python-name-property-is-not-defined-tp50p55.html
To unsubscribe from AttributeError: 'python_name' property is not defined, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

Jiba
Administrator
> It was not on purpose, just one more thing related to my inexperience in
> the topic.  So, I have to give them unique names, right?

Yes, you cannot have the same name as a class and as a property.

Kind regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13

> Merci Jiba!
>
> It was not on purpose, just one more thing related to my inexperience in
> the topic.  So, I have to give them unique names, right?
>
> Salutations,
> Guilherme
>
>
> Em sex, 17 de nov de 2017 às 14:11, Jiba [via Owlready] <
> [hidden email]> escreveu:  
>
> > Thank you for the file.
> >
> > There is a problem in your ontology: several entities are both a class and
> > a property. For example, incident_id is declared twice, as a property and
> > as a class.
> >
> > While some persons use this as an "advanced practice" (this is known as
> > punning), most of the tools do not support it well, including Owlready and
> > reasonners. For Owlready, a given entity must be a class, an individual, an
> > object property, a data property or an annotation property, but it cannot
> > be more that one of these types.
> >
> > Best regards,
> > Jiba
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> > http://owlready.8326.n8.nabble.com/AttributeError-python-name-property-is-not-defined-tp50p55.html
> > To unsubscribe from AttributeError: 'python_name' property is not defined, click
> > here
> > <
> > .
> > NAML
> > <
http://owlready.8326.n8.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> >  
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/AttributeError-python-name-property-is-not-defined-tp50p56.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

gbaesso
Mr. Lamy,

I have deleted all the classes that had the same name as a Data Property, because at the end, the Data Property is what I needed. Doing that, I could load the ontology properly with owlready and interact with it as expected!

Thanks again for the valuable help!

Je vous prie d'agréer mes sincères salutations,
Guilherme Baesso

PS: here is a TIP for other newbies, like me, that could end up finding this thread: in Protégé, the reasoner will not complain about entities with the same name. Use the "Search..." button on the top right of the window to look for the entities with same name. Keep the list with fewer items in the background (classes or properties), and seach for each item individualy (yes, it´s manual). The color code will help you quickly identify which ones are both a class and a property...

Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

amracel
In reply to this post by gbaesso
Hi -

I'm running into the same problem as that fellow.

Is there an easy way to check for the duplicates that might exist in my OWL file?
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

Jiba
Administrator
Hi,

The internal function default_world.graph._punned_entities() returns the list of identifiers of entities being both an Individual and a Class.

You can turn these identifiers to IRI as follows:

[default_world._unabbreviate(i) for i in default_world.graph._punned_entities()]

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

nicolas
Hello,
sorry to bother you but I have the same problem with an ontology that I didn't create.
I tried to use the function you mentionned (owlready2 v0.22) but the function _punned_entities() does't seems to exist and so it failed with the following message:

In [1]: from owlready2 import *
    ...:  
    ...: onto = get_ontology("anontology.owl")
    ...:  
    ...: with onto:
    ...:     class Onto(Thing):
    ...:         pass
    ...:                                                                          

In [2]: [onto._unabbreviate(i) for i in onto.graph._punned_entities()]          
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-17879c5f37bd> in <module>
----> 1 [onto._unabbreviate(i) for i in onto.graph._punned_entities()]

AttributeError: 'SubGraph' object has no attribute '_punned_entities'

Did you remove the function and if yes how can I adapt the code to determine the duplicate or is it something else?
Thanks,
Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'python_name' property is not defined

Jiba
Administrator
Hi,

The "_punned_entities()" method is only available on the "master" graph, corresponding to the world object.

You may call it as follows:

>>> default_world.graph._punned_entities()

Jiba