jean222 commited on
Commit
e2901f8
·
1 Parent(s): 80dad9b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ipywidgets as widgets
2
+ from IPython.display import display
3
+
4
+ def traduire_en_anvers(b):
5
+ correspondance = {
6
+ 'a': 'y', 'b': 'z', 'c': 'x', 'd': 'w', 'e': 'u', 'f': 'v', 'g': 't',
7
+ 'h': 's', 'i': 'ö', 'j': 'r', 'k': 'q', 'l': 'p', 'm': 'n', 'n': 'm',
8
+ 'o': 'i', 'p': 'l', 'q': 'k', 'r': 'j', 's': 'h', 't': 'g', 'u': 'e',
9
+ 'v': 'f', 'w': 'd', 'x': 'c', 'y': 'a', 'z': 'b', 'à': 'ỳ', 'è': 'ù',
10
+ 'é': 'ú', 'ï': 'ö', 'î': 'ô', 'û': 'ê', 'ç': 'x̩'
11
+ }
12
+
13
+ texte_fr = input_text.value
14
+ texte_anvers = ''
15
+
16
+ for lettre in texte_fr:
17
+ if lettre.lower() in correspondance:
18
+ texte_anvers += correspondance[lettre.lower()]
19
+ else:
20
+ texte_anvers += lettre
21
+
22
+ output_text.value = texte_anvers.capitalize()
23
+
24
+ # Création des widgets
25
+ input_text = widgets.Textarea(description='Français:')
26
+ output_text = widgets.Textarea(description='Anvers:')
27
+ translate_button = widgets.Button(description='Traduire')
28
+
29
+ # Configuration de la fonction de traduction
30
+ translate_button.on_click(traduire_en_anvers)
31
+
32
+ # Affichage des widgets
33
+ display(input_text)
34
+ display(output_text)
35
+ display(translate_button)