Giter Site home page Giter Site logo

Comments (4)

loureirorg avatar loureirorg commented on August 23, 2024

Hi @nagaharish! Thanks for reporting this.

As you discovered, Telangana are registered at database, but MaxMind (the db provider) don't put an acronym for it (like "MH" for Maharashtra, "GJ" for Gujarat and so on).

As you probably know, by opening the GeoLite2-City-Locations-en.csv file (you can discover where this file are located by running CS::CSV_FN_FULL at console) and searching for "Telangana" (in my PC its located at line 5409), you will see that the field immediately at its left (the acronym code for the state) is blank (I'm just explaining this here for documentational purposes).

I think they don't put an acronym because its a relatively new state and (I presume) there's not an official acronym for it - but I'm just speculating. The problem is that city-state don't expect a record with an empty acronym.

I've thinking in 3 approaches to solve this:
a) hardcode this state in the gem (maybe a yaml file with a lookup table).
b) automatically generate an acronym if there's no acronym provided (using some "acronymizer" algorithm) - but this can lead to misleading acronyms
c) use the full name of the state as the acronym

What I will do it's a mix of "a" and "c". I will put an lookup table (states-acronyms.yaml) for the cases where the acronyms are empty. If there's no acronym at MaxMind db neither in this lookup table, CS will use the full name of state.

from city-state.

loureirorg avatar loureirorg commented on August 23, 2024

done! I've created a db/states-replace.yml file, which can be used in cases like this. Hereafter it can be used to translate names too.

CS.states(:in)
# => {:AN=>"Union Territory of Andaman and Nicobar Islands", :AP=>"Andhra Pradesh", :AR=>"Arunachal Pradesh", :AS=>"Assam", :BR=>"Bihar", :CH=>"Chandigarh", :CT=>"State of Chhattisgarh", :DD=>"Daman and Diu", :DL=>"National Capital Territory of Delhi", :DN=>"Dadra and Nagar Haveli", :GA=>"Goa", :GJ=>"Gujarat", :HP=>"State of Himachal Pradesh", :HR=>"Haryana", :JH=>"State of Jharkhand", :JK=>"Kashmir", :KA=>"Karnataka", :KL=>"Kerala", :LD=>"Laccadives", :MH=>"Maharashtra", :ML=>"Meghalaya", :MN=>"Manipur", :MP=>"Madhya Pradesh", :MZ=>"Mizoram", :NL=>"Nagaland", :OR=>"Odisha", :PB=>"State of Punjab", :PY=>"Union Territory of Puducherry", :RJ=>"Rajasthan", :SK=>"Sikkim", :TG=>"Telangana", :TN=>"Tamil Nadu", :TR=>"Tripura", :UL=>"Uttarakhand", :UP=>"Uttar Pradesh", :WB=>"West Bengal"}
CS.cities(:tg, :in)
# => ["Adilabad", "Balanagar", "Bhongir", "Bodhan", "Gudur", "Hyderabad", "Karimnagar", "Khammam", "Kottagudem", "Mancherial", "Medak", "Medchal", "Nalgonda", "Narsapur", "Nizamabad", "Paloncha", "Patancheru", "Patelguda", "Pochampalli", "Secunderabad", "Shadnagar", "Suriapet", "Uppal", "Vikarabad", "Warangal"]

PS: don't forget to update the gem (bundle update)
PS II: if doesn't works after update, try to update the database with CS.update

from city-state.

nagaharish avatar nagaharish commented on August 23, 2024

Hi, Thanks a lot for adding this. Actually telangana is our state hence I could trace it.
May be we can check more states like this and if any balnk is there we can use the states-replace.yml file.

from city-state.

chandrasc avatar chandrasc commented on August 23, 2024

This one does not work for me when I'm using the latest version
running it on rails console:
CS.cities(:tg, :in)
=> []

This happens when I run cs.update. After running it, I looked at your gem folder and found it contains states and cities files and somehow your implementation is failing and TG is not being accepted.

from city-state.

Related Issues (20)

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.