Data Property of datatype 'float' being created as 'decimal'

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

Data Property of datatype 'float' being created as 'decimal'

gbaesso
Hello again, Mr. Lamy.

The Data Properties I am creating with the syntax below are being shown in Protégé as 'xsd:decimal', not 'xsd:float'.
On the same code I create a lot of other Data Properties, and the other datatypes are working fine (int, bool, str).

with onto:
    class impact_loss_max_ammount(onto.asset >> float): pass




Thanks in advance!
GB
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Jiba
Administrator
Hello,

You're right... I've just look more deeply at XSD types. Actually, Python floats have double precision, and thus they should be aligned with xsd:double. Similarly, Python ints are unlimited, so they should be aligned with xsd:integer.

I'm going to fix that.

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

> Hello again, Mr. Lamy.
>
> The Data Properties I am creating with the syntax below are being shown in
> Protégé as 'xsd:decimal', not 'xsd:float'.
> On the same code I create a lot of other Data Properties, and the other
> datatypes are working fine (int, bool, str).
>
> with onto:
>     class impact_loss_max_ammount(onto.asset >> float): pass
>
>
> <http://owlready.8326.n8.nabble.com/file/n87/screenshot.jpg>
>
> Thanks in advance!
> GB
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Data-Property-of-datatype-float-being-created-as-decimal-tp87.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: Data Property of datatype 'float' being created as 'decimal'

gbaesso
Merci pour la gentillesse habituelle.  :)

Salutations,
Guilherme
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

gbaesso
As I am creating classes and Properties in a dynamic way, through a recursive loop, I was looking for a way to "modify" some of the "automatically" created entities.

I just found out that I can do the following to turn an already created DataProperty into a Functional DataProperty....


    with onto:
        class incident_id(DataProperty, FunctionalProperty): pass


I am messing around a lot with owlready2. Count on me if you need any help updating the documentation anytime after I finish my masters essay (1-2 months).

Salutations,
Guilherme
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Jiba
Administrator
Hello,

Yes, you can modify entities (including properties) by redefining them. This is the usual way in OWL: if a class is defined in 2 ontologies, both definitions are "merged". For example, if a property is defined in an ontology without specifying it as functional, and the same property is also defined in another ontology as functional, it will be considered as functional. Owlready behaves similarly: when you redefine an entity, the new definition does not "destroy" the previous one but is merged with the older one.

You can also modify the property by changing .is_a :

        incident_id.is_a.append(FunctionalProperty)


> I am messing around a lot with owlready2. Count on me if you need any help
> updating the documentation anytime after I finish my masters essay (1-2
> months).

Thank you, any help is welcome ! I agree that many points still lacks documentation.

Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

gbaesso
Mr. Lamy, I´ll send you some 'ready to use' suggestions for the documentation as soon as I can.

Good to know about Owlready2 0.5 release!

I see that you fixed the datatypes alignments, great! My code still runs flawlessly on 0.5, thanks!  :)

Let me share some numbers of what I have done so far thanks to your project. This was created from scratch, completely using owlready2. Data Properties and Individuals were imported/converted from JSON datasets.

Ontology metrics (1/2)
Ontology metrics (2/2)

Salutations,
Guilherme
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

gbaesso
In reply to this post by Jiba
Hello Mr. Lamy,

Actually, the change did break something.  :/

At the end, xsd:decimal type was what I needed, because it accept numbers with or without the decimal point ("10" or "10.0", both are accepted without causing inconsistencies).

Is there any way to force xsd:decimal after the last update?

Salutations,
Guilherme
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Jiba
Administrator
Hello,

When you say "it accept", who is it? Is it the Protégé editor, the Hermit reasoner, or Owlready itself?

I've just verified, you are right: integer is a subtype of decimal, however (and weirdly) double is not...

This might be the undocumented reason for using decimal in previous version.

I'm considering reversing to decimal.

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

> Hello Mr. Lamy,
>
> Actually, the change did break something.  :/
>
> At the end, xsd:decimal type was what I needed, because it accept numbers
> with or without the decimal point ("10" or "10.0", both are accepted without
> causing inconsistencies).
>
> Is there any way to force xsd:decimal after the last update?
>
> Salutations,
> Guilherme
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Data-Property-of-datatype-float-being-created-as-decimal-tp87p97.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: Data Property of datatype 'float' being created as 'decimal'

gbaesso

When I say 'accept' I mean the Hermit reasoner (in Protégé) does not complain about. I still have to explore Hermit within owlready.

Sorry if I misguided you on that matter... :/
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Jiba
Administrator
Hello,

I have changed it back to decimal, to allow the use of int in place of float.

I've also added the set_datatype_iri(datatype, iri) global function for associating manually a Python datatype to an IRI.
For example :

        set_datatype_iri(float, "http://www.w3.org/2001/XMLSchema#double")

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

> When I say 'accept' I mean the Hermit reasoner (in Protégé) does not
> complain about. I still have to explore Hermit within owlready.
>
> Sorry if I misguided you on that matter... :/
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Data-Property-of-datatype-float-being-created-as-decimal-tp87p99.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: Data Property of datatype 'float' being created as 'decimal'

Suresh
In reply to this post by Jiba
Hi,
Is this issue fixed? I'm still facing the problem

Thanx
Suresh
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Suresh
The issue I'm facing is:
1. we can only pass float not decimal or double after loading the ontology in owlready2. and
2. if we try to assign some floating value to the data property assertion, it is getting stored as a decimal value in the ontology, resulting in an inconsistent ontology.
One of the above two issues needs to be fixed to get a consistent ontology.

Thanx a lot!
Suresh
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Suresh
I figured it out.

Thanx
Suresh
Reply | Threaded
Open this post in threaded view
|

Re: Data Property of datatype 'float' being created as 'decimal'

Bluer
Could you share how you figured it out to help the rest of us? :)

Bluer