Crates.io | ontprox |
lib.rs | ontprox |
version | 0.4.2 |
source | src |
created_at | 2024-05-26 17:28:19.68038 |
updated_at | 2024-06-02 17:14:30.089211 |
description | RDF format conversion as a web-service. |
homepage | https://codeberg.org/elevont/ontprox |
repository | https://codeberg.org/elevont/ontprox |
max_upload_size | |
id | 1252716 |
size | 180,896 |
ontprox
- Ontology ProxyRDF format conversion as a web-service.
A tiny HTTP service that allows to fetch an RDF ontology in a variety of different formats (e.g. RDF/XML, JSON-LD, Turtle, ...), as long as it is available in one of them.
This tool - when hosted - comes in handy when trying to comply with best practise of publishinig ontologies/vocabularies, as part of that pracice suggests to use content negotation to provide the ontology in different formats. We could just statically convert our ontology into different formats, and be done with it. As ontologies can somehow be though of standards for communication, it would be good if they'd be very stable in most cases. In practice though - as live goes - it is pretty unwise to consider them as static, never changing entities of the digital world; that would mean, setting ourselfs up for failure, stagnation, ... project death. No! Ontologies have to change, and in practice, they do. Just as in software, they are best hosted on VCS/SCM like git. Naturally, they will also have versions - releases and latest development states, all of which we might want to make available (under different IRI/URIs), following best practise for publishing ontologies. This is unfeasible/impractical to do by hosting statically converted files for each revision for each RDF serialization format + HTML. Thats where this tool enters the scene.
As an example,
let us imagine an ontology is served under IRI/URI
https://w3id.org/someorg/ont/thisone
as Turtle.
This tool - hosted as a public service - can then be used as a proxy,
given this URI plus a target MIME-type
(through the HTTP Accept
header) -
for example application/ld+json
or text/html
;
this MIME-type will then be served,
if the conversion is possible.
Internally we use pyLODE for conversion to HTML, and the python RDFlib (through a thin CLI wrapper) for all other conversion.
NOTE Caching is involved!
This tool is part of RDF-tools (not to be confused with rdftools), a Docker image, containing a collection of RDF related CLI and web-service tools. To use the tool alone/directly, follow the steps in the next few sections.
You need to have pylode
and rdf-convert
(from the rdftools tool set
installed and available on your PATH
.
As for now, you have two choices:
(see Install and Prerequisites first)
using the compiled binary:
$ ontprox
...
listening on 127.0.0.1:3000
or from source:
$ cargo run
...
listening on 127.0.0.1:3000
The available CLI arguments:
$ ontprox --help
A tiny HTTP service that allows to fetch an RDF ontology
that is available in one/a few format(s),
in others.
Usage: ontprox [OPTIONS]
Options:
-V, --version
Print version information and exit. May be combined with -q,--quiet, to really only output the version string.
-v, --verbose
more verbose output (useful for debugging)
-q, --quiet
Minimize or suppress output to stderr; stdout is never used by this program, with or without this option set.
-p, --port <PORT>
the IP port to host this service on
[default: 3000]
-a, --address <IP_ADDRESS>
the IP address (v4 or v6) to host this service on
[default: 127.0.0.1]
-c, --cache-dir <DIR_PATH>
a variable key-value pair to be used for substitution in the text
[default: ~/.cache/ontprox]
-C, --prefere-conversion
Preffer conversion from a cached format over downloading the requested format directly from the supplied URI.
-h, --help
Print help (see a summary with '-h')
(see Run first)
When the service is running on http://127.0.0.1:3000
,
you can fetch the HTML version
of e.g. the ValueFlows (VF) ontology as HTML,
either by opening http://127.0.0.1:3000?uri=https://w3id.org/valueflows/ont/vf.TTL
in your browser, or on the command line with CURL:
curl "http://127.0.0.1:3000?uri=https://w3id.org/valueflows/ont/vf.TTL" \
-H "Accept: text/html" \
> ont_vf.html
To give an other example, this fetches the Open Know-How (OKH) ontology as JSON-LD:
curl "http://127.0.0.1:3000?uri=https://w3id.org/oseg/ont/okh" \
-H "Accept: application/ld+json" \
> ont_okh.jsonld
You need to install Rust(lang) and Cargo. On most platforms, the best way to do this is with RustUp.
Then get the sources with:
git clone --recurse-submodules https://codeberg.org/elevont/ontprox.git
cd ontprox
Then you can compile with:
cargo build
If all goes well,
the executable can be found at target/debug/ontprox
.