Gleb Gleb
commited on
Commit
·
527919e
1
Parent(s):
f5b8179
adjusted disaplaying
Browse files
app.py
CHANGED
|
@@ -14,7 +14,18 @@ def normalize(text, lang_choice):
|
|
| 14 |
try:
|
| 15 |
lang = None if lang_choice == "Auto-detect" else lang_choice
|
| 16 |
result = pipeline(text, lang=lang, diagnostics=True)
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
except Exception as e:
|
| 19 |
print("❌ Pipeline error:", e)
|
| 20 |
return f"Error: {e}"
|
|
|
|
| 14 |
try:
|
| 15 |
lang = None if lang_choice == "Auto-detect" else lang_choice
|
| 16 |
result = pipeline(text, lang=lang, diagnostics=True)
|
| 17 |
+
|
| 18 |
+
# Format analyzer pipeline for better readability
|
| 19 |
+
analyzer_steps = []
|
| 20 |
+
if 'analyzer_pipeline' in result and result['analyzer_pipeline']:
|
| 21 |
+
for i, step in enumerate(result['analyzer_pipeline'], 1):
|
| 22 |
+
step_type = step.get('type', 'unknown')
|
| 23 |
+
step_name = step.get('name', 'unnamed')
|
| 24 |
+
analyzer_steps.append(f" {i}. {step_type}: {step_name}")
|
| 25 |
+
|
| 26 |
+
analyzer_display = "\n".join(analyzer_steps) if analyzer_steps else " No analyzer steps found"
|
| 27 |
+
|
| 28 |
+
return f"🌍 Language: {result['language']}\n\n🔤 Tokens:\n{result['tokens']}\n\n🚫 Detected stopwords:\n{result['stopwords_detected']}\n\n⚙️ Analyzer pipeline:\n{analyzer_display}"
|
| 29 |
except Exception as e:
|
| 30 |
print("❌ Pipeline error:", e)
|
| 31 |
return f"Error: {e}"
|