History of football_league_results
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/football_league_results/__init__.py b/entries/football_league_results/__init__.py
index 1fb3933..6bc2bb4 100644
--- a/entries/football_league_results/__init__.py
+++ b/entries/football_league_results/__init__.py
@@ -46,7 +46,7 @@ url = ['https://en.wikipedia.org/wiki/2016%E2%80%9317_Belgian_First_Division_A',
'https://en.wikipedia.org/wiki/2016%E2%80%9317_Ligue_1',
'https://en.wikipedia.org/wiki/2013%E2%80%9314_Premier_League']
citation = [('M. Fanuel, J. A. K. Suykens, "Deformed Laplacians and spectral ranking in directed networks." Applied and Computational Harmonic Analysis 47(2), 397-422 (2019)', 'https://doi.org/10.1016/j.acha.2017.09.002')]
-icon_hash = None
+date_added = '2026-10-27'
upstream_license = ("CC BY-SA 4.0", "https://creativecommons.org/licenses/by-sa/4.0/")
upstream_prefix = 'https://en.wikipedia.org/w'
# The wikitext of pinned revisions of the Wikipedia articles of the seasons
[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/football_league_results/__init__.py b/entries/football_league_results/__init__.py
index 512fe4d..1fb3933 100644
--- a/entries/football_league_results/__init__.py
+++ b/entries/football_league_results/__init__.py
@@ -35,11 +35,11 @@ The data are taken from pinned revisions of the Wikipedia articles "2016–17 Be
The networks have the following properties:
-- `name`: the name of the team.
-- `code`: the three-letter code of the team in the Wikipedia table.
-- Edge `home_goals`, `away_goals`: the goals scored by the home and the away team.
-- Edge `goal_difference`: the goals of the home team minus the goals of the away team.
-- Edge `note`: an annotation of the game in the source (empty for most games)."""
+- (Node) `name`: the name of the team.
+- (Node) `code`: the three-letter code of the team in the Wikipedia table.
+- (Edge) `home_goals`, `away_goals`: the goals scored by the home and the away team.
+- (Edge) `goal_difference`: the goals of the home team minus the goals of the away team.
+- (Edge) `note`: an annotation of the game in the source (empty for most games)."""
tags = ['Social', 'Offline', 'Sports', 'Signed', 'Weighted', 'Metadata']
url = ['https://en.wikipedia.org/wiki/2016%E2%80%9317_Belgian_First_Division_A',
'https://en.wikipedia.org/wiki/2016%E2%80%9317_Bundesliga',
[entries] Remove unneeded code from the entries 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/football_league_results/__init__.py b/entries/football_league_results/__init__.py
index 94c0e01..512fe4d 100644
--- a/entries/football_league_results/__init__.py
+++ b/entries/football_league_results/__init__.py
@@ -147,7 +147,6 @@ def read_results(text):
@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] Move contact, convote_mentions, douban, email_company, epinions, flixster, football_league_results, hyves, lastfm, libimseti, livemocha, reuters, sa_companies, sister_cities, tripadvisor_ratings, wikilens_ratings and wikipedia_discussions_de to their original sources 8f097de
These entries downloaded KONECT's copies of the data. They now download the original data (live, from pinned Wayback Machine snapshots, or by re-extracting from public dumps), gaining the metadata KONECT dropped (names, identifiers, timestamps, attributes), with descriptions and citations rewritten from the original sources and factual errors fixed (years and periods of contact, email_company, douban, flixster, libimseti, sa_companies; the rated objects of epinions; the sign of convote_mentions; songs merged by title alone in lastfm). New networks: the trust network of epinions, the links of wikilens_ratings, the JSON crawl of tripadvisor_ratings, and current versions of sister_cities and wikipedia_discussions_de next to the ones KONECT used. asu_social_networks only loses its mention of KONECT. Changed: upstream contact convote_mentions douban email_company epinions flixster football_league_results hyves lastfm libimseti livemocha reuters sa_companies sister_cities tripadvisor_ratings wikilens_ratings wikipedia_discussions_de
diff --git a/entries/football_league_results/__init__.py b/entries/football_league_results/__init__.py
index 5138d98..94c0e01 100644
--- a/entries/football_league_results/__init__.py
+++ b/entries/football_league_results/__init__.py
@@ -16,41 +16,132 @@
# 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 = 'Football league results (2013-2017)'
-description = """Results of the games of four national football (soccer) leagues, one network per season, compiled by hand from Wikipedia by Fanuel and Suykens, as distributed by KONECT:
+description = """Results of the games of the regular seasons of four national football (soccer) leagues, one network per season, from the results tables of the Wikipedia articles on the seasons:
-- `be1_2016`: Belgian Pro League, season 2016/2017;
+- `be1_2016`: Belgian First Division A, season 2016/2017 (regular season, before the play-offs);
- `de1_2016`: German Bundesliga, season 2016/2017;
- `fr1_2016`: French Ligue 1, season 2016/2017;
- `uk1_2013`: English Premier League, season 2013/2014.
-Each node is a team, and a directed edge from team A to team B is a game that A played at home against B. The edges are signed by the goal difference (positive if the home team won, negative if it lost, zero for a draw); the scores of the games are not included. Only the games of the regular seasons are included (in `be1_2016`, 239 of the 240 games of the regular season; one is missing). The data identify the teams only by indices (their names are not included).
+Each node is a team, and a directed edge from team A to team B is the game that A played at home against B, so that every team played every other team once at home and once away. The edges carry the scores, and are signed by the goal difference (positive if the home team won, negative if it lost, zero for a draw).
+
+Two games have an annotation in the source, which is kept in the edge property `note`: in `be1_2016`, the game Charleroi–Standard Liège was stopped after 68 minutes because of crowd trouble, with Standard leading 3–1; the score was kept, but no points were awarded to either team. In `fr1_2016`, the game Bastia–Lyon was abandoned at half-time, with no score, when Bastia fans attacked the Lyon players, and was awarded 3–0 to Lyon, the score recorded here (as 0–3 for the home team).
+
+The data are taken from pinned revisions of the Wikipedia articles "2016–17 Belgian First Division A", "2016–17 Bundesliga", "2016–17 Ligue 1" and "2013–14 Premier League". The `uk1_2013` season was analyzed by Fanuel and Suykens.
The networks have the following properties:
-- Edge `goal_difference`: the goals of the home team minus the goals of the away team."""
-tags = ['Social', 'Offline', 'Sports', 'Signed', 'Weighted']
-url = ['http://konect.cc/networks/league-be1-2016', 'http://konect.cc/networks/league-de1-2016', 'http://konect.cc/networks/league-fr1-2016', 'http://konect.cc/networks/league-uk1-2013']
-citation = [('M. Fanuel, J. A. K. Suykens, "Deformed Laplacians and spectral ranking in directed networks." Applied and Computational Harmonic Analysis 47(2), 397-422 (2019)', 'https://doi.org/10.1016/j.acha.2017.09.002'),
- ('J. Kunegis, "KONECT -- The Koblenz Network Collection." Proceedings of the 22nd International Conference on World Wide Web Companion, 1343-1350 (2013)', 'https://doi.org/10.1145/2487788.2488173')]
+- `name`: the name of the team.
+- `code`: the three-letter code of the team in the Wikipedia table.
+- Edge `home_goals`, `away_goals`: the goals scored by the home and the away team.
+- Edge `goal_difference`: the goals of the home team minus the goals of the away team.
+- Edge `note`: an annotation of the game in the source (empty for most games)."""
+tags = ['Social', 'Offline', 'Sports', 'Signed', 'Weighted', 'Metadata']
+url = ['https://en.wikipedia.org/wiki/2016%E2%80%9317_Belgian_First_Division_A',
+ 'https://en.wikipedia.org/wiki/2016%E2%80%9317_Bundesliga',
+ 'https://en.wikipedia.org/wiki/2016%E2%80%9317_Ligue_1',
+ 'https://en.wikipedia.org/wiki/2013%E2%80%9314_Premier_League']
+citation = [('M. Fanuel, J. A. K. Suykens, "Deformed Laplacians and spectral ranking in directed networks." Applied and Computational Harmonic Analysis 47(2), 397-422 (2019)', 'https://doi.org/10.1016/j.acha.2017.09.002')]
icon_hash = None
-upstream_license = None
-upstream_prefix = 'http://konect.cc/files'
-files = [(f'download.tsv.league-{l}.tar.bz2', l.replace('-', '_'), 'konect')
- for l in ['be1-2016', 'de1-2016', 'fr1-2016', 'uk1-2013']]
-
-def postprocess(alt, g):
- g.ep.goal_difference = g.ep.weight.copy("int")
- del g.ep["weight"]
+upstream_license = ("CC BY-SA 4.0", "https://creativecommons.org/licenses/by-sa/4.0/")
+upstream_prefix = 'https://en.wikipedia.org/w'
+# The wikitext of pinned revisions of the Wikipedia articles of the seasons
+revisions = {'be1_2016': 1374899869, # 2016–17 Belgian First Division A
+ 'de1_2016': 1381750143, # 2016–17 Bundesliga
+ 'fr1_2016': 1379693119, # 2016–17 Ligue 1
+ 'uk1_2013': 1380562642} # 2013–14 Premier League
+files = [(f'{alt}.wikitext', alt, None) for alt in revisions]
+archived_urls = {f'{alt}.wikitext':
+ f'{upstream_prefix}/index.php?oldid={rev}&action=raw'
+ for alt, rev in revisions.items()}
def fetch_upstream(force=False):
- return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
- force)
+ return fetch_archived_files(__name__.split(".")[-1], archived_urls, force)
+
+def _split_top(s, sep="|"):
+ "Split s at the separators that are outside [[...]] and {{...}}."
+ parts, depth, cur, i = [], 0, [], 0
+ while i < len(s):
+ two = s[i:i + 2]
+ if two in ("[[", "{{"):
+ depth += 1; cur.append(two); i += 2; continue
+ if two in ("]]", "}}"):
+ depth -= 1; cur.append(two); i += 2; continue
+ if s[i] == sep and depth == 0:
+ parts.append("".join(cur)); cur = []
+ else:
+ cur.append(s[i])
+ i += 1
+ parts.append("".join(cur))
+ return parts
+
+def _strip(v):
+ "Remove comments, references and footnotes; keep the text of links."
+ v = re.sub(r"<!--.*?-->", "", v, flags=re.S)
+ v = re.sub(r"<ref[^>/]*/>", "", v)
+ v = re.sub(r"<ref[^>]*>.*?</ref>", "", v, flags=re.S)
+ # templates (footnotes such as {{efn|...}}, {{in lang|..}}), innermost first
+ while True:
+ w = re.sub(r"\{\{[^{}]*\}\}", "", v)
+ if w == v:
+ break
+ v = w
+ v = re.sub(r"\[\[(?:[^|\]]*\|)?([^\]]*)\]\]", r"\1", v)
+ return v.strip()
+
+def read_results(text):
+ """Parse the {{#invoke:Sports results|main ...}} module of the wikitext:
+ returns the team codes in order, their names, and the scores of the
+ matches as a dict (home, away) -> (home goals, away goals), with the raw
+ values."""
+ m = re.search(r"\{\{#invoke:\s*[Ss]ports results\s*\|\s*main", text)
+ start = m.start()
+ depth, i = 0, start
+ while True:
+ if text.startswith("{{", i):
+ depth += 1; i += 2
+ elif text.startswith("}}", i):
+ depth -= 1; i += 2
+ if depth == 0:
+ break
+ else:
+ i += 1
+ body = text[m.end():i - 2]
+ args = {}
+ for p in _split_top(body):
+ if "=" not in p:
+ continue
+ k, v = p.split("=", 1)
+ args[k.strip()] = v
+ teams = []
+ while f"team{len(teams) + 1}" in args:
+ teams.append(_strip(args[f"team{len(teams) + 1}"]))
+ names = {t: _strip(args[f"name_{t}"]) for t in teams}
+ matches = {}
+ for h in teams:
+ for a in teams:
+ v = args.get(f"match_{h}_{a}", "")
+ sv = _strip(v)
+ if sv == "":
+ continue
+ s = re.fullmatch(r"(\d+)\s*[–-]\s*(\d+)", sv)
+ assert s is not None, (h, a, sv)
+ # a note, as a separate argument or as a footnote of the score
+ note = args.get(f"match_{h}_{a}_note", "")
+ fn = re.search(r"\{\{\s*efn\s*\|", v)
+ if fn is not None:
+ note = _split_top(v[fn.end():])[-1]
+ note = note[:note.rfind("}}")]
+ matches[(h, a)] = (int(s.group(1)), int(s.group(2)), _strip(note))
+ unknown = [k for k in args if k.startswith("match_") and
+ not any(k in (f"match_{h}_{a}", f"match_{h}_{a}_note")
+ for h in teams for a in teams)]
+ assert not unknown, unknown
+ return teams, names, matches
@cache_network()
@coerce_props()
@@ -61,7 +152,21 @@ def parse(alts=None):
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:
- g = parse_graph([f], fmt, directed=None)
- postprocess(alt, g)
+ with open_upstream_file(name, fname, "r") as f:
+ teams, names, matches = read_results(f.read())
+ g = Graph(directed=True)
+ g.add_vertex(len(teams))
+ g.vp.name = g.new_vp("string", vals=[names[t] for t in teams])
+ g.vp.code = g.new_vp("string", vals=teams)
+ idx = {t: i for i, t in enumerate(teams)}
+ g.ep.home_goals = g.new_ep("int")
+ g.ep.away_goals = g.new_ep("int")
+ g.ep.goal_difference = g.new_ep("int")
+ g.ep.note = g.new_ep("string")
+ for (h, a), (x, y, note) in matches.items():
+ e = g.add_edge(idx[h], idx[a])
+ g.ep.home_goals[e] = x
+ g.ep.away_goals[e] = y
+ g.ep.goal_difference[e] = x - y
+ g.ep.note[e] = note
yield alt, g
[entries] New entry: football_league_results ef68eed
diff --git a/entries/football_league_results/__init__.py b/entries/football_league_results/__init__.py
new file mode 100644
index 0000000..5138d98
--- /dev/null
+++ b/entries/football_league_results/__init__.py
@@ -0,0 +1,67 @@
+#! /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/>.
+
+
+
+from .. import *
+
+
+title = 'Football league results (2013-2017)'
+description = """Results of the games of four national football (soccer) leagues, one network per season, compiled by hand from Wikipedia by Fanuel and Suykens, as distributed by KONECT:
+
+- `be1_2016`: Belgian Pro League, season 2016/2017;
+- `de1_2016`: German Bundesliga, season 2016/2017;
+- `fr1_2016`: French Ligue 1, season 2016/2017;
+- `uk1_2013`: English Premier League, season 2013/2014.
+
+Each node is a team, and a directed edge from team A to team B is a game that A played at home against B. The edges are signed by the goal difference (positive if the home team won, negative if it lost, zero for a draw); the scores of the games are not included. Only the games of the regular seasons are included (in `be1_2016`, 239 of the 240 games of the regular season; one is missing). The data identify the teams only by indices (their names are not included).
+
+The networks have the following properties:
+
+- Edge `goal_difference`: the goals of the home team minus the goals of the away team."""
+tags = ['Social', 'Offline', 'Sports', 'Signed', 'Weighted']
+url = ['http://konect.cc/networks/league-be1-2016', 'http://konect.cc/networks/league-de1-2016', 'http://konect.cc/networks/league-fr1-2016', 'http://konect.cc/networks/league-uk1-2013']
+citation = [('M. Fanuel, J. A. K. Suykens, "Deformed Laplacians and spectral ranking in directed networks." Applied and Computational Harmonic Analysis 47(2), 397-422 (2019)', 'https://doi.org/10.1016/j.acha.2017.09.002'),
+ ('J. Kunegis, "KONECT -- The Koblenz Network Collection." Proceedings of the 22nd International Conference on World Wide Web Companion, 1343-1350 (2013)', 'https://doi.org/10.1145/2487788.2488173')]
+icon_hash = None
+upstream_license = None
+upstream_prefix = 'http://konect.cc/files'
+files = [(f'download.tsv.league-{l}.tar.bz2', l.replace('-', '_'), 'konect')
+ for l in ['be1-2016', 'de1-2016', 'fr1-2016', 'uk1-2013']]
+
+def postprocess(alt, g):
+ g.ep.goal_difference = g.ep.weight.copy("int")
+ del g.ep["weight"]
+
+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
+ with open_upstream_file(name, fname, "rb") as f:
+ g = parse_graph([f], fmt, directed=None)
+ postprocess(alt, g)
+ yield alt, g