Currency Process Flow

Identify the Country Name

getCurrency flow is used to get the Currency of a Country. Once getCurrency flow is invoked, Rawspeech is passed to the getCurrency flow to identify the Country Name.

getCountryName parses the RawSpeech against the list of country from pycountry and return the country name identified.

  • In case the country is not identified then default country name is returned.

  • This is for questions such as what is capital?, So no country is passed thus it default's the country and returns India in this example.

pycountry packages provides the ISO databases for the standards for Countries, Languages, Deleted Countries, Subdivisions of Countries, Currencies, Scripts.

while i<len(pycountry.countries):
    if subStrCheck(rawspeech,(list(pycountry.countries)[i].name)):
        countryname = list(pycountry.countries)[i].name
        break
    i = i+1
    if i == len(pycountry.countries):
        countryname = "India" 

Identify the Numeric Id for the Country Name

Once the country name is identified then pycountry package is used to get the numeric id of a Country.

Numeric Id will be used as lookup to get the currencies for a country.

countriesattributes = pycountry.countries.get(name=countryname)
countrynumericid = countriesattributes.numeric

Identify the Currency for the Given Numeric ID

Currency Name and Currency Symbol are identified using pycountry.currencies by passing the country numeric id identified in previous step.

Attribute name provides the name of the currency and alpha_3 gives the currency symbol.

currencyname = pycountry.currencies.get(numeric=countrynumericid).name
currencysymbol = pycountry.currencies.get(numeric=countrynumericid).alpha_3

Aryan Shares the Currency Name and Symbol for the requested Country and flow is completed successfully. Control is passed to NextStep.

PrintText(aifriend,"Currency for " + countryname + " is " + currencyname + " and symbol is " + currencysymbol )
SpeakText(aifriend,"Currency for " + countryname + " is " + currencyname + " and symbol is " + currencysymbol )

Last updated