Skip to content

Commit

Permalink
Slides du 12/10/2016 + brise marine POS
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-plancq committed Oct 12, 2016
1 parent ab92d44 commit 5fd3d3e
Show file tree
Hide file tree
Showing 6 changed files with 542 additions and 1 deletion.
16 changes: 16 additions & 0 deletions brise-marine-pos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
La/DET chair/NC est/V triste/ADJ ,/PONCT hélas/I !/PONCT et/CC j’/DET ai/NC lu/V tous/ADJ les/DET livres/NC ./PONCT
Fuir/I !/PONCT là-bas/DET fuir/NC !/PONCT Je/CLS sens/V que/CS des/DET oiseaux/NC sont_ivres/V
D’/P être/VINF parmi/P l’/DET écume/NC inconnue/ADJ et/CC les/DET cieux/NC !/PONCT
Rien/PRO ,/PONCT ni/CC les/DET vieux/ADJ jardins/NC reflétés/VPP par/P les/DET yeux/NC
Ne/ADV retiendra/V ce/DET coeur/NC qui/PROREL dans/P la/DET mer/NC se/CLR trempe/VS
Ô/DET nuits/NC !/PONCT ni/CC la/DET clarté/NC déserte/ADJ de/P ma/DET lampe/NC
Sur/P le/DET vide/NC papier/NC que/CS la/DET blancheur/NC défend/V
Et/CC ni/CC la/DET jeune/ADJ femme/NC allaitant/VPR son/DET enfant/NC ./PONCT
Je/CLS partirai/V !/PONCT Steamer/NPP balançant/VPR ta/DET mâture/NC ,/PONCT Lève/NPP l’/DET ancre/NC pour/P une/DET exotique/NC nature/ADJ !/PONCT

Un/DET Ennui/NC ,/PONCT désolé/VPP par/P les/DET cruels/ADJ espoirs/NC ,/PONCT
Croit/V encore/ADV à/P l’/DET adieu/NC suprême/ADJ des/P+D mouchoirs/NC !/PONCT
Et/CC ,/PONCT peut-être/ADV ,/PONCT les/DET mâts/NC ,/PONCT invitant/VPR les/DET orages/NC ,/PONCT
Sont/V -ils/CLS de/P ceux/PRO qu’/P un/DET vent/NC penche/ADJ sur/P les/DET naufrages/NC
Perdus/NPP ,/PONCT sans/P mâts/NC ,/PONCT sans/P mâts/NC ,/PONCT ni/CC fertiles/ADJ îlots/NC
Mais/CC ,/PONCT ô/P mon/DET coeur/NC ,/PONCT entends/NC le/DET chant/NC des/P+D matelots/NC !/PONCT
21 changes: 21 additions & 0 deletions exos/mime-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

dico = dict()
n = int(input()) # Number of elements which make up the association table.
q = int(input()) # Number Q of file names to be analyzed.
for i in range(n):
# ext: file extension
# mt: MIME type.
ext, mt = input().split()
dico[ext.lower()] = mt

print(repr(dico), file=sys.stderr)
for i in range(q):
fname = input() # One file name per line.
chops = fname.split('.')
ext = chops[-1].lower() if len(chops) > 1 else None
print(dico.get(ext, "UNKNOWN"))
32 changes: 32 additions & 0 deletions exos/mime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

dico = dict()
n = int(input()) # Number of elements which make up the association table.
q = int(input()) # Number Q of file names to be analyzed.
for i in range(n):
# ext: file extension
# mt: MIME type.
ext, mt = input().split()
dico[ext.lower()] = mt

print(repr(dico), file=sys.stderr)
for i in range(q):
fname = input() # One file name per line.
chops = fname.split('.')
if len(chops) < 2:
print("UNKNOWN")
continue

try:
print(chops, file=sys.stderr)
print(dico[chops[-1].lower()])
except IndexError:
print("index error", file=sys.stderr)
print("UNKNOWN")
except KeyError:
print("key error", file=sys.stderr)
print("UNKNOWN")
36 changes: 36 additions & 0 deletions exos/mk_dico_rimes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import pickle

def extract(filename):
""" Extrait du fichier arguement les deux premiers champs
arg : nom du fichier au format tsv
return : list de tuples (ortho, phon)
"""
words = []
with open(filename, 'r') as f:
f.readline() # première ligne
for line in f:
ortho, phon = line.split('\t')[0:2]
words.append((ortho, phon))
return words

def dico(lexique, n):
""" Construit un dictionnaire de rimes de longueur n
à partir d'un lexique phonétisé
args : lexique [(ortho, phon)], n (int)
return : dict { rime : [ortho1, ortho2, ...] }
"""


def main():
lexique = extract('noms-lexique.org.txt')
try:
f_lexique = open('lexique.pickle', 'wb')
except:
sys.exit('Error : cannot create lexique.pickle file')
pickle.dump(lexique, f_lexique)

if __name__ == '__main__':
main()
1 change: 0 additions & 1 deletion python-20161005.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@
La fonction `enumerate` peut être utile dans certains cas, elle renvoie un tuple contenant l'indice et la valeur de l'item à l'indice concerné
```python3
>>> for i, tem in enumerate(list):
... print(i, item)
```

---
Expand Down
Loading

0 comments on commit 5fd3d3e

Please sign in to comment.