Add Country demonym converter - #56
Open
LavX wants to merge 1 commit into
Open
Conversation
Convert between ISO 3166-1 alpha2 country codes and English demonyms:
>>> Country('FR').demonym
'French'
>>> Country.fromdemonym('French')
<Country [FR]>
Demonyms are not part of any ISO standard, so the data is generated from
the mledoze/countries dataset and bundled as data/countrydemonym.txt.
Nine demonyms are shared by more than one country (e.g. 'French' ->
FR/TF); reverse lookups resolve to a documented primary chosen by
population/common usage. Uninhabited Bouvet Island (BV) has no demonym.
Closes Diaoul#38
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.
Summary
Adds a country demonym converter (the part of #38 you approved: a
Countryfromdemonymconverter, without touchingLanguage.fromname).Change
CountryDemonymConverter(registered as the internaldemonymcountry converter), mirroringCountryNameConverter.data/countrydemonym.txt(alpha2;demonym), generated from the mledoze/countries dataset. Demonyms are not part of any ISO standard, hence an external source.French-> FR/TF,Dutch-> NL/BQ,American-> US/MP). Reverse lookups resolve to a documented primary chosen by population / common usage, kept inAMBIGUOUS_PRIMARYso the choices are visible and easy to adjust. All nine collisions are covered, soreverse()is deterministic.BV) has no demonym and is the only country without one.Forward
convert()covers 248/249 countries; reverse resolves all 239 distinct demonyms to a valid country.Closes #38