Giter Site home page Giter Site logo

Comments (7)

zbrox avatar zbrox commented on July 27, 2024 1

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 superseded
  • from_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.

zbrox avatar zbrox commented on July 27, 2024

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.

b4D8 avatar b4D8 commented on July 27, 2024

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 and XXX. All of them seem to be funds/specials except for the Namibian dollar NADwhich looks like a missing mapping to NA (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 and ZAR
  • 20 countries with more than 1 currency: BO, CH, CL, CO, CU, MX, SL, US, UY and VE
    • and those currencies are: BOB, BOV, CHE, CHW, CLF, CLP, COP, COU, CUC, CUP, MXN, MXV, SLE, SLL, USD USN UYI, UYU, UYW, VED and VES

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.

b4D8 avatar b4D8 commented on July 27, 2024

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 with X it doesn't discriminate (XAF and XOF are "real" currencies).
  • fund: BOV, CLF, COU, MXV, CHW, CHE, USN, UYI and UYW (this is exhaustive from official "list-two")
  • superseded: VED (in favor of VES since 2018), CUC (in favor of CUP since 2020), SLL (in favor or SLE 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.

zbrox avatar zbrox commented on July 27, 2024

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.

b4D8 avatar b4D8 commented on July 27, 2024

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 superseded
  • from_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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.