This release is a pre-release and may not be stable for production use.
A Python library for extracting place names from text and linking them to geographic locations.
Geoparsing is split into two stages, and the library keeps them separate: a recognizer finds which words are place names, and a resolver decides which place each name refers to, choosing from the entries of a gazetteer. You supply the recognizer, the resolver, and the gazetteer explicitly, and each can be exchanged for another: a module can be replaced by one that works differently, pointed at a different underlying model, or fine-tuned on your own annotated data, and you can write a module of your own against a small interface. The library ships gazetteer configurations for the modern world and for Switzerland, and other geographic data becomes a gazetteer through a YAML configuration file, with no code to write.
Installation
pip install geoparser
The library also needs a gazetteer, which is not bundled: it is the database of places that names are resolved against.
python -m geoparser install geonames
See the installation guide for environment setup, the available gazetteers, and their disk requirements.
Quick Start
from geoparser import Geoparser
from geoparser.modules import SentenceTransformerResolver, SpacyRecognizer
# Build a pipeline from a recognizer and a resolver
geoparser = Geoparser(
recognizer=SpacyRecognizer(),
resolver=SentenceTransformerResolver(gazetteer_name="geonames"),
)
# Parse text
document = geoparser.parse(
"The conference was held in Zurich, with satellite events in Geneva and Basel."
)
# Access results
for toponym in document.toponyms:
location = toponym.location # None if the name could not be resolved
print(f"{toponym.text} -> {location.data['name']}, {location.data['country_name']} "
f"({location.data['latitude']}, {location.data['longitude']})")
Zurich -> Zürich, Switzerland (47.36667, 8.55)
Geneva -> Geneva, Switzerland (46.20222, 6.14569)
Basel -> Basel, Switzerland (47.55839, 7.57327)
Each name here has been tied to one specific entry in GeoNames, so besides the name and coordinates printed above you also have a stable identifier for the place, what kind of place it is, the administrative units it belongs to, and a geometry you can map, measure, or export.
Documentation
Full documentation, including setup, guides, and the API reference, is available at docs.geoparser.app.
Project Status
The library is under active development and its architecture is still evolving; while the version remains below 1.0, minor releases may make breaking changes. ROADMAP.md describes the larger changes we intend to make.
Contributing
Questions, bug reports, and ideas are always welcome via issues. Pull requests are appreciated too — see CONTRIBUTING.md for local setup and development guidelines.
Acknowledgments
The Irchel Geoparser originated as part of Diego Gomes' Master's thesis and was further developed with support from the Department of Geography at the University of Zurich and the Public Data Lab of the Digitalization Initiative of the Zurich Higher Education Institutions. We thank Prof. Dr. Ross Purves for the opportunity to continue this work as part of a research project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Geoparser depends on a number of third-party libraries, listed in pyproject.toml. Each is distributed separately under its own license, which pip installs alongside it.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geoparser-0.6.0rc1.tar.gz.
File metadata
- Download URL: geoparser-0.6.0rc1.tar.gz
- Upload date:
- Size: 99.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
261caa512caf31888e2fb6ad5068dda1089775de57565805cd20c91821f6638b
|
|
| MD5 |
86cec7b7e2ddb54d67b68c6cbd983258
|
|
| BLAKE2b-256 |
daaabbc40fafbeeb7b1b9d7f99ed82633e86ee6076e3c1d25f921a3f1e5c57ae
|
Provenance
The following attestation bundles were made for geoparser-0.6.0rc1.tar.gz:
Publisher:
release.yml on dguzh/geoparser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geoparser-0.6.0rc1.tar.gz -
Subject digest:
261caa512caf31888e2fb6ad5068dda1089775de57565805cd20c91821f6638b - Sigstore transparency entry: 2492729766
- Sigstore integration time:
-
Permalink:
dguzh/geoparser@9d5e361d10a77029eb3328e23f51d51ae3f8b7da -
Branch / Tag:
refs/tags/0.6.0rc1 - Owner: https://github.com/dguzh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d5e361d10a77029eb3328e23f51d51ae3f8b7da -
Trigger Event:
push
-
Statement type:
File details
Details for the file geoparser-0.6.0rc1-py3-none-any.whl.
File metadata
- Download URL: geoparser-0.6.0rc1-py3-none-any.whl
- Upload date:
- Size: 139.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91af45a664d366f03e202d3e9d0abc581d1f2d3955444a9347370eb606b56d53
|
|
| MD5 |
517bc2501f92f5da77b1a5c0ff8e3001
|
|
| BLAKE2b-256 |
2e203044b1ee7de3d7417aa8035cfabc033494646238b56b18e3e88cd797182c
|
Provenance
The following attestation bundles were made for geoparser-0.6.0rc1-py3-none-any.whl:
Publisher:
release.yml on dguzh/geoparser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geoparser-0.6.0rc1-py3-none-any.whl -
Subject digest:
91af45a664d366f03e202d3e9d0abc581d1f2d3955444a9347370eb606b56d53 - Sigstore transparency entry: 2492729781
- Sigstore integration time:
-
Permalink:
dguzh/geoparser@9d5e361d10a77029eb3328e23f51d51ae3f8b7da -
Branch / Tag:
refs/tags/0.6.0rc1 - Owner: https://github.com/dguzh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d5e361d10a77029eb3328e23f51d51ae3f8b7da -
Trigger Event:
push
-
Statement type: