History of correspsearch_letters
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] Add the date when each entry was added, and remove icon_hash beff7c9
The dates are those of the commits that first added the entries' files (2020-08-11 for the entries of the initial commit); renamed entries keep the date of their first name. Changed: none
diff --git a/entries/correspsearch_letters/__init__.py b/entries/correspsearch_letters/__init__.py
index a16529f..7123df9 100644
--- a/entries/correspsearch_letters/__init__.py
+++ b/entries/correspsearch_letters/__init__.py
@@ -57,7 +57,7 @@ citation = [('E. Hyvönen, P. Leskinen and J. Tuominen, "LetterSampo correspSear
'https://doi.org/10.5281/zenodo.15210590'),
('S. Dumont, "correspSearch - Connecting Scholarly Editions of Letters." Journal of the Text Encoding Initiative 10 (2016)',
'https://doi.org/10.4000/jtei.1742')]
-icon_hash = None
+date_added = '2026-10-31'
upstream_license = ('CC BY 4.0', 'https://creativecommons.org/licenses/by/4.0/')
URLS = {"lettersampo_CorrespSearch_data_v2.zip":
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) bc3dbbd
The lists of properties at the end of the descriptions marked edge properties with "Edge" but left node properties unmarked, or grouped them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property was often unclear. Every item now starts with (Node), (Edge) or (Graph), followed by the property names, a colon and the explanation, one item per property or group of properties; qualifications (kinds of nodes, networks) follow the names in parentheses. Properties that were only named got a short explanation, and a few items that named the wrong kind of property were corrected.
diff --git a/entries/correspsearch_letters/__init__.py b/entries/correspsearch_letters/__init__.py
index ee9a9ac..a16529f 100644
--- a/entries/correspsearch_letters/__init__.py
+++ b/entries/correspsearch_letters/__init__.py
@@ -33,19 +33,19 @@ Each node is a correspondent (a person or a group, e.g. a society, a firm or an
The networks have the following properties:
-- `name`: the name of the correspondent.
-- `uri`: the URI of the correspondent in the knowledge graph.
-- `type`: `Person` or `Group` (`correspsearch_*`: both, for a few actors typed as both).
-- `gender`: `Female`, `Male`, or empty if not known.
-- `birth`, `death`: the dates of birth and death (or of the beginning and end of groups), as in the data (YYYY-MM-DD, or a year), or empty.
-- `gnd`, `viaf`, `wikidata` (`correspsearch_*`): the identifiers of the correspondent in the GND (German National Library), VIAF and Wikidata, or empty.
-- `sent_letters`, `received_letters` (`finland`): the numbers of letters sent and received by the actor in LetterSampo Finland.
-- Edge `date_from`, `date_to`: the range of possible dates of the letter (YYYY-MM-DD, or as given in `finland`, e.g. `1899-1909`), or empty if unknown.
-- Edge `label`: the label of the letter in the knowledge graph (e.g. "1520 Jul 22: Melanchthon, Philipp (Wittenberg) to Spalatin, Georg (Lochau)").
-- Edge `place_from`, `place_to` (`correspsearch_*`): the places from which the letter was sent and to which it was sent, or empty.
-- Edge `latitude_from`, `longitude_from`, `latitude_to`, `longitude_to` (`correspsearch_*`): the coordinates of these places (NaN if not known).
-- Edge `source`: the edition (`correspsearch_*`) or the source organization (`finland`) of the letter's metadata.
-- Edge `fonds` (`finland`): the archival fonds (collection) of the letter."""
+- (Node) `name`: the name of the correspondent.
+- (Node) `uri`: the URI of the correspondent in the knowledge graph.
+- (Node) `type`: `Person` or `Group` (`correspsearch_*`: both, for a few actors typed as both).
+- (Node) `gender`: `Female`, `Male`, or empty if not known.
+- (Node) `birth`, `death`: the dates of birth and death (or of the beginning and end of groups), as in the data (YYYY-MM-DD, or a year), or empty.
+- (Node) `gnd`, `viaf`, `wikidata` (`correspsearch_*`): the identifiers of the correspondent in the GND (German National Library), VIAF and Wikidata, or empty.
+- (Node) `sent_letters`, `received_letters` (`finland`): the numbers of letters sent and received by the actor in LetterSampo Finland.
+- (Edge) `date_from`, `date_to`: the range of possible dates of the letter (YYYY-MM-DD, or as given in `finland`, e.g. `1899-1909`), or empty if unknown.
+- (Edge) `label`: the label of the letter in the knowledge graph (e.g. "1520 Jul 22: Melanchthon, Philipp (Wittenberg) to Spalatin, Georg (Lochau)").
+- (Edge) `place_from`, `place_to` (`correspsearch_*`): the places from which the letter was sent and to which it was sent, or empty.
+- (Edge) `latitude_from`, `longitude_from`, `latitude_to`, `longitude_to` (`correspsearch_*`): the coordinates of these places (NaN if not known).
+- (Edge) `source`: the edition (`correspsearch_*`) or the source organization (`finland`) of the letter's metadata.
+- (Edge) `fonds` (`finland`): the archival fonds (collection) of the letter."""
tags = ['Social', 'Communication', 'Offline', 'Unweighted', 'Multigraph', 'Timestamps', 'Metadata']
url = ['https://doi.org/10.5281/zenodo.6631357', 'https://doi.org/10.5281/zenodo.15210590',
'https://zenodo.org/records/6631357', 'https://zenodo.org/records/15210590',
[entries] New entry: correspsearch_letters e3d4c5f
diff --git a/entries/correspsearch_letters/__init__.py b/entries/correspsearch_letters/__init__.py
new file mode 100644
index 0000000..ee9a9ac
--- /dev/null
+++ b/entries/correspsearch_letters/__init__.py
@@ -0,0 +1,359 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import csv
+import io
+import re
+import zipfile
+
+from .. import *
+
+title = "Historical correspondence networks (LetterSampo: correspSearch and Finland)"
+description = r"""Networks of historical letters from the knowledge graphs of the LetterSampo project (Semantic Computing Research Group, Aalto University and University of Helsinki), which harmonized the metadata of letters (sender, recipient, date and places) from several sources:
+
+- `correspsearch_v2` and `correspsearch_v1`: the letters of correspSearch, the service of the Berlin-Brandenburg Academy of Sciences that aggregates the metadata of letters (in the CMIF format) from hundreds of printed and digital scholarly editions of correspondence, mostly of German-speaking persons from the 16th to the 20th century, as converted to RDF by LetterSampo, in the two versions of the data publication (`v2` of June 2022, with 132,138 letters, and `v1` of February 2022). correspSearch has grown since; only these conversions are available as a bulk download.
+- `finland`: LetterSampo Finland (version 1.0.0, May 2025), the letters of 19th-century (and later) Finnish archives and editions (the Finnish Literature Society, the National Archives and National Library of Finland, the Swedish Literature Society in Finland, Åbo Akademi University Library, the editions of the letters of Topelius, Snellman, Lönnrot, Edelfelt, ...), with about 1.3 million letters.
+
+Each node is a correspondent (a person or a group, e.g. a society, a firm or an office), as identified by the sources and harmonized by LetterSampo, and a directed edge from $i$ to $j$ is a letter sent by $i$ to $j$; letters with several senders or recipients give an edge for each pair. Pairs of correspondents exchanged many letters (multigraphs). Letters without a known sender or recipient are left out. In `finland`, the correspondents of the sources ("proxies") are merged into the harmonized actors of LetterSampo, as in its portal; proxies without a harmonized actor are kept as they are.
+
+The networks have the following properties:
+
+- `name`: the name of the correspondent.
+- `uri`: the URI of the correspondent in the knowledge graph.
+- `type`: `Person` or `Group` (`correspsearch_*`: both, for a few actors typed as both).
+- `gender`: `Female`, `Male`, or empty if not known.
+- `birth`, `death`: the dates of birth and death (or of the beginning and end of groups), as in the data (YYYY-MM-DD, or a year), or empty.
+- `gnd`, `viaf`, `wikidata` (`correspsearch_*`): the identifiers of the correspondent in the GND (German National Library), VIAF and Wikidata, or empty.
+- `sent_letters`, `received_letters` (`finland`): the numbers of letters sent and received by the actor in LetterSampo Finland.
+- Edge `date_from`, `date_to`: the range of possible dates of the letter (YYYY-MM-DD, or as given in `finland`, e.g. `1899-1909`), or empty if unknown.
+- Edge `label`: the label of the letter in the knowledge graph (e.g. "1520 Jul 22: Melanchthon, Philipp (Wittenberg) to Spalatin, Georg (Lochau)").
+- Edge `place_from`, `place_to` (`correspsearch_*`): the places from which the letter was sent and to which it was sent, or empty.
+- Edge `latitude_from`, `longitude_from`, `latitude_to`, `longitude_to` (`correspsearch_*`): the coordinates of these places (NaN if not known).
+- Edge `source`: the edition (`correspsearch_*`) or the source organization (`finland`) of the letter's metadata.
+- Edge `fonds` (`finland`): the archival fonds (collection) of the letter."""
+tags = ['Social', 'Communication', 'Offline', 'Unweighted', 'Multigraph', 'Timestamps', 'Metadata']
+url = ['https://doi.org/10.5281/zenodo.6631357', 'https://doi.org/10.5281/zenodo.15210590',
+ 'https://zenodo.org/records/6631357', 'https://zenodo.org/records/15210590',
+ 'https://correspsearch.net/', 'https://seco.cs.aalto.fi/projects/rrl/',
+ 'https://kirjesampo.fi/']
+citation = [('E. Hyvönen, P. Leskinen and J. Tuominen, "LetterSampo correspSearch data publication." Zenodo (2022)',
+ 'https://doi.org/10.5281/zenodo.6631357'),
+ ('A. Ahola, M. Björklund, S. Drobac, et al., "LetterSampo Finland." Zenodo (2025)',
+ 'https://doi.org/10.5281/zenodo.15210590'),
+ ('S. Dumont, "correspSearch - Connecting Scholarly Editions of Letters." Journal of the Text Encoding Initiative 10 (2016)',
+ 'https://doi.org/10.4000/jtei.1742')]
+icon_hash = None
+upstream_license = ('CC BY 4.0', 'https://creativecommons.org/licenses/by/4.0/')
+
+URLS = {"lettersampo_CorrespSearch_data_v2.zip":
+ "https://zenodo.org/records/6631357/files/lettersampo_CorrespSearch_data_v2.zip?download=1",
+ "lettersampo_correspSearch_data_v1.zip":
+ "https://zenodo.org/records/6631357/files/lettersampo_correspSearch_data_v1.zip?download=1",
+ "lettersampo-finland-v1.0.0.zip":
+ "https://zenodo.org/records/15210590/files/lettersampo-finland-v1.0.0.zip?download=1"}
+
+upstream_prefix = None
+files = [("lettersampo_CorrespSearch_data_v2.zip", "correspsearch_v2", None),
+ ("lettersampo_correspSearch_data_v1.zip", "correspsearch_v1", None),
+ ("lettersampo-finland-v1.0.0.zip", "finland", None)]
+
+def fetch_upstream(force=False):
+ return fetch_archived_files(__name__.split(".")[-1], URLS, force=force,
+ tries=3)
+
+# For checks only: if set, only (about) this many letters are read
+_check_rows = None
+
+_TOK = re.compile(r'''\s*(?:
+ (?P<comment>\#[^\n]*) |
+ (?P<iri><[^>]*>) |
+ (?P<lit3>"""(?:[^"\\]|\\.|"(?!""))*""") |
+ (?P<lit>"(?:[^"\\\n]|\\.)*") |
+ (?P<lang>@[A-Za-z][A-Za-z0-9-]*) |
+ (?P<dt>\^\^) |
+ (?P<punct>[;,.]) |
+ (?P<name>[^\s;,\[\]()"<>]+)
+)''', re.X | re.S)
+
+_ESC = {"n": "\n", "t": "\t", "r": "\r"}
+
+def _triples(text):
+ """The triples of a Turtle document, of the subset written by rdflib's
+ serializer used for these files (prefixed names, IRIs and literals, with
+ ";" and "," abbreviations; no blank nodes or collections), as (s, p, o):
+ prefixed names and <IRIs> as written, literals as '"' + their unescaped
+ text (language tags and datatypes are dropped)."""
+ pos = 0
+ state = "s"
+ s = p = None
+ skip = False
+ while True:
+ m = _TOK.match(text, pos)
+ if m is None or m.end() == pos:
+ if text[pos:].strip():
+ raise ValueError(f"Turtle syntax: {text[pos:pos + 80]!r}")
+ return
+ pos = m.end()
+ k = m.lastgroup
+ v = m.group(k)
+ if k == "comment":
+ continue
+ if k == "lang":
+ if v in ("@prefix", "@base"):
+ state = "directive"
+ continue
+ if state == "directive":
+ if v == ".":
+ state = "s"
+ continue
+ if k == "dt":
+ skip = True # the datatype that follows
+ continue
+ if skip:
+ skip = False
+ continue
+ if k == "punct":
+ state = {";": "p", ",": "o", ".": "s"}[v]
+ continue
+ if k in ("lit", "lit3"):
+ q = 3 if k == "lit3" else 1
+ v = '"' + re.sub(r"\\(.)", lambda m: _ESC.get(m.group(1), m.group(1)),
+ v[q:-q])
+ if state == "s":
+ s, state = v, "p"
+ elif state == "p":
+ p, state = v, "o"
+ elif state == "o":
+ yield s, p, v
+ state = "next"
+ else:
+ raise ValueError(f"Turtle syntax: {text[pos - 80:pos]!r}")
+
+def _read_ttl(z, member):
+ with z.open(member) as f:
+ return f.read().decode("utf8")
+
+_TIME = re.compile(r"time_(-?\d+-\d\d-\d\d)T[\d:]+-(-?\d+-\d\d-\d\d)T")
+
+def _dates(t):
+ m = _TIME.search(t)
+ return (m.group(1), m.group(2)) if m else ("", "")
+
+def _lit(x):
+ return x[1:] if x.startswith('"') else ""
+
+def _correspsearch(z):
+ "The network of a LetterSampo correspSearch publication."
+ # places
+ places = {}
+ for s, p, o in _triples(_read_ttl(z, "places.ttl")):
+ d = places.setdefault(s, {})
+ if p == "skos:prefLabel":
+ d["name"] = _lit(o)
+ elif p == "geo:lat":
+ d["lat"] = _lit(o)
+ elif p == "geo:long":
+ d["lon"] = _lit(o)
+ sources = {}
+ for s, p, o in _triples(_read_ttl(z, "sources.ttl")):
+ if p == "skos:prefLabel":
+ sources[s] = _lit(o)
+ # actors, and the senders of the letters
+ actors = {}
+ senders = {}
+ for s, p, o in _triples(_read_ttl(z, "actors.ttl")):
+ if not s.startswith("actors_corresp:"):
+ continue
+ d = actors.setdefault(s, {"types": set()})
+ if p == "a":
+ d["types"].add(o)
+ elif p == "skos:prefLabel":
+ d.setdefault("name", _lit(o))
+ elif p == "foaf:gender":
+ d["gender"] = {"purl-code:sex-F": "Female",
+ "purl-code:sex-M": "Male"}.get(o, "")
+ elif p == "lssc:birthDate":
+ d["birth"] = _dates(o)[0]
+ elif p == "lssc:deathDate":
+ d["death"] = _dates(o)[0]
+ elif p == "lssc:created":
+ senders.setdefault(o, []).append(s)
+ elif p == "lssc:is_related_to":
+ for pre, k in (("gnd:", "gnd"), ("viaf:", "viaf"), ("wd:", "wikidata")):
+ if o.startswith(pre):
+ d.setdefault(k, o[len(pre):])
+ # letters
+ letters = {}
+ for s, p, o in _triples(_read_ttl(z, "letters.ttl")):
+ d = letters.get(s)
+ if d is None:
+ if _check_rows is not None and len(letters) >= _check_rows:
+ break
+ d = letters[s] = {"to": []}
+ if p == "lssc:was_addressed_to":
+ d["to"].append(o)
+ elif p in ("lssc:has_time", "crm:P4_has_time-span"):
+ d["date"] = _dates(o)
+ elif p == "lssc:was_sent_from":
+ d["from_place"] = o
+ elif p == "lssc:was_sent_to":
+ d["to_place"] = o
+ elif p == "lssc:source":
+ d["source"] = sources.get(o, o)
+ elif p == "skos:prefLabel":
+ d["label"] = _lit(o)
+
+ g = Graph(directed=True)
+ vmap = {}
+ def vertex(a):
+ v = vmap.get(a)
+ if v is None:
+ v = vmap[a] = len(vmap)
+ return v
+ eprops = [("date_from", "string"), ("date_to", "string"),
+ ("label", "string"), ("place_from", "string"),
+ ("place_to", "string"), ("latitude_from", "double"),
+ ("longitude_from", "double"), ("latitude_to", "double"),
+ ("longitude_to", "double"), ("source", "string")]
+ def coord(pl, k):
+ try:
+ return float(places.get(pl, {}).get(k, "nan"))
+ except ValueError:
+ return numpy.nan
+ edges = []
+ def num(lid):
+ m = re.search(r"(\d+)$", lid)
+ return int(m.group(1)) if m else 0
+ for lid in sorted(letters, key=num):
+ d = letters[lid]
+ for a in senders.get(lid, []):
+ for b in d["to"]:
+ pf, pt = d.get("from_place", ""), d.get("to_place", "")
+ edges.append((vertex(a), vertex(b), *d.get("date", ("", "")),
+ d.get("label", ""),
+ places.get(pf, {}).get("name", ""),
+ places.get(pt, {}).get("name", ""),
+ coord(pf, "lat"), coord(pf, "lon"),
+ coord(pt, "lat"), coord(pt, "lon"),
+ d.get("source", "")))
+ g.add_vertex(len(vmap))
+ for k, t in eprops:
+ g.ep[k] = g.new_ep(t)
+ g.add_edge_list(edges, eprops=[g.ep[k] for k, t in eprops])
+ for k in ["name", "uri", "type", "gender", "birth", "death", "gnd", "viaf",
+ "wikidata"]:
+ g.vp[k] = g.new_vp("string")
+ for a, v in vmap.items():
+ d = actors.get(a, {"types": set()})
+ g.vp.uri[v] = "http://ldf.fi/corresp/actors/" + a.split(":", 1)[1]
+ types = []
+ if "crm:E21_Person" in d["types"]:
+ types.append("Person")
+ if "crm:E74_Group" in d["types"]:
+ types.append("Group")
+ g.vp.type[v] = ", ".join(types)
+ for k in ["name", "gender", "birth", "death", "gnd", "viaf", "wikidata"]:
+ g.vp[k][v] = d.get(k, "")
+ return g
+
+def _finland(z):
+ "The network of LetterSampo Finland, from its CSV files."
+ proxy = {}
+ pat = re.compile(r"^actors:(p\d+) :proxy_for provided:(p\d+) \.$", re.M)
+ for a, b in pat.findall(_read_ttl(z, "ttl/actors.ttl")):
+ proxy["http://ldf.fi/coco/actors/" + a] = "http://ldf.fi/coco/provided/" + b
+ actors = {}
+ with z.open("csv/actors.csv") as f:
+ for r in csv.DictReader(io.TextIOWrapper(f, "utf8")):
+ actors[r["id"]] = r
+ g = Graph(directed=True)
+ vmap = {}
+ names = {}
+ def vertex(a, name):
+ a = proxy.get(a, a)
+ v = vmap.get(a)
+ if v is None:
+ v = vmap[a] = len(vmap)
+ names[a] = name
+ return v
+ eprops = [("date_from", "string"), ("date_to", "string"),
+ ("label", "string"), ("source", "string"), ("fonds", "string")]
+ edges = []
+ n = 0
+ for m in sorted(x for x in z.namelist()
+ if x.startswith("csv/letters_") and x.endswith(".csv")):
+ with z.open(m) as f:
+ for r in csv.DictReader(io.TextIOWrapper(f, "utf8")):
+ if _check_rows is not None and n >= _check_rows:
+ break
+ n += 1
+ if not r["sender_id"] or not r["recipient_id"]:
+ continue
+ # (a span "1901-1955" is a range of years; a single date or
+ # year is both the start and the end)
+ ts = r["timespan"]
+ m2 = re.fullmatch(r"(\d{4}(?:-\d\d-\d\d)?)(?:-(\d{4}(?:-\d\d-\d\d)?))?", ts)
+ if m2:
+ d0, d1 = m2.group(1), m2.group(2) or m2.group(1)
+ else:
+ d0, d1 = ts, ts
+ edges.append((vertex(r["sender_id"], r["sender"]),
+ vertex(r["recipient_id"], r["recipient"]),
+ d0, d1, r["label"], r["datasource"], r["fonds"]))
+ g.add_vertex(len(vmap))
+ for k, t in eprops:
+ g.ep[k] = g.new_ep(t)
+ g.add_edge_list(edges, eprops=[g.ep[k] for k, t in eprops])
+ for k in ["name", "uri", "type", "gender", "birth", "death"]:
+ g.vp[k] = g.new_vp("string")
+ g.vp.sent_letters = g.new_vp("int", val=-1)
+ g.vp.received_letters = g.new_vp("int", val=-1)
+ for a, v in vmap.items():
+ g.vp.uri[v] = a
+ r = actors.get(a)
+ if r is None:
+ g.vp.name[v] = names[a]
+ continue
+ g.vp.name[v] = r["label"]
+ g.vp.type[v] = r["type"]
+ g.vp.gender[v] = r["gender"]
+ g.vp.birth[v] = r["birth_time"]
+ g.vp.death[v] = r["death_time"]
+ for k, c in (("sent_letters", "number_of_sent_letters"),
+ ("received_letters", "number_of_received_letters")):
+ try:
+ g.vp[k][v] = int(r[c])
+ except ValueError:
+ pass
+ return g
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ name = __name__.split(".")[-1]
+ for fname, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ with open_upstream_file(name, fname, "rb") as f:
+ with zipfile.ZipFile(f) as z:
+ if alt == "finland":
+ g = _finland(z)
+ else:
+ g = _correspsearch(z)
+ yield alt, g