Repository navigation
Sort country agency labels case-insensitively - #675
Sinkleberg wants to merge 4 commits into
Conversation
|
Thanks for your work! A brief look tells me this is in the right direction.
|
|
Thanks! The Greenland count check passed (5 expected, 5 found), and a one-country Snowman build generated all six pages. I added RDFLib to the spelling dictionary and excluded Python source alongside the other source files. The new CI runs are waiting for maintainer approval. |
|
Do we have some examples of the impact on the actual rendering? |
|
Yes — here's New Zealand's Non-Public Service departments group from a local render:
The same five agencies remain. The old query sorted only by type, so it didn't guarantee name order within the group. This adds that ordering; the layout stays the same. I rendered the existing agency-table template using captured Wikidata rows, with platform cells omitted. This wasn't a full-site build, and the sorting still isn't locale-aware. |
|
The New Zealand example is a great case for this change, thanks for finding it! |
|
I looked a bit closer now, and turning the labels into strings is redundant since they are already strings. So instead of: |
|
I checked this on WDQS and found one catch: For example: SELECT ?label WHERE {
VALUES ?label { "charlie" "Bravo"@de "delta"@en "alpha"@en }
} ORDER BY LCASE(?label)This returns I'd keep |
|
Ah, that's a good point! While removing the STR would give a way to spot missing labels in a language, arguably we should do that earlier and not in the published data. |
|
|
||
| Use `LCASE(STR(...))` when sorting labels so capitalization and language tags do not separate otherwise alphabetical names. Keep the existing type grouping and direction for the country. This is case-insensitive ordering, not language-specific collation. | ||
|
|
||
| To check the ordering offline with synthetic data, install [RDFLib](https://rdflib.readthedocs.io/) in a Python virtual environment (`python -m pip install "rdflib>=7.1,<8"`), then run `python scripts/tests/test-query-order.py` from the repository root. The tests check the country queries and the agency examples above without contacting Wikidata. |
There was a problem hiding this comment.
I don't understand this paragraph. What is the point of testing with synthetic data? Wouldn't it be better to test our actual queries?
I am also weary of adding a test with an external dependency. Can this not be done without calling an external library? (If not, we should also add explicit instructions on how to install something in a Python virtual environment, or we are really narrowing down who will be able to add a country.)
There was a problem hiding this comment.
The synthetic cases checked mixed-case and fallback-language labels, but that setup should not be part of adding a country. I removed the RDFLib test and its setup instructions. The guide now asks contributors to run their actual country query in WDQS and check the name and group order, with nothing to install.
| Note that one can test the query in the Wikidata Query Service. One can also find more examples of [country queries here](https://github.com/govdirectory/website/tree/main/queries). | ||
| Use `LCASE(STR(...))` when sorting labels so capitalization and language tags do not separate otherwise alphabetical names. Keep the existing type grouping and direction for the country. This is case-insensitive ordering, not language-specific collation. | ||
|
|
||
| Run your country query in the [Wikidata Query Service](https://query.wikidata.org/) and check that agency names appear in alphabetical order within each type group, ignoring capitalization. Check that the type groups still follow the intended order for the country. This uses the actual query results and requires no local installation. |
There was a problem hiding this comment.
| Run your country query in the [Wikidata Query Service](https://query.wikidata.org/) and check that agency names appear in alphabetical order within each type group, ignoring capitalization. Check that the type groups still follow the intended order for the country. This uses the actual query results and requires no local installation. | |
| Run your country query in the [Wikidata Query Service](https://query.wikidata.org/) and check that agency names appear in alphabetical order within each type group, ignoring capitalization. Check that the type groups still follow the intended order for the country. |
I don't think that part is necessary any longer.
There was a problem hiding this comment.
Removed that sentence, thanks.
Fixes #571.
Sort labels without capitalization or language tags changing their position in the list. This updates all 49 country and subcountry queries while keeping their existing type grouping and sort direction. It also replaces nine unused topic sort keys, adds the missing name sort to three queries, and updates both examples in the country guide.
The guide now asks contributors to check their actual country query in Wikidata Query Service. The standalone RDFLib test and its setup instructions have been removed following review; no new test dependency is needed.
Validation: earlier offline checks passed for the revised query clauses and failed on the original ones. A Greenland build generated six pages and its live expected-count check passed 5/5. A local agency-table render using captured New Zealand data confirms the visible ordering change; platform cells were omitted from that example. The queries have not changed since those checks.
No full-site build was run. This is case-insensitive sorting, not locale-specific collation.