Skip to content

Instantly share code, notes, and snippets.

@nichtich
Last active Nov 15, 2021
Embed
What would you like to do?
Wikidata in KDL

Serialization of Wikidata data model in KDL

Two years ago a experimented with a data language for Wikibase. Maybe using KDL as syntax is a better approach.

# simple statement
Q4115189 P31=Q1   # KDL property
Q4115189 P31 Q1   # two KDL arguments

# multiple stataments on same item
Q4115189 {
  P31 Q1
  P373 "Antoni Ignacy Mietelski"       # String value
  P1476 (pl)"Krzyżacy"                 # Monolingual text
}

# more data types
Q3033 P856 (url)"https://www.goettingen.de/"
Q41576483 P569 (year)"1839-00"

# qualifiers and references in a children block
Q41577083 P570 +1586/7 {
  P1319 +1586/9             # qualifier
  references P248=Q52       # references
}

As ( and ) are valid in bare identifiers we can also extend identifiers with arbitrary labels for better readability:

"Wikidata Sandbox (Q4115189)" "instance of (P31)" "universe (Q1)"

wikidata-sandbox-(Q4115189) instance-of(P31) universe-(Q1)

Q4115189:wikidata-sandbox P31:instance-of Q1:universe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment