PERDIDO Geoparser python library
Project description
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(version='Standard')
doc = geoparser('Je visite la ville de Lyon, Annecy et Chamonix.')
- The
version
parameter can take 2 values: Standard (default), Encyclopedie.
Get tokens
- Access token attributes:
for token in doc:
print(f'{token.text}\tlemma: {token.lemma}\tpos: {token.pos}')
- Get the IOB format:
for token in doc:
print(token.iob_format())
- Get a TSV-IOB format:
for token in doc:
print(token.tsv_format())
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
perdido-0.1.24.tar.gz
(34.2 MB
view details)
Built Distribution
perdido-0.1.24-py3-none-any.whl
(35.2 MB
view details)
File details
Details for the file perdido-0.1.24.tar.gz
.
File metadata
- Download URL: perdido-0.1.24.tar.gz
- Upload date:
- Size: 34.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97356fd1044067bf820138d417a9d8da27c1b283e78d5f0b3a390ea893036f34 |
|
MD5 | eeb5e3ffed35afdeedf53149e3d74d3d |
|
BLAKE2b-256 | 9e84e63a1d1baf59c9b361c1b037e08c6e316e858b7442ca1d51314f48bfe23a |
File details
Details for the file perdido-0.1.24-py3-none-any.whl
.
File metadata
- Download URL: perdido-0.1.24-py3-none-any.whl
- Upload date:
- Size: 35.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eac6192fb5985ce1965c0098152200b903df7a64818714ba6f1f10203829ec10 |
|
MD5 | 424ee72e073b2e446958a4b45fa397e7 |
|
BLAKE2b-256 | d730c2a1230f5146b592d7ba0ca4b468d0be5ae71062acc0d2f951a9b5e3e5f7 |