Spaces:
Running
Running
fix: score com 4 casas decimais + aviso contextual quando todas contribuições são do mesmo lado
Browse files
app.py
CHANGED
|
@@ -101,7 +101,7 @@ def _score_card_html(p: float) -> str:
|
|
| 101 |
|
| 102 |
<div style="text-align:right;">
|
| 103 |
<div class="notinhas-score-label">P(útil)</div>
|
| 104 |
-
<div class="notinhas-score-value">{p:.
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
</div>
|
|
@@ -157,6 +157,30 @@ def _top_tokens_table_html(
|
|
| 157 |
pos_rows = "".join(_row(t, v, "pos") for t, v in pos) or empty
|
| 158 |
neg_rows = "".join(_row(t, v, "neg") for t, v in neg) or empty
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
return f"""
|
| 161 |
<div style="display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:12px;
|
| 162 |
font-family:system-ui, -apple-system, sans-serif;">
|
|
@@ -173,7 +197,7 @@ def _top_tokens_table_html(
|
|
| 173 |
<table style="width:100%;border-collapse:collapse;font-size:13px;">{neg_rows}</table>
|
| 174 |
</div>
|
| 175 |
</div>
|
| 176 |
-
"""
|
| 177 |
|
| 178 |
|
| 179 |
# ---------------------------------------------------------------------------
|
|
|
|
| 101 |
|
| 102 |
<div style="text-align:right;">
|
| 103 |
<div class="notinhas-score-label">P(útil)</div>
|
| 104 |
+
<div class="notinhas-score-value">{p:.4f}</div>
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
</div>
|
|
|
|
| 157 |
pos_rows = "".join(_row(t, v, "pos") for t, v in pos) or empty
|
| 158 |
neg_rows = "".join(_row(t, v, "neg") for t, v in neg) or empty
|
| 159 |
|
| 160 |
+
all_same_side = (not neg and pos) or (not pos and neg)
|
| 161 |
+
if not neg and pos:
|
| 162 |
+
side_warning = (
|
| 163 |
+
'<p style="font-size:12px;color:#6c757d;margin:10px 4px 0 4px;line-height:1.5;">'
|
| 164 |
+
'⚠️ <strong>Nenhuma palavra puxando para não-útil identificada.</strong> '
|
| 165 |
+
'O método leave-one-out compara a frase completa com cada ablação de uma palavra. '
|
| 166 |
+
'Quando todas as contribuições são positivas, a frase completa pontua '
|
| 167 |
+
'marginalmente <em>mais</em> do que qualquer subconjunto — comum em textos '
|
| 168 |
+
'muito curtos ou frases com sentido idiomático. '
|
| 169 |
+
'O texto permanece Não-útil porque P(útil) está longe do limiar (0.5); '
|
| 170 |
+
'o que o define é a <em>ausência</em> de características úteis '
|
| 171 |
+
'(fontes, dados, neutralidade), não palavras negativas específicas.'
|
| 172 |
+
'</p>'
|
| 173 |
+
)
|
| 174 |
+
elif not pos and neg:
|
| 175 |
+
side_warning = (
|
| 176 |
+
'<p style="font-size:12px;color:#6c757d;margin:10px 4px 0 4px;line-height:1.5;">'
|
| 177 |
+
'⚠️ <strong>Nenhuma palavra puxando para útil identificada.</strong> '
|
| 178 |
+
'Todas as palavras reduzem marginalmente P(útil) quando presentes.'
|
| 179 |
+
'</p>'
|
| 180 |
+
)
|
| 181 |
+
else:
|
| 182 |
+
side_warning = ""
|
| 183 |
+
|
| 184 |
return f"""
|
| 185 |
<div style="display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:12px;
|
| 186 |
font-family:system-ui, -apple-system, sans-serif;">
|
|
|
|
| 197 |
<table style="width:100%;border-collapse:collapse;font-size:13px;">{neg_rows}</table>
|
| 198 |
</div>
|
| 199 |
</div>
|
| 200 |
+
""" + side_warning
|
| 201 |
|
| 202 |
|
| 203 |
# ---------------------------------------------------------------------------
|