Spaces:
Sleeping
Sleeping
Commit
·
ca4f534
1
Parent(s):
5188f64
fixe tables
Browse files
app.py
CHANGED
|
@@ -281,60 +281,46 @@ class ZarmaLanguageAnalyzer:
|
|
| 281 |
}
|
| 282 |
|
| 283 |
def format_output(self, results: dict, lang: str = "en") -> str:
|
| 284 |
-
"""Format the analysis results for Gradio output in the selected language
|
| 285 |
if lang == "fr":
|
| 286 |
output = "=" * 80 + "\n"
|
| 287 |
-
output += "
|
| 288 |
output += "=" * 80 + "\n\n"
|
| 289 |
|
| 290 |
-
output += "
|
| 291 |
-
output += "
|
| 292 |
-
output += f"| Phrase Analysée | \"{results['sentence']}\" |\n"
|
| 293 |
-
output += f"| État de la Grammaire | {'Problèmes détectés' if results['grammar_issues'] else 'Correct'} |\n"
|
| 294 |
-
output += "|-------------|-------------|\n\n"
|
| 295 |
|
| 296 |
-
output += "
|
| 297 |
-
output += "
|
| 298 |
-
|
| 299 |
-
output += f"| {analysis_formatted} |\n"
|
| 300 |
-
output += "|-----------------------|\n\n"
|
| 301 |
|
| 302 |
-
output += "
|
| 303 |
-
output += "
|
| 304 |
if results["retrieved_context"]:
|
| 305 |
for i, context in enumerate(results["retrieved_context"], 1):
|
| 306 |
-
|
| 307 |
-
output += f"| Source {i} : {context_formatted} |\n"
|
| 308 |
else:
|
| 309 |
-
output += "
|
| 310 |
-
output += "|---------------------------------|\n"
|
| 311 |
output += "=" * 80
|
| 312 |
else: # Default to English
|
| 313 |
output = "=" * 80 + "\n"
|
| 314 |
-
output += "
|
| 315 |
output += "=" * 80 + "\n\n"
|
| 316 |
|
| 317 |
-
output += "
|
| 318 |
-
output += "
|
| 319 |
-
output += f"| Sentence Analyzed | \"{results['sentence']}\" |\n"
|
| 320 |
-
output += f"| Grammar Status | {'Issues detected' if results['grammar_issues'] else 'Correct'} |\n"
|
| 321 |
-
output += "|-------------|-------------|\n\n"
|
| 322 |
|
| 323 |
-
output += "
|
| 324 |
-
output += "
|
| 325 |
-
|
| 326 |
-
output += f"| {analysis_formatted} |\n"
|
| 327 |
-
output += "|-----------------------|\n\n"
|
| 328 |
|
| 329 |
-
output += "
|
| 330 |
-
output += "
|
| 331 |
if results["retrieved_context"]:
|
| 332 |
for i, context in enumerate(results["retrieved_context"], 1):
|
| 333 |
-
|
| 334 |
-
output += f"| Source {i}: {context_formatted} |\n"
|
| 335 |
else:
|
| 336 |
-
output += "
|
| 337 |
-
output += "|------------------------------|\n"
|
| 338 |
output += "=" * 80
|
| 339 |
|
| 340 |
return output
|
|
|
|
| 281 |
}
|
| 282 |
|
| 283 |
def format_output(self, results: dict, lang: str = "en") -> str:
|
| 284 |
+
"""Format the analysis results for Gradio output in the selected language."""
|
| 285 |
if lang == "fr":
|
| 286 |
output = "=" * 80 + "\n"
|
| 287 |
+
output += "ANALYSEUR DE LANGUE ZARMA\n"
|
| 288 |
output += "=" * 80 + "\n\n"
|
| 289 |
|
| 290 |
+
output += f"Phrase Analysée: \"{results['sentence']}\"\n"
|
| 291 |
+
output += f"État de la Grammaire: {'Problèmes détectés' if results['grammar_issues'] else 'Correct'}\n\n"
|
|
|
|
|
|
|
|
|
|
| 292 |
|
| 293 |
+
output += "Analyse Détaillée:\n"
|
| 294 |
+
output += "-" * 80 + "\n"
|
| 295 |
+
output += results['analysis_result'] + "\n\n"
|
|
|
|
|
|
|
| 296 |
|
| 297 |
+
output += "Sources de Contexte Fiables:\n"
|
| 298 |
+
output += "-" * 80 + "\n"
|
| 299 |
if results["retrieved_context"]:
|
| 300 |
for i, context in enumerate(results["retrieved_context"], 1):
|
| 301 |
+
output += f"Source {i}:\n{context}\n\n"
|
|
|
|
| 302 |
else:
|
| 303 |
+
output += "Aucune source de contexte fiable récupérée basée sur l'analyse.\n"
|
|
|
|
| 304 |
output += "=" * 80
|
| 305 |
else: # Default to English
|
| 306 |
output = "=" * 80 + "\n"
|
| 307 |
+
output += "ZARMA LANGUAGE ANALYZER\n"
|
| 308 |
output += "=" * 80 + "\n\n"
|
| 309 |
|
| 310 |
+
output += f"Sentence Analyzed: \"{results['sentence']}\"\n"
|
| 311 |
+
output += f"Grammar Status: {'Issues detected' if results['grammar_issues'] else 'Correct'}\n\n"
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
+
output += "Detailed Analysis:\n"
|
| 314 |
+
output += "-" * 80 + "\n"
|
| 315 |
+
output += results['analysis_result'] + "\n\n"
|
|
|
|
|
|
|
| 316 |
|
| 317 |
+
output += "Reliable Context Sources:\n"
|
| 318 |
+
output += "-" * 80 + "\n"
|
| 319 |
if results["retrieved_context"]:
|
| 320 |
for i, context in enumerate(results["retrieved_context"], 1):
|
| 321 |
+
output += f"Source {i}:\n{context}\n\n"
|
|
|
|
| 322 |
else:
|
| 323 |
+
output += "No reliable context sources retrieved based on the analysis.\n"
|
|
|
|
| 324 |
output += "=" * 80
|
| 325 |
|
| 326 |
return output
|