History of world_languages
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/world_languages/__init__.py b/entries/world_languages/__init__.py
index 78e63bd..72852ec 100644
--- a/entries/world_languages/__init__.py
+++ b/entries/world_languages/__init__.py
@@ -33,7 +33,7 @@ The network has the following properties:
tags = ['Language', 'Unweighted', 'Metadata']
url = 'https://resourcewatch.org/data/explore/20662342-dcdd-4a42-9f58-bcc80217de71'
citation = [('University of Groningen, "World Languages." University of Groningen Open Data (2016), accessed through Resource Watch', 'https://resourcewatch.org/data/explore/20662342-dcdd-4a42-9f58-bcc80217de71')]
-icon_hash = None
+date_added = '2026-10-25'
upstream_license = ("Open, with attribution to CIA World Factbook, University of Groningen", "https://www.arcgis.com/home/item.html?id=5c6ec52c374249a781aede5802994c95")
upstream_prefix = 'https://wri-public-data.s3.amazonaws.com/resourcewatch'
files = [('soc_071_world_languages.zip:World_Languages.dbf', None, None)]
[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/world_languages/__init__.py b/entries/world_languages/__init__.py
index c5fb858..78e63bd 100644
--- a/entries/world_languages/__init__.py
+++ b/entries/world_languages/__init__.py
@@ -24,9 +24,12 @@ description = """A bipartite network of countries and territories and their offi
The network has the following properties:
-- Nodes: `name`, the name of the country or territory, or of the language; `is_language`, whether the node is a language (otherwise a country or territory).
-- Country nodes: `sovereignty`, the sovereign state the territory belongs to; `type`, the political status of the territory ("Sovereign country", "Country", "Dependency", "Disputed" or "Indeterminate"); `world_language`, the category of world language(s) among English, French, Arabic, Spanish, Portuguese, Chinese and Russian that are official in the country, as given in the source (e.g. "English_French", or "Other").
-- Edges: `rank`, the rank of the official language in the source (1, 2 or 3, for the first, second and third official language)."""
+- (Node) `name`: the name of the country or territory, or of the language.
+- (Node) `is_language`: whether the node is a language (otherwise a country or territory).
+- (Node) `sovereignty` (countries): the sovereign state the territory belongs to.
+- (Node) `type` (countries): the political status of the territory ("Sovereign country", "Country", "Dependency", "Disputed" or "Indeterminate").
+- (Node) `world_language` (countries): the category of world language(s) among English, French, Arabic, Spanish, Portuguese, Chinese and Russian that are official in the country, as given in the source (e.g. "English_French", or "Other").
+- (Edge) `rank`: the rank of the official language in the source (1, 2 or 3, for the first, second and third official language)."""
tags = ['Language', 'Unweighted', 'Metadata']
url = 'https://resourcewatch.org/data/explore/20662342-dcdd-4a42-9f58-bcc80217de71'
citation = [('University of Groningen, "World Languages." University of Groningen Open Data (2016), accessed through Resource Watch', 'https://resourcewatch.org/data/explore/20662342-dcdd-4a42-9f58-bcc80217de71')]
[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/world_languages/__init__.py b/entries/world_languages/__init__.py
index 92403fc..c5fb858 100644
--- a/entries/world_languages/__init__.py
+++ b/entries/world_languages/__init__.py
@@ -66,7 +66,6 @@ def read_dbf(f):
@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: world_languages 6cc9e0d
diff --git a/entries/world_languages/__init__.py b/entries/world_languages/__init__.py
new file mode 100644
index 0000000..92403fc
--- /dev/null
+++ b/entries/world_languages/__init__.py
@@ -0,0 +1,108 @@
+#! /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 struct
+
+title = "Official languages of the world's countries (2015)"
+description = """A bipartite network of countries and territories and their official languages, from the "World Languages" dataset of the University of Groningen, compiled from the CIA World Factbook of 2015 and distributed by Resource Watch (dataset soc.071). An official language is a language given a special legal status in a country and used in administrative settings by its government. The data list up to three official languages for each of 234 countries, dependencies and other territories; each country is connected to its first, second and third official languages, when present. Some language entries are generic designations, e.g. "Indigenous", "Creole" or "Regional Chinese".
+
+The network has the following properties:
+
+- Nodes: `name`, the name of the country or territory, or of the language; `is_language`, whether the node is a language (otherwise a country or territory).
+- Country nodes: `sovereignty`, the sovereign state the territory belongs to; `type`, the political status of the territory ("Sovereign country", "Country", "Dependency", "Disputed" or "Indeterminate"); `world_language`, the category of world language(s) among English, French, Arabic, Spanish, Portuguese, Chinese and Russian that are official in the country, as given in the source (e.g. "English_French", or "Other").
+- Edges: `rank`, the rank of the official language in the source (1, 2 or 3, for the first, second and third official language)."""
+tags = ['Language', 'Unweighted', 'Metadata']
+url = 'https://resourcewatch.org/data/explore/20662342-dcdd-4a42-9f58-bcc80217de71'
+citation = [('University of Groningen, "World Languages." University of Groningen Open Data (2016), accessed through Resource Watch', 'https://resourcewatch.org/data/explore/20662342-dcdd-4a42-9f58-bcc80217de71')]
+icon_hash = None
+upstream_license = ("Open, with attribution to CIA World Factbook, University of Groningen", "https://www.arcgis.com/home/item.html?id=5c6ec52c374249a781aede5802994c95")
+upstream_prefix = 'https://wri-public-data.s3.amazonaws.com/resourcewatch'
+files = [('soc_071_world_languages.zip:World_Languages.dbf', None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+def read_dbf(f):
+ """Read the records of a dBase (DBF) file, as a list of dicts of strings."""
+ data = f.read()
+ n, hlen, rlen = struct.unpack("<IHH", data[4:12])
+ fields = []
+ pos = 32
+ while data[pos] != 0x0D:
+ d = data[pos:pos + 32]
+ fields.append((d[:11].split(b"\0")[0].decode(), d[16]))
+ pos += 32
+ rows = []
+ for i in range(n):
+ r = data[hlen + i * rlen: hlen + (i + 1) * rlen]
+ if r[0:1] == b"*": # deleted record
+ continue
+ p = 1
+ row = {}
+ for fname, l in fields:
+ row[fname] = r[p:p + l].decode("utf8").strip()
+ p += l
+ rows.append(row)
+ return rows
+
+@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]
+
+ rows = read_dbf(fs[0])
+
+ g = Graph(directed=False)
+ g.vp.name = g.new_vp("string")
+ g.vp.is_language = g.new_vp("bool")
+ g.vp.sovereignty = g.new_vp("string")
+ g.vp.type = g.new_vp("string")
+ g.vp.world_language = g.new_vp("string")
+ g.ep.rank = g.new_ep("int")
+ g.add_vertex(len(rows))
+ for v, r in enumerate(rows):
+ g.vp.name[v] = r["COUNTRY"]
+ g.vp.sovereignty[v] = r["SOVEREIGNT"]
+ g.vp.type[v] = r["TYPE_"]
+ g.vp.world_language[v] = r["WORLD_LANG"]
+ langs = {}
+ for v, r in enumerate(rows):
+ for rank, k in enumerate(["FIRST_OFFI", "SECOND_OFF",
+ "THIRD_OFFI"]):
+ l = r[k]
+ if l == "":
+ continue
+ u = langs.get(l)
+ if u is None:
+ u = langs[l] = g.add_vertex()
+ g.vp.name[u] = l
+ g.vp.is_language[u] = True
+ e = g.add_edge(v, u)
+ g.ep.rank[e] = rank + 1
+ yield alt, g