Command line

A name authority from a dated Wikidata snapshot: variant names, fold keys and identifiers for catalogue search across scripts.

usage: tetrak-authority [-h] [--version]
                        {count,snapshot,rekey,lookup,show,search} ...

Positional Arguments

command

Possible choices: count, snapshot, rekey, lookup, show, search

Named Arguments

--version

show program’s version number and exit

Sub-commands

count

how many items the scope holds, per kind, without fetching them

tetrak-authority count [-h] [--endpoint ENDPOINT] [--contact CONTACT]
                       [--fetch-endpoint FETCH_ENDPOINT] [--pause PAUSE]
                       [--kinds {person,organisation,place,agent} [{person,organisation,place,agent} ...]]
                       [--languages LANGUAGES [LANGUAGES ...]]
                       [--script SCRIPT] [--box WEST SOUTH EAST NORTH]
                       [--no-box]

Named Arguments

--endpoint

SPARQL endpoint: the QLever mirror (default, https://qlever.dev/api/wikidata) or the Query Service (https://query.wikidata.org/sparql), which times out on the enumeration queries

Default: 'https://qlever.dev/api/wikidata'

--contact

a URL or email for the user agent, as Wikimedia’s policy asks

--fetch-endpoint

SPARQL endpoint that fetches names and facts by batch of ids (default the Query Service, https://query.wikidata.org/sparql, which is faster at that than the mirror)

Default: 'https://query.wikidata.org/sparql'

--pause

seconds between requests (default 1)

Default: 1.0

--kinds

Possible choices: person, organisation, place, agent

which kinds to include; ‘agent’ is person and organisation

Default: ['person', 'organisation', 'place']

--languages

label languages that bring an item in (default hy hyw)

Default: ['hy', 'hyw']

--script

the tetrak-translit script that keys the names (default hy)

Default: 'hy'

--box

where a place must lie, in degrees; default an approximation of historic Armenia (26 31.7 51.6 43.6)

--no-box

places anywhere with a label in the languages

Default: False

snapshot

build a dated snapshot

tetrak-authority snapshot [-h] [--endpoint ENDPOINT] [--contact CONTACT]
                          [--fetch-endpoint FETCH_ENDPOINT] [--pause PAUSE]
                          [--kinds {person,organisation,place,agent} [{person,organisation,place,agent} ...]]
                          [--languages LANGUAGES [LANGUAGES ...]]
                          [--script SCRIPT] [--box WEST SOUTH EAST NORTH]
                          [--no-box] --out OUT [--batch BATCH] [--limit LIMIT]
                          [--resume]

Named Arguments

--endpoint

SPARQL endpoint: the QLever mirror (default, https://qlever.dev/api/wikidata) or the Query Service (https://query.wikidata.org/sparql), which times out on the enumeration queries

Default: 'https://qlever.dev/api/wikidata'

--contact

a URL or email for the user agent, as Wikimedia’s policy asks

--fetch-endpoint

SPARQL endpoint that fetches names and facts by batch of ids (default the Query Service, https://query.wikidata.org/sparql, which is faster at that than the mirror)

Default: 'https://query.wikidata.org/sparql'

--pause

seconds between requests (default 1)

Default: 1.0

--kinds

Possible choices: person, organisation, place, agent

which kinds to include; ‘agent’ is person and organisation

Default: ['person', 'organisation', 'place']

--languages

label languages that bring an item in (default hy hyw)

Default: ['hy', 'hyw']

--script

the tetrak-translit script that keys the names (default hy)

Default: 'hy'

--box

where a place must lie, in degrees; default an approximation of historic Armenia (26 31.7 51.6 43.6)

--no-box

places anywhere with a label in the languages

Default: False

--out

directory for snapshot.json and entities.jsonl

--batch

items per fetch query (default 200)

Default: 200

--limit

items per kind, for a trial run

--resume

keep the entities already in the output and fetch only the rest

Default: False

rekey

recompute every key in a snapshot with the installed tetrak-translit, after an upgrade of it

tetrak-authority rekey [-h] --snapshot SNAPSHOT [--script SCRIPT]

Named Arguments

--snapshot

the snapshot directory

--script

the tetrak-translit script (default: the manifest’s)

lookup

the entities a name reaches in a snapshot, and their names

tetrak-authority lookup [-h] --snapshot SNAPSHOT
                        [--kinds {person,organisation,place,agent} [{person,organisation,place,agent} ...]]
                        [--json]
                        names [names ...]

Positional Arguments

names

names as a catalogue or a reader wrote them

Named Arguments

--snapshot

the snapshot directory

--kinds

Possible choices: person, organisation, place, agent

restrict to these kinds

--json

print the matches as JSON

Default: False

show

one record by its Wikidata id

tetrak-authority show [-h] --snapshot SNAPSHOT QID [QID ...]

Positional Arguments

QID

Named Arguments

--snapshot

Examples

tetrak-authority count                                   # the default scope, per kind
tetrak-authority count --kinds place --box 43 38.8 46.7 41.4
tetrak-authority snapshot --out snapshots/hy --contact you@example.org
tetrak-authority snapshot --out trial --limit 20         # a trial run, twenty items per kind
tetrak-authority lookup --snapshot snapshots/hy "Tumanyan, Hovhannes" "Tiflis"
tetrak-authority lookup --snapshot snapshots/hy --json "Գրիգոր Նարեկացի"
tetrak-authority show --snapshot snapshots/hy Q380797
tetrak-authority rekey --snapshot snapshots/hy          # after a tetrak-translit upgrade
tetrak-authority search "Նարեկացի"

Exit status is 0 on success, 1 when a lookup or search finds nothing, and 2 for a bad argument or a failed request.