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.1.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.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for geonames_tagger-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f99d1709fbad38ab7891b49c0f2b3c016c35adee98e1a206802e93aa279a759e
MD5 a302162da115e5fc2319aa748ad7687b
BLAKE2b-256 98b4148fe1ee61e9a2c318a2d85e9010682728da332881a7561e799acb1710e3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for geonames_tagger-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae9d9fed3c324c9e0902ef88654f7236aa183e1ec7ee23232ea194f9047cafc0
MD5 3a2fd40b2ce4b3fa24177a28b5c9a9b8
BLAKE2b-256 c71eef79ff80faf5d5b258e4b7babfa857ca1d8d2b28f88221d7f7f9e41b380d

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