Skip to main content

PERDIDO Geoparser python library

Project description

Perdido Geoparser Python library

PyPI PyPI - License PyPI - Python Version

http://erig.univ-pau.fr/PERDIDO/

Installation

To install the latest stable version, you can use:

pip install --upgrade perdido

Quick start

Geoparsing

Binder Open In Colab

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.ne:
    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.nne:
    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}')

Geocoding

Binder Open In Colab

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'
content = 'Je visite la ville de Lyon, Annecy et le Mont-Blanc.'
parameters = {'api_key': 'demo', 'content': content}

r = requests.post(url+service, params=parameters)

print(r.text)

Acknowledgements

Perdido is an active project still under developpement.

This work was partially supported by the following projects:

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

perdido-0.1.8.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

perdido-0.1.8-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file perdido-0.1.8.tar.gz.

File metadata

  • Download URL: perdido-0.1.8.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for perdido-0.1.8.tar.gz
Algorithm Hash digest
SHA256 4bc54fd365e5268c64fcb515f21a90da5056f7d77a6844330b6f2e4c1c14bbd2
MD5 5e662447b3872f276149c646ffbc5fea
BLAKE2b-256 bd9519fa916477c5bb741283c7e29a5b91d634ec8d75079ddda18897aa920270

See more details on using hashes here.

File details

Details for the file perdido-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: perdido-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for perdido-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 79cd67dd9092b7b10a0ee7c27c441f3d729d83934c3cc7569d20ee4654171229
MD5 6fef82f4687d75d6c0b25d2cea687a6e
BLAKE2b-256 652c46d447fd51ba62b612865be4a0f8c064f363ed6a079603252662f7aa8323

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page