logo Netzschleuder network catalog, repository, and centrifuge

History of piano_codewords

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/piano_codewords/__init__.py b/entries/piano_codewords/__init__.py
index 2e57915..02562c8 100644
--- a/entries/piano_codewords/__init__.py
+++ b/entries/piano_codewords/__init__.py
@@ -32,7 +32,7 @@ The network has the following properties:
 tags = ['Informational', 'Weighted', 'Metadata']
 url = 'https://doi.org/10.17605/OSF.IO/JVZXG'
 citation = [('D. Park, J. Nam, J. Park, "Novelty and influence of creative works, and quantifying patterns of advances based on probabilistic references networks." EPJ Data Science 9, 2 (2020)', 'https://doi.org/10.1140/epjds/s13688-019-0214-8')]
-icon_hash = '5eb19e25e98a21e46c3b0b45'
+date_added = '2026-10-25'
 upstream_license = None
 upstream_prefix = 'https://osf.io/download'
 # total.gexf
[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/piano_codewords/__init__.py b/entries/piano_codewords/__init__.py
index cccaea4..2e57915 100644
--- a/entries/piano_codewords/__init__.py
+++ b/entries/piano_codewords/__init__.py
@@ -25,8 +25,10 @@ description = """A network of transitions between "codewords" (sets of simultane
 
 The network has the following properties:
 
-- Nodes: `name`, the node label in the source data, of the form "pitches-year"; `pitches`, the list of notes of the codeword, as MIDI note numbers (60 is the middle C); `year`, the year attached to the codeword in its label, which appears to be the year of the earliest work in which the codeword occurs (it ranges from 1703 to 1916).
-- Edges: `weight`, the number of occurrences of the transition."""
+- (Node) `name`: the node label in the source data, of the form "pitches-year".
+- (Node) `pitches`: the list of notes of the codeword, as MIDI note numbers (60 is the middle C).
+- (Node) `year`: the year attached to the codeword in its label, which appears to be the year of the earliest work in which the codeword occurs (it ranges from 1703 to 1916).
+- (Edge) `weight`: the number of occurrences of the transition."""
 tags = ['Informational', 'Weighted', 'Metadata']
 url = 'https://doi.org/10.17605/OSF.IO/JVZXG'
 citation = [('D. Park, J. Nam, J. Park, "Novelty and influence of creative works, and quantifying patterns of advances based on probabilistic references networks." EPJ Data Science 9, 2 (2020)', 'https://doi.org/10.1140/epjds/s13688-019-0214-8')]
[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/piano_codewords/__init__.py b/entries/piano_codewords/__init__.py
index 142264e..cccaea4 100644
--- a/entries/piano_codewords/__init__.py
+++ b/entries/piano_codewords/__init__.py
@@ -44,7 +44,6 @@ def fetch_upstream(force=False):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fnames, alt, fmt in files:
         if alts is not None and alt not in alts:
[entries] New entry: piano_codewords by Tiago de Paula Peixoto 4a92bc3
diff --git a/entries/piano_codewords/__init__.py b/entries/piano_codewords/__init__.py
new file mode 100644
index 0000000..142264e
--- /dev/null
+++ b/entries/piano_codewords/__init__.py
@@ -0,0 +1,71 @@
+#! /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 re
+
+title = "Classical piano codeword transitions (1703-1916)"
+description = """A network of transitions between "codewords" (sets of simultaneously played notes) in Western classical piano music of the common practice period, from Park, Nam and Park. The data consist of MIDI files of 900 piano works by 19 composers from the Baroque, Classical and Romantic periods (from J. S. Bach and G. F. Handel to M. Ravel), collected from the Kunst der Fuge and Classical Piano MIDI archives. The files were converted to MusicXML with MuseScore and "chordified" with the Music21 toolkit, which converts a score into a sequence of sets of simultaneously played notes (codewords), retaining octave and key information (tempo, rhythm, etc. are discarded). Each node is a codeword, and a directed edge goes from a codeword to the codeword that follows it in some work, weighted by the number of times this transition occurs in all works. Self-loops correspond to repeated codewords. This is the aggregated ("total") network of the source data; the separate networks of each work are not included.
+
+The network has the following properties:
+
+- Nodes: `name`, the node label in the source data, of the form "pitches-year"; `pitches`, the list of notes of the codeword, as MIDI note numbers (60 is the middle C); `year`, the year attached to the codeword in its label, which appears to be the year of the earliest work in which the codeword occurs (it ranges from 1703 to 1916).
+- Edges: `weight`, the number of occurrences of the transition."""
+tags = ['Informational', 'Weighted', 'Metadata']
+url = 'https://doi.org/10.17605/OSF.IO/JVZXG'
+citation = [('D. Park, J. Nam, J. Park, "Novelty and influence of creative works, and quantifying patterns of advances based on probabilistic references networks." EPJ Data Science 9, 2 (2020)', 'https://doi.org/10.1140/epjds/s13688-019-0214-8')]
+icon_hash = '5eb19e25e98a21e46c3b0b45'
+upstream_license = None
+upstream_prefix = 'https://osf.io/download'
+# total.gexf
+files = [('jpwtn', None, None)]
+
+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 fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        with open_upstream_file(name, fnames, "r") as f:
+            text = f.read()
+        # GEXF file written by NetworkX, without attributes; parsed directly
+        nodes = re.findall(r'<node id="([^"]*)"', text)
+        edges = re.findall(r'<edge id="\d+" source="([^"]*)" target="([^"]*)"(?: weight="([^"]*)")?',
+                           text)
+        idx = {n: i for i, n in enumerate(nodes)}
+        g = Graph(directed=True)
+        g.add_vertex(len(nodes))
+        g.ep.weight = g.new_ep("int")
+        g.add_edge_list([(idx[s], idx[t], int(float(w or 1))) for s, t, w in edges],
+                        eprops=[g.ep.weight])
+        g.vp.name = g.new_vp("string", vals=nodes)
+        g.vp.pitches = g.new_vp("vector<int>")
+        g.vp.year = g.new_vp("int")
+        for v, n in enumerate(nodes):
+            pitches, year = n.rsplit("-", 1)
+            g.vp.pitches[v] = [int(x) for x in pitches.split("|")]
+            g.vp.year[v] = int(year)
+        yield alt, g