vangelisv / thea

OWL2 library for Prolog
http://vangelisv.github.com/thea
108 stars 19 forks source link

Proposal: alternative lnterface for serializing into OWL formats #22

Open Kaljurand opened 14 years ago

Kaljurand commented 14 years ago

I would like to use the following interface to serialize the Prolog-represented OWL ontologies as RDF/XML, OWL 2 XML, etc.

owl_write(+Stream, +Term, +Options)

where Term is a Prolog term which closely matches the OWL structural specification, i.e. something like this:

'Ontology'([
    'SubClassOf'('Class'('iri#cat'),'Class'('iri#animal')),
    'DisjointClasses'([
            'Class'('iri#cat'),
            'ObjectSomeValuesFrom'('ObjectProperty'('iri#like'),'Class'('iri#dog')
)])])

(... possibly with lowercase term names, so that they wouldn't need quoting).

Are there plans to add such an interface, or does it already exist and I just couldn't find it?

cmungall commented 14 years ago

The native representation looks very much like this. See owl2_model for details. Also try

save_axioms('my.pl',owlpl)

One difference is that the generic forms of the predicates are used - e.g. someValuesFrom, not objectSomeValuesFrom. However, it would not be difficult to write an exporter that would write using the object/data specific forms.

Kaljurand commented 14 years ago

The predicate save_axioms('my.pl',owlpl) takes its input from the Prolog database and puts the output into a file. I.e. in order to use this predicate one needs to consult/assert axioms into the database and then name a file. I would like to avoid that, i.e. I would prefer an interface that takes its input from a term and puts the output into a stream.

cmungall commented 14 years ago

The existing owl2_io interface is a little short-sighted in that it expects file I/O, not stream I/O, and it expects an entire ontology to be saved, rather than just individual axioms. It would be useful to have save_ontology_to_stream(Ont,S) and save_axiom_to_stream(Ax,S) but this latter one would be hard to support for all syntaxes. For the native prolog syntax you can just use writeq/1 of course.

vangelisv commented 14 years ago

Hi Kaljurand, I understand one can easy write a module that converts owl2_model axioms to a prolog term as the one you mention and the reverse. Then you can use thea' save_axioms and load_axioms to serialise / parse. I invite you to join thea development team and write this module and the extensions Christ discusses in his earlier comment. Do you also have a specific use case for your proposed module?

Kaljurand commented 14 years ago

My concrete interest is to use Thea with two tools developed in the Attempto project (http://attempto.ifi.uzh.ch). One tool (ACE->OWL/SWRL) converts controlled English sentences into OWL, represented by a Prolog term and serialized by writeq, see e.g.:

http://attempto.ifi.uzh.ch/ws/ape/apews.perl?text=John+likes+every+cat.&solo=owlfss

'Ontology'('http://attempto.ifi.uzh.ch/ontologies/owlswrl/test',['SubClassOf'('Class'('':cat),'ObjectSomeValuesFrom'('ObjectInverseOf'('ObjectProperty'('':like)),'ObjectOneOf'(['NamedIndividual'('':'John')])))])

In this case, Thea could be used to write into other OWL formats (XML, RDF, Turtle, Manchester Syntax, etc., etc.).

The other tool (OWL verbalizer) converts OWL into controlled English. It currently supports only OWL 2 XML as the input format, see: http://attempto.ifi.uzh.ch/site/docs/owl_to_ace.html Thea could be used to support other OWL formats.

Neither tool needs to assert anything into a Prolog database nor create files. For my use case it would be an inconvenience, slower than necessary, and maybe even a security risk. I was expecting to find in Thea an interface that is similar to SWI's

xml_write(+Stream, +Term, +Options)

I was surprised that it wasn't there, so I opened this issue. ;) (I think the main value of asserting stuff into the Prolog db is for reasoning and search, but not for format conversion.)

Thank you for the invitation. I would like to join the team but at this point I'd limit my participation to these bugreports and feature requests, as I don't have time now to do any real development. :(

cmungall commented 14 years ago

Integration with ACE seems like a worthy goal. I'll contact their mailing list.

I think direct term<->xml element conversion should be possible with OWL-XML, because there is a 1:1 mapping between XML elements and axioms.

It should in theory also be possible for RDF/XML, but the output would look a little strange as OWL RDF/XML typically collects multiple axioms into 'frames'. I think it might be difficult the way we've implemented the RDF translation.

Anyway, I think conversion between the two prolog terms will be the most elegant for ACE, since this is already in prolog -- no need for any intermediates.