please, help me jiba

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

please, help me jiba

Pakbi
prefix="file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#"
      inter = list(my_world2.sparql('''SELECT ?p {'''+ prefix + file + ''' :fenilchetonuria ?p .}
                 SELECT ?q {'''+ prefix + file + ''' :diabete ?q .}
                 SELECT ?g {'''+ prefix + file + ''' :lattosio ?g .}
                 SELECT ?s {'''+ prefix + file + ''' :glutine ?s .}'''))

I have error:
C:\Users\Pasquale Bonasia\Downloads\OntoPharma>python OntoPharma.py
Traceback (most recent call last):
  File "OntoPharma.py", line 205, in compatibilita
    SELECT ?s {'''+ prefix + file + ''' :glutine ?s .}'''))
  File "C:\Users\Pasquale Bonasia\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\namespace.py", line 547, in sparql
    query = self._prepare_sparql(sparql, error_on_undefined_entities)
  File "C:\Users\Pasquale Bonasia\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\namespace.py", line 553, in _prepare_sparql
    return owlready2.sparql.main.Translator(self, error_on_undefined_entities).parse(sparql)
  File "C:\Users\Pasquale Bonasia\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\sparql\main.py", line 61, in parse
    self.main_query = PARSER.parse(LEXER.lex(sparql))
  File "C:\Users\Pasquale Bonasia\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\rply.py", line 451, in parse
    raise ParsingError("Error at %s" % lookahead, lookahead.source_pos)
owlready2.rply.ParsingError: ("Error at PNAME_NS:'file:'", 11)
Reply | Threaded
Open this post in threaded view
|

Re: please, help me guys

Pakbi
Hi Jiba and other members, I have problem with my sparql query. Can you help me, please?

my_world2 = World()
      on = my_world2.get_ontology("./"+file+".owl").load()
      g=my_world2.as_rdflib_graph()
      inter = list(my_world2.sparql('''PREFIX owl: <http://www.w3.org/2002/07/owl#>
                                                        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                                                        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
                                                        PREFIX : <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#>
                                                        SELECT ?p { <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#''' + file + '''> <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#fenilchetonuria> ?p .}
                                                        SELECT ?q { <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#''' + file + '''> <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#diabete> ?q .}
                                                        SELECT ?g [ <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#''' + file + '''> <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#lattosio> ?g .}
                                                        SELECT ?s { <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#''' + file + '''> <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#glutine> ?s .}'''))
      row=g.query_owlready(inter)
      for col in row:
        if col==0:
           f1=row[col]
        if col==1:
           d1=row[col]
        if col==2:
           l1=row[col]
        if col==3:
           g1=row[col]
Reply | Threaded
Open this post in threaded view
|

Re: please, help me guys

Jiba
Administrator
Hi,

I think there is a problem in you SPARQL query: you should have a single SELECT in the query. If they are independent SELECT, you must execute each of them separately.

If they are not independent, you have to combine them, e.g.:
      inter = list(my_world2.sparql('''
PREFIX onto: <file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#>
SELECT ?p ?q ?g ?s {
onto:''' + file + ''' onto:fenilchetonuria ?p .
onto:''' + file + ''' onto:diabete ?q .
onto:''' + file + ''' onto:lattosio ?g .
onto:''' + file + ''' onto:glutine ?s . }'''))

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: please, help me guys

Pakbi
C:\Users\Pasquale Bonasia\Downloads\OntoPharma>python ./OntoPharma.py
Traceback (most recent call last):
  File "C:\Users\Pasquale Bonasia\Downloads\OntoPharma\OntoPharma.py", line 201, in compatibilita
    inter = list(my_world2.sparql('''
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\namespace.py", line 547, in sparql
    query = self._prepare_sparql(sparql, error_on_undefined_entities)
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\namespace.py", line 553, in _prepare_sparql
    return owlready2.sparql.main.Translator(self, error_on_undefined_entities).parse(sparql)
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\sparql\main.py", line 61, in parse
    self.main_query = PARSER.parse(LEXER.lex(sparql))
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\rply.py", line 416, in parse
    current_state = self._reduce_production(
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\rply.py", line 465, in _reduce_production
    if state is None: value = p.func(targ)
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\sparql\parser.py", line 1015, in f
    p.storid = p.sql = translator.abbreviate(p.value)
  File "C:\Users\Pasquale Bonasia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\owlready2\sparql\main.py", line 293, in abbreviate
    if r is None: raise ValueError("No existing entity for IRI '%s'! (use error_on_undefined_entities=False to accept unknown entities in SPARQL queries)" % entity)
ValueError: No existing entity for IRI 'file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#BNSRNN97E48A893O'! (use error_on_undefined_entities=False to accept unknown entities in SPARQL queries)
Reply | Threaded
Open this post in threaded view
|

Re: please, help me guys

Jiba
Administrator
Hi,

This error means that the entity "file:/C:/Users/Pasquale%20Bonasia/Downloads/OntoPharma/base_paziente.owl#BNSRNN97E48A893O" has not been found. There is probably an error in the IRI.

Notice that you should avoid using filename (file:..) as IRI, since some tools do not support it well. I suggest to use plain URL (http://...)

Jiba