Spaces:
Sleeping
Sleeping
Suppression langcodes - code ISO direct
Browse files- app.py +7 -3
- requirements.txt +1 -3
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
-
import langcodes
|
| 4 |
|
| 5 |
detector = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection")
|
| 6 |
|
|
@@ -13,9 +12,14 @@ def detecter_langue(texte):
|
|
| 13 |
texte_result = "🌍 Résultats de la détection :\n\n"
|
| 14 |
for r in resultats:
|
| 15 |
code = r['label']
|
| 16 |
-
langue =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
score = round(r['score'] * 100, 2)
|
| 18 |
-
texte_result += f"🌍 {
|
| 19 |
|
| 20 |
return texte_result
|
| 21 |
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
detector = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection")
|
| 5 |
|
|
|
|
| 12 |
texte_result = "🌍 Résultats de la détection :\n\n"
|
| 13 |
for r in resultats:
|
| 14 |
code = r['label']
|
| 15 |
+
langue = code # on affiche le code ISO directement si pas trouvé
|
| 16 |
+
try:
|
| 17 |
+
import locale
|
| 18 |
+
langue = locale.windows_locale.get(code, code)
|
| 19 |
+
except:
|
| 20 |
+
langue = code
|
| 21 |
score = round(r['score'] * 100, 2)
|
| 22 |
+
texte_result += f"🌍 {code.upper()} - {score}%\n"
|
| 23 |
|
| 24 |
return texte_result
|
| 25 |
|
requirements.txt
CHANGED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
|
| 2 |
-
|
| 3 |
transformers
|
| 4 |
torch
|
| 5 |
-
gradio
|
| 6 |
-
langcodes[data]
|
|
|
|
| 1 |
|
|
|
|
| 2 |
transformers
|
| 3 |
torch
|
| 4 |
+
gradio
|
|
|