Skip to main content

Tag the names of countries and in text.

Project description

countrytagger

This library finds the names of places in a string of text and tries to associate them with countries. The goal is to tag a piece (or set) of text with country metadata. The place names are derived from the GeoNames database, and they include names of countries, major administrative areas and large cities. Place names that are used in several countries are not used.

Usage

import countrytagger

# match in a string using sequential matching:
text = 'I am in Berlin'
for (code, score, country) in countrytagger.tag_text_countries(text):
    print(score, country)

# find precise matches:
code, score, country = countrytagger.tag_place('Berlin')

Building the data

You can re-generate the place database like this:

$ make generate

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

Project details


Download files

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

Files for countrytagger, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size countrytagger-0.1.2-py2.py3-none-any.whl (703.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size countrytagger-0.1.2.tar.gz (693.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page