.. _corese-command-canonicalize:
canonicalize
============
The ``canonicalize`` command allows applying a specific canonicalization algorithm to RDF files. At times, it becomes necessary to compare the differences between sets of graphs, digitally sign them, or generate short identifiers for graphs via hashing algorithms. The canonicalization process ensures that the same RDF graph is represented in the same way, regardless of the order of triples or the use of blank nodes. The canonicalization process is based on the `RDFC 1.0 `_ specification.
**Usage:**
.. code-block:: bash
corese-command canonicalize [-hRvw] [-i=...] [-f=]
[-r=] [-o=]
[-c=]
**Options and arguments:**
- `-i`, `\-\-input-data` ` ` : Optional path to a file, directory, filename pattern, or URL containing the RDF data. Default: standard input.
- `-f`, `-if`, `\-\-input-format` `` : Input format is automatically detected for files. Use this option with the standard input or if you want to force the input file format. Supported input formats are listed :ref:`below `. Default: `rdfc-1.0-sha256`.
- `-R`, `\-\-recursive`: Recursively input all the files in the input directory and sub-directories.
- `-a`, `-r`, `-ca`, `-of`, `\-\-canonical-algo` `` : Canonicalization algorithm to apply. Supported algorithms/formats are listed :ref:`below `. Default: `rdfc-1.0-sha256`.
- `-o`, `\-\-output-data` `` : Optional path to save the query results. Default: standard output.
- `-c`, `\-\-config`, `\-\-init` `` : Optional path to the configuration file.
- `-w`, `\-\-no-owl-import` : Disables the automatic import of referenced ontologies specified in 'owl:imports' statements in the `profile.ttl` file. Default: enabled.
- `-v`, `\-\-verbose` : Display verbose output.
- `-h`, `\-\-help`: Display `sparql` command options.
**Example:**
To run this example you can download the sample data files :download:`beatles_blank.ttl <../_static/data/beatles_blank.ttl>` or :download:`figure3.ttl <../_static/data/figure3.ttl>`.
.. code-block:: bash
corese-command canonicalize -i beatles_blank.ttl -r rdfc-1.0
.. code-block:: xml
.
.
"1971-10-11"^^ .
"Imagine" .
.
.
.
"1970-04-17"^^ .
"McCartney" .
.
.
.
"1963-03-22"^^ .
"Please Please Me" .
_:c14n0 .
.
.
.
.
.
.
"The Beatles" .
.
_:c14n0 "125"^^ .
_:c14n0 "Love Me Do" .
_:c14n0 .
_:c14n0 .
_:c14n0 .
For more examples, see the `Getting Started Guide <../getting%20started/Getting%20Started%20With%20Corese-command.html#the-canonicalize-command>`_.
.. _corese-command-canonicalize-input-formats:
Input formats
^^^^^^^^^^^^^^^^
- RDF/XML: `rdfxml`, `rdf` or `application/rdf+xml`
- Turtle: `turtle`, `ttl` or `text/turtle`
- TriG: `trig` or `application/trig`
- JSON-LD: `jsonld` or `application/ld+json`
- NTRIPLES: `ntriples`, `nt` or `application/n-triples`
- NQUADS: `nquads`, `nq`, or `application/n-quads`
- RDFa/HTML: `rdfa`, `html`, `application/xhtml+xml`
.. _corese-command-canonicalize-output-formats:
Output (Canonicalization Algorithms) formats
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- RDFC: `rdfc-1.0`, `rdfc-1.0-sha256`, `rdfc-1.0-sha384`