vendredi 19 octobre 2018

Fetch random town names based on countries

I've been struggling with this for a while now, and I've gotten somewhere between having it work once in a blue moon and completely breaking down.

My ultimate goal is to replace the "!R"s in the dictionary with a random town names from a region/country the user can chose from. Or for a concrete example, basically this kind of thing: https://www.mithrilandmages.com/utilities/CityNames.php

After starting to simply go online and copy-paste lists of town names into a .csv I realised that would take way to long and would be by far not exhaustive enough, and there are databases set up for this.

So I tried to get something working using GeoCoder and GeoNames...but I simply can't seem to make it work as I want it to work (or efficiently for that matter).

Link to the script and code: https://github.com/Araxiel/CK2-Province_Set-Upper/blob/abandoned/1.3.0/Source/_workbench/databases.py

My current attempt was to just use children all the way down to the smallest child, but it's not very reliable and the queries take a while. Further, I can't seem to get something like United States work as a name. All the info I can find is to return specific longtitudes or IP addresses of specified locations, but that's far from what I'm looking for. I saw a library called "Faker", but I'm quite sure that's not what I'm looking for either, especially since I can't find any documentation on where its databases take their information from.

I'm just about ready to throw in the towel and try my hand at creating a RNG name generator that assembles words together.




Aucun commentaire:

Enregistrer un commentaire