logo Netzschleuder network catalog, repository, and centrifuge

History of cbdb

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 by Tiago de Paula Peixoto 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/cbdb/__init__.py b/entries/cbdb/__init__.py
index 50169b4..48f23a1 100644
--- a/entries/cbdb/__init__.py
+++ b/entries/cbdb/__init__.py
@@ -86,7 +86,7 @@ url = ['https://cbdb.hsites.harvard.edu/', 'https://huggingface.co/datasets/cbdb
        'https://github.com/cbdb-project/cbdb_sqlite']
 citation = [('Harvard University, Academia Sinica and Peking University, "China Biographical Database (CBDB)." (2019-2026)',
              'https://cbdb.hsites.harvard.edu/')]
-icon_hash = None
+date_added = '2026-10-31'
 upstream_license = ('CC BY-NC-SA 4.0 for the data of the standalone release; CBDB Data Licensing Terms (from 2026-08-20) for the rest',
                     'https://cbdb.hsites.harvard.edu/cbdb-data-licensing-terms')
 
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto 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/cbdb/__init__.py b/entries/cbdb/__init__.py
index 71a8f54..50169b4 100644
--- a/entries/cbdb/__init__.py
+++ b/entries/cbdb/__init__.py
@@ -68,19 +68,19 @@ Only the persons that take part in some relation of the network are included; th
 
 The networks have the following properties:
 
-- `name`, `name_chn`: the name of the person, in transliteration (Pinyin) and in Chinese characters.
-- `person_id`: the identifier of the person in CBDB (`c_personid`; e.g. `https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=<person_id>`).
-- `female`: whether the person is a woman.
-- `birth_year`, `death_year`: the years of birth and death (0 if unknown).
-- `index_year`: the index year of the person (an estimate of the year in which the person was 60, used to order persons in time; 0 if unknown).
-- `dynasty`: the dynasty of the person, or empty.
-- Edge `code`: the code of the kinship relation (`KINSHIP_CODES`) or of the association (`ASSOC_CODES`).
-- Edge `relation`, `relation_chn`: the relation, in English and Chinese.
-- Edge `source`: the identifier of the text that is the source of the record (in the `TEXT_CODES` of CBDB; 0 if not given).
-- Edge `first_year`, `last_year` (associations): the first and last years of the association (0 if unknown; older releases (e.g. 2019), which record a single year, give it as both).
-- Edge `count` (associations): the number of instances of the association (e.g. letters; 0 if not given).
-- Edge `kin_id`, `kin_relation` (associations): the kin of the first person through which the association is recorded and its kinship relation (0 and empty if none), and `assoc_kin_id`, `assoc_kin_relation`, the same for the second person.
-- Graph property `release`: the date of the release (YYYY-MM-DD)."""
+- (Node) `name`, `name_chn`: the name of the person, in transliteration (Pinyin) and in Chinese characters.
+- (Node) `person_id`: the identifier of the person in CBDB (`c_personid`; e.g. `https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=<person_id>`).
+- (Node) `female`: whether the person is a woman.
+- (Node) `birth_year`, `death_year`: the years of birth and death (0 if unknown).
+- (Node) `index_year`: the index year of the person (an estimate of the year in which the person was 60, used to order persons in time; 0 if unknown).
+- (Node) `dynasty`: the dynasty of the person, or empty.
+- (Edge) `code`: the code of the kinship relation (`KINSHIP_CODES`) or of the association (`ASSOC_CODES`).
+- (Edge) `relation`, `relation_chn`: the relation, in English and Chinese.
+- (Edge) `source`: the identifier of the text that is the source of the record (in the `TEXT_CODES` of CBDB; 0 if not given).
+- (Edge) `first_year`, `last_year` (associations): the first and last years of the association (0 if unknown; older releases (e.g. 2019), which record a single year, give it as both).
+- (Edge) `count` (associations): the number of instances of the association (e.g. letters; 0 if not given).
+- (Edge) `kin_id`, `kin_relation` (associations): the kin of the first person through which the association is recorded and its kinship relation (0 and empty if none), and `assoc_kin_id`, `assoc_kin_relation`, the same for the second person.
+- (Graph) `release`: the date of the release (YYYY-MM-DD)."""
 tags = ['Social', 'Offline', 'Relationships', 'Multigraph', 'Metadata']
 url = ['https://cbdb.hsites.harvard.edu/', 'https://huggingface.co/datasets/cbdb/cbdb-sqlite',
        'https://github.com/cbdb-project/cbdb_sqlite']
[entries] New entry: cbdb by Tiago de Paula Peixoto 0bd4c1e
diff --git a/entries/cbdb/__init__.py b/entries/cbdb/__init__.py
new file mode 100644
index 0000000..71a8f54
--- /dev/null
+++ b/entries/cbdb/__init__.py
@@ -0,0 +1,250 @@
+#! /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 re
+import sqlite3
+import subprocess
+import tempfile
+
+from .. import *
+
+# All the releases of the SQLite database in the history of the Hugging Face
+# dataset, as (name, date, files); split archives are given as their volumes
+_WEEKLY_2026 = ["20260205", "20260208", "20260210", "20260215", "20260221",
+                "20260304", "20260307", "20260314", "20260321", "20260328",
+                "20260502", "20260509", "20260516", "20260523", "20260530",
+                "20260606", "20260613", "20260620", "20260627", "20260704",
+                "20260711", "20260718", "20260725", "20260801", "20260808",
+                "20260815", "20260820", "20260822", "20260829", "20260905",
+                "20260912", "20260914", "20260919", "20260926", "20261003",
+                "20261010", "20261017", "20261024"]
+# (the first two of February 2026 are 7z archives, the others zip)
+RELEASES = ([("20190424", "2019-04-24", ["history/CBDB_20190424.rar"]),
+             ("20200528", "2020-05-28", ["history/CBDB_20200528.rar"]),
+             ("20201110", "2020-11-10", ["history/CBDB_20201110.7z"]),
+             ("20210525", "2021-05-25", ["history/CBDB_20210525.7z"]),
+             ("20211222", "2021-12-22", ["history/CBDB_20211222.7z"]),
+             ("20220727", "2022-07-27", ["history/CBDB_20220727.7z"]),
+             ("20220727_build20220831", "2022-08-31",
+              ["history/CBDB_20220727_build20220831.7z"]),
+             ("20230324", "2023-03-24", ["history/CBDB_20230324.7z"]),
+             ("20240208", "2024-02-08",
+              ["history/CBDB_20240208/CBDB_20240208.7z.001",
+               "history/CBDB_20240208/CBDB_20240208.7z.002"]),
+             ("20240820", "2024-08-20",
+              ["history/CBDB_20240820/CBDB_20240820.7z.001",
+               "history/CBDB_20240820/CBDB_20240820.7z.002"]),
+             ("20250520", "2025-05-20", ["history/CBDB_20250520/CBDB_20250520.7z"]),
+             ("20251010", "2025-10-10", ["history/cbdb_20251010.7z"])] +
+            [(d, f"{d[:4]}-{d[4:6]}-{d[6:]}",
+              [f"history/cbdb_{d[:6]}/cbdb_{d}." +
+               ("7z" if d in ("20260205", "20260208") else "zip")])
+             for d in _WEEKLY_2026])
+
+title = "China Biographical Database: kinship and associations (2019-2026)"
+description = r"""Networks of the kinship relations and social associations of persons of Chinese history, mainly from the 7th to the 19th century, from the China Biographical Database (CBDB), the relational database of biographical information compiled by Harvard University, Academia Sinica and Peking University from biographies, local gazetteers, official records, collected works and other sources (about 660,000 persons in 2026).
+
+There are two networks for each release of the database, all the 50 releases of the database's archive, from April 2019 to 24 October 2026 (weekly in 2026), named after the date of the release (e.g. `kinship_20261024`; `kinship_20220727_build20220831` is a rebuild of the release of 2022-07-27; the dates are given as graph properties):
+
+- `kinship_<release>`: nodes are persons, and a directed edge from person $i$ to person $j$ means that $j$ is a kin of $i$ of the given type, as recorded (e.g. "F" for father, "S" for son, "W" for wife, "B-" for younger brother, and more distant relations, e.g. "FBS" for the son of the father's brother). Most relations are recorded in both directions (e.g. father and son).
+- `association_<release>`: nodes are persons, and a directed edge from person $i$ to person $j$ is a social association of $i$ with $j$ of the given type (e.g. teacher and student, friendship, exchange of letters or poems, recommendation, writing an epitaph or a preface for someone, political alliances). Some associations are recorded through kin of the persons (e.g. writing the epitaph of someone's father), with the kin relations as edge properties.
+
+Only the persons that take part in some relation of the network are included; the few relations with the placeholder person 0 ("unknown"; e.g. 42 kinship and 297 association records in 2019) are left out. The offices, entries into government service, addresses, texts, institutions and the other data of the database are not included.
+
+The networks have the following properties:
+
+- `name`, `name_chn`: the name of the person, in transliteration (Pinyin) and in Chinese characters.
+- `person_id`: the identifier of the person in CBDB (`c_personid`; e.g. `https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=<person_id>`).
+- `female`: whether the person is a woman.
+- `birth_year`, `death_year`: the years of birth and death (0 if unknown).
+- `index_year`: the index year of the person (an estimate of the year in which the person was 60, used to order persons in time; 0 if unknown).
+- `dynasty`: the dynasty of the person, or empty.
+- Edge `code`: the code of the kinship relation (`KINSHIP_CODES`) or of the association (`ASSOC_CODES`).
+- Edge `relation`, `relation_chn`: the relation, in English and Chinese.
+- Edge `source`: the identifier of the text that is the source of the record (in the `TEXT_CODES` of CBDB; 0 if not given).
+- Edge `first_year`, `last_year` (associations): the first and last years of the association (0 if unknown; older releases (e.g. 2019), which record a single year, give it as both).
+- Edge `count` (associations): the number of instances of the association (e.g. letters; 0 if not given).
+- Edge `kin_id`, `kin_relation` (associations): the kin of the first person through which the association is recorded and its kinship relation (0 and empty if none), and `assoc_kin_id`, `assoc_kin_relation`, the same for the second person.
+- Graph property `release`: the date of the release (YYYY-MM-DD)."""
+tags = ['Social', 'Offline', 'Relationships', 'Multigraph', 'Metadata']
+url = ['https://cbdb.hsites.harvard.edu/', 'https://huggingface.co/datasets/cbdb/cbdb-sqlite',
+       'https://github.com/cbdb-project/cbdb_sqlite']
+citation = [('Harvard University, Academia Sinica and Peking University, "China Biographical Database (CBDB)." (2019-2026)',
+             'https://cbdb.hsites.harvard.edu/')]
+icon_hash = None
+upstream_license = ('CC BY-NC-SA 4.0 for the data of the standalone release; CBDB Data Licensing Terms (from 2026-08-20) for the rest',
+                    'https://cbdb.hsites.harvard.edu/cbdb-data-licensing-terms')
+
+# (the Hugging Face dataset at the commit of 2026-10-24)
+upstream_prefix = 'https://huggingface.co/datasets/cbdb/cbdb-sqlite/resolve/1756586fc48018c3eb4d470cbee6508faabf83ae'
+files = ([(tuple(fs), f"kinship_{y}", None) for y, d, fs in RELEASES] +
+         [(tuple(fs), f"association_{y}", None) for y, d, fs in RELEASES])
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force, check=False)
+
+# For checks only: if set, only this many relations are read
+_check_rows = None
+
+def _extract_db(fnames, tmpdir):
+    """Extract the SQLite database (the largest .db/.sqlite/.sqlite3 member)
+    of the archive (zip, rar or 7z, possibly in volumes) to `tmpdir`, with
+    the 7z command line tool, and return its path."""
+    name = __name__.split('.')[-1]
+    if len(fnames) == 1:
+        path = f"cache/upstream/{name}/{fnames[0]}"
+    else:
+        # the volumes of a split archive (stored compressed), joined
+        path = os.path.join(tmpdir, "joined.7z")
+        with open(path, "wb") as out:
+            for fn in fnames:
+                with open_upstream_file(name, fn, "rb") as f:
+                    shutil.copyfileobj(f, out, 1 << 24)
+    listing = subprocess.run(["7z", "l", "-slt", path], capture_output=True,
+                             check=True).stdout.decode("utf8", "replace")
+    best = None
+    for block in listing.split("\n\n"):
+        m = re.search(r"^Path = (.*)$", block, re.M)
+        s = re.search(r"^Size = (\d+)$", block, re.M)
+        if m is None or s is None:
+            continue
+        if re.search(r"\.(db|sqlite|sqlite3)$", m.group(1), re.I):
+            if best is None or int(s.group(1)) > best[1]:
+                best = (m.group(1), int(s.group(1)))
+    if best is None:
+        raise ValueError(f"no SQLite database in {path}")
+    subprocess.run(["7z", "e", "-y", f"-o{tmpdir}", path, best[0]],
+                   capture_output=True, check=True)
+    if len(fnames) > 1:
+        os.remove(path)
+    return os.path.join(tmpdir, os.path.basename(best[0]))
+
+def _columns(db, t):
+    return {r[1] for r in db.execute(f"pragma table_info({t})")}
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    for y, rdate, fnames in RELEASES:
+        alts_ = [a for a in (f"kinship_{y}", f"association_{y}")
+                 if alts is None or a in alts]
+        if not alts_:
+            continue
+        os.makedirs("cache/temp", exist_ok=True)
+        with tempfile.TemporaryDirectory(dir="cache/temp") as tmpdir:
+            db = sqlite3.connect(f"file:{_extract_db(fnames, tmpdir)}?mode=ro",
+                                 uri=True)
+            dyn = dict(db.execute("select c_dy, c_dynasty from DYNASTIES"))
+            kincodes = {r[0]: (r[1] or "", r[2] or "") for r in
+                        db.execute("select c_kincode, c_kinrel, c_kinrel_chn"
+                                   " from KINSHIP_CODES")}
+            assoccodes = {r[0]: (r[1] or "", r[2] or "") for r in
+                          db.execute("select c_assoc_code, c_assoc_desc,"
+                                     " c_assoc_desc_chn from ASSOC_CODES")}
+            lim = "" if _check_rows is None else f" limit {int(_check_rows)}"
+            for alt in alts_:
+                if alt.startswith("kinship"):
+                    rows = db.execute("select c_personid, c_kin_id, c_kin_code,"
+                                      " c_source from KIN_DATA order by rowid"
+                                      + lim).fetchall()
+                else:
+                    cols = _columns(db, "ASSOC_DATA")
+                    # (older releases have a single year of the association)
+                    fy = ("c_assoc_first_year" if "c_assoc_first_year" in cols
+                          else "c_assoc_year")
+                    ly = ("c_assoc_last_year" if "c_assoc_last_year" in cols
+                          else "c_assoc_year")
+                    rows = db.execute(
+                        "select c_personid, c_assoc_id, c_assoc_code, c_source,"
+                        f" {fy}, {ly}, c_assoc_count,"
+                        " c_kin_id, c_kin_code, c_assoc_kin_id,"
+                        " c_assoc_kin_code from ASSOC_DATA order by rowid"
+                        + lim).fetchall()
+                # relations with the placeholder person 0 ("unknown") are
+                # left out
+                rows = [r for r in rows if (r[0] or 0) > 0 and (r[1] or 0) > 0]
+                ids = sorted({r[0] for r in rows} | {r[1] for r in rows})
+                vmap = {p: i for i, p in enumerate(ids)}
+                g = Graph(directed=True)
+                g.add_vertex(len(ids))
+                g.vp.name = g.new_vp("string")
+                g.vp.name_chn = g.new_vp("string")
+                g.vp.person_id = g.new_vp("int")
+                g.vp.female = g.new_vp("bool")
+                g.vp.birth_year = g.new_vp("int")
+                g.vp.death_year = g.new_vp("int")
+                g.vp.index_year = g.new_vp("int")
+                g.vp.dynasty = g.new_vp("string")
+                g.vp.person_id.a = ids
+                for r in db.execute("select c_personid, c_name, c_name_chn,"
+                                    " c_female, c_birthyear, c_deathyear,"
+                                    " c_index_year, c_dy from BIOG_MAIN"):
+                    v = vmap.get(r[0])
+                    if v is None:
+                        continue
+                    g.vp.name[v] = r[1] or ""
+                    g.vp.name_chn[v] = r[2] or ""
+                    g.vp.female[v] = bool(r[3])
+                    for k, x in zip(["birth_year", "death_year", "index_year"],
+                                    r[4:7]):
+                        try:
+                            g.vp[k][v] = int(x or 0)
+                        except ValueError:
+                            pass
+                    g.vp.dynasty[v] = dyn.get(r[7], "") or ""
+                g.ep.code = g.new_ep("int")
+                g.ep.relation = g.new_ep("string")
+                g.ep.relation_chn = g.new_ep("string")
+                g.ep.source = g.new_ep("int")
+                if alt.startswith("kinship"):
+                    g.add_edge_list([(vmap[r[0]], vmap[r[1]], r[2] or 0,
+                                      *kincodes.get(r[2], ("", "")), r[3] or 0)
+                                     for r in rows],
+                                    eprops=[g.ep.code, g.ep.relation,
+                                            g.ep.relation_chn, g.ep.source])
+                else:
+                    for k in ["first_year", "last_year", "count", "kin_id",
+                              "assoc_kin_id"]:
+                        g.ep[k] = g.new_ep("int")
+                    g.ep.kin_relation = g.new_ep("string")
+                    g.ep.assoc_kin_relation = g.new_ep("string")
+                    def num(x):
+                        try:
+                            return int(x or 0)
+                        except ValueError:
+                            return 0
+                    el = [(vmap[r[0]], vmap[r[1]], num(r[2]),
+                           *assoccodes.get(r[2], ("", "")), num(r[3]),
+                           num(r[4]), num(r[5]), num(r[6]), num(r[7]),
+                           kincodes.get(r[8], ("", ""))[0] if num(r[7]) > 0 else "",
+                           num(r[9]),
+                           kincodes.get(r[10], ("", ""))[0] if num(r[9]) > 0 else "")
+                          for r in rows]
+                    g.add_edge_list(el, eprops=[g.ep[k] for k in
+                                                ["code", "relation",
+                                                 "relation_chn", "source",
+                                                 "first_year", "last_year",
+                                                 "count", "kin_id",
+                                                 "kin_relation",
+                                                 "assoc_kin_id",
+                                                 "assoc_kin_relation"]])
+                g.gp.release = g.new_gp("string", rdate)
+                yield alt, g
+            db.close()