Perdido Geoparser Python library
http://erig.univ-pau.fr/PERDIDO/
Installation
To install the latest stable version, you can use:
pip install --upgrade perdido
Quick start
Geoparsing
Import
from perdido.geoparser import Geoparser
Run geoparser
geoparser = Geoparser(lang='fr')
doc = geoparser('Je visite la ville de Lyon, Annecy et Chamonix.')
Get tokens
for token in doc:
print(f'{token.text}\tlemma: {token.lemma}\tpos: {token.pos}')
Print the XML-TEI output
print(doc.tei)
Print the GeoJSON output
print(doc.geojson)
Get the list of named entities
for entity in doc.named_entities:
print(f'entity: {entity.text}\ttag: {entity.tag}')
if entity.tag == 'place':
for t in entity.toponyms:
print(f' latitude: {t.lat}\tlongitude: {t.lng}\tsource {t.source}')
Get the list of nested named entities
for nestedEntity in doc.nested_named_entities:
print(f'entity: {nestedEntity.text}\ttag: {nestedEntity.tag}')
if nestedEntity.tag == 'place':
for t in nestedEntity.toponyms:
print(f' latitude: {t.lat}\tlongitude: {t.lng}\tsource {t.source}')
Shows named entities and nested named entities using the displacy library from spaCy
displacy.render(doc.to_spacy_doc(), style="ent", jupyter=True)
displacy.render(doc.to_spacy_doc(), style="span", jupyter=True)
Saving results
doc.to_xml('filename.xml')
doc.to_geojson('filename.geojson')
doc.to_csv('filename.csv')
Geocoding
Import
from perdido.geocoder import Geocoder
Geocode a single place name
geocoder = Geocoder()
doc = geocoder('Lyon')
Geocode a list of place names
geocoder = Geocoder()
doc = geocoder(['Lyon', 'Annecy', 'Chamonix'])
Get the geojson result
print(doc.geojson)
Get the list of toponym candidates
for t in doc.toponyms:
print(f'lat: {t.lat}\tlng: {t.lng}\tsource {t.source}\tsourceName {t.source_name}')
Perdido Geoparser REST APIs
http://choucas.univ-pau.fr/docs#
Example: call REST API in Python
import requests
url = 'http://choucas.univ-pau.fr/PERDIDO/api/'
service = 'geoparsing'
data = {'content': 'Je visite la ville de Lyon, Annecy et le Mont-Blanc.'}
parameters = {'api_key': 'demo'}
r = requests.post(url+service, params=parameters, json=data)
print(r.text)
Acknowledgements
Perdido is an active project still under developpement.
This work was partially supported by the following projects:
- GEODE (2020-2024): LabEx ASLAN (ANR-10-LABX-0081)
- GeoDISCO (2019-2020): MSH Lyon St-Etienne (ANR‐16‐IDEX‐0005)
- CHOUCAS (2017-2022): ANR (ANR-16-CE23-0018)
- PERDIDO (2012-2015): CDAPP and IGN
Metadata
Release files for perdido 0.1.20
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| perdido-0.1.20.tar.gz | 38.9 MB | Without provenance | Details for perdido-0.1.20.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| perdido-0.1.20-py3-none-any.whl | Python 3 | none | any | Details for perdido-0.1.20-py3-none-any.whl |
Total release size: 79.0 MB
Release files / perdido-0.1.20.tar.gz
| Download URL | perdido-0.1.20.tar.gz |
|---|---|
| Size | 38.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12d9f82d968c99411777fb8895bff5cb8f0f7a839fa09ef7cb67adcb489dd4bd
|
|
BLAKE2b-256 checksum How to use checksums |
e33d037e109840327b38ea531c106c1c12a4d7f0be62c0bfef35cc6eab31e46c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / perdido-0.1.20-py3-none-any.whl
| Download URL | perdido-0.1.20-py3-none-any.whl |
|---|---|
| Size | 40.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f68271f8917cea134b353c06a62cf1eb5765069f372cb1434c2c08d191b03ef9
|
|
BLAKE2b-256 checksum How to use checksums |
fc60d6571f0da1c96d77c949aa359b2ad681eb69a4b39ef5ee327e7d2d5acf2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for perdido 0.1.20
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.