Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triple interface for OWLAPI/Jena connection #340

Open
rsgoncalves opened this issue Feb 9, 2015 · 7 comments
Open

Triple interface for OWLAPI/Jena connection #340

rsgoncalves opened this issue Feb 9, 2015 · 7 comments

Comments

@rsgoncalves
Copy link
Member

The N-triples format output by toString() is invalid when the object of a triple is a literal; in the presence of a literal node the object should be wrapped in quotes. For replicating: it suffices to use an ontology with a data property assertion axiom with some string filler. I'm using RDFTranslator to get triples out of the input ontology, and serializing via RDFGraph.dumpTriples(...).

@rsgoncalves rsgoncalves added the bug label Feb 9, 2015
@ignazio1977
Copy link
Contributor

We can make this more literal friendly, but the toString() on RDFTriple is not supposed to produce NTriples, just a human readable representation of the triple, for debugging purposes.
dumpTriples is a public method, but RDFGraph is in parsers, not api, so its interface might change - I wouldn't recommend relying on it.

On a related topic, I've seen questions on StackOverflow asking for a triple interface, for doing things like connecting Jena and OWL API without having to go through serialization/deserialization. This might be good to have, if we can get a well designed interface. Would you be able to use something like this for your purposes? If so, it'd be good if you could comment on what you'd like to have in this interface. We can then see how to fit this in the api package.

@rsgoncalves
Copy link
Member Author

Understood. So I misinterpreted the functionality of dumpTriples(), which uses RDFTriple.toString(). My goal was basically to serialize an RDFGraph, and I expected said triples dump to be valid w.r.t. some format (the output was valid N-triples except for literals).

Getting around having to serialize and deserialize is definitely desirable. Even though this isn't a major problem for me right now, it would surely be convenient to have such interface! So in my situation I'd like to take an OWLOntology instance and serialize it in all triples formats that, e.g., Jena supports. The other use case I'll be looking into is updating a graph database with axioms (or their corresponding sets of triples) built within the OWL API. I'm testing the latter with Stardog. Both of these scenarios seem to require that unfortunate intermediate step.

@ignazio1977
Copy link
Contributor

I'll make a prototype for this triple interface.
You can output NTriples with NTriplesDocumentFormat, in version 4 - the format is provided by the Rio libraries, and I believe it's the same NTriples Jena uses.

@sesuncedu
Copy link
Contributor

I've been thinking quite a bit about this ; there are some big wins to
being able to having multiple t and a boxes (as well as non file oriented
ontology stores).

Most class & property assertions are irrelevant to classification, so
there's all sorts of opportunities to make it nicer to work with instances.
On Feb 9, 2015 4:06 PM, "Ignazio Palmisano" notifications@github.com
wrote:

We can make this more literal friendly, but the toString() on RDFTriple is
not supposed to produce NTriples, just a human readable representation of
the triple, for debugging purposes.
dumpTriples is a public method, but RDFGraph is in parsers, not api, so
its interface might change - I wouldn't recommend relying on it.

On a related topic, I've seen questions on StackOverflow asking for a
triple interface, for doing things like connecting Jena and OWL API without
having to go through serialization/deserialization. This might be good to
have, if we can get a well designed interface. Would you be able to use
something like this for your purposes? If so, it'd be good if you could
comment on what you'd like to have in this interface. We can then see how
to fit this in the api package.


Reply to this email directly or view it on GitHub
#340 (comment).

@ignazio1977 ignazio1977 changed the title Invalid N-triples format output by RDFTriple.toString() Triple interface for OWLAPI/Jena connection Apr 7, 2015
@valentin0h
Copy link

Any update on this?

@ansell
Copy link
Member

ansell commented Jul 7, 2015

It shouldn't be too difficult to follow the same pattern that has been implemented for Sesame Rio to stream triples into OWLAPI. For Sesame Rio the code is:

// need to source your OWLAPIManager from somewhere
OWLAPIManager m = OWLManager.createOWLOntologyManager();
OWLOntology ontology = m.createOntology();

// Get any CloseableIteration<Statement> or Iterator<Statement>
// Eg, QueryResult that comes from querying Sesame databases using
RepositoryConnection methods
QueryResult result = <The result of querying a Sesame database>;

try {
    RioMemoryTripleSource source = new RioMemoryTripleSource(result);
    // OWLAPI stores metadata in format objects, so even though there was no typical format, need to push one in to store metadata in
    RioRDFXMLDocumentFormat metadataFactory = new RioRDFXMLDocumentFormatFactory();
    RioParserImpl parser = new RioParserImpl(metadataFactory);
    OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration();
    OWLOntologyFormat metadata = parser.parse(source, ontology, config);
} finally {
    result.close();
}

I am not familiar with Jena, but if it supplies a lazy iterator, you could stream directly through to OWLAPI in a similar fashion (once the wrapper is written). Alternatively, you could wrap Jena Triple's as Sesame Statement's and use the code above to test it out now.

Even if Jena doesn't supply a lazy iterator, the main point is that you don't need to serialize to disk to push triples through the pattern above, so any Collection would work.

@sszuev
Copy link
Contributor

sszuev commented Mar 20, 2018

Hello everyone.
There is now ONT-API which is a jena-based owlapi-impl (v5) alternative.
Any contributing are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants