Rosetta ๐¶
Rosetta, inspired by the Rosetta Stone, transforms e.g. between:
- Text Encodings (e.g. UTF-8 โ ISO 8859-1 etc.)
- RDF Turtle โ JSON-LD โ YAML-LD โ Enola Things
- YAML & JSON โ RDF Turtle with JSON-LD Contexts
YAML
โJSON
โTextProto
โ Binary Protocol Buffer “Wire” formats- Graph Diagrams from RDF et al.
- Many other formats!
- XML
Specifying the --schema
flag is optional for YAML <=> JSON conversion, but required for TextProto.
Rosetta transforms a (single) input resource into one output resource of another format. Alternatively, generate can load (possibly several) resources (or “logical IRIs”) which contain Things and transform them into (some of) these formats.
Graph Diagrams¶
Enola can generate Graph Diagrams like this, through DocGen (see Tutorial), or Rosetta.
Graphviz¶
Similarly to e.g. rdflib’s rdf2dot
(and rdfs2dot
):
$ ./enola rosetta --in test/picasso.ttl --out "docs/BUILT/picasso.gv?full=true" && dot -Tsvg -O docs/BUILT/picasso.gv
produces picasso.gv
and picasso.gv.svg
:
The full
URL query string can be used to control appearance, and --no-file-loader
suppresses the file; see:
$ ./enola rosetta --no-file-loader --in test/picasso.ttl --out "docs/BUILT/picasso-small.gv?full=false" && dot -Tsvg -O docs/BUILT/picasso-small.gv
GEXF¶
$ ./enola rosetta --in test/picasso.ttl --out docs/BUILT/picasso.gexf
produces picasso.gexf
in GEXF format (see also GEXF examples), which can be opened e.g. in Gephi Lite or Retina.
Tika¶
YAML to JSON¶
$ ./enola rosetta --in test/picasso.yaml --out /tmp/picasso.json
Turtle ๐ข to JSON-LD ๐¶
$ ./enola rosetta --in test/picasso.ttl --out /tmp/picasso.jsonld
JSON & YAML to Turtle ๐ข via JSON-LD¶
XML¶
$ ./enola rosetta --in test/greeting1-nested.xml --out="fd:1?mediaType=text/turtle"
@prefix ex: <https://example.org/> .
<file:/home/runner/work/enola/enola/test/greeting1-nested.xml> ex:greeting1 [
ex:message "hello, world"
] .
Turtle ๐ข to Things โ๏ธ¶
$ ./enola rosetta --in test/picasso.ttl --out /tmp/picasso.thing.yaml
UTF-8 to ISO 8859-1¶
$ file docs/use/rosetta/hello.txt
docs/use/rosetta/hello.txt: Unicode text, UTF-8 text
$ cat docs/use/rosetta/hello.txt
hello, wรถrld ๐
$ ./enola rosetta --in 'docs/use/rosetta/hello.txt?charset=UTF-8' --out '/tmp/hello-windows.txt?charset=ISO-8859-1'
$ file /tmp/hello-windows.txt
/tmp/hello-windows.txt: ISO-8859 text
$ cat /tmp/hello-windows.txt
hello, w๏ฟฝrld ?