Consistent ontology can not be materialized using HERMIT - ontology

For my experiment, I need to materialize a dbpedia ontology which consists of the TBox/schema and ABox/data.
To do so, I merge the dbpedia ontology/TBox/schema (http://downloads.dbpedia.org/2016-04/dbpedia_2016-04.owl) with the ABox/data part from the DBPedia knowledge graph (I just took 2% of the data in http://downloads.dbpedia.org/2016-04/core-i18n/en/mappingbased_objects_en.ttl.bz2).
Before materialized this merged file, I ran the consistency checking first using HerMit reasoner. The merged file was consistent.
But when I ran the materialization service using HerMit reasoner (I used the code from https://github.com/owlcs/owlapi/issues/643), I found this error : comparison method violates its general contract!
When I debugged the code, the error was raised when the compiler invoked this process : manager.saveOntology(inferredAxiomsOntology,outputStream)
It's quite strange that a consistent ontology can not be materialized by the reasoner.
Any idea how to solve this error? (The merged file can be downloaded from https://www.dropbox.com/s/l689hejgyv2xn7l/DBPRule1Ite1.owl.zip?dl=0 )
Thank you very much.

You need to use a more recent version of the libraries. The bug you found was fixed at the beginning of the V4 series, in 2014.
You can use HermiT 1.3.8.413 (which uses OWLAPI 4.1.3) or HermiT 1.4.1.513 (which uses OWLAPI 5.1.3). Both are available on Maven Central:
http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22net.sourceforge.owlapi%22%20AND%20a%3A%22org.semanticweb.hermit%22

Related

How to retrieve database cross references linked to definitions in OBO ontologies using ROBOT?

Some entities in OBO ontologies are documented with a database_cross_reference --> PMID as reference for an entry. For example, https://ontobee.org/ontology/CL?iri=http://purl.obolibrary.org/obo/CL_0000742 has the definition A round chondrocyte that first differentiates in the late embryonic growth plate of bone. [database_cross_reference: PMID:15951842]
I am currently using the following snippet to retrieve a table of entities in an ontology:
robot export --input data/$1.owl \
--header "ID|LABEL|IAO_0000115|hasDbXref|subClassOf [ID]" \
--export data/$1.csv
Is there a way to also retrieve these cross references linked to definitions? In the .owl file it looks like:
<owl:Axiom>
<owl:annotatedSource rdf:resource="http://purl.obolibrary.org/obo/CL_0000742"/>
<owl:annotatedProperty rdf:resource="http://purl.obolibrary.org/obo/IAO_0000115"/>
<owl:annotatedTarget rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A round chondrocyte that first differentiates in the late embryonic growth plate of bone.</owl:annotatedTarget>
<oboInOwl:hasDbXref rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PMID:15951842</oboInOwl:hasDbXref>
</owl:Axiom>
ROBOT doesn't support retrieval of axiom annotations using the export command, so the only way to do this in ROBOT is with a custom SPARQL query over the OWL reification model, as this is the way cross references linked to definitions are stored in the Cell Ontology (CL) and many other ontologies.
Note that other ontologies such as the Ontology of Biomedical Investigations (OBI) do this in a different way, using a plain entity annotation, this is retrievable using ROBOT export. Always remember that ontologies use annotations in a heterogeneous fashion, so approaches that work on one may not work on another (see this issue for context and discussion of unifying these styles).
If you are willing to consider a different approach, OAK can be used to retrieve definitions alongside axiom annotations, bridging across the different modeling styles in different ontologies, see this example.

Using Z3 to return model with least value

I thought I read somewhere that Z3 has some option for returning the model with the "least" value eg given something like
x >= 2
Z3 would return 2. I could swear that I saw some reference to this recently, but I am unable to find it now. Can anyone confirm this?
No, Z3 does not produce 'least' models. However, a separate branch of Z3 that adds optimization features is being developed at the moment (the branch is called `opt'), and perhaps will later be integrated into Z3 proper. A tutorial for the current optimization features is available here: Z3Opt Guide

Can we check the translated function calls generated by Cypher or Gremlin?

I believe internally Cypher / Gremlin translate statement into corresponding Java method calls. Is there a way to trace what method calls in run?
For example, in Hibernate, we can specify "show sql" to see generated sql statement.
[Edit]
The reasonws I want to do that:
1. For Debugging purpose:
To find out why the cypher / gremlin doesn't produce the expected result.
For learning purpose:
To find what's happening under the hood
For optimization:
To find out where the bottleneck is.
In Cypher, that is planned for the coming months to add. Ultimately, yes, currently the methods used under the Hood are the Java Neo4j core API and the Traversal Framework. Mind adding a case that is causing you problem?
For Gremlin, do a .toString() at the end of your Gremlin expression to see which Pipes (http://pipes.tinkerpop.com) it ultimately compiles down to.

Why build an AST walker instead of having the nodes responsible for their own output?

Given an AST, what would be the reason behind making a Walker class that walks over the tree and does the output, as opposed to giving each Node class a compile() method and having it responsible for its own output?
Here are some examples:
Doctrine 2 (an ORM) uses a SQLWalker to walk over an AST and generate SQL from nodes.
Twig (a templating language) has the nodes output their own code (this is an if statement node).
Using a separate Walker for code generation avoids combinatorial explosion in the number of AST node classes as the number of target representations increases. When a Walker is responsible for code generation, you can retarget it to a different representation just by altering the Walker class. But when the AST nodes themselves are responsible for compilation, you need a different version of each node for each separate target representation.
Mostly because of old literature and available tools. Experimenting with both methods you can easily find that AST traversal produces very slow and convoluted code. Moreover, code separated from immediate syntax doesn't resemble it anymore. It's very much like supporting two synchronized code bases, which is always a bad idea. Debugging, maintenance become difficult.
Of course, it can be also difficult to process semantics on the nodes unless you have a well designed state machine. In fact you are never worse than having to traverse AST after the fact, because it's just one particular case of processing semantics on nodes.
You can often hear that AST traversal allows for implementation of multiple semantics for the same syntax. In reality you would never want that, not only because it's rarely needed, but also for performance reasons. And frankly, there is no difficulty in writing separate syntax for a different semantics. The results were always better when both designed together.
And finally, in every non-trivial task, get syntax parsed is the easiest part, getting semantics correct and process actions fast is a challenge. Focusing on AST is approaching the task backwards.
To have support for a feature that the "internal AST walker" doesn't have.
For example, there are several ways to trasnverse a "hierarchical" or "tre" structure,
like "walk thru the leafs first", or "walk thru the branches first".
Or if the nodes siblings have a sort index, and you want to "walk" / "visit" them decremantally by their index, instead of incrementally.
If the AST class or structure you have only works with one method, you may want to use another method using your custom "walker" / "visitor".

Convert Neo4j DB to XML?

Can I convert Neo4J Database files to XML?
I agree, GraphML is the way to go, if you don't have problems with the verbosity of XML. A simple way to do it is to open the Neo4j graph from Gremlin, where GraphML is the default import/export format, something like
peters: ./gremlin.sh
gremlin> $_g := neo4j:open('/tmp/neo4j')
==>neograph[/tmp/neo4j, vertices:2, edges:1]
gremlin> g:save('graphml-export.xml')
As described here
Does that solve your problem?
With Blueprints, simply do:
Graph graph = new Neo4jGraph("/tmp/mygraph");
GraphMLWriter.outputGraph(graph, new FileOutputStream("mygraph.xml"));
Or, with Gremlin (which does the same thing in the back):
g = new Neo4jGraph('/tmp/mygraph');
g.saveGraphML('mygraph.xml');
Finally, to the constructor for Neo4jGraph, you can also pass in a GraphDatabaseService instance.
I don't believe anything exists out there for this, not as of few months ago when messing with it. From what I saw, there are 2 main roadblocks:
XML is hierarchical, you can't represent graph data readily in this format.
Lack of explicit IDs for nodes. Even though implicit IDs exist it'd be like using ROWID in oracle for import/export...not guaranteed to be the same.
Some people have suggested that GraphML would be the proper format for this, I'm inclined to agree. If you don't have graphical structures and you would be fine represented in an XML/hierarchical format...well then that's just bad luck. Since the majority of users who would tackle this sort of enhancement task are using data that wouldn't store that way, I don't see an XML solution coming out...more likely to see a format supporting all uses first.
Take a look at NoSqlUnit
It has tools for converting GraphML to neo4j and back again.
In particular, there is com.lordofthejars.nosqlunit.graph.parser.GraphMLWriter and com.lordofthejars.nosqlunit.graph.parser.GraphMLReader which read / write XML files to / from a neo4j database.

Resources