phillord / tawny-owl

Build OWL Ontologies in a Programmatic Environment
GNU Lesser General Public License v3.0
253 stars 55 forks source link

Showing anonymous ontologies #69

Open cordawyn opened 5 years ago

cordawyn commented 5 years ago

Hi!

I made a few adjustments to the ontology printers – specifically, I added a check for "anonymous" ontologies (w/o ontology URIs) that will make the printer output a blank string instead of crashing ;)

(Also, leiningen was complaining about non-HTTPs URI for the repo – I changed that to "https" in project.clj).

phillord commented 5 years ago

Out of curiosity, how are you making an anonymous ontology? I don't think tawny supports it (perhaps it should).

cordawyn commented 5 years ago

I've been trying to add a few ontologies to the ontology manager as follows:

(.loadOntologyFromOntologyDocument
  (tawny.owl/owl-ontology-manager)
  (tawny.owl/iri (clojure.java.io/resource "ontology.ttl")))

... which seems to work, but produces an anonymous ontology 😄

cordawyn commented 5 years ago

That said, I'm getting the feeling that tawny may not be the right tool for me, as I've been struggling to make it work with a combination of "external" ontologies and ontologies defined with tawny DSL... I find myself making too many raw Java method calls, not so many Clojure's.

phillord commented 5 years ago

tawny.repl/load-ontology does that. I mostly do this where I want to work with an ontology interactively. Other wise, if you want to cross refer to lots of entities in the external ontology, using tawny.read/defread is the way to go. If you don't, then you can just use an owl-import with the IRI which should work.

phillord commented 5 years ago

Are you sure that ontology.ttl has a declared IRI in it? That might well be the problem. Consider:

user> (def sio (load-ontology (iri (clojure.java.io/resource "sio.owl"))))
Started Loading: #object[com.google.common.base.Absent 0x61a016a7 Optional.absent()]  from: #[iri file:/home/phillord/src/knowledge/tawny-owl-git/master/dev-resources/sio.owl]
Finished Loading: #object[com.google.common.base.Present 0x49c5da59 Optional.of(http://semanticscience.org/ontology/sio.owl)] ...succeeded
#'user/sio
user> (as-iri sio)
#[iri http://semanticscience.org/ontology/sio.owl]
user> (as-iri sio)
#[iri http://semanticscience.org/ontology/sio.owl]

This should work if you run a repl directly in a clone of the tawny-owl repo.

Still, either way, you are correct, it should print nicely.

cordawyn commented 5 years ago

Are you sure that ontology.ttl has a declared IRI in it? That might well be the problem.

Yes, that might be the problem, indeed. But I have a bunch of those, and there can be a random SKOS vocabulary or some "snippets", that don't necessarily have an ontology IRI.

Thanks for the hints about tawny API – I somehow missed those functions from the start.