feat(Search): More flexible name search byCountry()
I find this library to be extremely useful, and grateful that I found it but I have a single suggestion.
Make the byCountry() function a bit more flexible by parsing both the input and the output by homologating both strings.
Ej.-
- Transform into all miniscule letters
- Trim extra spaces
- Maybe, add name variants for some countries EJ
- The United States of America
- United States of America
I would love to help implementing this new functionalities, if I may so :smile:
I have made a local branch where I added a function that uses regex and a couple of other methods to help out in making the byCountry() function a bit more flexible.
For example, all of the countries within this list now can be matched to their country:
let sampleCountries = ["The United States of America", " Qatar ", "Canada", "United Kingdom", "United States", "United States of America", "United Kingdom of Great Britain", " mexico", "jamaica ", "Republic of the Congo"];
If you agree, I could send a PR so you can review the proposed changes that were made in your code :smile:
Hi @IvanDLar great to hear you're finding the library useful!
Fuzzy matching on country name is not something I oppose, but it wasn't a usecase I had anticipated. I added more for completeness than for anything useful.
A challenge I see is that some countries (my own included!) have an official name, and another name that is more commonly used. For example "United Kingdom of Great Britain" could also be "Britain", "Great Britain", "UK" and some people would expect "England" as well. I don't have a data source for all of these variations, and it's not the intention of this library to fix that.
Curious to know your thoughts?
The python iso3166 module maintains an apolitical_name field that is quite useful in these contexts if you're looking for source/inspiration @IvanDLar