History of wiki_categories
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/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 9ec240b..aa31718 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -33,7 +33,7 @@ The network has the following properties:
tags = ['Informational', 'Relatedness', 'Unweighted', 'Timestamps', 'Metadata']
url = 'https://dumps.wikimedia.org/'
citation = [('"Wikimedia Foundation. Wikimedia downloads."', 'https://dumps.wikimedia.org/')]
-icon_hash = '575b8753bd3e93b53c69562b'
+date_added = '2020-08-11'
upstream_license = ("Creative Commons Attribution-ShareAlike 4.0 (CC BY-SA 4.0) and GFDL",
"https://dumps.wikimedia.org/legal.html")
[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/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 7ec11ad..9ec240b 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -26,10 +26,10 @@ This network replaces an earlier version, of uncertain date, without node names,
The network has the following properties:
-- `name`: the article title, or the category name (without the "Category:" prefix).
-- `is_category`: whether the node is a category (otherwise it is an article).
-- `is_redirect`: whether the article is a redirect (false for categories).
-- Edge `time`: the time when the membership was last updated (Unix time, in seconds)."""
+- (Node) `name`: the article title, or the category name (without the "Category:" prefix).
+- (Node) `is_category`: whether the node is a category (otherwise it is an article).
+- (Node) `is_redirect`: whether the article is a redirect (false for categories).
+- (Edge) `time`: the time when the membership was last updated (Unix time, in seconds)."""
tags = ['Informational', 'Relatedness', 'Unweighted', 'Timestamps', 'Metadata']
url = 'https://dumps.wikimedia.org/'
citation = [('"Wikimedia Foundation. Wikimedia downloads."', 'https://dumps.wikimedia.org/')]
[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/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 087ab11..7ec11ad 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -114,7 +114,6 @@ def fetch_upstream(force=False):
@coerce_props(vforce={"name": "string"})
@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] Remove the mentions of KONECT from the descriptions of edit_wikibooks, edit_wikinews, edit_wikipedia, edit_wikiquote, edit_wiktionary, linux, prosper, reactome, unicodelang, wiki_categories, wiki_link_dyn, wikipedia_link and wordnet 2216557
These entries were originally taken from KONECT and now download their data from the original sources, so their descriptions no longer refer to KONECT.
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index cab6b58..087ab11 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -22,7 +22,7 @@ import re
title = "English Wikipedia article-category network (2026)"
description = """A bipartite network of the articles of the English Wikipedia and the categories they belong to, extracted from the Wikimedia database dumps of 1 October 2026 (tables `page`, `linktarget` and `categorylinks`). Nodes are articles (pages in the main namespace, including redirects that are categorized) and categories, and an edge connects an article to a category that the article is placed in, either directly in its wikitext or through a template. Only articles and categories with at least one such membership are included. Categories are identified by name, and include hidden maintenance categories (e.g. "Articles with short description") as well as categories without a description page. The memberships of categories in other categories (the category hierarchy), and of pages in other namespaces, are not included.
-This network replaces an earlier version distributed by KONECT, of uncertain date, without node names, and with 2,036,440 nodes and 3,795,796 edges.
+This network replaces an earlier version, of uncertain date, without node names, and with 2,036,440 nodes and 3,795,796 edges.
The network has the following properties:
[entries] Rebuild the Wikimedia and Stack Overflow entries from the original dumps b65b158
- edit_wikibooks, edit_wikinews, edit_wikiquote, edit_wiktionary, wikipedia_link, wiki_categories, wiki_link_dyn: from the Wikimedia dumps of 2026-10-01 (newer than KONECT's extractions), with page titles, user names (including unregistered editors, marked `anonymous`), timestamps and namespaces; the sister projects gain the language editions added since. - stackoverflow: from the Stack Exchange data dump of December 2011 (the one KONECT used), with KONECT's swapped sides corrected and user and question properties.
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index f9b3e61..cab6b58 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -17,23 +17,101 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
from .. import *
+import re
-title = "en-Wikipedia article-category network"
-description = """A bipartite network of English-language Wikipedia articles and the categories they belong to. The date of this snapshot is uncertain.[^icon]
-[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
-tags = ['Informational', 'Relatedness', 'Unweighted']
-url = 'http://konect.cc/networks/wiki-en-cat'
-citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'https://doi.org/10.1145/2487788.2488173')]
+title = "English Wikipedia article-category network (2026)"
+description = """A bipartite network of the articles of the English Wikipedia and the categories they belong to, extracted from the Wikimedia database dumps of 1 October 2026 (tables `page`, `linktarget` and `categorylinks`). Nodes are articles (pages in the main namespace, including redirects that are categorized) and categories, and an edge connects an article to a category that the article is placed in, either directly in its wikitext or through a template. Only articles and categories with at least one such membership are included. Categories are identified by name, and include hidden maintenance categories (e.g. "Articles with short description") as well as categories without a description page. The memberships of categories in other categories (the category hierarchy), and of pages in other namespaces, are not included.
+
+This network replaces an earlier version distributed by KONECT, of uncertain date, without node names, and with 2,036,440 nodes and 3,795,796 edges.
+
+The network has the following properties:
+
+- `name`: the article title, or the category name (without the "Category:" prefix).
+- `is_category`: whether the node is a category (otherwise it is an article).
+- `is_redirect`: whether the article is a redirect (false for categories).
+- Edge `time`: the time when the membership was last updated (Unix time, in seconds)."""
+tags = ['Informational', 'Relatedness', 'Unweighted', 'Timestamps', 'Metadata']
+url = 'https://dumps.wikimedia.org/'
+citation = [('"Wikimedia Foundation. Wikimedia downloads."', 'https://dumps.wikimedia.org/')]
icon_hash = '575b8753bd3e93b53c69562b'
-upstream_prefix = 'http://konect.cc/files'
-files = [('download.tsv.wiki-en-cat.tar.bz2', None, 'konect')]
+upstream_license = ("Creative Commons Attribution-ShareAlike 4.0 (CC BY-SA 4.0) and GFDL",
+ "https://dumps.wikimedia.org/legal.html")
+
+# Fixed dump date (see entries/edit_wikipedia)
+DUMP_DATE = "20261001"
+# Too large to process on an ordinary machine (see --skip-huge)
+huge = True
+upstream_prefix = 'https://dumps.wikimedia.org'
+files = [(sql_files("enwiki", ["page", "linktarget", "categorylinks"],
+ date=DUMP_DATE), None, None)]
+
+# categorylinks: cl_from, cl_sortkey, cl_timestamp, cl_sortkey_prefix,
+# cl_type, cl_collation_id, cl_target_id
+CATEGORYLINKS_RE = re.compile(rb"\((\d+),'(?:[^'\\]|\\.)*','([^']*)',"
+ rb"'(?:[^'\\]|\\.)*','(page|subcat|file)',"
+ rb"\d+,(\d+)\)", re.S)
+
+def parse_categories(f_page, f_linktarget, f_categorylinks):
+ page_ids, redirect, length, titles, index = read_pages(f_page)
+ del index, length
+ pidx = numpy.argsort(page_ids)
+ page_keys = page_ids[pidx]
+
+ # Category names, by link target id
+ cat_index = {}
+ cat_names = []
+ lt_ids, lt_cats = [], []
+ for m in sql_rows(f_linktarget, LINKTARGET_RE):
+ if int(m.group(2)) != 14:
+ continue
+ t = sql_unescape(m.group(3))
+ c = cat_index.get(t)
+ if c is None:
+ c = cat_index[t] = len(cat_names)
+ cat_names.append(t.decode("utf8", errors="replace").replace("_", " "))
+ lt_ids.append(int(m.group(1)))
+ lt_cats.append(c)
+ del cat_index
+ lt_ids = numpy.array(lt_ids, dtype="int64")
+ lt_cats = numpy.array(lt_cats, dtype="int64")
+ idx = numpy.argsort(lt_ids)
+ lt_ids, lt_cats = lt_ids[idx], lt_cats[idx]
+
+ e_from, e_target, e_time = [], [], []
+ for m in sql_rows(f_categorylinks, CATEGORYLINKS_RE):
+ if m.group(3) != b"page":
+ continue
+ e_from.append(int(m.group(1)))
+ e_target.append(int(m.group(4)))
+ e_time.append(wiki_time(m.group(2)))
+ a = lookup(page_keys, pidx, numpy.array(e_from, dtype="int64"))
+ c = lookup(lt_ids, lt_cats, numpy.array(e_target, dtype="int64"))
+ e_time = numpy.array(e_time, dtype="int64")
+ del e_from, e_target
+ ok = (a >= 0) & (c >= 0) # articles only
+ a, c, e_time = a[ok], c[ok], e_time[ok]
+
+ # Keep only the articles and categories with some membership
+ ua, a = numpy.unique(a, return_inverse=True)
+ uc, c = numpy.unique(c, return_inverse=True)
+ g = Graph(directed=False)
+ g.add_vertex(len(ua) + len(uc))
+ g.add_edge_list(numpy.column_stack((a, c + len(ua))))
+ g.ep.time = g.new_ep("int64_t", vals=e_time)
+ g.vp.name = g.new_vp("string", vals=[titles[i] for i in ua] +
+ [cat_names[i] for i in uc])
+ g.vp.is_category = g.new_vp("bool")
+ g.vp.is_category.a[len(ua):] = 1
+ g.vp.is_redirect = g.new_vp("bool")
+ g.vp.is_redirect.a[:len(ua)] = redirect[ua]
+ return g
def fetch_upstream(force=False):
return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
force)
@cache_network()
-@coerce_props()
+@coerce_props(vforce={"name": "string"})
@annotate()
def parse(alts=None):
global files
@@ -41,9 +119,8 @@ def parse(alts=None):
for fnames, alt, fmt in files:
if alts is not None and alt not in alts:
continue
- if isinstance(fnames, str):
- fnames = [fnames]
with ExitStack() as stack:
- fs = [stack.enter_context(open_upstream_file(name, fn, "rb")) for fn in fnames]
- g = parse_graph(fs, fmt, directed=False)
+ fs = [stack.enter_context(open_upstream_file(name, fn, "rb"))
+ for fn in fnames]
+ g = parse_categories(*fs)
yield alt, g
Update copyright information 73a4f0d
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 771d534..f9b3e61 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2024 Tiago de Paula Peixoto <tiago@skewed.de>
+# 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
Update copyright information 3d288ea
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 42b7694..771d534 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2023 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2024 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
Update copyright information 8d005ae
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index b75b558..42b7694 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2021 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2023 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
Update copyright info db2efcc
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index f7db5d1..b75b558 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2021 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
Un-orphan KONECT datasets 894eba5
KONECT has been brought back from the dead for the time being.
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index e031f0f..f7db5d1 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -26,7 +26,6 @@ url = 'http://konect.cc/networks/wiki-en-cat'
citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'https://doi.org/10.1145/2487788.2488173')]
icon_hash = '575b8753bd3e93b53c69562b'
upstream_prefix = 'http://konect.cc/files'
-orphan = True
files = [('download.tsv.wiki-en-cat.tar.bz2', None, 'konect')]
def fetch_upstream(force=False):
Update citations to use DOIs e878874
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 68d2ac1..e031f0f 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -23,7 +23,7 @@ description = """A bipartite network of English-language Wikipedia articles and
[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
tags = ['Informational', 'Relatedness', 'Unweighted']
url = 'http://konect.cc/networks/wiki-en-cat'
-citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'http://konect.cc/')]
+citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'https://doi.org/10.1145/2487788.2488173')]
icon_hash = '575b8753bd3e93b53c69562b'
upstream_prefix = 'http://konect.cc/files'
orphan = True
Add support for 'orphan' datasets and tag konect entries e330b80
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 8219861..68d2ac1 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -26,6 +26,7 @@ url = 'http://konect.cc/networks/wiki-en-cat'
citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'http://konect.cc/')]
icon_hash = '575b8753bd3e93b53c69562b'
upstream_prefix = 'http://konect.cc/files'
+orphan = True
files = [('download.tsv.wiki-en-cat.tar.bz2', None, 'konect')]
def fetch_upstream(force=False):
Change license from GPLv3 to AGPLv3 d754be5
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 9b2412d..8219861 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -3,18 +3,18 @@
#
# Copyright (C) 2020 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 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 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 General Public License for more details.
+# 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 General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# 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 *
Add explicit attribution to descriptions obtained from ICON 1645314
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
index 232e51d..9b2412d 100644
--- a/entries/wiki_categories/__init__.py
+++ b/entries/wiki_categories/__init__.py
@@ -19,7 +19,8 @@
from .. import *
title = "en-Wikipedia article-category network"
-description = "A bipartite network of English-language Wikipedia articles and the categories they belong to. The date of this snapshot is uncertain."
+description = """A bipartite network of English-language Wikipedia articles and the categories they belong to. The date of this snapshot is uncertain.[^icon]
+[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
tags = ['Informational', 'Relatedness', 'Unweighted']
url = 'http://konect.cc/networks/wiki-en-cat'
citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'http://konect.cc/')]
Initial commit cc85872
diff --git a/entries/wiki_categories/__init__.py b/entries/wiki_categories/__init__.py
new file mode 100644
index 0000000..232e51d
--- /dev/null
+++ b/entries/wiki_categories/__init__.py
@@ -0,0 +1,48 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+title = "en-Wikipedia article-category network"
+description = "A bipartite network of English-language Wikipedia articles and the categories they belong to. The date of this snapshot is uncertain."
+tags = ['Informational', 'Relatedness', 'Unweighted']
+url = 'http://konect.cc/networks/wiki-en-cat'
+citation = [('J. Kunegis, "Wikipedia (en) network dataset." KONECT, the Koblenz Network Collection (2016)', 'http://konect.cc/')]
+icon_hash = '575b8753bd3e93b53c69562b'
+upstream_prefix = 'http://konect.cc/files'
+files = [('download.tsv.wiki-en-cat.tar.bz2', None, 'konect')]
+
+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
+ if isinstance(fnames, str):
+ fnames = [fnames]
+ with ExitStack() as stack:
+ fs = [stack.enter_context(open_upstream_file(name, fn, "rb")) for fn in fnames]
+ g = parse_graph(fs, fmt, directed=False)
+ yield alt, g