VladimirAlexiev / soml

Semantic Objects Modeling Language
8 stars 2 forks source link

add tsv2owl.pl and options -vocab and -ontology #5

Closed VladimirAlexiev closed 1 year ago

VladimirAlexiev commented 1 year ago

tsv2soml.pl generates SOML from a sheet. In internal projects we've been using a script owl-gen.pl that generates OWL from the same sheet. Commit it here as tsv2owl.pl.

For example, for the Ontotext KG (OTKG), we use schema.org (s:) as vocabulary namespace but otkg: as the ontology URL. Typically you'd use an ontology preamble, eg like this otkg-preamble.ttl:

@prefix otkg: <https://kg.ontotext.com/resource/ontology/>.
@prefix s:    <http://schema.org/> .

<https://kg.ontotext.com/resource/ontology> a owl:Ontology ;
  rdfs:label      "OTKG Ontology" ;
  dct:created     "2023-01-25"^^xsd:date ;
  dct:creator     <http://ontotext.com> ;
  owl:versionInfo "1.0" .

Add two options:

You can run the tool with a Makefile like this:

otkg.ttl ::
    curl -Ls "https://docs.google.com/spreadsheets/d/.../export?format=tsv" |  perl -S tsv2owl.pl  | cat otkg-preamble.ttl - > OTKG-unformatted.ttl
    riot --formatted=ttl OTKG-unformatted.ttl | perl -00e '@a=<>; print sort @a' > otkg.ttl
    rm OTKG-unformatted.ttl

This generates term definitions from the sheet, prepends the preamble, formats the result with Jena riot, and finally sorts it by term (Turtle block: such "paragraphs" are separated by a double newline)