How can I place a formula in a data property where another data property is used in protege 5.5.0?

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

How can I place a formula in a data property where another data property is used in protege 5.5.0?

Erickaan
This post was updated on .
Hello friends, thanks for taking the time to read the post

I would like to know if I can use a data property in another data property as a formula, here I leave the example I want to perform

Reputation = Initial perception (data property) * 0.20 + Travel confidence (data property) * 0.30 +
experience history (previous data) * 0.50

The experience history is the data that was previously received from the reputation, I would also like to know how to obtain the data that was previously had in the ontology of that property data

Is there any way to do this in owlready2? taking into account that the data is already assigned previously in protege
Reply | Threaded
Open this post in threaded view
|

Re: How can I place a formula in a data property where another data property is used in protege 5.5.0?

Jiba
Administrator
Hi,

You can do such computation in Python with Owlready, however, the formula with not be stored in the ontology nor the value of 'reputation' updated automatically when the values  of 'initial perception', etc change (if you need that, you probably want to use an SWRL rule).

In Owlready you may use (after getting your individual):

individual.reputation = individual.initial_perception * 0.2 + individual.travel_confidence * 0.3 + individual.reputation * 0.5

(NB if properties are not functional, their values are lists, so you'll have to manage that).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How can I place a formula in a data property where another data property is used in protege 5.5.0?

Erickaan
Hello, thanks for answering, I am trying to carry out the steps you have told me, I am something new with this and I do not know very well what I am doing wrong.

I try to get the age of an individual and change it and save it, but when looking at it in the ontology the value is still 19 when the result should be 20.

below the code

Edad = "Edad"
for prop in onto.Nancy.get_properties():
    for value in prop[onto.Nancy]:
        print(".%s == %s" % (prop.python_name, value))
        if prop.python_name == Edad:
            value = value + 1
            #ValorEdad = value
           # print("El valor de la edad es : ",value)
            onto.save(file = "C:/Users/achev/Documents/Carro.owl", format = "rdfxml")    
Reply | Threaded
Open this post in threaded view
|

Re: How can I place a formula in a data property where another data property is used in protege 5.5.0?

Jiba
Administrator
Hi,

I think you can do:

onto.Nancy.Edad = onto.Nancy.Edad + 1 # for a functional property

or :

onto.Nancy.Edad[0] = onto.Nancy.Edad[0] + 1 # for a non-functional property


Or, if you really want to use the loops and the prop[] syntax, replace:

            value = value + 1

By :

            prop[onto.Nancy] = [value + 1]

"value = value + 1" just increases the local variable "value", but not the property value in the ontology.

Jiba
Jiba