Skip to content

Add five parliaments and Malaysia's election candidates to the local corpora - #1472

Merged
derek73 merged 3 commits into
masterfrom
feat/local-corpora-my-pk-eg-so
Nov 19, 2026
Merged

derek73 merged 3 commits into
masterfrom
feat/local-corpora-my-pk-eg-so

Conversation

@derek73

@derek73 derek73 commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Adds the sources the 3.2 research round (#1465) found worth keeping as local corpora. No file under nameparser/ changes and no parse moves: tools/differential/snapshot.jsonl is byte-identical.

opensanctions-parliaments: five more chambers

local_parliaments.DATASETS gains my_parliament, pk_na_members, pk_senate_members, eg_house_representatives and so_house_people: twenty-eight national chambers plus Indonesia's 2018 regional heads (29 datasets). Each export has the columns the loader reads (id, schema, name, aliases), and before adding them each was read through the unchanged _read. Every row is a Person, with no malformed rows and no foreign separators.

Dataset Members Spellings What the aliases hold
my_parliament 276 292 16 aliases writing the bin or a/l the name leaves out
pk_na_members 332 332 none
pk_senate_members 95 95 none
eg_house_representatives 594 1,182 Arabic script; 588 written twice, a short name and the full chain of names
so_house_people 275 310 35 aliases with a nickname in brackets

As fetched on 2026-11-19, the whole corpus holds 20,856 members, 26,515 spellings and 26,400 distinct names. Licence: CC BY-NC 4.0, crediting OpenSanctions, the same as the datasets already there.

my-candidates: a new local corpus

tools/differential/local_mycandidates.py reads Malaysia's candidates from Thevesh Theva's analysis-election-msia: data/candidates_ge12.csv to candidates_ge15.csv and candidates_prn15.csv. The fetch is pinned to commit b20331b0 (the repository's last, 2023-08-13), with a sha256 for each file.

Which column is read. GE12 to GE14 have one name column, the ballot name. GE15's name is the full name recased into title case by the repository's author. The capitals it came from are not in the file, so only name_display (the ballot name, in capitals) is read. PRN15 writes both of its columns in capitals, so name_ballot and name are read, as the forms ballot and full.

What a record is. One distinct spelling within an election and ethnicity, with election, form and ethnicity. ethnicity is the Source.group, so config_diff.py --group chinese works. The general elections write bumiputera, which takes in Sabah's and Sarawak's peoples; PRN15's peninsular states write malay.

Size as fetched on 2026-11-19. 3,261 rows gave 3,683 spellings (3,260 ballot, 423 full) and 3,077 distinct names.

What it measures. BIN, BINTI, B. and BT (#1467); A/L, A/P and ANAK (#1468); the @ alias (#1164); MD; honorific heads such as USTAZ and CIKGU (#1179); Chinese names written family first (#1183).

Licence. GPL-3.0. The data is cached only, never committed or shipped, and the README row says so. shipped-data-licences covers shipped data only, so nothing is recorded there.

Refusals. A fetch refuses a file other than the pinned one (retried first). It then refuses another header, a body that does not end with a line break or whose last row is short (each arm tested), another row count, and rows of another width or with an empty name past their shares. Each share is tested at its shipped 1/100: accepted at 1 of 100 rows, refused at 2. The corpus is not fielded, so it is read through snapshot.py --local, not local_agreement.py.

Docs. The new source has a row and a paragraph in tools/differential/README.md, and is added to its other corpus lists and to config_diff.py's group lists and help. In root AGENTS.md, the opensanctions-parliaments paragraph gains a newly dated figure (the older dated ones are kept), and "Validating a new parsing rule" gains a sentence saying which changes read my-candidates.

Verified

  • uv run pytest: 50,421 passed. uv run pytest -n0 -m serial: 38 passed. uv run mypy and uv run ruff check are clean. Each new test passes alone with -n0.
  • Mutations: with the no-closing-line-break arm off, the short-last-row arm off, the dedupe off, or MY_MAX_BAD raised, a test fails each time. Counting nameless per cell (the pre-fix form) fails the new per-row test.
  • Tests plant their corpus through own_cache. The shared cache was written only by the intended real fetch of both corpora (my-candidates <1s, opensanctions-parliaments 49s).
  • No shared snapshot was re-recorded. Neither corpus had one before (the parliaments directory held baselines only), and none was recorded here.

Review

PR review toolkit aspects run:

  • code review, covering code, tests, comments and silent failures in one pass. It found a mypy invariance error in the test helper, a README sentence pointing at the wrong fetch, three lists of grouped corpora missing the new one, bumiputera labelled as Malay, and the nameless share counted per cell where the docs say per row. All were fixed in the second commit.
  • review of the fix commit. It found one more --group list (the help text) and a wrong "family last" note on the one mixed-case record. Both were fixed in the third commit.

Type-design review does not apply: the only new type is a frozen record of pins.

Refers to #1465, which stays open.

🤖 Generated with Claude Code

derek73 and others added 3 commits November 19, 2026 02:34
…corpora

opensanctions-parliaments reads Malaysia's Dewan Rakyat, Pakistan's National
Assembly and Senate, Egypt's House of Representatives and Somalia's House of
the People beside its twenty-three chambers. A new local corpus,
my-candidates, reads Malaysia's GE12-GE15 and 2023 state-election candidates
from five pinned CSVs, grouped by ethnicity (#1465).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@derek73 derek73 added this to the 3.2 milestone Nov 19, 2026
@derek73 derek73 self-assigned this Nov 19, 2026
@derek73
derek73 merged commit a6198e5 into master Nov 19, 2026
14 checks passed
@derek73
derek73 deleted the feat/local-corpora-my-pk-eg-so branch November 19, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant