1.1.0 • Published 1 year ago

merweb v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

🕸 Merweb

Merweb (Mermaid meets Semantic Web) is library and command line interface to generate SHACL shapes and vocabularies from Mermaid class diagrams.

Usage

  • Install via npm i -g merweb.
  • Execute tool via merweb -f path/to/diagram -s path/to/jsonld. You can try
merweb -f examples/diagram.txt \
  -s shapes.jsonld \
  -b "sc=https://w3id.org/idlab/ns/supply-chain/#" \
  -v "sc=https://w3id.org/idlab/ns/supply-chain/#" \
  -p "swrl=http://www.w3.org/2003/11/swrl#;owl=http://www.w3.org/2002/07/owl#" \
  -c vocab.jsonld

or

merweb -f examples/diagram_with_supertypes.txt \
  -s shapes.jsonld \
  -b "ex=https://example.org/examples#" \
  -v "ex=https://example.org/examples#" \
  -p "swrl=http://www.w3.org/2003/11/swrl#;owl=http://www.w3.org/2002/07/owl#" \
  -c vocab.jsonld

Examples

You can find example diagrams in the folder examples.

Annotations

Memweb reuses one existing Mermaid annotation and uses five new annotations to generate the correct shapes and vocabularies from the class diagrams. Below you can find a table of these annotations.

AnnotationDescriptionShapeVocabularyExisting or new annotation
@typeThe type of a classObject of sh:targetNodeA rdfs:ClassNew
@superTypesThe super-types of a classN/AObject(s) of rdfs:subClassOfNew
@extraTypesThe extra types of a classObject of sh:property with rdf:type as sh:pathA rdfs:ClassNew
@labelThe label of a class or propertyN/AObject of rdfs:labelNew
@commentThe comment of a class or propertyN/AObject of rdfs:commentNew
Cardinality on a class attributeThe cardinality of datatype propertyObjects of sh:minCount and sh:maxCountN/ANew
Cardinality on a relationship between two classesThe cardinality of object propertyObjects of sh:minCount and sh:maxCountN/AExisting

Please note that the annotations @type, @superTypes, and @extraTypes assume a strict ordering: @type should always be declared before @superTypes and @extraTypes are declared. The internal ordering of the latter two can be arbitrary.

Remove annotations from diagrams

You can remove the annotations starting with @ from diagrams via the -r, --remove-annotations option. The changed diagram is outputted to the terminal.

merweb -f examples/diagram.txt -r

License

This code is copyrighted by Ghent University – imec and released under the MIT license.