self._unabbreviate_d[storid]

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

self._unabbreviate_d[storid]

Arciniegas
Hi, it's me again
I'm working on align parts of ontologies according to its relationships with keyworks, so
 
    onto1.MedicalTest must be related to onto2.CovidTest for keyword "Test"

and then:

    OntoGenerada.MadicalTest
    OntoGenerada.CovidTest

all is fine in this part, but i wanna use the reasoner (Pellet or Hermit, both fails) and i get this:

example:
* Owlready2 * Warning: Cannot find new parent '1915'
* Owlready2 * Warning: Cannot find new parent '3616'
...
OntoGenerada.save(RDF)
  File "...\owlready2\namespace.py", line 871, in save
    self.graph.save(file, format, **kargs)
  File "...\owlready2\driver.py", line 219, in save
    _save(f, format, self, **kargs)
  File "...\owlready2\driver.py", line 494, in _save
    o = _unabbreviate(o)
  File "\owlready2\driver.py", line 286, in _unabbreviate
    r = graph._unabbreviate(storid).replace("&", "&")
  File "...\owlready2\triplelite.py", line 489, in _unabbreviate_dict
    return self._unabbreviate_d[storid]
KeyError: 9709

Please, what's happening? what's the cause of the error? what can i do?
Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Jiba
Administrator
Hi,

The error means that some class has been reclassified as belonging to another class, but this other class does not exist / is unknown to Owlready.

Could you send me some working example to reproduce the problem, please?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Arciniegas
Hi, i'm here again :3 i cannot send you the entire project, but i can describe you its important parts.

The project is about generate ontologies dynamically with classes from a set of ontologies loaded in a world.

So i search classes in the ontologies in this way:

results = []
coincidencias= []
arr = default_world.search(label="*" + word + "*", type= owl_class, _case_sensitive=False)
    for result in arr:
        if not result in results:
            results.append(result)
            #print(result.label)
            coincidencias.append(result)

after a process of selection, the new onto is created like this:

OntoGenerada = Ontology(world=tempWorld, base_iri=mainSubject + "#")

    with OntoGenerada:
        for coincidencia in coincidencias:
            class_orig = coincidencia
            class_dest = types.new_class(class_orig.name, (class_orig,))
            class_dest.label = class_orig.label

And, finally i can choose if use the reasoner or not. With the reasoner, the error didn't happen but if i try to return the onto without reasoning, the app throws the exception in the format to RDF method.
return self._unabbreviate_d[storid]
KeyError: 3553

def toRDF(OntoGenerada):
    virtualFile = BytesIO()
    OntoGenerada.save(virtualFile)
    result = virtualFile.getvalue().decode('utf8')
    virtualFile.close()
    return result

If you need more details to know the cause of the problem, i will response shortly.
Thanks for your time. I appreciate so much your help for the owlready community.
Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Jiba
Administrator
Hi,

Sorry for the delay, I was (and I am still) very sick...

The information you provide me are actually of little help for understanding the problem. This type of problems is typically difficult to understand without running the program :-(

Here are 3 hints you may use to try to obtain more information on the problem (and then send them to me):

 * Add the following at the beginning of the program, just after importing Owlready :

set_log_level(9)

It will print all modification to the quadstore. Normally, you should get an error before saving the ontology, when the unknown Store ID 3553 is employed.

 * You may also try to save the ontology after the creation of each class (inside the loop), and add in the loop a print with the name of the current class. This would allow to understand which class causes the problem.

 * The following command (to add after creating the ontology) will display all rows in the quadstore referring to Store ID 3553:

for i in owlready2.default_world.graph.execute("SELECT * FROM quads where s=3553 or p=3553 or o=3553 or d=3553"): print(i)

By reading those lines, we may gain more info on what 3553 is supposed to be.

Jiba

Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Arciniegas
In reply to this post by Arciniegas
Hi, Jiba, happy to see you again. I hope you are well

I tried your recommendations and now i get this:

Traceback (most recent call last):
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 39, in _set_ontology_copy_if_needed
    try:   self._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 323, in _set_ontology
    if isinstance(self.value,    Construct): self.value   ._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 209, in _set_ontology
    if isinstance(Class, Construct): Class._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 209, in _set_ontology
    if isinstance(Class, Construct): Class._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 323, in _set_ontology
    if isinstance(self.value,    Construct): self.value   ._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 209, in _set_ontology
    if isinstance(Class, Construct): Class._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 323, in _set_ontology
    if isinstance(self.value,    Construct): self.value   ._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 209, in _set_ontology
    if isinstance(Class, Construct): Class._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 323, in _set_ontology
    if isinstance(self.value,    Construct): self.value   ._set_ontology(ontology)
  File "C:\Users\fredi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\owlready2\class_construct.py", line 55, in _set_ontology
    raise OwlReadySharedBlankNodeError("A Construct cannot be shared by two ontologies, because it correspond to a RDF blank node. Please create a dupplicate.")
owlready2.base.OwlReadySharedBlankNodeError: A Construct cannot be shared by two ontologies, because it correspond to a RDF blank node. Please create a dupplicate.

It is showed again, and again, and again; and finally it trhows a "RecursionError: maximum recursion depth exceeded".

As you has been suggesting, dhre is the link of the project for try to reply the error:
https://github.com/ElbenevoloSenorArciniegas/GeneradorOntologico

It needs a folder in root with name "sources" just between "outputs" and "static" where putting the ontos and the "World.sqlite3" file.

Actually i am using those ontologies (from the https://bioportal.bioontology.org/) for testing. I don't know if one of those can be a factor for crash. I think no.
http://www.semanticweb.org/clininf/covid19#
http://www.semanticweb.org/bakaev/ontologies/2020/3/untitled-ontology-25#
http://purl.obolibrary.org/obo/stato.owl#
http://purl.org/vodan/whocovid19crfsemdatamodel#
http://eulersharp.sourceforge.net/2003/03swap/countries#

I hope you can help me to solve the error. It's the last part for my degree project U.U

Best wishes, Arciniegas.
Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Jiba
Administrator
Hi,

I've downloaded your source, but http://semanticweb.org seems down and I am unable to download 2 of the ontologies. With the 3 remnant ontologies, I was able to run your code without error, but the produced ontology is empty. This is probably not the expected result, but might be caused by the missing ontologies...

In addition, the last ontology (http://eulersharp.sourceforge.net/2003/03swap/countries#) is in Turtle or N3 format, which is not supported by Owlready. You should convert it to RDF/XML (e.g. using Protégé). This might also be a cause of the problem.

I will retry in a few days, if I can get the other ontologies from http://semanticweb.org.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Arciniegas
Hi, Jiba, tanks for your help. I remove the following ontologies and the error has gone. That's great.
http://purl.org/vodan/whocovid19crfsemdatamodel#
http://eulersharp.sourceforge.net/2003/03swap/countries#

The thing is that those ontologies was not loaded by my, but loaded when i had imported another one.
In my project we can load ontologies for search inside them, but i don't know how to allow/reject some ontologies by its type or format Dinamically. I only left a api for get the IRI as a parameter, or a folder where paste the files, and load it used by default_world.get_ontology(IRI).load(). I think those ontos I deleted were imported into the .../obo/stato.owl file.

Do you know how i can parse or reject the ontologies that load "in background" that have another format?

Thanks again n.n
Reply | Threaded
Open this post in threaded view
|

Re: self._unabbreviate_d[storid]

Jiba
Administrator
Hi,

Guessing the format of an ontology file is not an easy at all, especially because the number of formats is high (about 10!). I fear there is no other solution that trying to load the file and test whether it work or not (Protégé does like that and tries to read using several file formats when opening a file).

Jiba