diff --git a/brise-marine-pos.txt b/brise-marine-pos.txt new file mode 100644 index 0000000..87a74a1 --- /dev/null +++ b/brise-marine-pos.txt @@ -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 \ No newline at end of file diff --git a/exos/mime-2.py b/exos/mime-2.py new file mode 100644 index 0000000..96a0c49 --- /dev/null +++ b/exos/mime-2.py @@ -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")) diff --git a/exos/mime.py b/exos/mime.py new file mode 100644 index 0000000..2c5c022 --- /dev/null +++ b/exos/mime.py @@ -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") diff --git a/exos/mk_dico_rimes.py b/exos/mk_dico_rimes.py new file mode 100644 index 0000000..a7bb642 --- /dev/null +++ b/exos/mk_dico_rimes.py @@ -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() diff --git a/python-20161005.html b/python-20161005.html index fcf1455..b4a79db 100644 --- a/python-20161005.html +++ b/python-20161005.html @@ -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) ``` --- diff --git a/python-20161012.html b/python-20161012.html new file mode 100644 index 0000000..6c215d6 --- /dev/null +++ b/python-20161012.html @@ -0,0 +1,437 @@ + + + + Python - 12/10/2016 + + + + + + + + +