Open mdebellis opened 1 year ago
Happens because of OWL API version conflict, specific issue opened here: https://github.com/protegeproject/rdf-library/issues/12
Same issue on mac m1
Hi, I am suffering the same problem. What is the solution? I have reached a repository with AbstractTranslator.java file but I unknow how to fix the problem.
Best Regards, Leo
Unfortunately, to the best of my knowledge the only "fix" is to use something else. It's a known bug that has been documented on the Protege github site. In any case, IMO the Snap SPARQL Plugin is better than the default SPARQL tab anyway. You have to load Snap SPARQL from the plugin menu. Once you do that and restart Protege go to Window>Views>Query Views>Snap SPARQL Query
You will then be prompted to add the Snap SPARQL view to some tab. Best to navigate to that tab ahead of time (or create a new tab). I usually put Snap SPARQL on to the DL Query tab because I often go back and forth between the two. I think Snap SPARQL is better (besides the fact that it actually works when you have an ontology open) for several reasons:
1) It can see inferences by the reasoner
2) You can use it to add info to the ontology. I don't think you can do that with the default SPARQL tab. Neither of them support INSERT or DELETE which is the standard way to use SPARQL to add info but if you do CONSTRUCT {...} then Snap SPARQL will match anything in the ",,," and the WHERE clause and give you a list of triples. It will then ask you if you want to add those triples to your ontology. I often use that for basic things like adding labels to entities that I created with user defined names: https://www.michaeldebellis.com/post/refactoring-names-w-sparql
3) Snap SPARQL provides you with prompts as you write your query so you can see if something won't parse and if so where the problem probably is.
Snap SPARQL has some limitations though. One of them is I don't think it support a wild card in the predicate position. E.g., if you want to see all the properties that link the individuals :Foo and :Bar you should be able to do:
SELECT * WHERE {:Foo ?fbpred :Bar}
You should be able to do that but it won't work in Snap SPARQL.
Michael
On Wed, Aug 2, 2023 at 10:15 AM santos-sicilia @.***> wrote:
Hi, I am suffering the same problem. What is the solution? I have reached a repository with AbstractTranslator.java file but I unknow how to fix the problem.
Best Regards, Leo
— Reply to this email directly, view it on GitHub https://github.com/protegeproject/protege/issues/1110#issuecomment-1662634310, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7TPBBLV7UQM2AV76QOMBTXTKDLPANCNFSM6AAAAAAVRPHIDA . You are receiving this because you authored the thread.Message ID: @.***>
Thanks Michael,
But I have tried a simple query with Snap SPARQL and I cannot understand why it does not work. The query is:
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 bfiao: http://www.semanticweb.org/leopo/ontologies/2021/0/BFiaO_v1.24#
SELECT ?subclass where { ?subclass rdfs:subClassOf bfiao:node }
Instead of listing all the subclasses of node, I get a syntax error in SPARQL query: "Encountered bfiao:node at line 7 column 30. Expected one of: Variable Class name (prefix name)"
Do you have any idea of this syntax error? (thanks in advance) Leo
It sounds like bfiao:node is not a class. Although I also wonder if bfiao:node is an instance or any entity in the ontology because I think if it was then you wouldn't get a syntax error. You wouldn't get any results but I don't think it would be a syntax error. BTW, if you want to see all the subclasses in your ontology you can just do:
SELECT * WHERE {?subclass rdfs:subClassOf ?superclass}
You could also do:
SELECT * WHERE {?subclass rdfs:subClassOf owl:Thing}
Make sure you run the reasoner first.
Michael
On Wed, Aug 2, 2023 at 11:22 AM santos-sicilia @.***> wrote:
Thanks Michael,
But I have tried a simple query with Snap SPARQL and I cannot understand why it does not work. The query is:
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 bfiao: http://www.semanticweb.org/leopo/ontologies/2021/0/BFiaO_v1.24#
SELECT ?subclass where { ?subclass rdfs:subClassOf bfiao:node }
Instead of listing all the subclasses of node, I get a syntax error in SPARQL query: "Encountered bfiao:node at line 7 column 30. Expected one of: Variable Class name (prefix name)"
Do you have any idea of this syntax error? (thanks in advance) Leo
— Reply to this email directly, view it on GitHub https://github.com/protegeproject/protege/issues/1110#issuecomment-1662730165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7TPBC3BWTUJWVIXEPVL3DXTKLFXANCNFSM6AAAAAAVRPHIDA . You are receiving this because you authored the thread.Message ID: @.***>
Thanks again Michael,
Your sentences work perfectly but I would like to be more restrictive and just obtain the subclasses of an specific class. It is quite curious that with a specific class of the ontology it does not work. It is a pity that I cannot load an image to show you a part of the ontology with node as a class.
In any case, thanks for your time !! Leo
Leo, I'm replying here because I didn't want to take up the bandwidth of the whole list for this. First, have you done my revised Pizza tutorial? If you haven't I think it would be worthwhile although you might want to skip the parts on SWRL and SHACL but I have a section on SPARQL that is a good overview: https://www.michaeldebellis.com/post/new-protege-pizza-tutorial
Second, you can use the same pattern as I used to get the subclasses of owl:Thing to get the subclasses of any class. Just replace owl:Thing with dmn:MyClass where dmn is a correctly prefixed namespace for your ontology. Make sure you run the reasoner first and that should work in Snap SPARQL.
Third, you can take screenshots of your ontology and send them to me directly: mdebellissf@gmail.com I use Snipping Tool on Windows and whatever OS you are on there must be something similar. It depends how much time I have but I often spend an hour or so a day helping random new users with basic OWL questions. You can also just send your ontology to me as long as it isn't too large. In the future when you submit things to the Protégé list it is best to include screen snapshots and the ontology as well (as long as the ontology is fairly small). That makes it much easier for me and others to debug things. It depends who has time, often no one has the time to debug ontologies but sometimes people like me and others can just take a quick look and spot basic issues very quickly so if the ontology is small (which is usually the case for new users) it is best to attach it when you submit a message to the list. Good luck, feel free to let me know if you need more help.
Thank you very much Michael,
I have followed your tutorial, and everything worked with the previous Protégé version. But I will follow your advise and try it again just to see if I have done some mistake with the PREFIX and the ontology.
I will send you some screenshots of the ontology to your email. I am sure that there is something simple behind but I cannot see it yet. I promise no to abuse your time, and of course I really appreciate it.
Thanks for the information and workaround.
The Issue is still there in Protege 5.6.2, hope it can be fixed soon in future version.
During learning Michael's tutorial, I've made one specific video on this issue through certain testing, for your reference: https://youtu.be/oz1JaawLmJQ
I just wanted to add a bit of information to this issue. Some have suggested using the Snap SPARQL plugin as an alternative. It is worth mentioning that the Snap SPARQL plugin does not support property path expressions (e.g does not support all of SPARQL 1.1).
As I mentioned in my first comment, this is an easy to fix issue, the Github issue is also there: https://github.com/protegeproject/rdf-library/issues/12 But it looks like not being that important or nobody had time to invest.
As a workaround, I uploaded a fixed rdf-library JAR file at my fork: https://github.com/LorenzBuehmann/rdf-library/
Maybe @mdebellis can give it a try.
this is an easy to fix issue
Maybe not, unfortunately – even if rdf-library
is updated to use the same version of the OWL API as Protégé itself, it still causes Protégé to hang when attempting to use the SPARQL Query tab.
Can't reproduce this with Protege 5.6.3 and the rdf-library
file I uploaded here
Did you replace the existing rdf-library.jar
file?
What does the log say when it hangs?
Is there still the exception?
java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.<init>(org.semanticweb.owlapi.model.OWLOntologyManager, org.semanticweb.owlapi.model.OWLOntology, boolean, org.semanticweb.owlapi.util.IndividualAppearance, org.semanticweb.owlapi.util.AxiomAppearance, java.util.concurrent.atomic.AtomicInteger, java.util.Map)'
Yes, I replaced the existing rdf-library.jar
file. I tried both with your build and my own build from the tip of RDF-Library’s master branch, both on macOS and GNU/Linux (Protégé 5.6.3 in both cases). Same result.
The library and the SPARQL plugins are loaded fine without errors, but Protégé hangs as soon as I try to get to the SPARQL Query tab. No exceptions, nothing at all in the log.
Can't reproduce this with Protege 5.6.3 and the
rdf-library
file I uploaded here
Did you replace the existing
rdf-library.jar
file? What does the log say when it hangs? Is there still the exception?java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.<init>(org.semanticweb.owlapi.model.OWLOntologyManager, org.semanticweb.owlapi.model.OWLOntology, boolean, org.semanticweb.owlapi.util.IndividualAppearance, org.semanticweb.owlapi.util.AxiomAppearance, java.util.concurrent.atomic.AtomicInteger, java.util.Map)'
Thanks very much. It works for me.
Just tried it and still get the same error. I didn't try loading any jar files or anything so perhaps that's the problem, I notice it seems to be calling an undefined method in rdf.model. I had an ontology open and when I tried to open the SPARQL tab I get the following error. Note: the error may have to do with the GUI because when I do Window>Tabs>SPARQL Query I don't see any error messages but then when I click on the new SPARQL tab, I see the error below and I can't enter anything into the SPARQL tab, it doesn't respond. I'm running on Windows 11 Pro.
ERROR 17:25:26 Uncaught Exception in thread 'AWT-EventQueue-0'
java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.
I used the jar available here - https://github.com/LorenzBuehmann/rdf-library/releases/tag/rdf-library-3.0.0
Using the jar file mentioned by @vjborges, which I just place it in my Protege 5.6.3's plugins folder, leave the old rdf-library-3.0.0.jar
still there, and the SPARQL query tab is now working fine.
Thanks @vjborges
That won't work keeping the old JAR still in use.
According to the README,
remove rdf-library-3.0.0.jar from $PROTEGE_HOME/plugins
@gouttegd After replacing the Protege-5.6.2/plugins/rdf-library-3.0.0.jar
file with Lorenz' patched version, and after placing the SPARQL query view on the SPARQL query tab, I saw a "ghost frame" (a transparent rectangle with grey border) where the view was about to be placed, and the Protege app was in a nonresponsive state for a while.
However I had to wait 3 minutes for the blank rectangle to disappear. Finally the SPARQL query tab showed up and was usable again even when an ontology was loaded. I have tried only 1 simple SPARQL queries though.
So I had to wait really long time, no idea what protege was doing.
Protege works with OWL API as Java library to load and process OWL ontologies. SPARQL on the other hand is based on RDF, and as Java library rdf4j or better said its predecessor Sesame is being used. So Protege has to convert from OWL API to Sesame API - this happens once you open the SPARQL query tab or to be more precise its wrapped SPARQL query view.
Each OWL axiom a
is converted to a set of RDF triples T_a
, then those triples are added to an in-memory triple store. To keep track of the correspondence between axiom and triples, i.e. as a kind of provenance, ''T_a'' is loaded into a separate named graph g_a
.
Depending on the size of the data it may take some time, but I can't judge if a 3 minute waiting time is realistic.
What is the size of your ontology?
I've used the relatively big, recent DBPedia Ontology - After the initial import , reopening Protege with that big ontology works much faster, almost instantly. The point is, The nonresponsive "hanging state" happened only once.
In any event, thanks for your great patched jar file. Respect! It really blows my my how you have figured that out. It requires so much background knowledge.
This is a low priority IMO because I almost never use the SPARQL Tab anyway, perhaps it should just be removed. But there was something I wanted to do that Snap SPARQL didn't support (coercing strings to decimals using: "xsd:decimal(?numstr)" ) that I wanted to try to see if the SPARQLTab might support. If you just open Protégé and do Windows>Tab>SPARQL Query you get the normal SPARQL query. But if you first open an ontology and then do Windows>Tab>SPARQL Query the SPARQL Tab is empty and you can't enter a query and there is a bug in the log: