Correct problem of scene 7 of act 4 exception

parent 927abc4f
......@@ -491,6 +491,11 @@
" # Récupération du dernier élément de la colonne des auteurs\n",
" # qui est l'auteur de la réplique précédente\n",
" previousAuthor = emptyAnalysisDict['author'][-1]\n",
" if len(scenePersoList)==1:\n",
" # Si la liste des personnages ne contient qu'un\n",
" # seul protagoniste, c'est la scène qui fait exception\n",
" # avec Harpagon.\n",
" previousAuthor = 'Harpagon'\n",
" emptyAnalysisDict['author'].append(currentAuthor)\n",
" emptyAnalysisDict['recipient'].append(previousAuthor)\n",
" # On a incrémenté le numéro d'acte, il faut donc \n",
......@@ -557,6 +562,8 @@
" if currentLine.startswith(\" \"):\n",
" # La ligne commence avec un espace, elle déclare donc l'auteur d'une réplique\n",
" # on va parcourir la liste des protagonistes de la scène et identifier l'auteur\n",
" if actNum==4 and sceneNum==7:\n",
" print(\"persosList : {}\".format(scenePersoList))\n",
" for perso in scenePersoList:\n",
" # On fait une recherche ignorant si les lettres sont en majuscules ou minuscules\n",
" # grâce à l'option passée à la fonction de recherche d'expression régulière\n",
......@@ -620,12 +627,16 @@
" else:\n",
" # La ligne courante présente forcément les personnages de la scène\n",
" # car c'est la ligne qui suit la déclaration de scène,\n",
" # à l'exception d'un seule scène, la 7 de l'acte 4\n",
" # à l'exception d'une seule scène, la 7 de l'acte 4\n",
" # On peut donc réduire l'analyse du texte à ces seuls\n",
" # protagonistes.\n",
" # Boucle sur les clés du dictionnaire de personnage\n",
" # qui sont leur nom.\n",
" if currentLine:\n",
"\n",
" # Si la ligne contient autre chose que des caractères \"blancs\"\n",
" # espaces, tabulations, retour ligne etc...\n",
" # ce n'est pas l'exception.\n",
" if not re.match('^[\\s]+$',currentLine):\n",
" # La ligne n'est pas vide, ce n'est pas l'exception\n",
" for namePerso in persoDict:\n",
" # On vérifie si namePerso fait partie des protagonistes\n",
......@@ -644,6 +655,7 @@
" else:\n",
" # La ligne est vide on sait que c'est le cas particulier\n",
" # le seul protagoniste est Harpagon\n",
" print(\"Exception scene 7 of act 4\")\n",
" scenePersoList.append('Harpagon')\n",
" #print(\"*********************************\")\n",
" #print(\"Liste des personnages de la scène\")\n",
......@@ -666,6 +678,14 @@
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Exception scene 7 of act 4\n",
"persosList : ['Harpagon']\n"
]
},
{
"data": {
"text/html": [
......@@ -1288,6 +1308,172 @@
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Y-a-t-il des éléments à NaN ou null dans le tableau construit?"
]
},
{
"cell_type": "code",
"execution_count": 14,
"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>act</th>\n",
" <th>author</th>\n",
" <th>recipient</th>\n",
" <th>scene</th>\n",
" <th>speech_length</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [act, author, recipient, scene, speech_length]\n",
"Index: []"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
" textDataSynthesisTableDf[textDataSynthesisTableDf.isnull().any(axis=1)]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"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>act</th>\n",
" <th>author</th>\n",
" <th>recipient</th>\n",
" <th>scene</th>\n",
" <th>speech_length</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>746</th>\n",
" <td>4</td>\n",
" <td>La Flèche</td>\n",
" <td>Cléante</td>\n",
" <td>6</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>748</th>\n",
" <td>4</td>\n",
" <td>La Flèche</td>\n",
" <td>Cléante</td>\n",
" <td>6</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>750</th>\n",
" <td>4</td>\n",
" <td>La Flèche</td>\n",
" <td>Cléante</td>\n",
" <td>6</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>752</th>\n",
" <td>4</td>\n",
" <td>La Flèche</td>\n",
" <td>Cléante</td>\n",
" <td>6</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>754</th>\n",
" <td>4</td>\n",
" <td>La Flèche</td>\n",
" <td>Cléante</td>\n",
" <td>6</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>756</th>\n",
" <td>4</td>\n",
" <td>La Flèche</td>\n",
" <td>Cléante</td>\n",
" <td>6</td>\n",
" <td>9</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" act author recipient scene speech_length\n",
"746 4 La Flèche Cléante 6 11\n",
"748 4 La Flèche Cléante 6 8\n",
"750 4 La Flèche Cléante 6 3\n",
"752 4 La Flèche Cléante 6 7\n",
"754 4 La Flèche Cléante 6 9\n",
"756 4 La Flèche Cléante 6 9"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"debugDf = textDataSynthesisTableDf[textDataSynthesisTableDf[\"author\"]==\"La Flèche\"]\n",
"debugDf[debugDf[\"act\"]==float(4)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -1325,7 +1511,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"outputs": [
{
......@@ -1414,7 +1600,7 @@
" <td>Cléante</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5753</th>\n",
" <th>6160</th>\n",
" <td>Harpagon</td>\n",
" </tr>\n",
" </tbody>\n",
......@@ -1438,10 +1624,10 @@
"2370 Frosine\n",
"2740 Valère\n",
"3331 Cléante\n",
"5753 Harpagon"
"6160 Harpagon"
]
},
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1477,6 +1663,13 @@
"Nous pouvons désormais finir de répondre à la premiè question posée. Le personnage s'exprimant le plus dans la pièce de _L'Avare_ de Molière et qui est donc le protagoniste principal, n'est autre qu'**Harpagon**. Quant aux personnages ne s'exprimant pas, nous en avons deux, le **clerc** du commissaire ainsi que **Dame Claude** qui est la servante d'Harpagon."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Réponse à la seconde question"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -1486,7 +1679,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 17,
"metadata": {},
"outputs": [
{
......@@ -1503,6 +1696,7 @@
}
],
"source": [
"from matplotlib import pyplot as plt\n",
"from matplotlib import cm\n",
"\n",
"# On affiche une sélection automatique de couleur dans une colormap\n",
......@@ -1523,7 +1717,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 18,
"metadata": {},
"outputs": [
{
......@@ -1561,7 +1755,7 @@
" 'color': array([0.35882353, 0.21994636, 0.99385914, 1. ])}}"
]
},
"execution_count": 24,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1577,13 +1771,6 @@
"avarePersoDict"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Réponse à la seconde question"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -1593,25 +1780,29 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"act 1 persos ['Valère' 'Élise' 'Cléante' 'Harpagon' 'La Flèche']\n",
" Cléante Harpagon La Flèche Valère scene Élise\n",
"0 0 0 0 630 1 491\n",
"1 761 0 0 0 2 154\n",
"2 0 465 257 0 3 0\n",
"3 216 1150 0 0 4 162\n",
"4 0 273 0 707 5 36\n",
"act 2 persos ['Cléante' 'La Flèche' 'Maître Simon' 'Harpagon' 'Frosine']\n",
" Cléante Frosine Harpagon La Flèche Maître Simon scene\n",
"0 379 0 0 903 0 1\n",
"1 127 0 171 12 197 2\n",
"2 0 1 21 0 0 3\n",
"3 0 130 0 301 0 4\n",
"4 0 1496 555 0 0 5\n",
"act 3 persos ['Harpagon' 'Maître Jacques' 'La Merluche' 'Brindavoine' 'Élise' 'Cléante'\n",
" 'Valère' 'Frosine' 'Mariane']\n",
" Brindavoine Cléante Frosine Harpagon La Merluche Mariane \\\n",
"0 23 76 0 757 26 0 \n",
"1 0 0 0 0 0 0 \n",
......@@ -1633,23 +1824,27 @@
"6 0 0 7 0 \n",
"7 0 0 8 0 \n",
"8 0 0 9 0 \n",
" scene Cléante Élise Mariane Frosine Harpagon Maître Jacques \\\n",
"0 1 245 58 236 436 0 0 \n",
"1 2 14 3 0 0 54 0 \n",
"2 3 418 0 0 0 393 0 \n",
"3 4 170 0 0 0 141 300 \n",
"4 5 163 0 0 0 129 0 \n",
"5 6 17 0 0 0 0 0 \n",
"6 7 0 0 0 0 0 0 \n",
"act 4 persos ['Cléante' 'Élise' 'Mariane' 'Frosine' 'Harpagon' 'Maître Jacques'\n",
" 'La Flèche']\n",
" Cléante Frosine Harpagon La Flèche Mariane Maître Jacques scene \\\n",
"0 245 436 0 0 236 0 1 \n",
"1 14 0 54 0 0 0 2 \n",
"2 418 0 393 0 0 0 3 \n",
"3 170 0 141 0 0 300 4 \n",
"4 163 0 129 0 0 0 5 \n",
"5 17 0 0 47 0 0 6 \n",
"6 0 0 407 0 0 0 7 \n",
"\n",
" La Flèche NaN \n",
"0 0 0 \n",
"1 0 0 \n",
"2 0 0 \n",
"3 0 0 \n",
"4 0 0 \n",
"5 47 0 \n",
"6 0 0 \n",
" Élise \n",
"0 58 \n",
"1 3 \n",
"2 0 \n",
"3 0 \n",
"4 0 \n",
"5 0 \n",
"6 0 \n",
"act 5 persos ['Le Commissaire' 'Harpagon' 'Maître Jacques' 'Valère' 'Élise' 'Frosine'\n",
" 'Anselme' 'Mariane' 'Cléante' 'le Commissaire']\n",
" Anselme Cléante Frosine Harpagon Le Commissaire Mariane \\\n",
"0 0 0 0 89 109 0 \n",
"1 0 0 0 182 159 0 \n",
......@@ -1681,8 +1876,6 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"# Il va nous falloir compter le nombre d'actes de la pièce\n",
"# et faire une boucle sur ces derniers pour construire \n",
"# un dataframe par acte à partir du dataframe global\n",
......@@ -1700,6 +1893,7 @@
" #actDf\n",
" sceneNums = pd.unique(actDf[\"scene\"])\n",
" actPersos = pd.unique(actDf[\"author\"])\n",
" print(\"act {0:} persos {1:}\".format(actNum,actPersos))\n",
" actDict = {\"scene\":[]}\n",
" for perso in actPersos:\n",
" # Création d'une colonne par personnage de l'acte\n",
......@@ -1725,6 +1919,8 @@
" #print(actDict)\n",
" actSceneSynthesisGraphDf = pd.DataFrame.from_dict(actDict)\n",
" print(actSceneSynthesisGraphDf)\n",
" subFig = plt.subplot(nbActs, 1, actNum)\n",
" \n",
" pass"
]
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment