localCountryAdjectiveDemonym={}localCountryAdjectiveDemonymDataLoaded=falselocalcountryAdjectivesToNounsTable={}localcountryNounsToAdjectivesTable={}localcountryDemonymsToNounsTable={}localcountryNounsToDemonymsTable={}localcountriesPrefixedByTheTable={}functionCountryAdjectiveDemonymDoLoadData()countriesPrefixedByTheTable=mw.loadData('Module:CountryAdjectiveDemonym/The')countryNounsToAdjectivesTable=mw.loadData('Module:CountryAdjectiveDemonym/Adjectives')countryNounsToDemonymsTable=mw.loadData('Module:CountryAdjectiveDemonym/Demonyms')localmyNoun,myAdjective-- first, load the adjectives tableformyNoun,myAdjectiveinpairs(countryNounsToAdjectivesTable)docountryAdjectivesToNounsTable[myAdjective]=myNounend-- Now load the denomyms tablelocalmyDemonymformyNoun,myDemonyminpairs(countryNounsToDemonymsTable)docountryDemonymsToNounsTable[myDemonym]=myNounendCountryAdjectiveDemonymDataLoaded=truereturnend-- ############### Publicly accesible functions #######################-- if the country name is prefixed by "the" in running text,-- then return that prefix-- Otherwise just return an empty stringfunctionCountryAdjectiveDemonym.countryPrefixThe(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endif(countriesPrefixedByTheTable[s]==true)thenreturn"the "endreturn""endfunctionCountryAdjectiveDemonym.getCountryFromAdjective(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryAdjectivesToNounsTable[s]ifretval==nilthenifs=="Georgia (country)"thenreturnsendreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getCountryFromString(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endforadjective,nouninpairs(countryAdjectivesToNounsTable)doifstring.find(s,adjective)orstring.find(s,noun)thenreturnnounendendendfunctionCountryAdjectiveDemonym.getCountryFromDemonym(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryDemonymsToNounsTable[s]ifretval==nilthenretval=countryAdjectivesToNounsTable[s]endifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getAdjectiveFromCountry(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryNounsToAdjectivesTable[s]ifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getDemonymFromCountry(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretvalretval=countryNounsToDemonymsTable[s]ifretval==nilthenretval=countryNounsToAdjectivesTable[s]endifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.stripThe(frame)locals=frame.args[1]ifs==nilthenreturn""endifmw.ustring.match(s,"^[T]he Gambia$")~=nilthenreturnsendlocalstripped=mw.ustring.gsub(s,"^[tT]he ","")returnstrippedendreturnCountryAdjectiveDemonym