Skip to main content

followthemoney query dsl and io helpers

Project description

geonames-tagger on pypi PyPI Downloads PyPI - Python Version Python test and package pre-commit Coverage Status AGPLv3+ License Pydantic v2

geonames-tagger

Inspired by countrytagger

This library finds the names of places in a string of text and tries to associate them with known locations from geonames.org. The goal is to tag a piece (or set) of text with mentioned locations, optionally to refine location names to a more canonized value. As well, the corresponding geoname IDs are returned in a tagging result.

As opposed to the original countrytagger, this library doesn't ship with the data included, so one needs to build it locally and then use it with the GEONAMES_DB env var set.

Data

Usage of the GeoNames data is licensed under a Creative Commons Attribution 4.0 License. Please verify that usage complies with your project.

Install

pip install geonames-tagger

Usage

cli

echo "I just visited Sant Julia de loria last week" | geonames-tagger tag

this results in the following json response:

{
  "name": "sant julia de loria",
  "caption": [
    "Sant Julià de Lòria"
  ],
  "id": [
    3039162,
    3039163
  ]
}

python

from geonames_tagger import tag_location:

text = 'I am in Berlin'
for result in tag_locations(text):
    print(result.name)  # the normalized but original name found in text
    print(result.caption)  # the canonical names as list from GeoNames db
    print(result.ids)  # the GeoName IDs

Building the data

You can re-generate the place database like this:

geonames-tagger build

This will download GeoNames and parse it into the format used by this library.

License and Copyright

geonames-tagger, (C) 2025 Data and Research Center – DARC

geonames-tagger is licensed under the AGPLv3 or later license.

The original countrytagger is released under the MIT license.

see NOTICE and LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geonames_tagger-1.0.2.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geonames_tagger-1.0.2-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file geonames_tagger-1.0.2.tar.gz.

File metadata

  • Download URL: geonames_tagger-1.0.2.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.5 Linux/6.12.63+deb13-amd64

File hashes

Hashes for geonames_tagger-1.0.2.tar.gz
Algorithm Hash digest
SHA256 23db330e4a394e11941152ff3caa8ae02537381c1df149914b8d0eb079f3d2ae
MD5 b891b67abce77e484dbd7690fd3053e6
BLAKE2b-256 f8b1285b88ce01f00fceb32606da872cba8f29213716af0002c966b03297e376

See more details on using hashes here.

File details

Details for the file geonames_tagger-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: geonames_tagger-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.5 Linux/6.12.63+deb13-amd64

File hashes

Hashes for geonames_tagger-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8d67c7a29c412bfac0c5204eb655bfb61cebb12229749deb2b4273587ebf153
MD5 144b4cbe14b1970cf7ed7213dfba9bae
BLAKE2b-256 2bd121316a516ff4a2d293ca154dda7cba6b7578c6f3531eb074b78be5c69992

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page