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
d927a08c
Commit
d927a08c
authored
Apr 01, 2023
by
ce9a2e8f95a59bf8ceb3cb087dad994a
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no commit message
parent
0c9afacd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
231 additions
and
35 deletions
+231
-35
exercice.ipynb
module3/exo3/exercice.ipynb
+231
-35
No files found.
module3/exo3/exercice.ipynb
View file @
d927a08c
...
...
@@ -23,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 1
30
,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count":
133
,
"execution_count":
2
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count":
135
,
"execution_count":
3
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -71,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count":
136
,
"execution_count":
4
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -82,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count":
137
,
"execution_count":
5
,
"metadata": {
"scrolled": true
},
...
...
@@ -93,7 +93,7 @@
"'# ACTEURS.\\n'"
]
},
"execution_count":
137
,
"execution_count":
5
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count":
138
,
"execution_count":
6
,
"metadata": {
"scrolled": false
},
...
...
@@ -151,36 +151,232 @@
},
{
"cell_type": "code",
"execution_count":
228
,
"execution_count":
16
,
"metadata": {},
"outputs": [],
"source": [
"#Vérification structure du texte\n",
"for k in range(34,len(lignes)) :\n",
" l = lignes[k]\n",
" if l[:3] == '###' :\n",
" scène_courante += 1\n",
" dico_scènes[scène_courante]= {}\n",
" for perso in persos :\n",
" dico_scènes[scène_courante][perso] = 0\n",
" elif l[:2] == '##' :\n",
" if acte_courant >= 1 :\n",
" dico_acte[acte_courant] = dico_scènes\n",
" scène_courante = 0\n",
" acte_courant += 1\n",
" dico_scènes = {}\n",
" if l in persos :\n",
" Nombre_repliques[l] += 1\n",
" dico_scènes[scène_courante][l] += 1\n",
" Nombre_mots[l] += len(lignes[k+1].split()) #problème ponctuation\n",
" if not (acte_courant in Nombre_actes[l]) :\n",
" Nombre_actes[l].append(acte_courant)\n",
"dico_acte[acte_courant] = dico_scènes\n"
"caractères = []\n",
"for k in range(len(lignes)) :\n",
" ligne = lignes[k]\n",
" for i in range(len(ligne)) :\n",
" if not(ligne[i] in caractères) :\n",
" caractères.append(ligne[i])"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['-',\n",
" '\\n',\n",
" 'i',\n",
" 'd',\n",
" 'e',\n",
" 'n',\n",
" 't',\n",
" 'f',\n",
" 'r',\n",
" ':',\n",
" ' ',\n",
" 'm',\n",
" 'o',\n",
" 'l',\n",
" '_',\n",
" 'a',\n",
" 'v',\n",
" 'c',\n",
" 'M',\n",
" 'è',\n",
" '.',\n",
" '1',\n",
" '6',\n",
" '8',\n",
" 'L',\n",
" \"'\",\n",
" 'A',\n",
" 'C',\n",
" 'é',\n",
" 'V',\n",
" 'R',\n",
" 'E',\n",
" ',',\n",
" 'O',\n",
" 'É',\n",
" 'D',\n",
" 'I',\n",
" 'P',\n",
" 'J',\n",
" 'B',\n",
" 'È',\n",
" 'À',\n",
" 'S',\n",
" 'h',\n",
" 'z',\n",
" 'N',\n",
" 'U',\n",
" 'u',\n",
" 's',\n",
" 'à',\n",
" 'g',\n",
" 'p',\n",
" 'X',\n",
" '*',\n",
" 'G',\n",
" '#',\n",
" 'T',\n",
" '–',\n",
" 'H',\n",
" 'x',\n",
" 'F',\n",
" 'q',\n",
" 'b',\n",
" '?',\n",
" 'j',\n",
" '!',\n",
" 'ù',\n",
" 'y',\n",
" 'î',\n",
" 'ê',\n",
" '\\xa0',\n",
" ';',\n",
" 'œ',\n",
" 'ç',\n",
" 'ô',\n",
" 'â',\n",
" 'û',\n",
" 'ï',\n",
" 'Q',\n",
" '…',\n",
" 'Ê',\n",
" 'Ô',\n",
" 'Y',\n",
" 'Î',\n",
" '<',\n",
" '>']"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"caractères"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"lettres = ['i',\n",
" 'd',\n",
" 'e',\n",
" 'n',\n",
" 't',\n",
" 'f',\n",
" 'r',\n",
" 'm',\n",
" 'o',\n",
" 'l',\n",
" 'a',\n",
" 'v',\n",
" 'c',\n",
" 'M',\n",
" 'è',\n",
" 'L',\n",
" 'A',\n",
" 'C',\n",
" 'é',\n",
" 'V',\n",
" 'R',\n",
" 'E',\n",
" 'O',\n",
" 'É',\n",
" 'D',\n",
" 'I',\n",
" 'P',\n",
" 'J',\n",
" 'B',\n",
" 'È',\n",
" 'À',\n",
" 'S',\n",
" 'h',\n",
" 'z',\n",
" 'N',\n",
" 'U',\n",
" 'u',\n",
" 's',\n",
" 'à',\n",
" 'g',\n",
" 'p',\n",
" 'X',\n",
" 'G',\n",
" 'T',\n",
" 'H',\n",
" 'x',\n",
" 'F',\n",
" 'q',\n",
" 'b',\n",
" 'j',\n",
" 'ù',\n",
" 'y',\n",
" 'î',\n",
" 'ê',\n",
" 'œ',\n",
" 'ç',\n",
" 'ô',\n",
" 'â',\n",
" 'û',\n",
" 'ï',\n",
" 'Q',\n",
" 'Ê',\n",
" 'Ô',\n",
" 'Y',\n",
" 'Î']"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"def split_string(s) :\n",
" n = len(s)\n",
" liste_mots = []\n",
" k = 0\n",
" while k < n :\n",
" mot = \"\"\n",
" while (k < n) and not (s[k] in lettres) :\n",
" k +=1\n",
" mot += s[k]\n",
" k+=1\n",
" while (k < n) and (s[k] in lettres) :\n",
" mot += s[k]\n",
" k +=1\n",
" k+=1\n",
" liste_mots.append(mot)\n",
" return liste_mots"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"split_string(lignes[48])"
]
},
{
"cell_type": "code",
"execution_count":
139
,
"execution_count":
8
,
"metadata": {},
"outputs": [
{
...
...
@@ -223,7 +419,7 @@
},
{
"cell_type": "code",
"execution_count":
140
,
"execution_count":
9
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -253,7 +449,7 @@
},
{
"cell_type": "code",
"execution_count": 1
42
,
"execution_count": 1
0
,
"metadata": {},
"outputs": [
{
...
...
@@ -275,7 +471,7 @@
" ' HARPAGON.\\n': 5179}"
]
},
"execution_count": 1
42
,
"execution_count": 1
0
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -286,7 +482,7 @@
},
{
"cell_type": "code",
"execution_count": 1
43
,
"execution_count": 1
1
,
"metadata": {},
"outputs": [
{
...
...
@@ -308,7 +504,7 @@
" ' HARPAGON.\\n': 344}"
]
},
"execution_count": 1
43
,
"execution_count": 1
1
,
"metadata": {},
"output_type": "execute_result"
}
...
...
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