Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ce9a2e8f95a59bf8ceb3cb087dad994a
mooc-rr
Commits
64f692f5
Commit
64f692f5
authored
Mar 31, 2023
by
ce9a2e8f95a59bf8ceb3cb087dad994a
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no commit message
parent
0ca9cb92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
188 additions
and
27 deletions
+188
-27
exercice.ipynb
module3/exo3/exercice.ipynb
+188
-27
No files found.
module3/exo3/exercice.ipynb
View file @
64f692f5
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
0
,
"execution_count": 1
6
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
1
,
"execution_count": 1
7
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
"'/home/jovyan/work/module3/exo3'"
"'/home/jovyan/work/module3/exo3'"
]
]
},
},
"execution_count": 1
1
,
"execution_count": 1
7
,
"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)",
"\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",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: ' moliere_avare.txt'"
]
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"fichier = open(\" moliere_avare.txt\", \"r\")"
"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": [
"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": 1
5
,
"execution_count": 1
38
,
"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": 1
5
,
"execution_count": 1
38
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"
os.listdir()
"
"
Nombre_actes
"
]
]
},
},
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment