query insert not save data in owl

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

query insert not save data in owl

Bento Dias de Carvalho
hello dear,

I try to add a new user to owl with sparql insert data from a user register. When I check individual instances has showing in browser but when I check in protege, the data was not added or when I restart the program, the data was lossed.

graph2 = graph.get_context(onto)
    graph2.update("""
        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        PREFIX owl: <http://www.w3.org/2002/07/owl#>
        PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
        PREFIX gr: <http://www.semanticweb.org/bentofuascarvalho/ontologies/OntoBase#>

       INSERT {
             gr:""" + username + """ rdf:type gr:Person.
         } WHERE {}""")

How to save a new data to synchronize with in Protege and in python?

Thanks...!
Reply | Threaded
Open this post in threaded view
|

Re: query insert not save data in owl

Jiba
Administrator
Hi,

I tried the script below and it does create a new individuals, which can be seen in Protégé.

If you really want to be fully compatible with OWL, you may also add the following RDF triple:

gr:""" + username + """ rdf:type owl:NamedIndividual.

Jiba

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

from owlready2 import *

onto = get_ontology('http://www.semanticweb.org/bentofuascarvalho/ontologies/OntoBase#')

with onto:
    class Person(Thing): pass

username = "jiba"

graph2 = default_world.as_rdflib_graph().get_context(onto)
graph2.update("""
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX gr: <http://www.semanticweb.org/bentofuascarvalho/ontologies/OntoBase#>

INSERT {
gr:""" + username + """ rdf:type gr:Person.
} WHERE {}""")
   
default_world.graph.dump()

onto.save("/tmp/z.owl")

Reply | Threaded
Open this post in threaded view
|

Re: query insert not save data in owl

Bento Dias de Carvalho
Thanks, Jiba.

Done.