Package: perdido
Perdido Geoparser Python libraryInstallationTo install the latest stable version, you can use:pipinstall--upgradeperdidoQuick startGeoparsingImportfromperdido.geoparserimportGeoparserRun geoparsertext="J'ai rendez-vous proche de la place Bellecour, de la place des Célestins, au sud de la fontaine des Jacobins et près du pont Bonaparte."geoparser=Geoparser()doc=geoparser(text)Some parameters can be set when initializing theGeoparserobject:version:Standard(default),Encyclopediepos_tagger:spacy(default),stanza, andtreetaggerGet tokensAccess token attributes (text, lemma andUPOSpart-of-speech tag):fortokenindoc:print(f'{token.text}\tlemma:{token.lemma}\tpos:{token.pos}')Get the IOB format:fortokenindoc:print(token.iob_format())Get a TSV-IOB format:fortokenindoc:print(token.tsv_format())Print the XML-TEI outputprint(doc.tei)Print the XML-TEI output with XML syntax highlightingfromdisplay_xmlimportXMLXML(doc.tei,style='lovelace')Print the GeoJSON outputprint(doc.geojson)Get the list of named entitiesforentityindoc.named_entities:print(f'entity:{entity.text}\ttag:{entity.tag}')ifentity.tag=='place':fortinentity.toponym_candidates:print(f' latitude:{t.lat}\tlongitude:{t.lng}\tsource{t.source}')Get the list of nested named entitiesfornested_entityindoc.nested_named_entities:print(f'entity:{nested_entity.text}\ttag:{nested_entity.tag}')ifnested_entity.tag=='place':fortinnested_entity.toponym_candidates:print(f' latitude:{t.lat}\tlongitude:{t.lng}\tsource{t.source}')Get the list of spatial relationsforsp_relationindoc.sp_relations:print(f'spatial relation:{sp_relation.text}\ttag:{sp_relation.tag}')Shows named entities and nested named entities using the displacy library from spaCydisplacy.render(doc.to_spacy_doc(),style="ent",jupyter=True)displacy.render(doc.to_spacy_doc(),style="span",jupyter=True)Display the map (using folium library)doc.get_folium_map()Saving resultsdoc.to_xml('filename.xml')doc.to_geojson('filename.geojson')doc.to_iob('filename.tsv')doc.to_csv('filename.csv')GeocodingImportfromperdido.geocoderimportGeocoderGeocode a single place namegeocoder=Geocoder()doc=geocoder('Lyon')Some parameters can be set when initializing theGeocoderobject:sources:max_rows:country_code:bbox:Geocode a list of place namesgeocoder=Geocoder()doc=geocoder(['Lyon','la place des Célestins','la fontaine des Jacobins'])Get the geojson resultprint(doc.geojson)Get the list of toponym candidatesfortindoc.toponyms:print(f'lat:{t.lat}\tlng:{t.lng}\tsource{t.source}\tsourceName{t.source_name}')Get the toponym candidates as a GeoDataframeprint(doc.to_geodataframe())Perdido Geoparser REST APIshttp://choucas.univ-pau.fr/docs#Example: call REST API in Pythonimportrequestsurl='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)TutorialsPerdido: Python library for geoparsing and geocoding French texts: presented at the 1st GeoExT International Workshop at the ECIR 2023 conference.Perdido Geoparser tutorialPerdido Geocoder tutorialPerdido Web services tutorialCite this workMoncla, L. and Gaio, M. (2023). Perdido: Python library for geoparsing and geocoding French texts. In proceedings of the First International Workshop on Geographic Information Extraction from Texts (GeoExT'23), ECIR Conference, Dublin, Ireland.AcknowledgementsPerdidois 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):CDAPPandIGN