Comments (7)
Hi @zbrox, sorry I couldn't get back at you sooner. Yes this is exactly the implementation I was thinking about. For convenience, we could include a set of related functions:
flag() -> Option<Flag>
has_flag(flag: Flag) -> bool
is_fund() -> bool
is_superseded() -> bool
is_special() -> bool
latest() -> Self
which would return the Currency itself or its replacement if supersededfrom_country(country: Country) -> Option<Vec<Self>>
impl From<Country> for Currency {}
which would return the only unflagged Currency associated with the Country
Sounds good. We can probably start with the simpler flags like if it's a fund or a special currency.
from iso_currency.
Yeah, that is a good idea, it should have the inverse of used_by()
. from_country
seems straightforward enough.
What is your idea about reworking the source data to be able to implement guess_from_country
? Also wondering now, how many countries use more than one currency and do we have the data (without extra input, just the country itself) to decide which is the likely currency used in those cases?
from iso_currency.
Thanks for merging the PR and your being so reactive about this.
I had a deeper look into it. This is the current state of the internal dataset:
- 181 unique currencies
- 248 unique countries
- 14 currencies without country:
NAD
,XAG
,XAU
,XBA
,XBB
,XBC
,XBD
,XDR
,XPD
,XPT
,XSU
,XTS
,XUA
andXXX
. All of them seem to be funds/specials except for the Namibian dollarNAD
which looks like a missing mapping toNA
(probably stripped during data sanitation) - 17 currencies with more than 1 country:
ANG
,AUD
,CHF
,DKK
,EUR
,GBP
,ILS
,INR
,MAD
,NOK
,NZD
,USD
,XAF
,XCD
,XOF
,XPF
andZAR
- 20 countries with more than 1 currency:
BO
,CH
,CL
,CO
,CU
,MX
,SL
,US
,UY
andVE
- and those currencies are:
BOB
,BOV
,CHE
,CHW
,CLF
,CLP
,COP
,COU
,CUC
,CUP
,MXN
,MXV
,SLE
,SLL
,USD
USN
UYI
,UYU
,UYW
,VED
andVES
- and those currencies are:
Those last one are the one to tackle if we want to provide the "best guess".
Looking at them, it shouldn't be that hard as a human to decide but for the function would require to rework on the data.
A possible option would be to add a new flags
column that accepts a semicolon separated list of flags (which we could easily extendable in the future) among: special
, fund
, superseded
etc.
Those flags could also have their own column with a bool.
EDIT: Missed USD
and USN
both linked to US
from iso_currency.
Following up on this "flags" idea, we would have:
special
:XDR
,XSU
,XUA
,XBA
,XBB
,XBC
,XBD
,XTS
,XXX
,XAU
,XPD
,XPT
,XAG
(this is exhaustive from official "list-one"). Although they are always prefixed withX
it doesn't discriminate (XAF
andXOF
are "real" currencies).fund
:BOV
,CLF
,COU
,MXV
,CHW
,CHE
,USN
,UYI
andUYW
(this is exhaustive from official "list-two")superseded
:VED
(in favor ofVES
since 2018),CUC
(in favor ofCUP
since 2020),SLL
(in favor orSLE
since 2022) (this is from on my own research)deprecated
: this flag could be reserved for currencies of the "list-three" but supporting it is probably overkill and would require to rework on the data because some code get recycled
Then the 19 countries with more than 1 currency mentioned before correctly resolve to 1 currency that is neither special, a fund nor superseded.
from iso_currency.
Ok, when you said "rework" of the data I imagined you mean some complete restructuring but adding one more column would not be a big hassle. It would be nice to have some metadata like deprecated
and others you describe. And from your research it seems it should be a huge amount of effort to manually edit in the data in the tsv.
How do you see the serialization of those flags? An extra flag function on the Currency
enum returning some Flags
struct or something else?
from iso_currency.
Hi @zbrox, sorry I couldn't get back at you sooner. Yes this is exactly the implementation I was thinking about. For convenience, we could include a set of related functions:
flag() -> Option<Flag>
has_flag(flag: Flag) -> bool
is_fund() -> bool
is_superseded() -> bool
is_special() -> bool
latest() -> Self
which would return the Currency itself or its replacement if supersededfrom_country(country: Country) -> Option<Vec<Self>>
impl From<Country> for Currency {}
which would return the only unflagged Currency associated with the Country
from iso_currency.
Related Issues (14)
- Add data about centesimal symbols for every currency
- a more authoritative data source HOT 1
- Subunits fraction are not always correct HOT 2
- Missing currency: VES HOT 1
- Missing currency: SEL HOT 1
- Add data about English representations of some currency symbols
- Proposal: get Country from Currency HOT 2
- Proposal: add option to customize casing for de-/serialization when using "with-serde" HOT 2
- Add data about position of symbol (according to locale) when formatting HOT 1
- Maybe add data about alternative variants of the symbols
- Add serde support feature HOT 2
- Use iso_country in Currency::used_by HOT 9
- Maybe numeric currency codes should be strings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iso_currency.