简体   繁体   中英

Updating values in ontology triples with Jena rules

I have a question. I have a Jena rule like this:

[rule1:

(?if rdf:type p:InferredConfiguration)
(?if p:userName ?userEmail)
(?subProfile rdf:type u:PersonSubProfile)
(?subProfile u:hasUsername ?email)
equal(?userEmail, ?email)

(?subProfile u:hasName "")
(?subProfile u:hasLastname "")
(?subProfile u:hasPhone "")
(?subProfile u:hasEducation "Low")
->
(?subProfile u:hasPhone "00000")

print('**************** Phone defined - Rule 1 ***************')
]

The problem is that the rule above does not update the value of "hasPhone" property, but it adds one more value. How can I update the value or remove the old one and add the new one?

Thank you.

I found solution

[rule1:

(?if rdf:type p:InferredConfiguration)
(?if p:userName ?userEmail)
(?subProfile rdf:type u:PersonSubProfile)
(?subProfile u:hasUsername ?email)
equal(?userEmail, ?email)

(?subProfile u:hasName "")
(?subProfile u:hasLastname "")
(?subProfile u:hasPhone ?var)
equal (?var, "")
(?subProfile u:hasEducation "Low")
  ->
drop(7)
(?subProfile u:hasPhone "00000")

print('**************** Phone defined - Rule 1 ***************')
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM