Vocabularies¶
The vocabulary:* commands import, update, list and delete the RDF vocabularies that provide the
classes and properties of an Omeka S installation. A vocabulary can come from a local file, a URL, a
JSON configuration file, or a repository such as Linked Open Vocabularies
(LOV).
List the vocabularies¶
vocabulary:list shows the installed vocabularies with their prefix, namespace URI and the number of
properties and classes:
+----+------------------------+---------+--------------------------------+---------------+---------------------+--------+
| Id | Label | Prefix | NamespaceUri | PropertyCount | ResourcesClassCount | Owner |
+----+------------------------+---------+--------------------------------+---------------+---------------------+--------+
| 1 | Dublin Core | dcterms | http://purl.org/dc/terms/ | 55 | 22 | system |
| 2 | Dublin Core Type | dctype | http://purl.org/dc/dcmitype/ | 0 | 12 | system |
| 3 | Bibliographic Ontology | bibo | http://purl.org/ontology/bibo/ | 67 | 58 | system |
| 4 | Friend of a Friend | foaf | http://xmlns.com/foaf/0.1/ | 62 | 13 | system |
+----+------------------------+---------+--------------------------------+---------------+---------------------+--------+
These four come with every Omeka S installation. Add --json for output a script can process:
Import a vocabulary¶
vocabulary:import reads an RDF file and creates the vocabulary. --source takes a local path or a URL;
--namespace-uri, --prefix and --label are required:
omeka-s-cli vocabulary:import \
--source ~/vocabularies/archive.ttl \
--namespace-uri "https://example.org/archive#" \
--prefix arch \
--label "Archive" \
--format turtle
The namespace URI must match the one the classes and properties in the file use: only the terms in that
namespace are imported, and the import fails if there are none. --format is rdfxml, turtle,
ntriples, jsonld or auto (the default, which guesses the format). The same command imports from a
URL:
omeka-s-cli vocabulary:import \
--source https://www.w3.org/TR/skos-reference/skos.rdf \
--namespace-uri "http://www.w3.org/2004/02/skos/core#" \
--prefix skos \
--label "SKOS"
Use --comment to describe the vocabulary. --lang picks the language of the labels and comments when
the RDF has several, and --label-property / --comment-property name the RDF properties to read
them from (by default rdfs:comment for comments, and skos:prefLabel, rdfs:label or a few other
common label properties for labels).
If a vocabulary with the same namespace URI already exists, the command changes nothing, prints a notice and exits with code 0. To apply changes, see Update a vocabulary.
Note
--url and --file are deprecated aliases of --source; they still work, with a warning.
Use a configuration file¶
The options of an import can live in a JSON file, so the import is easy to repeat or to keep in version
control. vocabulary:create-import-config takes the same options as vocabulary:import and writes them
as a configuration file (without --output, it prints the JSON):
cd ~/vocabularies
omeka-s-cli vocabulary:create-import-config \
--source archive.ttl \
--namespace-uri "https://example.org/archive#" \
--prefix arch \
--label "Archive" \
--comment "Classes and properties for the letters collection." \
--format turtle \
--output archive.json
{
"source": "archive.ttl",
"label": "Archive",
"namespaceUri": "https://example.org/archive#",
"prefix": "arch",
"comment": "Classes and properties for the letters collection.",
"format": "turtle"
}
source, label, namespaceUri and prefix are required; comment, format, lang, labelProperty
and commentProperty are optional and match the command options. A relative source is resolved
against the location of the configuration file, so the file and the RDF can be moved together. Import it
with --config:
--config also accepts a URL; a relative source then resolves against that URL.
Update a vocabulary¶
When the RDF of an installed vocabulary changes, re-import it with --update. The existing vocabulary is
found by its namespace URI:
An update adds new classes and properties and updates the labels and comments of the existing ones. It does not remove classes or properties that are no longer in the RDF, and it keeps the label, prefix and comment of the vocabulary itself.
Find and import from a repository¶
vocabulary:search searches the vocabularies of the known repositories (currently only LOV, with id
lov) by id, label, prefix or namespace URI. Without a query it lists them all; --repository limits the
search to one repository:
vocabulary:import-from-repo imports a result by its id, <repository>:<prefix>. The label, prefix,
namespace URI and download URL come from the repository:
Resolved to vocabulary 'The Event Ontology' (ns: http://purl.org/NET/c4dm/event.owl#, prefix: event)
Importing vocabulary from https://lov.linkeddata.es/dataset/lov/vocabs/event/versions/2007-10-25.n3 ... done
Successfully created vocabulary 'The Event Ontology'.
To match on the prefix or the namespace URI instead of the id, add --prefix or --namespace-uri.
--update updates a vocabulary that is already installed, as in Update a
vocabulary:
The repository data is cached for 24 hours in ~/.cache/omeka-s-cli; vocabulary:search --refresh
fetches it again.
Delete a vocabulary¶
vocabulary:delete takes the prefix or the id of a vocabulary. With --ignore-not-found, a vocabulary
that does not exist is not an error:
Warning
Deleting a vocabulary also deletes its classes and properties, and with them every value that uses one of its properties. The vocabularies that come with Omeka S cannot be deleted.
Reference¶
All commands also accept the global options.
vocabulary:list¶
List vocabularies
| Option | Description | Default |
|---|---|---|
-j, --json |
Output json |
vocabulary:import¶
Import a vocabulary
| Option | Description | Default |
|---|---|---|
--source <value> |
Path or URL to the vocabulary RDF (absolute, relative to the config, or a URI) | |
--url <value> |
Vocabulary URL (deprecated: use --source) | |
--file <value> |
Path to Vocabulary file (deprecated: use --source) | |
-l, --label <value> |
Label for the vocabulary (required) | |
-c, --comment <value> |
Comment/description for the vocabulary | |
-n, --namespace-uri <value> |
Namespace URI for the vocabulary (required) | |
-p, --prefix <value> |
Namespace prefix for the vocabulary (required) | |
-f, --format <value> |
Format of the vocabulary (rdfxml, turtle, ntriples, or auto) | 'auto' |
-l, --lang <value> |
Preferred language for labels and comments (e.g., en, fr) | |
-lp, --label-property <value> |
RDF property for labels | |
-cp, --comment-property <value> |
RDF property for comments | |
--config <value> |
Path or URL to a JSON import configuration file (instead of the options above) | |
-u, --update |
Update existing vocabulary (if it exists) |
vocabulary:create-import-config¶
Create a config file for the import command
| Option | Description | Default |
|---|---|---|
--source <value> |
Path or URL to the vocabulary RDF (absolute, relative to the config, or a URI) | |
--url <value> |
Vocabulary URL (deprecated: use --source) | |
--file <value> |
Path to Vocabulary file (deprecated: use --source) | |
-l, --label <value> |
Label for the vocabulary (required) | |
-c, --comment <value> |
Comment/description for the vocabulary | |
-n, --namespace-uri <value> |
Namespace URI for the vocabulary (required) | |
-p, --prefix <value> |
Namespace prefix for the vocabulary (required) | |
-f, --format <value> |
Format of the vocabulary (rdfxml, turtle, ntriples, or auto) | 'auto' |
-l, --lang <value> |
Preferred language for labels and comments (e.g., en, fr) | |
-lp, --label-property <value> |
RDF property for labels | |
-cp, --comment-property <value> |
RDF property for comments | |
--output <value> |
Output the import configuration to a file |
vocabulary:search¶
Search/list available vocabularies
| Argument | Description | Default |
|---|---|---|
[query] |
Part of the vocabulary id, name or description |
| Option | Description | Default |
|---|---|---|
-r, --repository [repositoryId] |
Filter by repository id | |
--refresh |
Refresh the repository data | |
-j, --json |
Output json | |
-x, --extended |
Extended output |
vocabulary:import-from-repo¶
Import a vocabulary from a repository
| Argument | Description | Default |
|---|---|---|
<identifier> |
Vocabulary identifier |
| Option | Description | Default |
|---|---|---|
-p, --prefix |
Match vocabulary by prefix | |
-n, --namespace-uri |
Match vocabulary by namespace uri | |
-r, --repository-id [repositoryId] |
Filter by repository | |
-u, --update |
Update existing vocabulary (if it exists) |
vocabulary:delete¶
Delete a vocabulary
| Argument | Description | Default |
|---|---|---|
<identifier> |
Vocabulary ID or prefix |
| Option | Description | Default |
|---|---|---|
--ignore-not-found |
Do nothing if the vocabulary does not exist (default: throw an error) |