no commit message

parent 0ca9cb92
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
"'/home/jovyan/work/module3/exo3'" "'/home/jovyan/work/module3/exo3'"
] ]
}, },
"execution_count": 11, "execution_count": 17,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 37,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -65,52 +65,213 @@ ...@@ -65,52 +65,213 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"fichier = open(\"moliere_avare.txt\", \"r\")"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"ename": "FileNotFoundError", "data": {
"evalue": "[Errno 2] No such file or directory: ' moliere_avare.txt'", "text/plain": [
"output_type": "error", "<_io.TextIOWrapper name='moliere_avare.txt' mode='r' encoding='UTF-8'>"
"traceback": [ ]
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", },
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", "execution_count": 39,
"\u001b[0;32m<ipython-input-12-8a385dec2720>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfichier\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\" moliere_avare.txt\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"r\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "metadata": {},
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: ' moliere_avare.txt'" "output_type": "execute_result"
}
],
"source": [
"fichier"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"lignes = fichier.readlines()"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [],
"source": [
"k = 0\n",
"while lignes[k] != '# ACTEURS.\\n' :\n",
" k +=1"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'# ACTEURS.\\n'"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lignes[k]"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" – Harpagon, Père de Cléante et d'Élise, et Amoureux de Mariane.\n",
"\n",
" – Cléante, Fils d'Harpagon, Amant de Mariane.\n",
"\n",
" – Élise, Fille d'Harpagon, Amante de Valère.\n",
"\n",
" – Valère, Fils d'Anselme, et Amant d'Élise.\n",
"\n",
" – Mariane, Amante de Cléante, et aimée d'Harpagon.\n",
"\n",
" – Anselme, Père de Valère et de Mariane.\n",
"\n",
" – Frosine, Femme d'Intrigue.\n",
"\n",
" – Maitre Simon, Courtier.\n",
"\n",
" – Maitre Jacques, Cuisinier et Cocher d'Harpagon.\n",
"\n",
" – La Flèche, Valet de Cléante.\n",
"\n",
" – Dame Claude, Servante d'Harpagon.\n",
"\n",
" – Brindavoine, laquais d'Harpagon.\n",
"\n",
" – La Merluche, laquais d'Harpagon.\n",
"\n",
" – Le commissaire, et son clerc.\n",
"\n"
] ]
} }
], ],
"source": [ "source": [
"fichier = open(\" moliere_avare.txt\", \"r\")" "for k in range(19,33) :\n",
" print(lignes[k])"
]
},
{
"cell_type": "code",
"execution_count": 134,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[' HARPAGON.\\n', ' CLÉANTE.\\n', ' ÉLISE.\\n', ' VALÈRE.\\n', ' MARIANE.\\n', ' ANSELME.\\n', ' FROSINE.\\n', ' MAITRE SIMON.\\n', ' MAITRE JACQUES.\\n', ' LA FLÈCHE.\\n', ' DAME CLAUDE.\\n', ' BRINDAVOINE.\\n', ' LA MERLUCHE.\\n', ' LE COMMISSAIRE.\\n']\n"
]
}
],
"source": [
"persos = []\n",
"for k in range(19,33) :\n",
" l = lignes[k]\n",
" i = 3\n",
" perso = \"\"\n",
" while l[i] != \",\" :\n",
" perso += l[i]\n",
" i+=1\n",
" persos.append(\" \"+perso.upper()+\".\\n\")\n",
"print(persos)\n",
"persos[7] = ' MAÎTRE SIMON.\\n'\n",
"persos[8] = ' MAÎTRE JACQUES.\\n'\n",
"Nombre_repliques = {}\n",
"for perso in persos :\n",
" Nombre_repliques[perso] = 0\n",
"\n",
"Nombre_mots = {}\n",
"for perso in persos :\n",
" Nombre_mots[perso] = 0\n",
"\n",
"Nombre_scènes = {}\n",
"for perso in persos :\n",
" Nombre_scènes[perso] = 0\n",
"\n",
"Nombre_actes = {}\n",
"for perso in persos :\n",
" Nombre_actes[perso] = []"
]
},
{
"cell_type": "code",
"execution_count": 137,
"metadata": {},
"outputs": [],
"source": [
"acte_courant = 0\n",
"for k in range(34,len(lignes)) :\n",
" l = lignes[k]\n",
" if l[:3] == '###' :\n",
" scène_courante += 1\n",
" elif l[:2] == '##' :\n",
" scène_courante = 0\n",
" acte_courant += 1\n",
" if l in persos :\n",
" Nombre_repliques[l] += 1\n",
" Nombre_mots[l] += len(l.split()) #problème ponctuation\n",
" if not (acte_courant in Nombre_actes[l]) :\n",
" Nombre_actes[l].append(acte_courant)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 138,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"['exercice_python_en.org',\n", "{' HARPAGON.\\n': [1, 2, 3, 4, 5],\n",
" 'exercice_fr.ipynb',\n", " ' CLÉANTE.\\n': [1, 2, 3, 4, 5],\n",
" 'exercice.ipynb',\n", " ' ÉLISE.\\n': [1, 3, 4, 5],\n",
" 'exercice_fr.Rmd',\n", " ' VALÈRE.\\n': [1, 3, 5],\n",
" 'exercice_python_fr.org',\n", " ' MARIANE.\\n': [3, 4, 5],\n",
" 'exercice_R_en.org',\n", " ' ANSELME.\\n': [5],\n",
" 'exercice_R_fr.org',\n", " ' FROSINE.\\n': [2, 3, 4, 5],\n",
" 'exercice_en.Rmd',\n", " ' MAÎTRE SIMON.\\n': [2],\n",
" 'exercice_en.ipynb',\n", " ' MAÎTRE JACQUES.\\n': [3, 4, 5],\n",
" '.ipynb_checkpoints']" " ' LA FLÈCHE.\\n': [1, 2, 4],\n",
" ' DAME CLAUDE.\\n': [],\n",
" ' BRINDAVOINE.\\n': [3],\n",
" ' LA MERLUCHE.\\n': [3],\n",
" ' LE COMMISSAIRE.\\n': [5]}"
] ]
}, },
"execution_count": 15, "execution_count": 138,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"os.listdir()" "Nombre_actes"
] ]
}, },
{ {
......
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