forked from LoicGrobol/python-im
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slides du 12/10/2016 + brise marine POS
- Loading branch information
1 parent
ab92d44
commit 5fd3d3e
Showing
6 changed files
with
542 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.