cheikhaidev-ui Claude Sonnet 4.6 commited on
Commit
ddfc44c
·
1 Parent(s): 32e2766

feat(app): accordion "Comment ca marche" + fix inline code dark mode

Browse files

- Ajoute gr.Accordion .ls-how-it-works en bas de page (replie par defaut)
- Contenu : sentiment, mots parasites, structure, clarte
- CSS accordion : fond #1e1e2e, titres #a5b4fc, tables sombres
- CSS code inline : fond #0f0f1a, texte #c7d2fe, border-radius 4px

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +127 -0
app.py CHANGED
@@ -279,6 +279,83 @@ CSS = """
279
  height: 6px; border-radius: 4px;
280
  }
281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  /* ── Examples table ───────────────────────────────────────────────── */
283
  .table-wrap {
284
  background-color: #0f0f1a !important;
@@ -330,6 +407,53 @@ CSS = """
330
  .ls-results-col { gap: 0.85rem !important; }
331
  """
332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  _HEADER_MD = """<div class="ls-logo">🔭</div>
334
 
335
  # LinguaScope
@@ -393,6 +517,9 @@ with gr.Blocks(title="LinguaScope", js=_DARK_JS, css=CSS, fill_width=False) as d
393
  outputs=[text_input, lang_radio] + outputs,
394
  )
395
 
 
 
 
396
 
397
  if __name__ == "__main__":
398
  demo.launch(theme=THEME)
 
279
  height: 6px; border-radius: 4px;
280
  }
281
 
282
+ /* ── How it works accordion ──────────────────────────────────────── */
283
+ .ls-how-it-works {
284
+ margin-top: 2rem !important;
285
+ border: 1px solid #2d2d44 !important;
286
+ border-radius: 12px !important;
287
+ background-color: #1e1e2e !important;
288
+ overflow: hidden !important;
289
+ }
290
+
291
+ .ls-how-it-works > .label-wrap {
292
+ padding: 0.85rem 1.25rem !important;
293
+ background-color: #1e1e2e !important;
294
+ cursor: pointer !important;
295
+ }
296
+
297
+ .ls-how-it-works > .label-wrap span {
298
+ color: #c7d2fe !important;
299
+ font-weight: 600 !important;
300
+ font-size: 0.95rem !important;
301
+ letter-spacing: 0.02em !important;
302
+ }
303
+
304
+ .ls-how-it-works .prose {
305
+ padding: 0 1.5rem 1.5rem !important;
306
+ }
307
+
308
+ .ls-how-it-works .prose h3 {
309
+ color: #a5b4fc !important;
310
+ font-size: 0.95rem !important;
311
+ font-weight: 700 !important;
312
+ margin: 1.25rem 0 0.4rem !important;
313
+ letter-spacing: 0.01em !important;
314
+ }
315
+
316
+ .ls-how-it-works .prose p,
317
+ .ls-how-it-works .prose li {
318
+ color: #cbd5e1 !important;
319
+ font-size: 0.875rem !important;
320
+ line-height: 1.65 !important;
321
+ }
322
+
323
+ .ls-how-it-works .prose table {
324
+ border-collapse: collapse !important;
325
+ width: 100% !important;
326
+ margin: 0.75rem 0 !important;
327
+ font-size: 0.85rem !important;
328
+ }
329
+
330
+ .ls-how-it-works .prose th {
331
+ background-color: #13131f !important;
332
+ color: #a5b4fc !important;
333
+ padding: 0.4rem 0.75rem !important;
334
+ text-align: left !important;
335
+ border: 1px solid #2d2d44 !important;
336
+ }
337
+
338
+ .ls-how-it-works .prose td {
339
+ color: #cbd5e1 !important;
340
+ background-color: #13131f !important;
341
+ padding: 0.35rem 0.75rem !important;
342
+ border: 1px solid #1e1e2e !important;
343
+ }
344
+
345
+ .ls-how-it-works .prose hr {
346
+ border-color: #2d2d44 !important;
347
+ margin: 1rem 0 !important;
348
+ }
349
+
350
+ .ls-how-it-works .prose code {
351
+ background-color: #0f0f1a !important;
352
+ color: #c7d2fe !important;
353
+ padding: 0.15rem 0.4rem !important;
354
+ border-radius: 4px !important;
355
+ font-size: 0.82rem !important;
356
+ border: 1px solid #2d2d44 !important;
357
+ }
358
+
359
  /* ── Examples table ───────────────────────────────────────────────── */
360
  .table-wrap {
361
  background-color: #0f0f1a !important;
 
407
  .ls-results-col { gap: 0.85rem !important; }
408
  """
409
 
410
+ _HOW_IT_WORKS_MD = """
411
+ ### Analyse de sentiment
412
+
413
+ Deux moteurs selon la langue détectée :
414
+ - **Français** — [textblob-fr](https://github.com/sloria/textblob-fr) avec `PatternTagger` et `PatternAnalyzer` (port du Pattern NLP de CLiPS).
415
+ - **Anglais** — [TextBlob](https://textblob.readthedocs.io/) natif avec son analyseur de polarité et de subjectivité.
416
+
417
+ Le score de **polarité** va de **−1** (très négatif) à **+1** (très positif). La classification applique un seuil à ±0.1 : en dessous de −0.1 → négatif, au-dessus de +0.1 → positif, entre les deux → neutre. La **subjectivité** (0 = factuel, 1 = très subjectif) n'est disponible qu'en anglais.
418
+
419
+ ---
420
+
421
+ ### Détection des mots parasites
422
+
423
+ Chaque langue dispose d'un lexique de référence :
424
+ - **Français (~20 entrées)** : *euh, bah, ben, hein, voilà, quoi, enfin, du coup, en fait, genre, machin, truc, chose, nan, ouais, bref, bon, donc, genre, wesh*
425
+ - **Anglais (~18 entrées)** : *um, uh, like, you know, basically, literally, honestly, right, so, anyway, sort of, kind of, I mean, well, okay, actually, whatever, seriously*
426
+
427
+ La détection s'effectue par tokenisation avec correspondance de mots entiers (regex `\bfiller\b`) pour éviter les faux positifs. Un **ratio fillers / mots totaux > 5 %** déclenche une alerte.
428
+
429
+ ---
430
+
431
+ ### Structure du discours
432
+
433
+ Trois marqueurs sont recherchés par mots-clés bilingues :
434
+
435
+ | Partie | Exemples de marqueurs FR | Exemples de marqueurs EN |
436
+ |---|---|---|
437
+ | **Introduction** | *pour commencer, premièrement, aujourd'hui* | *first, to begin, today* |
438
+ | **Développement** | *(minimum 3 phrases dans le corps)* | *(minimum 3 sentences in the body)* |
439
+ | **Conclusion** | *en conclusion, finalement, en résumé* | *in conclusion, finally, overall* |
440
+
441
+ Chaque partie présente rapporte 1 point. Le **score de structure** est sur **3**.
442
+
443
+ ---
444
+
445
+ ### Score de clarté
446
+
447
+ Le score démarre à 100 et subit deux pénalités :
448
+
449
+ | Critère | Seuil | Pénalité max |
450
+ |---|---|---|
451
+ | **Longueur des phrases** | > 25 mots/phrase | −40 pts |
452
+ | **Diversité lexicale** (Type-Token Ratio) | TTR < 0.5 | −20 pts |
453
+
454
+ Le **TTR** est le rapport *mots uniques / mots totaux*. Un texte qui répète beaucoup les mêmes mots aura un TTR bas. Le score final est borné entre 0 et 100.
455
+ """
456
+
457
  _HEADER_MD = """<div class="ls-logo">🔭</div>
458
 
459
  # LinguaScope
 
517
  outputs=[text_input, lang_radio] + outputs,
518
  )
519
 
520
+ with gr.Accordion("Comment ça marche", open=False, elem_classes=["ls-how-it-works"]):
521
+ gr.Markdown(_HOW_IT_WORKS_MD)
522
+
523
 
524
  if __name__ == "__main__":
525
  demo.launch(theme=THEME)