logo Netzschleuder network catalog, repository, and centrifuge

History of charnet

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] Remove superfluous details of the upstream distribution from the descriptions by Tiago de Paula Peixoto dc07aa0
The descriptions mentioned incidental details of how the upstream data
are made available: the file formats (CSV, JSON, XML, GEXF, SBML, HIF,
Pajek, UCINET, ...), file names, where the files were published or
obtained from (Zenodo, figshare, Kaggle, the Pajek datasets page, the
Internet Archive), and that some networks are only available in the gt
format. These are left out; caveats about the data themselves are kept,
referring to "the data" instead of "the file". The description of
sp_baboons now lists its properties instead of the upstream columns,
and says that events without a recipient are left out.
diff --git a/entries/charnet/__init__.py b/entries/charnet/__init__.py
index a4c4e21..d15ef80 100644
--- a/entries/charnet/__init__.py
+++ b/entries/charnet/__init__.py
@@ -22,7 +22,7 @@ import io
 import itertools
 
 title = "Character encounter networks of books (CharNet, 2017)"
-description = """Networks of encounters among the characters of twelve books of different genres (fiction, legendary texts, biographies), from the CharNet project of A. J. Holanda and collaborators. Nodes are characters (sometimes a group of people acting as a character, such as "the Thessalians"), and an undirected edge connects two characters who meet in the book, i.e., who take part together in at least one encounter; edges are weighted by the number of encounters in which both take part. The encounters were annotated manually, chapter by chapter, as groups of characters who interact in a part of the book, following the format of the character data of D. E. Knuth's Stanford GraphBase, from which the data for two of the books are taken. Characters listed in a book's data file but without any encounter appear as isolated nodes. The networks are:
+description = """Networks of encounters among the characters of twelve books of different genres (fiction, legendary texts, biographies), from the CharNet project of A. J. Holanda and collaborators. Nodes are characters (sometimes a group of people acting as a character, such as "the Thessalians"), and an undirected edge connects two characters who meet in the book, i.e., who take part together in at least one encounter; edges are weighted by the number of encounters in which both take part. The encounters were annotated manually, chapter by chapter, as groups of characters who interact in a part of the book, following the format of the character data of D. E. Knuth's Stanford GraphBase, from which the data for two of the books are taken. Characters listed in a book's data but without any encounter appear as isolated nodes. The networks are:
 
 - `acts`: the Acts of the Apostles (Bible).
 - `luke`: the Gospel of Luke (Bible).
@@ -39,7 +39,7 @@ description = """Networks of encounters among the characters of twelve books of
 
 The networks have the following properties:
 
-- (Node) `code`: the two-letter label of the character in the source files.
+- (Node) `code`: the two-letter label of the character in the source data.
 - (Node) `name`: its name or description (e.g. "Gandalf", "Aunt Polly, aunt who raises TS").
 - (Edge) `weight`: the number of encounters in which both characters take part.[^icon].
 
[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/charnet/__init__.py b/entries/charnet/__init__.py
index b4e8773..a4c4e21 100644
--- a/entries/charnet/__init__.py
+++ b/entries/charnet/__init__.py
@@ -48,7 +48,7 @@ tags = ['Social', 'Fictional', 'Weighted', 'Metadata']
 url = 'https://ajholanda.github.io/charnet/'
 citation = [('A. J. Holanda, M. Matias, S. M. S. P. Ferreira, G. M. L. Benevides, O. Kinouchi, "Character networks and book genre classification." International Journal of Modern Physics C 30(08), 1950058 (2019)', 'https://doi.org/10.1142/S012918311950058X'),
             ('D. E. Knuth, "The Stanford GraphBase: A Platform for Combinatorial Computing." Addison-Wesley, Reading, MA (1993)', 'https://www-cs-faculty.stanford.edu/~knuth/sgb.html')]
-icon_hash = '592de3cc67ec90f1500d4e40'
+date_added = '2026-10-25'
 upstream_license = ("GNU General Public License v2.0 (GPL-2.0)",
                     "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html")
 upstream_prefix = 'https://raw.githubusercontent.com/ajholanda/charnet/015cd83193803848353000436ef05fa2e5a5ef51'
[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/charnet/__init__.py b/entries/charnet/__init__.py
index e4d6973..b4e8773 100644
--- a/entries/charnet/__init__.py
+++ b/entries/charnet/__init__.py
@@ -39,8 +39,9 @@ description = """Networks of encounters among the characters of twelve books of
 
 The networks have the following properties:
 
-- Nodes: `code`, the two-letter label of the character in the source files; `name`, its name or description (e.g. "Gandalf", "Aunt Polly, aunt who raises TS").
-- Edges: `weight`, the number of encounters in which both characters take part.[^icon]
+- (Node) `code`: the two-letter label of the character in the source files.
+- (Node) `name`: its name or description (e.g. "Gandalf", "Aunt Polly, aunt who raises TS").
+- (Edge) `weight`: the number of encounters in which both characters take part.[^icon].
 
 [^icon]: Description obtained in part from the [ICON](https://icon.colorado.edu) project."""
 tags = ['Social', 'Fictional', 'Weighted', 'Metadata']
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 2c69f19
Unneeded "global files" statements, unused imports and variables,
f-strings without placeholders, duplicate keys in foodweb_little_rock
(keeping the order and the values used), and the second definition of
get_lines() in twitter_higgs. Nothing changes in the networks or
descriptions.

Changed: none
diff --git a/entries/charnet/__init__.py b/entries/charnet/__init__.py
index 2f28b37..e4d6973 100644
--- a/entries/charnet/__init__.py
+++ b/entries/charnet/__init__.py
@@ -65,7 +65,6 @@ def fetch_upstream(force=False):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fname, alt, fmt in files:
         if alts is not None and alt not in alts:
[entries] New entry: charnet by Tiago de Paula Peixoto 8500750
diff --git a/entries/charnet/__init__.py b/entries/charnet/__init__.py
new file mode 100644
index 0000000..2f28b37
--- /dev/null
+++ b/entries/charnet/__init__.py
@@ -0,0 +1,102 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-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/>.
+
+
+from .. import *
+import io
+import itertools
+
+title = "Character encounter networks of books (CharNet, 2017)"
+description = """Networks of encounters among the characters of twelve books of different genres (fiction, legendary texts, biographies), from the CharNet project of A. J. Holanda and collaborators. Nodes are characters (sometimes a group of people acting as a character, such as "the Thessalians"), and an undirected edge connects two characters who meet in the book, i.e., who take part together in at least one encounter; edges are weighted by the number of encounters in which both take part. The encounters were annotated manually, chapter by chapter, as groups of characters who interact in a part of the book, following the format of the character data of D. E. Knuth's Stanford GraphBase, from which the data for two of the books are taken. Characters listed in a book's data file but without any encounter appear as isolated nodes. The networks are:
+
+- `acts`: the Acts of the Apostles (Bible).
+- `luke`: the Gospel of Luke (Bible).
+- `apollonius`: "The Life of Apollonius of Tyana", by Flavius Philostratus (English translation by F. C. Conybeare).
+- `pythagoras`: "The Life of Pythagoras", by Iamblichus.
+- `arthur`: "The Winter King" (first volume of "The Warlord Chronicles"), by Bernard Cornwell.
+- `hobbit`: "The Hobbit", by J. R. R. Tolkien.
+- `tolkien`: "J. R. R. Tolkien", a biography by Michael White.
+- `newton`: "Isaac Newton", a biography by James Gleick.
+- `hawking`: a biography of Stephen Hawking ("The Theory of Everything").
+- `dick`: "A vida de Philip K. Dick" (a biography of Philip K. Dick), by Anthony Peake.
+- `david`: "David Copperfield", by Charles Dickens (from the Stanford GraphBase).
+- `huck`: "Huckleberry Finn", by Mark Twain (from the Stanford GraphBase).
+
+The networks have the following properties:
+
+- Nodes: `code`, the two-letter label of the character in the source files; `name`, its name or description (e.g. "Gandalf", "Aunt Polly, aunt who raises TS").
+- Edges: `weight`, the number of encounters in which both characters take part.[^icon]
+
+[^icon]: Description obtained in part from the [ICON](https://icon.colorado.edu) project."""
+tags = ['Social', 'Fictional', 'Weighted', 'Metadata']
+url = 'https://ajholanda.github.io/charnet/'
+citation = [('A. J. Holanda, M. Matias, S. M. S. P. Ferreira, G. M. L. Benevides, O. Kinouchi, "Character networks and book genre classification." International Journal of Modern Physics C 30(08), 1950058 (2019)', 'https://doi.org/10.1142/S012918311950058X'),
+            ('D. E. Knuth, "The Stanford GraphBase: A Platform for Combinatorial Computing." Addison-Wesley, Reading, MA (1993)', 'https://www-cs-faculty.stanford.edu/~knuth/sgb.html')]
+icon_hash = '592de3cc67ec90f1500d4e40'
+upstream_license = ("GNU General Public License v2.0 (GPL-2.0)",
+                    "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html")
+upstream_prefix = 'https://raw.githubusercontent.com/ajholanda/charnet/015cd83193803848353000436ef05fa2e5a5ef51'
+files = [(f'data/{b}.dat', b, None) for b in ['acts', 'luke', 'apollonius',
+                                             'pythagoras', 'arthur', 'hobbit',
+                                             'tolkien', 'newton', 'hawking',
+                                             'dick']] + \
+        [(f'sgb_data/{b}.dat', b, None) for b in ['david', 'huck']]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fname, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        chars = {}
+        names = []
+        weights = {}
+        with open_upstream_file(name, fname, "rb") as bf:
+            f = io.TextIOWrapper(bf, encoding="latin-1")
+            section = 0
+            for line in f:
+                line = line.rstrip("\r\n")
+                if line.startswith("*"):
+                    continue
+                if line.strip() == "":
+                    section = 1
+                    continue
+                if section == 0:
+                    chars[line[:2]] = len(names)
+                    names.append(line[3:].strip())
+                    continue
+                chapter, rest = line.split(":", 1)
+                for group in rest.split(";"):
+                    cs = sorted(set(chars[c] for c in group.split(",") if c))
+                    for u, v in itertools.combinations(cs, 2):
+                        weights[(u, v)] = weights.get((u, v), 0) + 1
+        g = Graph(directed=False)
+        g.add_vertex(len(names))
+        g.vp.code = g.new_vp("string", vals=list(chars.keys()))
+        g.vp.name = g.new_vp("string", vals=names)
+        g.ep.weight = g.new_ep("int")
+        g.add_edge_list([(u, v, w) for (u, v), w in weights.items()],
+                        eprops=[g.ep.weight])
+        yield alt, g