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)docountryAdjectivesToNounsTablemyAdjective=myNounend-- Now load the denomyms tablelocalmyDemonymformyNoun,myDemonyminpairs(countryNounsToDemonymsTable)docountryDemonymsToNounsTablemyDemonym=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.args1ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endif(countriesPrefixedByTheTables==true)thenreturn"the "endreturn""endfunctionCountryAdjectiveDemonym.getCountryFromAdjective(frame)locals=frame.args1ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryAdjectivesToNounsTablesifretval==nilthenifs=="Georgia (country)"thenreturnsendreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getCountryFromString(frame)locals=frame.args1ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalsimilarLongerNouns=mw.loadData('Module:CountryAdjectiveDemonym/LongerNouns')foradjective,nouninpairs(countryAdjectivesToNounsTable)doifstring.find(s,adjective)orstring.find(s,noun)thenforlongerNoun,nameToUseinpairs(similarLongerNouns)doifstring.find(s,longerNoun)thenreturnnameToUseendendreturnnounendendendfunctionCountryAdjectiveDemonym.getCountryFromDemonym(frame)locals=frame.args1ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryDemonymsToNounsTablesifretval==nilthenretval=countryAdjectivesToNounsTablesendifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getAdjectiveFromCountry(frame)locals=frame.args1ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryNounsToAdjectivesTablesifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getDemonymFromCountry(frame)locals=frame.args1ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretvalretval=countryNounsToDemonymsTablesifretval==nilthenretval=countryNounsToAdjectivesTablesendifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.stripThe(frame)locals=frame.args1ifs==nilthenreturn""endifmw.ustring.match(s,"^[T]he Gambia$")~=nilthenreturnsendlocalstripped=mw.ustring.gsub(s,"^[tT]he ","")returnstrippedendreturnCountryAdjectiveDemonym