{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "YrOKr9pwkxJw"
   },
   "source": [
    "![CNRS](https://anf-tdm-2022.sciencesconf.org/data/header/LOGO_CNRS_CMJN_150x150.png)\n",
    "\n",
    "\n",
    "# Tutoriel - ANF TDM 2022 Python Geoparsing \n",
    "\n",
    "Supports pour l'atelier [Librairies Python et Services Web pour la reconnaissance d’entités nommées et la résolution de toponymes](https://anf-tdm-2022.sciencesconf.org/resource/page/id/11) de la formation CNRS [ANF TDM 2022](https://anf-tdm-2022.sciencesconf.org).\n",
    "\n",
    "**Animateurs**: [Ludovic Moncla](https://ludovicmoncla.github.io) (INSA Lyon) et [Alice Brenon](https://perso.liris.cnrs.fr/abrenon/) (CNRS / INSA Lyon)\n",
    "\n",
    "## 1. En bref\n",
    "\n",
    "\n",
    "Dans ce tutoriel, nous allons apprendre plusieurs choses :\n",
    "\n",
    "- Charger des jeux de données :\n",
    "  - à partir de fichiers txt importés depuis le disque dur ;\n",
    "  - à partir de la librairie Python [Perdido](https://github.com/ludovicmoncla/perdido) dans un [Pandas dataframe](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) (articles encyclopédiques et descriptions de randonnées).\n",
    "- Manipuler et interroger un dataframe\n",
    "- Utiliser les librairies [Stanza](https://stanfordnlp.github.io/stanza/index.html), [spaCy](https://spacy.io) et [Perdido](https://github.com/ludovicmoncla/perdido) pour la reconnaissance d'entités nommées\n",
    "  - afficher les entités nommées annotées ;\n",
    "  - comparer les résultats de `Stanza`, `spaCy` et `Perdido` ;\n",
    "  - discuter les limites des 3 outils pour la tâche de NER.\n",
    "- Utiliser la librarie `Perdido` pour le geoparsing :\n",
    "  - cartographier les lieux geocodés ;\n",
    "  - illustrer la problématique de désambiguïsation des toponymes."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Introduction"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. Configurer l'environnement\n",
    "\n",
    "### 3.1 Installer les librairies Python\n",
    "\n",
    "* Si vous avez configuré votre environnement Conda en utilisant le fichier `requirements.txt`, vous pouvez sauter cette étape et aller à la section `3.2 Importer les librairies`.\n",
    "* Si vous avez configuré votre environnement Conda en utilisant le fichier `environment.yml` ou si vous utilisez un environnement Google Colab / Binder, vous devez installer `perdido` en utilisant `pip` :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install perdido"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Si vous avez déjà configuré votre environnement conda, soit avec conda, soit avec pip (voir le fichier readme), vous pouvez ignorer la cellule suivante.\n",
    "* Si vous exécutez ce notebook depuis Google Colab / Binder, vous devez exécuter la cellule suivante :\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install stanza"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.2 Importer les librairies\n",
    "\n",
    "\n",
    "Tout d'abord, nous allons charger certaines bibliothèques spécifiques de `Perdido` que nous utiliserons dans ce notebook. Ensuite, nous importons quelques outils qui nous aideront à analyser et à visualiser le texte."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "from perdido.geoparser import Geoparser\n",
    "from perdido.geocoder import Geocoder\n",
    "\n",
    "from perdido.datasets import load_edda_artfl, load_edda_perdido, load_choucas_perdido\n",
    "\n",
    "from spacy import displacy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. Chargement et exploration des données\n",
    "\n",
    "### 4.1 Chargement d'un document texte à partir d'un fichier\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "filepath = 'data/volume01-4083.txt'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(filepath) as f:\n",
    "    content = f.read()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher le contenu du fichier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "* ARQUES, (Géog.) petite ville de France, en Normandie, au pays de Caux, sur la petite riviere d'Arques. Long. 18. 50. lat. 49. 54.\n"
     ]
    }
   ],
   "source": [
    "print(content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.2 Chargement d'un jeu de données à partir de la librairie Perdido\n",
    "\n",
    "Perdido embarque deux jeux de données : \n",
    " 1. articles encyclopédiques (volume 7 de l'Encyclopédie de Diderot et d'Alembert (1751-1772)), fournit par l'[ARTFL](https://encyclopedie.uchicago.edu) dans le cadre du projet [GEODE](https://geode-project.github.io) ;\n",
    " 2. descriptions de randonnées (chaque description est associée à sa trace GPS. Elles proviennent du site [www.visorando.fr](https://www.visorando.com) et ont été collectées dans le cadre du projet [ANR CHOUCAS](http://choucas.ign.fr).\n",
    "\n",
    " Dans un premier temps nous allons nous intéresser au jeu de données des articles encyclopédiques. Ce jeu de données est présent dans la librairie en deux versions, une version \"brute\" (articles fournis par l'ARTFL) au format dataframe et une version déjà annotée par Perdido (format PerdidoCollection). Nous allons charger la version brute et voir comment manipuler un dataframe."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Charger le jeu de données :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset_artfl = load_edda_artfl()\n",
    "data_artfl = dataset_artfl['data']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher les informations sur le jeu de données :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 3385 entries, 0 to 3384\n",
      "Data columns (total 7 columns):\n",
      " #   Column     Non-Null Count  Dtype \n",
      "---  ------     --------------  ----- \n",
      " 0   filename   3385 non-null   object\n",
      " 1   volume     3385 non-null   int64 \n",
      " 2   number     3385 non-null   int64 \n",
      " 3   head       3384 non-null   object\n",
      " 4   normClass  3384 non-null   object\n",
      " 5   author     3384 non-null   object\n",
      " 6   text       3385 non-null   object\n",
      "dtypes: int64(2), object(5)\n",
      "memory usage: 185.2+ KB\n"
     ]
    }
   ],
   "source": [
    "data_artfl.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On remarque que certaines colonnes ont une donnée manquante (3384 lignes non nulles contre 3385 lignes au total). Pour la suite des opérations que nous allons réaliser il est nécessaire de supprimer les lignes incomplètes.\n",
    "\n",
    "* Supprimer la ligne incomplète :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_artfl.dropna(inplace=True)     # data_artfl = data_artfl.dropna()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Vérifier le résultat :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 3384 entries, 0 to 3384\n",
      "Data columns (total 7 columns):\n",
      " #   Column     Non-Null Count  Dtype \n",
      "---  ------     --------------  ----- \n",
      " 0   filename   3384 non-null   object\n",
      " 1   volume     3384 non-null   int64 \n",
      " 2   number     3384 non-null   int64 \n",
      " 3   head       3384 non-null   object\n",
      " 4   normClass  3384 non-null   object\n",
      " 5   author     3384 non-null   object\n",
      " 6   text       3384 non-null   object\n",
      "dtypes: int64(2), object(5)\n",
      "memory usage: 211.5+ KB\n"
     ]
    }
   ],
   "source": [
    "data_artfl.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher la liste des premiers articles :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>volume</th>\n",
       "      <th>number</th>\n",
       "      <th>head</th>\n",
       "      <th>normClass</th>\n",
       "      <th>author</th>\n",
       "      <th>text</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>volume07-1.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>Title Page</td>\n",
       "      <td>unclassified</td>\n",
       "      <td>unsigned</td>\n",
       "      <td>ENCYCLOPÉDIE, ou DICTIONNAIRE RAISONNÉ DES SCI...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>volume07-10.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>10</td>\n",
       "      <td>FOESNE ou FOUANE</td>\n",
       "      <td>Marine | Pêche</td>\n",
       "      <td>Bellin</td>\n",
       "      <td>FOESNE ou FOUANE, sub. s. (Marine &amp; Pêche.) c'...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>volume07-100.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>100</td>\n",
       "      <td>Fond de la hune</td>\n",
       "      <td>unclassified</td>\n",
       "      <td>Bellin</td>\n",
       "      <td>Fond de la hune ; ce sont les planches qu on p...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>volume07-1000.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1000</td>\n",
       "      <td>Fronteau</td>\n",
       "      <td>Bourrelier | Sellier</td>\n",
       "      <td>Diderot</td>\n",
       "      <td>* Fronteau, terme de Sellier-Bourrelier ; c'es...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>volume07-1001.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1001</td>\n",
       "      <td>FRONTIERE</td>\n",
       "      <td>Géographie</td>\n",
       "      <td>Diderot</td>\n",
       "      <td>* FRONTIERE, s. f. (Géog.) se dit des limites,...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            filename  volume  number              head             normClass  \\\n",
       "0     volume07-1.tei       7       1        Title Page          unclassified   \n",
       "1    volume07-10.tei       7      10  FOESNE ou FOUANE        Marine | Pêche   \n",
       "2   volume07-100.tei       7     100   Fond de la hune          unclassified   \n",
       "3  volume07-1000.tei       7    1000          Fronteau  Bourrelier | Sellier   \n",
       "4  volume07-1001.tei       7    1001         FRONTIERE            Géographie   \n",
       "\n",
       "     author                                               text  \n",
       "0  unsigned  ENCYCLOPÉDIE, ou DICTIONNAIRE RAISONNÉ DES SCI...  \n",
       "1    Bellin  FOESNE ou FOUANE, sub. s. (Marine & Pêche.) c'...  \n",
       "2    Bellin  Fond de la hune ; ce sont les planches qu on p...  \n",
       "3   Diderot  * Fronteau, terme de Sellier-Bourrelier ; c'es...  \n",
       "4   Diderot  * FRONTIERE, s. f. (Géog.) se dit des limites,...  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_artfl.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.3 Manipulation d'un dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Nous avons maintenant accès à tous les attributs et méthodes de l'objet [dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html). Par exemple, nous pouvons facilement connaître le nombre de lignes dans notre dataframe qui correspond au nombre d'articles dans notre corpus :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Il y a 3384 articles dans le jeu de données.\n"
     ]
    }
   ],
   "source": [
    "n = data_artfl.shape[0]\n",
    "print('Il y a ' + str(n) + ' articles dans le jeu de données.')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 4.3.1 Recherche par métadonnées\n",
    "\n",
    "\n",
    "Maintenant que les données sont chargées dans un dataframe, nous pouvons sélectionner des groupes d'articles sur la base de leurs métadonnées.\n",
    "\n",
    "Pour cela on utilise la méthode [loc()](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.loc.html).\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Selectionner la ligne du dataframe qui correspond à l'article 'FRONTIGNAN' :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>volume</th>\n",
       "      <th>number</th>\n",
       "      <th>head</th>\n",
       "      <th>normClass</th>\n",
       "      <th>author</th>\n",
       "      <th>text</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>volume07-1002.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1002</td>\n",
       "      <td>FRONTIGNAN</td>\n",
       "      <td>Géographie</td>\n",
       "      <td>Jaucourt</td>\n",
       "      <td>FRONTIGNAN, (Géog.) petite ville de France. au...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            filename  volume  number        head   normClass    author  \\\n",
       "5  volume07-1002.tei       7    1002  FRONTIGNAN  Géographie  Jaucourt   \n",
       "\n",
       "                                                text  \n",
       "5  FRONTIGNAN, (Géog.) petite ville de France. au...  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frontignan = data_artfl.loc[data_artfl['head'] == 'FRONTIGNAN']\n",
    "frontignan "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Récupérer les valeurs des attributs (colonnes) :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "filename : volume07-1002.tei\n",
      "text : FRONTIGNAN, (Géog.) petite ville de France. au Bas-Languedoc, connue par ses excellens vins muscats, & ses raisins de caisse qu'on appelle passerilles. Quelques savans croyent, sans en donner de preuves, que cette ville est le forum Domitii des Romains. Elle est située sur l'étang de Maguelone, à six lieues N. E. d'Agde, & cinq S. O. de Montpellier. Long. 15d. 24'. lat. 43d. 28'. (D. J.)\n"
     ]
    }
   ],
   "source": [
    "print('filename :', frontignan.filename.item())   # similaire à frontignan['normClass'].item()\n",
    "\n",
    "print('text :', frontignan.text.item())\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Nous pouvons également filtrer les données sur la base de l'auteur.\n",
    "\n",
    "* Extraire les articles rédigés par Jaucourt :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "698 articles ont été rédigés par Jaucourt\n"
     ]
    }
   ],
   "source": [
    "req = 'Jaucourt'\n",
    "d_Jaucourt = data_artfl.loc[data_artfl['author'] == req]\n",
    "\n",
    "n = d_Jaucourt.shape[0]\n",
    "print(str(n) + ' articles ont été rédigés par '+ req)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>volume</th>\n",
       "      <th>number</th>\n",
       "      <th>head</th>\n",
       "      <th>normClass</th>\n",
       "      <th>author</th>\n",
       "      <th>text</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>volume07-1002.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1002</td>\n",
       "      <td>FRONTIGNAN</td>\n",
       "      <td>Géographie</td>\n",
       "      <td>Jaucourt</td>\n",
       "      <td>FRONTIGNAN, (Géog.) petite ville de France. au...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>volume07-1024.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1024</td>\n",
       "      <td>FROWARD, le cap.</td>\n",
       "      <td>Géographie</td>\n",
       "      <td>Jaucourt</td>\n",
       "      <td>FROWARD, le cap. (Géog.) &amp; par les François le...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>volume07-1027.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1027</td>\n",
       "      <td>FRUGALITÉ</td>\n",
       "      <td>Morale</td>\n",
       "      <td>Jaucourt</td>\n",
       "      <td>FRUGALITÉ, (Morale.) simplicité de moeurs &amp; de...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>volume07-1031.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1031</td>\n",
       "      <td>Fruit verreux</td>\n",
       "      <td>Histoire naturelle</td>\n",
       "      <td>Jaucourt</td>\n",
       "      <td>Fruit verreux, (Hist. nat.) c'est le nom qu'on...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>volume07-1032.tei</td>\n",
       "      <td>7</td>\n",
       "      <td>1032</td>\n",
       "      <td>Fruit, (art de conserver le)</td>\n",
       "      <td>Economie rustique</td>\n",
       "      <td>Jaucourt</td>\n",
       "      <td>Fruit, (art de conserver le) Economie rustiq. ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             filename  volume  number                           head  \\\n",
       "5   volume07-1002.tei       7    1002                     FRONTIGNAN   \n",
       "29  volume07-1024.tei       7    1024               FROWARD, le cap.   \n",
       "32  volume07-1027.tei       7    1027                      FRUGALITÉ   \n",
       "37  volume07-1031.tei       7    1031                  Fruit verreux   \n",
       "38  volume07-1032.tei       7    1032  Fruit, (art de conserver le)    \n",
       "\n",
       "             normClass    author  \\\n",
       "5           Géographie  Jaucourt   \n",
       "29          Géographie  Jaucourt   \n",
       "32              Morale  Jaucourt   \n",
       "37  Histoire naturelle  Jaucourt   \n",
       "38   Economie rustique  Jaucourt   \n",
       "\n",
       "                                                 text  \n",
       "5   FRONTIGNAN, (Géog.) petite ville de France. au...  \n",
       "29  FROWARD, le cap. (Géog.) & par les François le...  \n",
       "32  FRUGALITÉ, (Morale.) simplicité de moeurs & de...  \n",
       "37  Fruit verreux, (Hist. nat.) c'est le nom qu'on...  \n",
       "38  Fruit, (art de conserver le) Economie rustiq. ...  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d_Jaucourt.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Autre exemple, nous pouvons filtrer les articles en fonction de leur classification dans l'*Encyclopédie*. \n",
    "Pour cela nous utiliserons le champ `normclass`, qui indique la classifications retenue (et normalisée) par l'ARTFL. \n",
    "\n",
    "Par exemple pour la classe 'Géographie', nous pouvons faire la requête suivante (le résultat est stocké dans un nouveau cadre de données `df_geo` : "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "496 articles sont classés en Géographie\n"
     ]
    }
   ],
   "source": [
    "req = 'Géographie'\n",
    "d_geo = data_artfl[data_artfl['normClass'].str.contains(req, case=False)]\n",
    "\n",
    "n = d_geo.shape[0]\n",
    "print(str(n) + ' articles sont classés en '+ req)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On peut également regrouper les données selon un ou plusieurs attributs (colonnes) et compter le nombre de données de chaque groupe avec les méthodes [groupby()](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.groupby.html) et [count()](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.count.html).\n",
    "\n",
    "* Afficher le nombre d'articles classés en Géographie par auteur :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "author\n",
       "Desmarest                            1\n",
       "Diderot                              1\n",
       "Jaucourt                           476\n",
       "La Condamine                         1\n",
       "Mallet                               1\n",
       "Robert de Vaugondy                   2\n",
       "Robert de Vaugondy & d'Alembert      1\n",
       "unsigned                            13\n",
       "Name: filename, dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d_geo.groupby(['author'])[\"filename\"].count()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Dans cette partie nous avons vu brievement comment manipuler un dataframe pour selectionner certaines données en filtrant selon certaines métadonnées ou par une recheche par mot clés. Ces opérations sont utiles mais un peu limitées, nous allons voir dans la suite de ce notebook comment enrichir les métadonnées et en particulier comment annoter les entités nommées présents dans les textes."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. Reconnaissance d'Entités Nommées (NER)\n",
    "\n",
    "La reconnaissance d'entités nommées, *Named Entity Recognition* (NER) en anglais, est une tâche très importante et incontournable en traitement automatique des langues (TAL) et en compréhension du langage naturel (NLU en anglais). \n",
    "Cette tâche consiste à rechercher des objets textuels (un mot, ou un groupe de mots, souvent associés aux noms propres) catégorisables dans des classes telles que noms de personnes, noms d'organisations ou d'entreprises, noms de lieux, quantités, distances, valeurs, dates, etc.\n",
    "\n",
    "Dans cet atelier nous allons expérimenter et comparer trois outils de NER. \n",
    "\n",
    "1. [Stanza](https://stanfordnlp.github.io/stanza/index.html)\n",
    "2. [spaCy](https://spacy.io)\n",
    "3. [Perdido](https://github.com/ludovicmoncla/perdido)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.1 Stanza NER\n",
    "\n",
    "`Stanza` est une librairie Python de traitement du langage naturel. Elle contient des outils, qui peuvent être utilisés dans une chaîne de traitement, pour convertir du texte en listes de phrases et de mots, pour générer les formes de base de ces mots, leurs parties du discours et leurs caractéristiques morphologiques, pour produire une analyse syntaxique de dépendance, et pour reconnaître les entités nommées. \n",
    "\n",
    "`Stanza` se base sur des modèles entrainés par des réseaux de neurones à partir de la bibliothèque [PyTorch](https://pytorch.org) et permet de traiter plus de 70 langues.\n",
    "\n",
    "Dans cette partie nous allons voir comment utiliser `Stanza` pour la reconnaissance d'entités nommées à partir de textes en français.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Importer la librairie `Stanza` et télécharger le modèle pré-entrainé pour le français : "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "b98f0029867448a199b879e25dace917",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading https://raw.githubusercontent.com/stanfordnlp/stanza-resources/main/resources_1.4.0.json:   0%|   …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-09-16 09:16:43 INFO: Downloading default packages for language: fr (French)...\n",
      "2022-09-16 09:16:44 INFO: File exists: /Users/lmoncla/stanza_resources/fr/default.zip\n",
      "2022-09-16 09:16:47 INFO: Finished downloading models and saved to /Users/lmoncla/stanza_resources.\n"
     ]
    }
   ],
   "source": [
    "import stanza\n",
    "\n",
    "stanza.download('fr')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Instancier et paramétrer la chaîne de traitement :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "561ecbb0a447489e9ccf9dbe8dbf3b16",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading https://raw.githubusercontent.com/stanfordnlp/stanza-resources/main/resources_1.4.0.json:   0%|   …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-09-16 09:16:56 WARNING: Language fr package default expects mwt, which has been added\n",
      "2022-09-16 09:16:57 INFO: Loading these models for language: fr (French):\n",
      "=======================\n",
      "| Processor | Package |\n",
      "-----------------------\n",
      "| tokenize  | gsd     |\n",
      "| mwt       | gsd     |\n",
      "| ner       | wikiner |\n",
      "=======================\n",
      "\n",
      "2022-09-16 09:16:57 INFO: Use device: cpu\n",
      "2022-09-16 09:16:57 INFO: Loading: tokenize\n",
      "2022-09-16 09:16:57 INFO: Loading: mwt\n",
      "2022-09-16 09:16:57 INFO: Loading: ner\n",
      "2022-09-16 09:16:58 INFO: Done loading processors!\n"
     ]
    }
   ],
   "source": [
    "stanza_parser = stanza.Pipeline(lang='fr', processors='tokenize,ner')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* On utilise la variable `content` qui contient le texte chargé précédemment à partir du fichier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "* ARQUES, (Géog.) petite ville de France, en Normandie, au pays de Caux, sur la petite riviere d'Arques. Long. 18. 50. lat. 49. 54.\n"
     ]
    }
   ],
   "source": [
    "print(content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Executer la reconnaissance d'entités nommées :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "doc = stanza_parser(content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher la liste des entités nommées repérées :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ARQUES LOC\n",
      "(Géog LOC\n",
      "France LOC\n",
      "Normandie LOC\n",
      "pays de Caux LOC\n",
      "Arques LOC\n"
     ]
    }
   ],
   "source": [
    "for ent in doc.ents:\n",
    "    print(ent.text, ent.type)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.2 SpaCy NER\n",
    "\n",
    "\n",
    "`spaCy` est également une librairie Python de traitement du langage naturel. \n",
    "Elle se compose de modèles pré-entrainés et supporte actuellement la tokenisation et l'entrainement pour plus de 60 langues. Elle est doté de modèles de réseaux neuronaux pour le balisage, l'analyse syntaxique, la reconnaissance d'entités nommées, la classification de textes, l'apprentissage multi-tâches avec des transformateurs pré-entraînés comme BERT, ainsi qu'un système d'entraînement prêt pour la production et un déploiement simple des modèles. `spaCy` est un logiciel commercial, publié en open-source sous la licence MIT.\n",
    "\n",
    "Dans cette partie nous allons voir comment utiliser `spaCy` pour la reconnaissance d'entités nommées toujours à partir de notre exemple en français."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Installer le modèle français pré-entrainé de `spaCy` :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting fr-core-news-sm==3.4.0\n",
      "  Downloading https://github.com/explosion/spacy-models/releases/download/fr_core_news_sm-3.4.0/fr_core_news_sm-3.4.0-py3-none-any.whl (16.3 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m16.3/16.3 MB\u001b[0m \u001b[31m10.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: spacy<3.5.0,>=3.4.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from fr-core-news-sm==3.4.0) (3.4.1)\n",
      "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (1.9.2)\n",
      "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.9 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (3.0.10)\n",
      "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (3.3.0)\n",
      "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (1.0.3)\n",
      "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (3.0.7)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (4.64.1)\n",
      "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2.4.4)\n",
      "Requirement already satisfied: setuptools in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (65.3.0)\n",
      "Requirement already satisfied: typer<0.5.0,>=0.3.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (0.4.2)\n",
      "Requirement already satisfied: packaging>=20.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (21.3)\n",
      "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2.28.1)\n",
      "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2.0.6)\n",
      "Requirement already satisfied: pathy>=0.3.5 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (0.6.2)\n",
      "Requirement already satisfied: numpy>=1.15.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (1.23.3)\n",
      "Requirement already satisfied: wasabi<1.1.0,>=0.9.1 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (0.10.1)\n",
      "Requirement already satisfied: thinc<8.2.0,>=8.1.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (8.1.1)\n",
      "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (1.0.8)\n",
      "Requirement already satisfied: jinja2 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (3.1.2)\n",
      "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2.0.8)\n",
      "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from packaging>=20.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (3.0.9)\n",
      "Requirement already satisfied: smart-open<6.0.0,>=5.2.1 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from pathy>=0.3.5->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (5.2.1)\n",
      "Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (4.3.0)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (3.3)\n",
      "Requirement already satisfied: charset-normalizer<3,>=2 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2.1.1)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (1.26.11)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2022.6.15.1)\n",
      "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from thinc<8.2.0,>=8.1.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (0.0.1)\n",
      "Requirement already satisfied: blis<0.10.0,>=0.7.8 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from thinc<8.2.0,>=8.1.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (0.9.1)\n",
      "Requirement already satisfied: click<9.0.0,>=7.1.1 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from typer<0.5.0,>=0.3.0->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (8.1.3)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in /opt/homebrew/Caskroom/miniforge/base/envs/tdm-geoparsing-py39/lib/python3.9/site-packages (from jinja2->spacy<3.5.0,>=3.4.0->fr-core-news-sm==3.4.0) (2.1.1)\n",
      "Installing collected packages: fr-core-news-sm\n",
      "Successfully installed fr-core-news-sm-3.4.0\n",
      "\u001b[38;5;2m✔ Download and installation successful\u001b[0m\n",
      "You can now load the package via spacy.load('fr_core_news_sm')\n"
     ]
    }
   ],
   "source": [
    "!python -m spacy download fr_core_news_sm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Importer la librarie `spaCy` :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "import spacy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Charger le modèle français pré-entrainé de `spaCy`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "spacy_parser = spacy.load('fr_core_news_sm')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Executer la reconnaissance d'entités nommées :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "doc = spacy_parser(content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher la liste des entités nommées repérées :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Géog MISC\n",
      "de France LOC\n",
      "Normandie LOC\n",
      "pays de Caux LOC\n",
      "Arques LOC\n"
     ]
    }
   ],
   "source": [
    "for ent in doc.ents:\n",
    "    print(ent.text, ent.label_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher de manière graphique les entités nommées avec `displaCy` :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">* ARQUES, (\n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Géog\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       ".) petite ville \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    de France\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       ", en \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Normandie\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       ", au \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    pays de Caux\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       ", sur la petite riviere d'\n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Arques\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       ". Long. 18. 50. lat. 49. 54.</div></span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "displacy.render(doc, style=\"ent\", jupyter=True) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.3 Perdido Geoparser"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Instancier et paramétrer la chaîne de traitement :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "geoparser = Geoparser(version=\"Encyclopedie\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Executer la reconnaissance d'entités nommées :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "doc = geoparser(content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher la liste des entités nommées repérées :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ARQUES place\n",
      "France place\n",
      "Normandie place\n",
      "Caux place\n",
      "Arques place\n",
      "Long . 18 . 50 . lat . 49 . 54 . latlong\n"
     ]
    }
   ],
   "source": [
    "for ent in doc.named_entities:\n",
    "    print(ent.text, ent.tag)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher de manière graphique les entités nommées avec `displaCy` :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">* \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    ARQUES\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , ( Géog . ) petite ville de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    France\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , en \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Normandie\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , au pays de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Caux\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , sur la petite riviere d' \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Arques\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " . \n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Long . 18 . 50 . lat . 49 . 54 .\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       " </div></span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "displacy.render(doc.to_spacy_doc(), style=\"ent\", jupyter=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher de manière graphique les entités nommées étendues avec `displaCy` :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span class=\"tex2jax_ignore\"><div class=\"spans\" style=\"line-height: 2.5; direction: ltr\">\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    *\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ddd; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        MISC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 77px;\">\n",
       "    ARQUES\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       ", ( Géog . ) \n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    petite\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    ville\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    de\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 77px;\">\n",
       "    France\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       ", en \n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    Normandie\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       ", au \n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    pays\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    de\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 77px;\">\n",
       "    Caux\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       ", sur \n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    la\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    petite\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    riviere\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    d'\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 77px;\">\n",
       "    Arques\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ff9561; top: 57px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ff9561; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        LOC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       ". \n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    Long\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "    <span style=\"background: #ddd; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px\">\n",
       "        MISC\n",
       "    </span>\n",
       "</span>\n",
       "\n",
       "\n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    .\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    18\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    .\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    50\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    .\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    lat\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    .\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    49\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    .\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    54\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "\n",
       "<span style=\"font-weight: bold; display: inline-block; position: relative; height: 60px;\">\n",
       "    .\n",
       "    \n",
       "<span style=\"background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;\">\n",
       "</span>\n",
       "\n",
       "    \n",
       "</span>\n",
       "</div></span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "displacy.render(doc.to_spacy_doc(), style=\"span\", jupyter=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.4 Expérimentations et comparaison"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6. Geoparsing / Geocoding\n",
    "\n",
    "En complément de la tâche de reconnaissance des entités nommées la librairie `Perdido` propose également celle de résolution des toponymes, on parle alors de *Geoparsing*. Cette tâche consiste a associer à un nom de lieu des coordonnées géographiques non ambigus. De manière classique elle s'appuie sur le repérage des entités spatiales identifées lors de la reconnaissance des entités nommées et fait appel à des ressources externes de type *gazetier* (ou dictionnaires topographique) pour localiser les lieux."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6.1 Perdido Geoparser"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* On re-execute Perdido sur l'exemple de l'article `ARQUES`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "content = \"* ARQUES, (Géog.) petite ville de France, en Normandie, au pays de Caux, sur la petite riviere d'Arques. Long. 18. 50. lat. 49. 54.\"\n",
    "doc = geoparser(content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* En plus de pouvoir afficher la liste des entités nommées comme nous l'avons fait précédemmment, nous pouvons directement afficher la carte des lieux localisés"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">* \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    ARQUES\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , ( Géog . ) petite ville de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    France\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , en \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Normandie\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , au pays de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Caux\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , sur la petite riviere d' \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Arques\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " . \n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Long . 18 . 50 . lat . 49 . 54 .\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       " </div></span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "displacy.render(doc.to_spacy_doc(), style=\"ent\", jupyter=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_94e5b4d94b94e9cc40b870c5ed322bdc {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_94e5b4d94b94e9cc40b870c5ed322bdc&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_94e5b4d94b94e9cc40b870c5ed322bdc = L.map(\n",
       "                &quot;map_94e5b4d94b94e9cc40b870c5ed322bdc&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_25a9a829337af9eb39ad4504b0038ef4 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_94e5b4d94b94e9cc40b870c5ed322bdc);\n",
       "        \n",
       "    \n",
       "            map_94e5b4d94b94e9cc40b870c5ed322bdc.fitBounds(\n",
       "                [[43.509654, 0.313853], [50.739664, 3.363576]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a_add (data) {\n",
       "            geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a\n",
       "                .addData(data)\n",
       "                .addTo(map_94e5b4d94b94e9cc40b870c5ed322bdc);\n",
       "        }\n",
       "            geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [2.306207, 50.739664], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.3&quot;, &quot;name&quot;: &quot;ARQUES&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.888334, 46.603354], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [0.313853, 49.067771], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.9&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Normandie, France m\\u00e9tropolitaine, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.363576, 43.509654], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.13&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Caux, B\\u00e9ziers, H\\u00e9rault, Occitanie, France m\\u00e9tropolitaine, 34720, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.306207, 50.739664], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.17&quot;, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_7baf9297b4ebcbe96bd71ce6c3deed7a.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2ea090b80>"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# afficher la carte des lieux localisés\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Par défaut, lors de l'instanciation du `Geoparser()`, seul [OpenStreetMap](https://www.openstreetmap.org/) est utilisé pour le geocoding et au maximum un résultat est retourné pour chaque lieu (nous verrons dans la suite comment paramétrer le geocoding).\n",
    "\n",
    "On a déjà ici un aperçu de la difficulté de la tâche de résolution des toponymes. En effet, un grand nombre d'ambiguïtés existent tels que plusieurs lieux ayant le même nom, plusieurs noms pour un même lieu ou encore le fait qu'un lieu ne soit pas référencé dans les ressources que l'on interroge."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6.2 Perdido Geocoder\n",
    "\n",
    "En complément du `Geoparser` qui prend en paramètre un texte et qui fait la reconnaissance d'entités nommées en amont de l'étape de geocoding, `Perdido`propose également une fonction de geocoding disctincte prenant en paramètre directement un nom de lieu (ou une liste de noms de lieux)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_e10fc9f543e651396bfbe0c40805f167 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_e10fc9f543e651396bfbe0c40805f167&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_e10fc9f543e651396bfbe0c40805f167 = L.map(\n",
       "                &quot;map_e10fc9f543e651396bfbe0c40805f167&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_5bd445761ca880d456df216c8c21baee = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_e10fc9f543e651396bfbe0c40805f167);\n",
       "        \n",
       "    \n",
       "            map_e10fc9f543e651396bfbe0c40805f167.fitBounds(\n",
       "                [[43.509654, 0.313853], [50.739664, 3.363576]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_47cfcb0b85833c215e0616c0b57df4d8_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_47cfcb0b85833c215e0616c0b57df4d8 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_47cfcb0b85833c215e0616c0b57df4d8_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_47cfcb0b85833c215e0616c0b57df4d8_add (data) {\n",
       "            geo_json_47cfcb0b85833c215e0616c0b57df4d8\n",
       "                .addData(data)\n",
       "                .addTo(map_e10fc9f543e651396bfbe0c40805f167);\n",
       "        }\n",
       "            geo_json_47cfcb0b85833c215e0616c0b57df4d8_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [2.306207, 50.739664], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.888334, 46.603354], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [0.313853, 49.067771], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Normandie, France m\\u00e9tropolitaine, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.363576, 43.509654], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Caux, B\\u00e9ziers, H\\u00e9rault, Occitanie, France m\\u00e9tropolitaine, 34720, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_47cfcb0b85833c215e0616c0b57df4d8.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2ea090580>"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geocoder = Geocoder()\n",
    "doc = geocoder(['Arques', 'France', 'Normandie', 'Caux'])\n",
    "\n",
    "# afficher la carte des lieux localisés\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6.2 Résolution de toponymes / désambiguïsation\n",
    "\n",
    "\n",
    "#### 6.2.1 Exemple : Arques\n",
    "\n",
    "* Cherchons à localiser la ville `Arques`\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_be6124bcf640029daca852b2cbdb4231 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_be6124bcf640029daca852b2cbdb4231&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_be6124bcf640029daca852b2cbdb4231 = L.map(\n",
       "                &quot;map_be6124bcf640029daca852b2cbdb4231&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_b9370e9f8be546bdc6580266e27d367d = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_be6124bcf640029daca852b2cbdb4231);\n",
       "        \n",
       "    \n",
       "            map_be6124bcf640029daca852b2cbdb4231.fitBounds(\n",
       "                [[50.739664, 2.306207], [50.739664, 2.306207]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_2397947c8ad71c3f6bb866e59390c38b_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_2397947c8ad71c3f6bb866e59390c38b = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_2397947c8ad71c3f6bb866e59390c38b_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_2397947c8ad71c3f6bb866e59390c38b_add (data) {\n",
       "            geo_json_2397947c8ad71c3f6bb866e59390c38b\n",
       "                .addData(data)\n",
       "                .addTo(map_be6124bcf640029daca852b2cbdb4231);\n",
       "        }\n",
       "            geo_json_2397947c8ad71c3f6bb866e59390c38b_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [2.306207, 50.739664], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_2397947c8ad71c3f6bb866e59390c38b.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2ea090ee0>"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geocoder = Geocoder()\n",
    "doc = geocoder('Arques')\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On remarque que par défaut, la localisation retournée pour le nom de lieu `Arques` n'est pas celle que l'on recherche. En effet, le texte indique qu'il s'agit d'une ville de Normandie hors ici la localisation proposée est située dans le Pas-de-Calais !\n",
    "\n",
    "Changeons les paramètres du `Geocoder` (ces paramètres sont similaires pour le `Geoparser`) pour essayer de retrouver la bonne localisation.\n",
    "\n",
    "* Augmenter le nombre de résultats retournés par les gazetiers interrogés"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_147b68973bd8a4617348ab054d1515e8 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_147b68973bd8a4617348ab054d1515e8&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_147b68973bd8a4617348ab054d1515e8 = L.map(\n",
       "                &quot;map_147b68973bd8a4617348ab054d1515e8&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_28748615e9f174a487f0d9f695c1261f = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_147b68973bd8a4617348ab054d1515e8);\n",
       "        \n",
       "    \n",
       "            map_147b68973bd8a4617348ab054d1515e8.fitBounds(\n",
       "                [[41.661452, -8.721672], [50.746125, 3.119602]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_8e2a0159718eca287c433a12e1b757de_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_8e2a0159718eca287c433a12e1b757de = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_8e2a0159718eca287c433a12e1b757de_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_8e2a0159718eca287c433a12e1b757de_add (data) {\n",
       "            geo_json_8e2a0159718eca287c433a12e1b757de\n",
       "                .addData(data)\n",
       "                .addTo(map_147b68973bd8a4617348ab054d1515e8);\n",
       "        }\n",
       "            geo_json_8e2a0159718eca287c433a12e1b757de_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [2.306207, 50.739664], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.374819, 42.952872], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Limoux, Aude, Occitanie, France m\\u00e9tropolitaine, 11190, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.799134, 44.317619], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Millau, Aveyron, Occitanie, France m\\u00e9tropolitaine, 12290, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.648002, 44.968669], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Strenquels, Gourdon, Lot, Occitanie, France m\\u00e9tropolitaine, 46110, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-8.721672, 41.661452], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Portugal&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Vila de Punhe, Viana do Castelo, 4905-643, Portugal&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.119602, 44.004793], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Lapanouse-de-Cernon, Millau, Aveyron, Occitanie, France m\\u00e9tropolitaine, 12230, France&quot;, &quot;type&quot;: &quot;isolated_dwelling&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.320674, 50.746125], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques (Parc naturel r\\u00e9gional des caps et marais d\\u0027Opale), Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;admin_fraction&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.05149, 42.812241], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Galinagues, Limoux, Aude, Occitanie, France m\\u00e9tropolitaine, 11140, France&quot;, &quot;type&quot;: &quot;locality&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [0.252495, 43.245551], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arqu\\u00e8s, Goudon, Tarbes, Hautes-Pyr\\u00e9n\\u00e9es, Occitanie, France m\\u00e9tropolitaine, 65190, France&quot;, &quot;type&quot;: &quot;locality&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.302074, 50.728092], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Arques, Rue de Boulogne, Arques, Saint-Omer, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62510, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_8e2a0159718eca287c433a12e1b757de.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2d7067910>"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geocoder = Geocoder(max_rows=10)\n",
    "doc = geocoder('Arques')\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On observe parmi les 10 localisations retournées par OpenStreetMap (gazetier par défaut) qu'aucune ne se situe en Normandie.\n",
    "\n",
    "* Remplacer OpenStreetMap par l'IGN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_dbd840986bf0902bc4b8155da08ddc99 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_dbd840986bf0902bc4b8155da08ddc99&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_dbd840986bf0902bc4b8155da08ddc99 = L.map(\n",
       "                &quot;map_dbd840986bf0902bc4b8155da08ddc99&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_e7e286511395268233aaa50b6fe19ca2 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_dbd840986bf0902bc4b8155da08ddc99);\n",
       "        \n",
       "    \n",
       "            map_dbd840986bf0902bc4b8155da08ddc99.fitBounds(\n",
       "                [[42.734711, 1.544996], [42.734711, 1.544996]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_1b868beb5b1893a2cd9654b8c6102169_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_1b868beb5b1893a2cd9654b8c6102169 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_1b868beb5b1893a2cd9654b8c6102169_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_1b868beb5b1893a2cd9654b8c6102169_add (data) {\n",
       "            geo_json_1b868beb5b1893a2cd9654b8c6102169\n",
       "                .addData(data)\n",
       "                .addTo(map_dbd840986bf0902bc4b8155da08ddc99);\n",
       "        }\n",
       "            geo_json_1b868beb5b1893a2cd9654b8c6102169_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [1.544996, 42.734711], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Siguer&quot;, &quot;type&quot;: &quot;Versant&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_1b868beb5b1893a2cd9654b8c6102169.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2d7074730>"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geocoder = Geocoder(sources=['ign'])\n",
    "doc = geocoder('Arques')\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On observe que le premier résultat retourné par l'IGN ne se situe ni en Normandie (comme attendu), ni dans le Pas-de-Calais comme le premier résultat retourné par OpenStreetMap.\n",
    "\n",
    "* Augmenter le nombre de résultats retournés par l'IGN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_46429928ee4bb195ccc43e51bb0faa68 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_46429928ee4bb195ccc43e51bb0faa68&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_46429928ee4bb195ccc43e51bb0faa68 = L.map(\n",
       "                &quot;map_46429928ee4bb195ccc43e51bb0faa68&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_e4163f67394617bad21dd8885fb1d484 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_46429928ee4bb195ccc43e51bb0faa68);\n",
       "        \n",
       "    \n",
       "            map_46429928ee4bb195ccc43e51bb0faa68.fitBounds(\n",
       "                [[42.734711, 0.253068], [50.733882, 2.799876]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_eda3647008bc9fd3c836bd1839931f40_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_eda3647008bc9fd3c836bd1839931f40 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_eda3647008bc9fd3c836bd1839931f40_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_eda3647008bc9fd3c836bd1839931f40_add (data) {\n",
       "            geo_json_eda3647008bc9fd3c836bd1839931f40\n",
       "                .addData(data)\n",
       "                .addTo(map_46429928ee4bb195ccc43e51bb0faa68);\n",
       "        }\n",
       "            geo_json_eda3647008bc9fd3c836bd1839931f40_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [1.544996, 42.734711], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Siguer&quot;, &quot;type&quot;: &quot;Versant&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.376764, 42.952434], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Arques&quot;, &quot;type&quot;: &quot;Commune&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.799876, 44.317956], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Arques&quot;, &quot;type&quot;: &quot;Commune&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.250132, 43.293669], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Marquefave&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.647947, 44.968879], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Strenquels&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.294824, 50.733882], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Arques&quot;, &quot;type&quot;: &quot;Commune&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [0.253068, 43.245235], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Goudon&quot;, &quot;type&quot;: &quot;Lieu-dit non habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.792246, 44.065762], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Viala-du-Tarn&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.793915, 44.068551], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Viala-du-Tarn&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.125078, 49.880248], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Arques&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Arques-la-Bataille&quot;, &quot;type&quot;: &quot;Commune&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_eda3647008bc9fd3c836bd1839931f40.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2e81b0100>"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geocoder = Geocoder(sources=['ign'], max_rows=10)\n",
    "doc = geocoder('Arques')\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Cette fois-ci on retrouve bien une localisation en Normandie au sud de Dieppe avec pour nom `Arques-la-Bataille'. On peut faire l'hypotèse que le nom a évolué car cette localisation se situe bien dans le Pays de Caux (voir illustration ci-dessous, source [Wikipedia](https://fr.wikipedia.org/wiki/Pays_de_Caux)) comme l'indique le texte de l'article.\n",
    "\n",
    "![Pays de Caux](https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Carte_pays_Caux1.png/497px-Carte_pays_Caux1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Il reste néanmoins le problème de retrouver cette localisation de manière automatique. \n",
    "Plusieurs approches existent dans la littérature mais ne sont pas encore implémentées dans `Perdido`.\n",
    "\n",
    "Cet exemple illustre bien la difficulté de la problématique de désambiguïsation des toponymes avec notamment la gestion des natures de lieux différentes (pays, régions, communes, lieux-dits, lac, rivières, etc.) associés à un même nom, l'homonymie, la non exaustivité des ressources, l'évolution des noms au cours du temps ou encore les erreurs d'orthographe."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Afficher la carte obtenue après le geoparsing avec l'IGN et 10 résultats max par nom de lieu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_2f0c11ee659bebebb73f5ace63d9efc0 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_2f0c11ee659bebebb73f5ace63d9efc0&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_2f0c11ee659bebebb73f5ace63d9efc0 = L.map(\n",
       "                &quot;map_2f0c11ee659bebebb73f5ace63d9efc0&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_e722ba722b5a3bfd4cddc51cf8ded6bb = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_2f0c11ee659bebebb73f5ace63d9efc0);\n",
       "        \n",
       "    \n",
       "            map_2f0c11ee659bebebb73f5ace63d9efc0.fitBounds(\n",
       "                [[43.079622, -4.068862], [50.130325, 5.821841]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_668bf5efb10db7221ebe4ddb6f95ce3b_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_668bf5efb10db7221ebe4ddb6f95ce3b = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_668bf5efb10db7221ebe4ddb6f95ce3b_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_668bf5efb10db7221ebe4ddb6f95ce3b_add (data) {\n",
       "            geo_json_668bf5efb10db7221ebe4ddb6f95ce3b\n",
       "                .addData(data)\n",
       "                .addTo(map_2f0c11ee659bebebb73f5ace63d9efc0);\n",
       "        }\n",
       "            geo_json_668bf5efb10db7221ebe4ddb6f95ce3b_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [5.096652, 45.869265], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Bressolles&quot;, &quot;type&quot;: &quot;Quartier&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [5.354185, 46.233164], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Meillonnas&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [5.67897, 44.471041], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;La Piarre&quot;, &quot;type&quot;: &quot;Bois&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.175565, 43.079622], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Gaja-et-Villedieu&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.789769, 43.233532], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Saint-Sernin&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [5.577606, 43.570891], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Vauvenargues&quot;, &quot;type&quot;: &quot;Ruines&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-0.848019, 45.603663], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Gr\\u00e9zac&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-0.581724, 45.494817], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Bois&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.617984, 45.368456], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Lagrauli\\u00e8re&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [0.941046, 43.167396], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.5&quot;, &quot;name&quot;: &quot;France&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Mancioux&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [4.851823, 50.130325], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Givet&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.447184, 44.723667], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Junhac&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-0.855164, 46.246698], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Saint-Jean-de-Liversay&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-2.743228, 48.323177], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Pl\\u0153uc-L\\u0027Hermitage&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.102508, 49.443031], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Rouen&quot;, &quot;type&quot;: &quot;R\\u00e9gion&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-4.068862, 48.297443], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Pont-de-Buis-l\\u00e8s-Quimerch&quot;, &quot;type&quot;: &quot;Lieu-dit non habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-1.64847, 48.231258], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Melesse&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [5.821841, 47.307332], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Brussey&quot;, &quot;type&quot;: &quot;Lieu-dit non habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.90554, 48.223278], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Lorrez-le-Bocage-Pr\\u00e9aux&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.240619, 44.159185], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Normandie&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Lafran\\u00e7aise&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.553925, 46.432375], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;La Chapelaude&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.255493, 43.225454], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Caux-et-Sauzens&quot;, &quot;type&quot;: &quot;Commune&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.047133, 45.725903], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Peyrelevade&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.039653, 45.401722], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;\\u00c9gletons&quot;, &quot;type&quot;: &quot;Quartier&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.888828, 45.30495], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Saint-Priest-de-Gimel&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.787262, 46.284578], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;La Celle-Dunoise&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.368457, 43.50344], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Caux&quot;, &quot;type&quot;: &quot;Commune&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.448328, 45.208555], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Saint-Privat-du-Dragon&quot;, &quot;type&quot;: &quot;Bois&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.13549, 44.381744], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Montcuq-en-Quercy-Blanc&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.684528, 45.458418], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;Caux&quot;, &quot;source&quot;: &quot;ign&quot;, &quot;sourceName&quot;: &quot;Saint-Donat&quot;, &quot;type&quot;: &quot;Lieu-dit habit\\u00e9&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_668bf5efb10db7221ebe4ddb6f95ce3b.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2ea1e3280>"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geoparser = Geoparser(sources=['ign'], max_rows=10)\n",
    "doc = geoparser(content)\n",
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### 6.3 Le cas des descriptions de randonnées\n",
    "\n",
    "Prenons maintenant l'exemple du geoparsing de descriptions de randonnées. Certaines solutions de désambiguisation ont pu être développées et intégrées au sein de la librairie `Perdido` (d'autres sont en cours d'intégration). Les solutions décrites dans la suite de cette partie ont été développées dans le cadre des projets [Perdido](http://erig.univ-pau.fr/PERDIDO/) (2012-2015) et [ANR CHOUCAS](http://choucas.ign.fr) (2017-2022). \n",
    "\n",
    "> Ludovic Moncla, Walter Renteria-Agualimpia, Javier Nogueras-Iso and Mauro Gaio (2014). \"Geocoding for texts with fine-grain toponyms: an experiment on a geoparsed hiking descriptions corpus\". In Proceedings of the 22nd ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems, pp 183-192.\n",
    "\n",
    "> Mauro Gaio and Ludovic Moncla (2019). “Geoparsing and geocoding places in a dynamic space context.“ In The Semantics of Dynamic Space in French: Descriptive, experimental and formal studies on motion expression, 66, 353.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Charger le jeu de données CHOUCAS de descriptions de randonnées fourni par `Perdido`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>text</th>\n",
       "      <th>geometry</th>\n",
       "      <th>#_places</th>\n",
       "      <th>#_person</th>\n",
       "      <th>#_event</th>\n",
       "      <th>#_date</th>\n",
       "      <th>#_misc</th>\n",
       "      <th>#_locations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Chalets de la Fullie</td>\n",
       "      <td>\\n\\nBoucle des chalets de la Fullie au départ ...</td>\n",
       "      <td>(LINESTRING (6.11174 45.616041, 6.11174 45.616...</td>\n",
       "      <td>17</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Traversée cabane de Pravouta  à la Plagne</td>\n",
       "      <td>\\n\\nPartir de la cabane de Pravouta juste de l...</td>\n",
       "      <td>(LINESTRING (5.832543 45.315222, 5.832444 45.3...</td>\n",
       "      <td>23</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Refuge Entre Le Lac - Refuge de la Leisse</td>\n",
       "      <td>\\n\\nDépart du refuge d'Entre le Lac près du la...</td>\n",
       "      <td>(LINESTRING (6.839184 45.480323, 6.83987 45.47...</td>\n",
       "      <td>22</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Le lac du Retour</td>\n",
       "      <td>\\n\\nDu parking de Pierre Giret, suivre la rout...</td>\n",
       "      <td>(LINESTRING (6.917631 45.619278, 6.917527 45.6...</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Traversée Alpette - Dent de Crolles</td>\n",
       "      <td>\\n</td>\n",
       "      <td>(LINESTRING (5.907402 45.440585, 5.907439 45.4...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        name  \\\n",
       "0                       Chalets de la Fullie   \n",
       "1  Traversée cabane de Pravouta  à la Plagne   \n",
       "2  Refuge Entre Le Lac - Refuge de la Leisse   \n",
       "3                           Le lac du Retour   \n",
       "4        Traversée Alpette - Dent de Crolles   \n",
       "\n",
       "                                                text  \\\n",
       "0  \\n\\nBoucle des chalets de la Fullie au départ ...   \n",
       "1  \\n\\nPartir de la cabane de Pravouta juste de l...   \n",
       "2  \\n\\nDépart du refuge d'Entre le Lac près du la...   \n",
       "3  \\n\\nDu parking de Pierre Giret, suivre la rout...   \n",
       "4                                                 \\n   \n",
       "\n",
       "                                            geometry  #_places  #_person  \\\n",
       "0  (LINESTRING (6.11174 45.616041, 6.11174 45.616...        17         0   \n",
       "1  (LINESTRING (5.832543 45.315222, 5.832444 45.3...        23         2   \n",
       "2  (LINESTRING (6.839184 45.480323, 6.83987 45.47...        22         0   \n",
       "3  (LINESTRING (6.917631 45.619278, 6.917527 45.6...         6         1   \n",
       "4  (LINESTRING (5.907402 45.440585, 5.907439 45.4...         0         0   \n",
       "\n",
       "   #_event  #_date  #_misc  #_locations  \n",
       "0        0       0       0           17  \n",
       "1        0       0       0           23  \n",
       "2        0       0       0           22  \n",
       "3        0       0       0            6  \n",
       "4        0       0       0            0  "
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset_choucas = load_choucas_perdido()\n",
    "data_choucas = dataset_choucas['data']\n",
    "\n",
    "\n",
    "data_choucas.to_dataframe().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data_choucas)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Sélectionner une randonnée (parmi les 30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "id_rando = 2\n",
    "doc = data_choucas[id_rando]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\n\\nDépart du refuge d'Entre le Lac près du lac de la Plagne.\\nDu refuge Entre le Lac, un sentier remonte les pentes herbeuses et permet de rejoindre le GR5 un peu avant le chalet de la Grassaz (chalet du berger 2335m). Toujours en direction du sud, on remonte le vallon en longeant le ruisseau. On parvient ainsi à l'extrémité ouest du lac de Grattaleu; un peu plus haut, on atteint le refuge du col du Palet (2550m). On admire la beauté de la vallée et le sommet de Bellecote recouvert de glaciers. Le GR descend vers l'Est; le sentier serpente entre des entonnoirs créés dans le gypse par dissolution. Le GR passe sous un 1er télésiège, celui de Grattaleu, et près de l'arrivée d'un second, le Tichot. Au chalet de Lognan (croix) prendre à droite un sentier qui descend à Val Claret (2107m) (station de ski). Poursuivre jusqu'au chalet de la Leisse. Le GR55 s'élève vers le vallon du paquis. On passe en contrebas du chalet du Prariond; un peu plus loin on arrive à la bifurcation du col de Fresse (2531m). Laisser à gauche le sentier montant au col de Fresse (2576m), le GR55 continue sud sud ouest dans un décor sauvage entre le massif de la Grande motte et la pointe du Grand Pré; il grimpe parmi des rochers: les balises peuvent être des cairns; bien être attentif pour bien les suivre jusqu'au col de la Leisse (2758 m). Le GR55 descend dans une zone d'éboulis, bien suivre les cairns, par une piste peu visible. Ensuite, il longe le lac des Nettes dans un univers très minéral sur sa rive et pour en atteindre l'extrémité sud. On retrouve dans les alpages le sentier bien tracé qui parcourt le plan des Nettes sur la rive droite du torrent. Peu après un petit barrage qui est en cours de destruction, on arrive au refuge de la Leisse (2487m).\\n\\n\\n\\n\""
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "doc.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span class=\"tex2jax_ignore\"><div class=\"entities\" style=\"line-height: 2.5; direction: ltr\">Départ du refuge d' Entre le Lac près du lac de la \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Plagne\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " . Du refuge Entre le Lac , un sentier remonte les pentes herbeuses et permet de rejoindre le GR5 un peu avant le chalet de la \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Grassaz\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( chalet du \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    berger\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " 2335m ) . Toujours en direction du sud , on remonte le vallon en longeant le ruisseau . On parvient ainsi à l' extrémité ouest du lac de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Grattaleu\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ; un peu plus haut , on atteint le refuge du \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    col\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " du \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Palet\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( 2550m ) . On admire la beauté de la vallée et le sommet de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Bellecote\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " recouvert de glaciers . Le \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    GR\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " descend vers l' Est ; le sentier serpente entre des entonnoirs créés dans le gypse par dissolution . Le \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    GR\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " passe sous un 1er télésiège , celui de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Grattaleu\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " , et près de l' arrivée d' un second , le \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Tichot\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " . Au chalet de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Lognan\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( croix ) prendre à droite un sentier qui descend à Val \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Claret\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( 2107m ) ( station de ski ) . Poursuivre jusqu' au chalet de la \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Leisse\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " . Le \n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    GR55\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       " s' élève vers le vallon du \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    paquis\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " . On passe en contrebas du chalet du \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Prariond\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ; un peu plus loin on arrive à la bifurcation du col de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Fresse\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( 2531m ) . Laisser à gauche le sentier montant au col de \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Fresse\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( 2576m ) , le \n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    GR55\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       " continue sud sud ouest dans un décor sauvage entre le massif de la \n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Grande\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       " motte et la pointe du Grand Pré ; il grimpe parmi des rochers : les balises peuvent être des cairns ; bien être attentif pour bien les suivre jusqu' au col de la \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Leisse\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( 2758 m ) . Le \n",
       "<mark class=\"entity\" style=\"background: #ddd; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    GR55\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">MISC</span>\n",
       "</mark>\n",
       " descend dans une zone d' éboulis , bien suivre les cairns , par une piste peu visible . Ensuite , il longe le lac des \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Nettes\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " dans un univers très minéral sur sa rive et pour en atteindre l' extrémité sud . On retrouve dans les alpages le sentier bien tracé qui parcourt le plan des \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Nettes\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " sur la rive droite du torrent . Peu après un petit barrage qui est en cours de destruction , on arrive au refuge de la \n",
       "<mark class=\"entity\" style=\"background: #ff9561; padding: 0.45em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em;\">\n",
       "    Leisse\n",
       "    <span style=\"font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; vertical-align: middle; margin-left: 0.5rem\">LOC</span>\n",
       "</mark>\n",
       " ( 2487m ) . </div></span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "displacy.render(doc.to_spacy_doc(), style=\"ent\", jupyter=True) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_70b18832967330e906b27f597aeb9732 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_70b18832967330e906b27f597aeb9732&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_70b18832967330e906b27f597aeb9732 = L.map(\n",
       "                &quot;map_70b18832967330e906b27f597aeb9732&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_93867c68e8bb29f0913303d071cc33d8 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_70b18832967330e906b27f597aeb9732);\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_c9dc27ac7a26440e2debd813aa954813_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_c9dc27ac7a26440e2debd813aa954813 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_c9dc27ac7a26440e2debd813aa954813_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_c9dc27ac7a26440e2debd813aa954813_add (data) {\n",
       "            geo_json_c9dc27ac7a26440e2debd813aa954813\n",
       "                .addData(data)\n",
       "                .addTo(map_70b18832967330e906b27f597aeb9732);\n",
       "        }\n",
       "            geo_json_c9dc27ac7a26440e2debd813aa954813_add({&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;features&quot;: [{&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;geometry&quot;: {&quot;coordinates&quot;: [[[6.839184, 45.480323], [6.83987, 45.479299], [6.841973, 45.478562], [6.843969, 45.47857], [6.845235, 45.479931], [6.847187, 45.479675], [6.847766, 45.480112], [6.848368, 45.479932], [6.849569, 45.480172], [6.850213, 45.479029], [6.850685, 45.477254], [6.8509, 45.476306], [6.851114, 45.474425], [6.851758, 45.472889], [6.853217, 45.471626], [6.855106, 45.46982], [6.855534, 45.468766], [6.855191, 45.468014], [6.85605, 45.46684], [6.856092, 45.464914], [6.856049, 45.463891], [6.855663, 45.462356], [6.856093, 45.461679], [6.856822, 45.46137], [6.857122, 45.460038], [6.857166, 45.458864], [6.857724, 45.458021], [6.858754, 45.457765], [6.859698, 45.458503], [6.860513, 45.458097], [6.861564, 45.458676], [6.861575, 45.457732], [6.860641, 45.456396], [6.864246, 45.456245], [6.865748, 45.455944], [6.867508, 45.455763], [6.869139, 45.455884], [6.870942, 45.456034], [6.875319, 45.454649], [6.879224, 45.455432], [6.881391, 45.454996], [6.883816, 45.455463], [6.886091, 45.455613], [6.887936, 45.456004], [6.890725, 45.457841], [6.890789, 45.45608], [6.891379, 45.454687], [6.892742, 45.454379], [6.894287, 45.453084], [6.896261, 45.45191], [6.896733, 45.452663], [6.898192, 45.452602], [6.899759, 45.453009], [6.90184, 45.452392], [6.902398, 45.451308], [6.903771, 45.450827], [6.905102, 45.450525], [6.906303, 45.451308], [6.909179, 45.449742], [6.911582, 45.448568], [6.913986, 45.447755], [6.916839, 45.44619], [6.917944, 45.444971], [6.920036, 45.444083], [6.92214, 45.441493], [6.921732, 45.440138], [6.91921, 45.437713], [6.916174, 45.435741], [6.915831, 45.433859], [6.915701, 45.432067], [6.914092, 45.430877], [6.912398, 45.429567], [6.912054, 45.428845], [6.910767, 45.428423], [6.910209, 45.4277], [6.910423, 45.427038], [6.908664, 45.425321], [6.906861, 45.423603], [6.905509, 45.42261], [6.903985, 45.421586], [6.904544, 45.420486], [6.904587, 45.418784], [6.903986, 45.41779], [6.9039, 45.416254], [6.904393, 45.414838], [6.9042, 45.413301], [6.902741, 45.411855], [6.90081, 45.411524], [6.900123, 45.410636], [6.90111, 45.409476], [6.901003, 45.408707], [6.900349, 45.408564], [6.900064, 45.409095], [6.899343, 45.408773], [6.89742, 45.408511], [6.893514, 45.404624], [6.890639, 45.403811], [6.889116, 45.403374], [6.887592, 45.402576], [6.886176, 45.401822], [6.886262, 45.400858], [6.886444, 45.400128], [6.887142, 45.4], [6.88652, 45.399201], [6.885339, 45.398297], [6.885704, 45.397966], [6.88403, 45.397318], [6.88227, 45.396851]]], &quot;type&quot;: &quot;MultiLineString&quot;}, &quot;id&quot;: &quot;0&quot;, &quot;properties&quot;: {}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "            map_70b18832967330e906b27f597aeb9732.fitBounds(\n",
       "                [[45.412971, 6.837532], [45.462018, 6.963285]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_6d5300315b25fd6c35618511577f3679_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_6d5300315b25fd6c35618511577f3679 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_6d5300315b25fd6c35618511577f3679_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_6d5300315b25fd6c35618511577f3679_add (data) {\n",
       "            geo_json_6d5300315b25fd6c35618511577f3679\n",
       "                .addData(data)\n",
       "                .addTo(map_70b18832967330e906b27f597aeb9732);\n",
       "        }\n",
       "            geo_json_6d5300315b25fd6c35618511577f3679_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [6.837532, 45.456069], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.456069, &quot;longitude&quot;: 6.837532, &quot;name&quot;: &quot;Grassaz&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col de la Grassaz, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;xmlID&quot;: &quot;en.7&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.461481, &quot;longitude&quot;: 6.858926, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;xmlID&quot;: &quot;en.15&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.863067, 45.451642], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.451642, &quot;longitude&quot;: 6.863067, &quot;name&quot;: &quot;Palet&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Signal du Palet, Champagny-en-Vanoise, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73350, France&quot;, &quot;xmlID&quot;: &quot;en.22&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.963285, 45.462018], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.462018, &quot;longitude&quot;: 6.963285, &quot;name&quot;: &quot;Bellecote&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Bellecote, Sentier de la Vall\\u00e9e Perdue, Le Cr\\u00eat, La Daille, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: &quot;en.26&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.461481, &quot;longitude&quot;: 6.858926, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;xmlID&quot;: &quot;en.32&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.896874, 45.454039], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.454039, &quot;longitude&quot;: 6.896874, &quot;name&quot;: &quot;Tichot&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Tichot, Tarte \\u00e0 Lognan, Val-Claret, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;xmlID&quot;: &quot;en.34&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.898275, 45.419228], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.419228, &quot;longitude&quot;: 6.898275, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Leisse, Chemin de Borsat, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: &quot;en.46&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.914334, 45.458216], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.458216, &quot;longitude&quot;: 6.914334, &quot;name&quot;: &quot;paquis&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Paquis, GunPowder, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;xmlID&quot;: &quot;en.52&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.92583, 45.442088], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.442088, &quot;longitude&quot;: 6.92583, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, Piste du Col de Fresse, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: &quot;en.62&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.92583, 45.442088], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.442088, &quot;longitude&quot;: 6.92583, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, Piste du Col de Fresse, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: &quot;en.66&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.898275, 45.419228], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.419228, &quot;longitude&quot;: 6.898275, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Leisse, Chemin de Borsat, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: &quot;en.76&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.412971, &quot;longitude&quot;: 6.89952, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;xmlID&quot;: &quot;en.82&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.412971, &quot;longitude&quot;: 6.89952, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;xmlID&quot;: &quot;en.86&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.898275, 45.419228], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.419228, &quot;longitude&quot;: 6.898275, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Leisse, Chemin de Borsat, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: &quot;en.90&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_6d5300315b25fd6c35618511577f3679.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2f1fb9af0>"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "doc.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On observe ici le résultat déjà pré-traité par `Perdido`. Nous allons maintenant illustrer le processus de désambiguïsation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On recommence le processus de geoparsing en entier à partir du texte de la randonnées choisie."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [],
   "source": [
    "geoparser = Geoparser()\n",
    "doc_geoparsed = geoparser(doc.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_3be5297bcda82ebe8c95fa85e5b69029 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_3be5297bcda82ebe8c95fa85e5b69029&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_3be5297bcda82ebe8c95fa85e5b69029 = L.map(\n",
       "                &quot;map_3be5297bcda82ebe8c95fa85e5b69029&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_9b3df20b0a14d61cf597cfb63f05e725 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_3be5297bcda82ebe8c95fa85e5b69029);\n",
       "        \n",
       "    \n",
       "            map_3be5297bcda82ebe8c95fa85e5b69029.fitBounds(\n",
       "                [[38.674213, -91.338769], [53.582329, 21.987713]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_7e7065bb4d17ca5707a88375cf728cfd_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_7e7065bb4d17ca5707a88375cf728cfd = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_7e7065bb4d17ca5707a88375cf728cfd_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_7e7065bb4d17ca5707a88375cf728cfd_add (data) {\n",
       "            geo_json_7e7065bb4d17ca5707a88375cf728cfd\n",
       "                .addData(data)\n",
       "                .addTo(map_3be5297bcda82ebe8c95fa85e5b69029);\n",
       "        }\n",
       "            geo_json_7e7065bb4d17ca5707a88375cf728cfd_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [1.060214, 43.157123], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.3&quot;, &quot;name&quot;: &quot;Plagne&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Plagne, Muret, Haute-Garonne, Occitanie, France m\\u00e9tropolitaine, 31220, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.837532, 45.456069], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.7&quot;, &quot;name&quot;: &quot;Grassaz&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col de la Grassaz, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;yes&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-91.338769, 38.674213], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;United States&quot;, &quot;id&quot;: &quot;en.11&quot;, &quot;name&quot;: &quot;berger&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Berger, Franklin County, Missouri, United States&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.15&quot;, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.959974, 50.938361], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Deutschland&quot;, &quot;id&quot;: &quot;en.20&quot;, &quot;name&quot;: &quot;col&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;K\\u00f6ln, Nordrhein-Westfalen, Deutschland&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-1.244805, 48.200191], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.22&quot;, &quot;name&quot;: &quot;Palet&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Palet, Taillis, Foug\\u00e8res-Vitr\\u00e9, Ille-et-Vilaine, Bretagne, France m\\u00e9tropolitaine, 35500, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.963285, 45.462018], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.26&quot;, &quot;name&quot;: &quot;Bellecote&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Bellecote, Sentier de la Vall\\u00e9e Perdue, Le Cr\\u00eat, La Daille, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;type&quot;: &quot;yes&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [21.987713, 38.995368], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;\\u0395\\u03bb\\u03bb\\u03ac\\u03c2&quot;, &quot;id&quot;: &quot;en.28&quot;, &quot;name&quot;: &quot;GR&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;\\u0395\\u03bb\\u03bb\\u03ac\\u03c2&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [21.987713, 38.995368], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;\\u0395\\u03bb\\u03bb\\u03ac\\u03c2&quot;, &quot;id&quot;: &quot;en.30&quot;, &quot;name&quot;: &quot;GR&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;\\u0395\\u03bb\\u03bb\\u03ac\\u03c2&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.32&quot;, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.896874, 45.454039], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.34&quot;, &quot;name&quot;: &quot;Tichot&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Tichot, Tarte \\u00e0 Lognan, Val-Claret, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.926505, 45.978552], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.38&quot;, &quot;name&quot;: &quot;Lognan&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lognan, Chemin de la Glaci\\u00e8re, Les Chosalets, Argenti\\u00e8re, Chamonix-Mont-Blanc, Bonneville, Haute-Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 74400, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.905872, 43.862148], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.42&quot;, &quot;name&quot;: &quot;Claret&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Claret, Lod\\u00e8ve, H\\u00e9rault, Occitanie, France m\\u00e9tropolitaine, 34270, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [8.303371, 51.188893], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Deutschland&quot;, &quot;id&quot;: &quot;en.46&quot;, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lei\\u00dfe, Bad Fredeburg, Schmallenberg, Hochsauerlandkreis, Nordrhein-Westfalen, 57392, Deutschland&quot;, &quot;type&quot;: &quot;stream&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.147314, 46.219521], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Schweiz/Suisse/Svizzera/Svizra&quot;, &quot;id&quot;: &quot;en.52&quot;, &quot;name&quot;: &quot;paquis&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;P\\u00e2quis, Gen\\u00e8ve, 1202, Schweiz/Suisse/Svizzera/Svizra&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [7.072597, 45.650494], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Italia&quot;, &quot;id&quot;: &quot;en.57&quot;, &quot;name&quot;: &quot;Prariond&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Prariond, Plant\\u00e9, Valgrisenche, Valle d\\u0027Aosta / Vall\\u00e9e d\\u0027Aoste, Italia&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.844478, 45.408958], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.62&quot;, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, \\u00c9gliseneuve-d\\u0027Entraigues, Issoire, Puy-de-D\\u00f4me, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 63850, France&quot;, &quot;type&quot;: &quot;isolated_dwelling&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.844478, 45.408958], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.66&quot;, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, \\u00c9gliseneuve-d\\u0027Entraigues, Issoire, Puy-de-D\\u00f4me, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 63850, France&quot;, &quot;type&quot;: &quot;isolated_dwelling&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [10.38635, 53.582329], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Deutschland&quot;, &quot;id&quot;: &quot;en.72&quot;, &quot;name&quot;: &quot;Grande&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Grande, Trittau, Stormarn, Schleswig-Holstein, Deutschland&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [8.303371, 51.188893], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Deutschland&quot;, &quot;id&quot;: &quot;en.76&quot;, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lei\\u00dfe, Bad Fredeburg, Schmallenberg, Hochsauerlandkreis, Nordrhein-Westfalen, 57392, Deutschland&quot;, &quot;type&quot;: &quot;stream&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.82&quot;, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: &quot;en.86&quot;, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [8.303371, 51.188893], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;Deutschland&quot;, &quot;id&quot;: &quot;en.90&quot;, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lei\\u00dfe, Bad Fredeburg, Schmallenberg, Hochsauerlandkreis, Nordrhein-Westfalen, 57392, Deutschland&quot;, &quot;type&quot;: &quot;stream&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_7e7065bb4d17ca5707a88375cf728cfd.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2f2a2c880>"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "doc_geoparsed.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On voit clairement la différence par rapport au résultat précédent. Nous allons alors essayer de retrouver le même résultat en déroulant les différentes étapes pour désambiguïser avec `Perdido`.\n",
    "\n",
    "Pour gagner un peu de temps lors des prochaines executions nous allons faire directement appel à la fonction de geocoding à partir de la liste des noms de lieux.\n",
    "\n",
    "* Récuperer la liste des noms de lieux (sans doublon)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Prariond', 'col', 'Fresse', 'berger', 'Leisse', 'Grassaz', 'Tichot', 'Nettes', 'Grande', 'GR', 'Grattaleu', 'Lognan', 'Plagne', 'Claret', 'Bellecote', 'Palet', 'paquis']\n"
     ]
    }
   ],
   "source": [
    "places_list = list(set([ent.text for ent in doc_geoparsed.ne_place]))\n",
    "print(places_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6.3.1 Ajout d'un filtre \"code pays\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_8ae897deb5c0ea4cf86261ced0b8cd07 {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_8ae897deb5c0ea4cf86261ced0b8cd07&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_8ae897deb5c0ea4cf86261ced0b8cd07 = L.map(\n",
       "                &quot;map_8ae897deb5c0ea4cf86261ced0b8cd07&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_15b583af933bb47d47ae15f191f85006 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_8ae897deb5c0ea4cf86261ced0b8cd07);\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_cc248b50e49c3bf08c85030efc441ea3_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_cc248b50e49c3bf08c85030efc441ea3 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_cc248b50e49c3bf08c85030efc441ea3_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_cc248b50e49c3bf08c85030efc441ea3_add (data) {\n",
       "            geo_json_cc248b50e49c3bf08c85030efc441ea3\n",
       "                .addData(data)\n",
       "                .addTo(map_8ae897deb5c0ea4cf86261ced0b8cd07);\n",
       "        }\n",
       "            geo_json_cc248b50e49c3bf08c85030efc441ea3_add({&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;features&quot;: [{&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;geometry&quot;: {&quot;coordinates&quot;: [[[6.839184, 45.480323], [6.83987, 45.479299], [6.841973, 45.478562], [6.843969, 45.47857], [6.845235, 45.479931], [6.847187, 45.479675], [6.847766, 45.480112], [6.848368, 45.479932], [6.849569, 45.480172], [6.850213, 45.479029], [6.850685, 45.477254], [6.8509, 45.476306], [6.851114, 45.474425], [6.851758, 45.472889], [6.853217, 45.471626], [6.855106, 45.46982], [6.855534, 45.468766], [6.855191, 45.468014], [6.85605, 45.46684], [6.856092, 45.464914], [6.856049, 45.463891], [6.855663, 45.462356], [6.856093, 45.461679], [6.856822, 45.46137], [6.857122, 45.460038], [6.857166, 45.458864], [6.857724, 45.458021], [6.858754, 45.457765], [6.859698, 45.458503], [6.860513, 45.458097], [6.861564, 45.458676], [6.861575, 45.457732], [6.860641, 45.456396], [6.864246, 45.456245], [6.865748, 45.455944], [6.867508, 45.455763], [6.869139, 45.455884], [6.870942, 45.456034], [6.875319, 45.454649], [6.879224, 45.455432], [6.881391, 45.454996], [6.883816, 45.455463], [6.886091, 45.455613], [6.887936, 45.456004], [6.890725, 45.457841], [6.890789, 45.45608], [6.891379, 45.454687], [6.892742, 45.454379], [6.894287, 45.453084], [6.896261, 45.45191], [6.896733, 45.452663], [6.898192, 45.452602], [6.899759, 45.453009], [6.90184, 45.452392], [6.902398, 45.451308], [6.903771, 45.450827], [6.905102, 45.450525], [6.906303, 45.451308], [6.909179, 45.449742], [6.911582, 45.448568], [6.913986, 45.447755], [6.916839, 45.44619], [6.917944, 45.444971], [6.920036, 45.444083], [6.92214, 45.441493], [6.921732, 45.440138], [6.91921, 45.437713], [6.916174, 45.435741], [6.915831, 45.433859], [6.915701, 45.432067], [6.914092, 45.430877], [6.912398, 45.429567], [6.912054, 45.428845], [6.910767, 45.428423], [6.910209, 45.4277], [6.910423, 45.427038], [6.908664, 45.425321], [6.906861, 45.423603], [6.905509, 45.42261], [6.903985, 45.421586], [6.904544, 45.420486], [6.904587, 45.418784], [6.903986, 45.41779], [6.9039, 45.416254], [6.904393, 45.414838], [6.9042, 45.413301], [6.902741, 45.411855], [6.90081, 45.411524], [6.900123, 45.410636], [6.90111, 45.409476], [6.901003, 45.408707], [6.900349, 45.408564], [6.900064, 45.409095], [6.899343, 45.408773], [6.89742, 45.408511], [6.893514, 45.404624], [6.890639, 45.403811], [6.889116, 45.403374], [6.887592, 45.402576], [6.886176, 45.401822], [6.886262, 45.400858], [6.886444, 45.400128], [6.887142, 45.4], [6.88652, 45.399201], [6.885339, 45.398297], [6.885704, 45.397966], [6.88403, 45.397318], [6.88227, 45.396851]]], &quot;type&quot;: &quot;MultiLineString&quot;}, &quot;id&quot;: &quot;0&quot;, &quot;properties&quot;: {}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "            map_8ae897deb5c0ea4cf86261ced0b8cd07.fitBounds(\n",
       "                [[43.157123, -1.244805], [50.823249, 7.211431]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_460c04e1cc847389755455850b2d7ae1_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_460c04e1cc847389755455850b2d7ae1 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_460c04e1cc847389755455850b2d7ae1_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_460c04e1cc847389755455850b2d7ae1_add (data) {\n",
       "            geo_json_460c04e1cc847389755455850b2d7ae1\n",
       "                .addData(data)\n",
       "                .addTo(map_8ae897deb5c0ea4cf86261ced0b8cd07);\n",
       "        }\n",
       "            geo_json_460c04e1cc847389755455850b2d7ae1_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [6.43923, 45.445076], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Prariond&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Prariond, Mottet, Les Avanchers-Valmorel, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73260, France&quot;, &quot;type&quot;: &quot;platter&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [4.467755, 44.831458], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;col&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col, Saint-Pierreville, Tournon-sur-Rh\\u00f4ne, Ard\\u00e8che, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 07190, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.844478, 45.408958], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, \\u00c9gliseneuve-d\\u0027Entraigues, Issoire, Puy-de-D\\u00f4me, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 63850, France&quot;, &quot;type&quot;: &quot;isolated_dwelling&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [5.060961, 46.105022], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;berger&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Berger, Saint-Andr\\u00e9-le-Bouchoux, Bourg-en-Bresse, Ain, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 01240, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.898275, 45.419228], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Leisse, Chemin de Borsat, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.837532, 45.456069], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Grassaz&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col de la Grassaz, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;yes&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.896874, 45.454039], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Tichot&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Tichot, Tarte \\u00e0 Lognan, Val-Claret, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.682996, 44.905336], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Grande&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Grande, Alleyras, Le Puy-en-Velay, Haute-Loire, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 43580, France&quot;, &quot;type&quot;: &quot;residential&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [2.014202, 50.823249], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;GR&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Grande Rue, Louches, Calais, Pas-de-Calais, Hauts-de-France, France m\\u00e9tropolitaine, 62610, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.926505, 45.978552], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Lognan&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lognan, Chemin de la Glaci\\u00e8re, Les Chosalets, Argenti\\u00e8re, Chamonix-Mont-Blanc, Bonneville, Haute-Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 74400, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [1.060214, 43.157123], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Plagne&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Plagne, Muret, Haute-Garonne, Occitanie, France m\\u00e9tropolitaine, 31220, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [3.905872, 43.862148], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Claret&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Claret, Lod\\u00e8ve, H\\u00e9rault, Occitanie, France m\\u00e9tropolitaine, 34270, France&quot;, &quot;type&quot;: &quot;administrative&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.963285, 45.462018], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Bellecote&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Bellecote, Sentier de la Vall\\u00e9e Perdue, Le Cr\\u00eat, La Daille, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;type&quot;: &quot;yes&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [-1.244805, 48.200191], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Palet&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Palet, Taillis, Foug\\u00e8res-Vitr\\u00e9, Ille-et-Vilaine, Bretagne, France m\\u00e9tropolitaine, 35500, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [7.211431, 48.207614], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;paquis&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Paquis, Aubure, Colmar-Ribeauvill\\u00e9, Haut-Rhin, Grand Est, France m\\u00e9tropolitaine, 68150, France&quot;, &quot;type&quot;: &quot;locality&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_460c04e1cc847389755455850b2d7ae1.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2f5e69fd0>"
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# instancier le geocoder avec le code pays\n",
    "geocoder = Geocoder(country_code = 'fr')\n",
    "doc_geocoded = geocoder(places_list)\n",
    "\n",
    "# ajouter la trace GPS \n",
    "doc_geocoded.geometry_layer = doc.geometry_layer\n",
    "\n",
    "doc_geocoded.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6.3.2 Ajout d'un filtre \"bounding box\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_35b6ec2c5ddc6a2a0c2dbc58974d252f {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_35b6ec2c5ddc6a2a0c2dbc58974d252f&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_35b6ec2c5ddc6a2a0c2dbc58974d252f = L.map(\n",
       "                &quot;map_35b6ec2c5ddc6a2a0c2dbc58974d252f&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_f9ad6977b3a945af9274ce7c0b721078 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_35b6ec2c5ddc6a2a0c2dbc58974d252f);\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_ebc8c86364c56973a4794e370e29036c_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_ebc8c86364c56973a4794e370e29036c = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_ebc8c86364c56973a4794e370e29036c_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_ebc8c86364c56973a4794e370e29036c_add (data) {\n",
       "            geo_json_ebc8c86364c56973a4794e370e29036c\n",
       "                .addData(data)\n",
       "                .addTo(map_35b6ec2c5ddc6a2a0c2dbc58974d252f);\n",
       "        }\n",
       "            geo_json_ebc8c86364c56973a4794e370e29036c_add({&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;features&quot;: [{&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;geometry&quot;: {&quot;coordinates&quot;: [[[6.839184, 45.480323], [6.83987, 45.479299], [6.841973, 45.478562], [6.843969, 45.47857], [6.845235, 45.479931], [6.847187, 45.479675], [6.847766, 45.480112], [6.848368, 45.479932], [6.849569, 45.480172], [6.850213, 45.479029], [6.850685, 45.477254], [6.8509, 45.476306], [6.851114, 45.474425], [6.851758, 45.472889], [6.853217, 45.471626], [6.855106, 45.46982], [6.855534, 45.468766], [6.855191, 45.468014], [6.85605, 45.46684], [6.856092, 45.464914], [6.856049, 45.463891], [6.855663, 45.462356], [6.856093, 45.461679], [6.856822, 45.46137], [6.857122, 45.460038], [6.857166, 45.458864], [6.857724, 45.458021], [6.858754, 45.457765], [6.859698, 45.458503], [6.860513, 45.458097], [6.861564, 45.458676], [6.861575, 45.457732], [6.860641, 45.456396], [6.864246, 45.456245], [6.865748, 45.455944], [6.867508, 45.455763], [6.869139, 45.455884], [6.870942, 45.456034], [6.875319, 45.454649], [6.879224, 45.455432], [6.881391, 45.454996], [6.883816, 45.455463], [6.886091, 45.455613], [6.887936, 45.456004], [6.890725, 45.457841], [6.890789, 45.45608], [6.891379, 45.454687], [6.892742, 45.454379], [6.894287, 45.453084], [6.896261, 45.45191], [6.896733, 45.452663], [6.898192, 45.452602], [6.899759, 45.453009], [6.90184, 45.452392], [6.902398, 45.451308], [6.903771, 45.450827], [6.905102, 45.450525], [6.906303, 45.451308], [6.909179, 45.449742], [6.911582, 45.448568], [6.913986, 45.447755], [6.916839, 45.44619], [6.917944, 45.444971], [6.920036, 45.444083], [6.92214, 45.441493], [6.921732, 45.440138], [6.91921, 45.437713], [6.916174, 45.435741], [6.915831, 45.433859], [6.915701, 45.432067], [6.914092, 45.430877], [6.912398, 45.429567], [6.912054, 45.428845], [6.910767, 45.428423], [6.910209, 45.4277], [6.910423, 45.427038], [6.908664, 45.425321], [6.906861, 45.423603], [6.905509, 45.42261], [6.903985, 45.421586], [6.904544, 45.420486], [6.904587, 45.418784], [6.903986, 45.41779], [6.9039, 45.416254], [6.904393, 45.414838], [6.9042, 45.413301], [6.902741, 45.411855], [6.90081, 45.411524], [6.900123, 45.410636], [6.90111, 45.409476], [6.901003, 45.408707], [6.900349, 45.408564], [6.900064, 45.409095], [6.899343, 45.408773], [6.89742, 45.408511], [6.893514, 45.404624], [6.890639, 45.403811], [6.889116, 45.403374], [6.887592, 45.402576], [6.886176, 45.401822], [6.886262, 45.400858], [6.886444, 45.400128], [6.887142, 45.4], [6.88652, 45.399201], [6.885339, 45.398297], [6.885704, 45.397966], [6.88403, 45.397318], [6.88227, 45.396851]]], &quot;type&quot;: &quot;MultiLineString&quot;}, &quot;id&quot;: &quot;0&quot;, &quot;properties&quot;: {}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "            map_35b6ec2c5ddc6a2a0c2dbc58974d252f.fitBounds(\n",
       "                [[45.207191, 5.867346], [45.462018, 6.963285]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_fb57b35f8d16bd07d4991ba94440c58c_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_fb57b35f8d16bd07d4991ba94440c58c = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_fb57b35f8d16bd07d4991ba94440c58c_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_fb57b35f8d16bd07d4991ba94440c58c_add (data) {\n",
       "            geo_json_fb57b35f8d16bd07d4991ba94440c58c\n",
       "                .addData(data)\n",
       "                .addTo(map_35b6ec2c5ddc6a2a0c2dbc58974d252f);\n",
       "        }\n",
       "            geo_json_fb57b35f8d16bd07d4991ba94440c58c_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [6.43923, 45.445076], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Prariond&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Prariond, Mottet, Les Avanchers-Valmorel, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73260, France&quot;, &quot;type&quot;: &quot;platter&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.60536, 45.273046], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;col&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col, Boulevard Lauzes, Slalom, Saint-Martin-de-Belleville, Les Belleville, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73440, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.92583, 45.442088], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, Piste du Col de Fresse, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [5.867346, 45.308667], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;berger&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Berger, Saint-Hilaire, Plateau-des-Petites-Roches, Grenoble, Is\\u00e8re, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 38660, France&quot;, &quot;type&quot;: &quot;footway&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.898275, 45.419228], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Leisse, Chemin de Borsat, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.837532, 45.456069], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Grassaz&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col de la Grassaz, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;yes&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.896874, 45.454039], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Tichot&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Tichot, Tarte \\u00e0 Lognan, Val-Claret, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.579058, 45.298166], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;GR&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Grande Rue, Saint-Martin-de-Belleville, Les Belleville, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73440, France&quot;, &quot;type&quot;: &quot;quarter&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;type&quot;: &quot;water&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.395829, 45.350595], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Lognan&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Cr\\u00eat Lognan, Les Belleville, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, France&quot;, &quot;type&quot;: &quot;peak&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.392506, 45.207191], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Plagne&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Plagne, Copies, La Plagne, Albanne, Montricher-Albanne, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73870, France&quot;, &quot;type&quot;: &quot;platter&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.422623, 45.255481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Claret&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Claret, Saint-Julien-Mont-Denis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73870, France&quot;, &quot;type&quot;: &quot;hamlet&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.963285, 45.462018], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Bellecote&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Bellecote, Sentier de la Vall\\u00e9e Perdue, Le Cr\\u00eat, La Daille, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;type&quot;: &quot;yes&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.863067, 45.451642], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;Palet&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Signal du Palet, Champagny-en-Vanoise, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73350, France&quot;, &quot;type&quot;: &quot;peak&quot;}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.914334, 45.458216], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;country&quot;: &quot;France&quot;, &quot;id&quot;: 0, &quot;name&quot;: &quot;paquis&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Paquis, GunPowder, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;type&quot;: &quot;station&quot;}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_fb57b35f8d16bd07d4991ba94440c58c.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2f2a2cf70>"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bbox = [5.62216508714297, 45.051683489057, 7.18563279407213, 45.9384576816403] # zone d'intervention du PGHM Isère\n",
    "\n",
    "# instancier le geocoder avec le code pays et une bounding box\n",
    "geocoder = Geocoder(country_code = 'fr', bbox = bbox)\n",
    "doc_geocoded = geocoder(places_list)\n",
    "\n",
    "# ajouter la trace GPS \n",
    "doc_geocoded.geometry_layer = doc.geometry_layer\n",
    "\n",
    "# affiche la carte\n",
    "doc_geocoded.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6.3.3 Clustering par densité spatiale"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
       "&lt;head&gt;    \n",
       "    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
       "    \n",
       "        &lt;script&gt;\n",
       "            L_NO_TOUCH = false;\n",
       "            L_DISABLE_3D = false;\n",
       "        &lt;/script&gt;\n",
       "    \n",
       "    &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
       "    &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
       "    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
       "    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
       "    \n",
       "            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
       "                initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
       "            &lt;style&gt;\n",
       "                #map_fe2cfa179d84b5e254153f369ebe752f {\n",
       "                    position: relative;\n",
       "                    width: 100.0%;\n",
       "                    height: 100.0%;\n",
       "                    left: 0.0%;\n",
       "                    top: 0.0%;\n",
       "                }\n",
       "            &lt;/style&gt;\n",
       "        \n",
       "    \n",
       "                    &lt;style&gt;\n",
       "                        .foliumtooltip {\n",
       "                            \n",
       "                        }\n",
       "                       .foliumtooltip table{\n",
       "                            margin: auto;\n",
       "                        }\n",
       "                        .foliumtooltip tr{\n",
       "                            text-align: left;\n",
       "                        }\n",
       "                        .foliumtooltip th{\n",
       "                            padding: 2px; padding-right: 8px;\n",
       "                        }\n",
       "                    &lt;/style&gt;\n",
       "            \n",
       "&lt;/head&gt;\n",
       "&lt;body&gt;    \n",
       "    \n",
       "            &lt;div class=&quot;folium-map&quot; id=&quot;map_fe2cfa179d84b5e254153f369ebe752f&quot; &gt;&lt;/div&gt;\n",
       "        \n",
       "&lt;/body&gt;\n",
       "&lt;script&gt;    \n",
       "    \n",
       "            var map_fe2cfa179d84b5e254153f369ebe752f = L.map(\n",
       "                &quot;map_fe2cfa179d84b5e254153f369ebe752f&quot;,\n",
       "                {\n",
       "                    center: [0, 0],\n",
       "                    crs: L.CRS.EPSG3857,\n",
       "                    zoom: 1,\n",
       "                    zoomControl: true,\n",
       "                    preferCanvas: false,\n",
       "                }\n",
       "            );\n",
       "\n",
       "            \n",
       "\n",
       "        \n",
       "    \n",
       "            var tile_layer_67f56a2e2a71291a8a3789435daae069 = L.tileLayer(\n",
       "                &quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;,\n",
       "                {&quot;attribution&quot;: &quot;Data by \\u0026copy; \\u003ca href=\\&quot;http://openstreetmap.org\\&quot;\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\&quot;http://www.openstreetmap.org/copyright\\&quot;\\u003eODbL\\u003c/a\\u003e.&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
       "            ).addTo(map_fe2cfa179d84b5e254153f369ebe752f);\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_926132e84a8700abc9f52e3b79d1902e_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_926132e84a8700abc9f52e3b79d1902e = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_926132e84a8700abc9f52e3b79d1902e_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_926132e84a8700abc9f52e3b79d1902e_add (data) {\n",
       "            geo_json_926132e84a8700abc9f52e3b79d1902e\n",
       "                .addData(data)\n",
       "                .addTo(map_fe2cfa179d84b5e254153f369ebe752f);\n",
       "        }\n",
       "            geo_json_926132e84a8700abc9f52e3b79d1902e_add({&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;features&quot;: [{&quot;bbox&quot;: [6.839184, 45.396851, 6.92214, 45.480323], &quot;geometry&quot;: {&quot;coordinates&quot;: [[[6.839184, 45.480323], [6.83987, 45.479299], [6.841973, 45.478562], [6.843969, 45.47857], [6.845235, 45.479931], [6.847187, 45.479675], [6.847766, 45.480112], [6.848368, 45.479932], [6.849569, 45.480172], [6.850213, 45.479029], [6.850685, 45.477254], [6.8509, 45.476306], [6.851114, 45.474425], [6.851758, 45.472889], [6.853217, 45.471626], [6.855106, 45.46982], [6.855534, 45.468766], [6.855191, 45.468014], [6.85605, 45.46684], [6.856092, 45.464914], [6.856049, 45.463891], [6.855663, 45.462356], [6.856093, 45.461679], [6.856822, 45.46137], [6.857122, 45.460038], [6.857166, 45.458864], [6.857724, 45.458021], [6.858754, 45.457765], [6.859698, 45.458503], [6.860513, 45.458097], [6.861564, 45.458676], [6.861575, 45.457732], [6.860641, 45.456396], [6.864246, 45.456245], [6.865748, 45.455944], [6.867508, 45.455763], [6.869139, 45.455884], [6.870942, 45.456034], [6.875319, 45.454649], [6.879224, 45.455432], [6.881391, 45.454996], [6.883816, 45.455463], [6.886091, 45.455613], [6.887936, 45.456004], [6.890725, 45.457841], [6.890789, 45.45608], [6.891379, 45.454687], [6.892742, 45.454379], [6.894287, 45.453084], [6.896261, 45.45191], [6.896733, 45.452663], [6.898192, 45.452602], [6.899759, 45.453009], [6.90184, 45.452392], [6.902398, 45.451308], [6.903771, 45.450827], [6.905102, 45.450525], [6.906303, 45.451308], [6.909179, 45.449742], [6.911582, 45.448568], [6.913986, 45.447755], [6.916839, 45.44619], [6.917944, 45.444971], [6.920036, 45.444083], [6.92214, 45.441493], [6.921732, 45.440138], [6.91921, 45.437713], [6.916174, 45.435741], [6.915831, 45.433859], [6.915701, 45.432067], [6.914092, 45.430877], [6.912398, 45.429567], [6.912054, 45.428845], [6.910767, 45.428423], [6.910209, 45.4277], [6.910423, 45.427038], [6.908664, 45.425321], [6.906861, 45.423603], [6.905509, 45.42261], [6.903985, 45.421586], [6.904544, 45.420486], [6.904587, 45.418784], [6.903986, 45.41779], [6.9039, 45.416254], [6.904393, 45.414838], [6.9042, 45.413301], [6.902741, 45.411855], [6.90081, 45.411524], [6.900123, 45.410636], [6.90111, 45.409476], [6.901003, 45.408707], [6.900349, 45.408564], [6.900064, 45.409095], [6.899343, 45.408773], [6.89742, 45.408511], [6.893514, 45.404624], [6.890639, 45.403811], [6.889116, 45.403374], [6.887592, 45.402576], [6.886176, 45.401822], [6.886262, 45.400858], [6.886444, 45.400128], [6.887142, 45.4], [6.88652, 45.399201], [6.885339, 45.398297], [6.885704, 45.397966], [6.88403, 45.397318], [6.88227, 45.396851]]], &quot;type&quot;: &quot;MultiLineString&quot;}, &quot;id&quot;: &quot;0&quot;, &quot;properties&quot;: {}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "            map_fe2cfa179d84b5e254153f369ebe752f.fitBounds(\n",
       "                [[45.412971, 6.837532], [45.462018, 6.963285]],\n",
       "                {}\n",
       "            );\n",
       "        \n",
       "    \n",
       "\n",
       "        function geo_json_4b64839f8529cbdc6738c611d105d767_onEachFeature(feature, layer) {\n",
       "            layer.on({\n",
       "            });\n",
       "        };\n",
       "        var geo_json_4b64839f8529cbdc6738c611d105d767 = L.geoJson(null, {\n",
       "                onEachFeature: geo_json_4b64839f8529cbdc6738c611d105d767_onEachFeature,\n",
       "            \n",
       "        });\n",
       "\n",
       "        function geo_json_4b64839f8529cbdc6738c611d105d767_add (data) {\n",
       "            geo_json_4b64839f8529cbdc6738c611d105d767\n",
       "                .addData(data)\n",
       "                .addTo(map_fe2cfa179d84b5e254153f369ebe752f);\n",
       "        }\n",
       "            geo_json_4b64839f8529cbdc6738c611d105d767_add({&quot;features&quot;: [{&quot;geometry&quot;: {&quot;coordinates&quot;: [6.92583, 45.442088], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.442088, &quot;longitude&quot;: 6.92583, &quot;name&quot;: &quot;Fresse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Fresse, Piste du Col de Fresse, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.898275, 45.419228], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.419228, &quot;longitude&quot;: 6.898275, &quot;name&quot;: &quot;Leisse&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Leisse, Chemin de Borsat, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.837532, 45.456069], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.456069, &quot;longitude&quot;: 6.837532, &quot;name&quot;: &quot;Grassaz&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Col de la Grassaz, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.896874, 45.454039], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.454039, &quot;longitude&quot;: 6.896874, &quot;name&quot;: &quot;Tichot&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Tichot, Tarte \\u00e0 Lognan, Val-Claret, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.89952, 45.412971], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.412971, &quot;longitude&quot;: 6.89952, &quot;name&quot;: &quot;Nettes&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac des Nettes, Termignon, Val-Cenis, Saint-Jean-de-Maurienne, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73500, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.858926, 45.461481], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.461481, &quot;longitude&quot;: 6.858926, &quot;name&quot;: &quot;Grattaleu&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Lac du Grattaleu, Peisey-Nancroix, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73210, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.963285, 45.462018], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.462018, &quot;longitude&quot;: 6.963285, &quot;name&quot;: &quot;Bellecote&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Bellecote, Sentier de la Vall\\u00e9e Perdue, Le Cr\\u00eat, La Daille, Val-d\\u0027Is\\u00e8re, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73150, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.863067, 45.451642], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.451642, &quot;longitude&quot;: 6.863067, &quot;name&quot;: &quot;Palet&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Signal du Palet, Champagny-en-Vanoise, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73350, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}, {&quot;geometry&quot;: {&quot;coordinates&quot;: [6.914334, 45.458216], &quot;type&quot;: &quot;Point&quot;}, &quot;properties&quot;: {&quot;cluster&quot;: 0, &quot;country&quot;: &quot;France&quot;, &quot;latitude&quot;: 45.458216, &quot;longitude&quot;: 6.914334, &quot;name&quot;: &quot;paquis&quot;, &quot;source&quot;: &quot;nominatim&quot;, &quot;sourceName&quot;: &quot;Paquis, GunPowder, Tignes, Albertville, Savoie, Auvergne-Rh\\u00f4ne-Alpes, France m\\u00e9tropolitaine, 73320, France&quot;, &quot;xmlID&quot;: 0}, &quot;type&quot;: &quot;Feature&quot;}], &quot;type&quot;: &quot;FeatureCollection&quot;});\n",
       "\n",
       "        \n",
       "    \n",
       "    geo_json_4b64839f8529cbdc6738c611d105d767.bindTooltip(\n",
       "    function(layer){\n",
       "    let div = L.DomUtil.create(&#x27;div&#x27;);\n",
       "    \n",
       "    let handleObject = feature=&gt;typeof(feature)==&#x27;object&#x27; ? JSON.stringify(feature) : feature;\n",
       "    let fields = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let aliases = [&quot;name&quot;, &quot;source&quot;];\n",
       "    let table = &#x27;&lt;table&gt;&#x27; +\n",
       "        String(\n",
       "        fields.map(\n",
       "        (v,i)=&gt;\n",
       "        `&lt;tr&gt;\n",
       "            &lt;th&gt;${aliases[i].toLocaleString()}&lt;/th&gt;\n",
       "            \n",
       "            &lt;td&gt;${handleObject(layer.feature.properties[v]).toLocaleString()}&lt;/td&gt;\n",
       "        &lt;/tr&gt;`).join(&#x27;&#x27;))\n",
       "    +&#x27;&lt;/table&gt;&#x27;;\n",
       "    div.innerHTML=table;\n",
       "    \n",
       "    return div\n",
       "    }\n",
       "    ,{&quot;className&quot;: &quot;foliumtooltip&quot;, &quot;sticky&quot;: true});\n",
       "                     \n",
       "&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x2f1e1cd00>"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# appliquer la désambiguïsation \n",
    "doc_geocoded.cluster_disambiguation()\n",
    "doc_geocoded.get_folium_map()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Désambiguisation basé sur la proximité géographique\n",
    "\n",
    "Clustering avec la méthode DBSCAN implémenté dans la librairie [Scikit-Learn](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html). Cette stratégie est adaptée pour une description d'itinéraire où les différents lieux cités doivent être localisés à proximité les uns des autres."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Utilisation du contexte (autres entités nommées repérées dans le texte, relations spatiales, etc...). Développées dans le cadre du projet [Perdido]() (add ref 2014 et 2016) mais pas encore intégré à la librairie Python Perdido. Cette librairie est toujours en cours de développement et d'amélioration. Vos remarques et retours seront les bienvenues."
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "Geoparsing.ipynb",
   "provenance": [],
   "toc_visible": true
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "vscode": {
   "interpreter": {
    "hash": "ac6d00d97418b1a9db80d25edbc60018a184534aba90cc2f485de2791198ec07"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}