Repository navigation
Record a country on ctgov-officials and add ctgov-contacts - #1454
Merged
Merged
Conversation
An overall official takes the ISO code of the one country every site of its study is in, and none otherwise; the study's site contacts go in a sibling corpus, ctgov-contacts, each with its site's country. The registry's country names are mapped to ISO 3166-1 alpha-2 codes, and an unmapped name fails the fetch, naming it. Both corpora declare country as their group, so config_diff.py --group keeps one country, and a corpus fetched before the country is refused on load by a read version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the country change: a renamed "country" or "locations" key would have emptied every record's country without failing, since the corpus-key guard reaches only names. Both fetches now refuse a corpus holding no country, and one past a measured share of officials with no site or of records at a site stating no country; a country or role that is not text fails the fetch naming the study. The docs now give the contacts' repeat key as name, role, study and country, the precedence of the officials' site buckets, and where the counts are printed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
The five choices listed under "Choices the issue did not settle" are accepted as made (2026-11-18): central contacts left out, repeats within a study and country kept once, no country where any site states none, the four codes for names with no current ISO code, and a pass of the registry per corpus. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1451
What changed
ctgov-officialsrecords gaincountry: an ISO 3166-1 alpha-2 code. An official gets one only where every site of its study is in the same country. It is empty where the study lists no site, a site states no country, or the sites are in several countries. The affiliation text is not read.Source.group = "country", soconfig_diff.py diff --local ctgov-officials --group KRkeeps one country.snapshot.py --localstill reads the whole corpus, since it has no--group.New sibling corpus
ctgov-contacts(fetch_ctgov_contacts): the named contacts under each study's sites, each record holding name, role, study and the site's country, grouped the same way. It is a corpus of its own, so every count already quoted fromctgov-officialsstays true.CTGOV_COUNTRIESmaps all 226 country names the registry writes (/api/v2/stats/field/values?fields=LocationCountry, 2026-11-18) to codes. A name the map does not hold fails the fetch, naming the name and the study.Stale cache: a corpus fetched before this change, or read by another
CTGOV_READ_VERSION, is refused on load withfetch <source> --refresh. It is never read as "no country". The check is_pinnedonread_version, asjrc-namesdoes it.Gates against a moved key. Both fetches refuse a result where no record holds a country. They also refuse one past a measured share:
CTGOV_MAX_NO_SITE= 0.25;CTGOV_MAX_COUNTRYLESS= 0.01.A country or role that is not text fails the fetch, naming the study.
Docs: the module docstring,
meta.json's detail counts, tools/differential/README.md's "Local corpora" (both rows, the read-version paragraph and the--groupsentence), and the docstrings of config_diff.py, local_corpora.py, local_core.py and name_usage.py.Choices the issue did not settle (please check)
ctgov-contacts. They belong to no site, so they have no country of their own.ctgov-contactskeeps one record per name, role, study and country. A name listed again with the same role at another site of the same study in the same country is kept once and counted (repeated_in_study_and_country). Without this, multi-site studies would weight the counts.Kosovo→XK(user-assigned, in common use).Serbia and Montenegro→CS,Federal Republic of Yugoslavia→YU,Netherlands Antilles→AN(former codes, ISO 3166-3).PR,GU,RE, ...).Virgin Islands→VI: its sites are in Charlotte Amalie and Christiansted.Real re-fetch, 2026-11-18 (data as of 2026-11-18T10:00:05, 612,549 studies)
ctgov-officials: 539,368 officials (536,981 on 2026-10-21), 353,747 distinct names.Top 20 countries: US 163,648, CN 35,562, FR 25,140, CA 19,033, TR 18,690, GB 14,178, EG 13,073, DE 12,536, ES 11,681, IT 11,049, KR 9,556, DK 8,523, BR 7,462, NL 7,024, TW 6,610, CH 6,010, BE 5,667, PK 5,119, SE 5,080, IL 5,018.
ctgov-contacts: 522,688 contacts, 359,428 distinct names.Top 20 countries: US 133,648, CN 82,379, FR 49,143, IT 26,823, ES 19,484, CA 17,703, DE 17,379, GB 15,711, KR 10,974, TR 10,325, EG 9,202, NL 8,388, TW 7,456, BE 7,447, BR 6,836, AU 6,798, IL 6,496, CH 5,814, DK 5,737, JP 5,042.
config_diff.local_names(..., ["KR", "TR"])against the real corpora keeps 21,677 officials' names and 15,102 contacts' names.Verification
uv run pytestpasses: 49,920 passed.uv run mypyanduv run ruff checkare clean.--groupon both corpora.tools/differential/snapshot.jsonlis byte-identical. No parser code changed.Review aspects run
pr-review-toolkit's code-reviewer, silent-failure-hunter, pr-test-analyzer and comment-analyzer ran on the first commit. Their findings are fixed in 302fc9f:
name_usage.py's docstring;A second code-reviewer pass on the fix commit found no defects. It re-measured the gate shares across the whole registry (about 7.4% of studies with an official list no site), and its two nits are fixed in 00bb538.
🤖 Generated with Claude Code