Update app.py
Browse files
app.py
CHANGED
|
@@ -35,219 +35,55 @@ UI = {
|
|
| 35 |
|
| 36 |
MODEL_LINK = "https://huggingface.co/Setur/BRAGD"
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
--primary-100:#E1ECEA; --primary-200:#C6DAD6;
|
| 44 |
-
|
| 45 |
-
/* LIGHT */
|
| 46 |
-
--page-bg:#f7f7f8;
|
| 47 |
-
--panel-bg:#ffffff;
|
| 48 |
-
--text:#0b1b19;
|
| 49 |
-
--muted:#4b5a58;
|
| 50 |
-
--border: rgba(11,27,25,0.15);
|
| 51 |
-
}
|
| 52 |
-
#btn_tag{
|
| 53 |
-
background: var(--primary-500) !important;
|
| 54 |
-
border-color: var(--primary-600) !important;
|
| 55 |
-
color:#0b1b19 !important;
|
| 56 |
-
}
|
| 57 |
-
#btn_tag:hover{
|
| 58 |
-
background: var(--primary-600) !important;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
/* Page background */
|
| 62 |
-
html, body, .gradio-container{
|
| 63 |
-
background: var(--page-bg) !important;
|
| 64 |
-
}
|
| 65 |
-
body, .gradio-container, .prose, .markdown, textarea, input, select, button, table{
|
| 66 |
-
font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Noto Sans", sans-serif !important;
|
| 67 |
-
}
|
| 68 |
-
a{ color:var(--primary-700)!important; }
|
| 69 |
-
|
| 70 |
-
/* Primary button (Marka/Tag) */
|
| 71 |
-
.gr-button-primary, button.primary, .primary{
|
| 72 |
-
background:var(--primary-500)!important;
|
| 73 |
-
border-color:var(--primary-600)!important;
|
| 74 |
-
color:#0b1b19!important;
|
| 75 |
-
}
|
| 76 |
-
.gr-button-primary:hover, button.primary:hover, .primary:hover{ background:var(--primary-600)!important; }
|
| 77 |
-
.gr-button-primary{ padding:0.35rem 0.85rem!important; font-size:0.95rem!important; }
|
| 78 |
|
| 79 |
-
|
| 80 |
-
#
|
| 81 |
-
|
| 82 |
-
border-color: var(--primary-600) !important;
|
| 83 |
color:#0b1b19 !important;
|
| 84 |
}
|
| 85 |
-
#btn_tag:hover{
|
| 86 |
-
background:
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
/* --- Keep the textbox exactly as-is: wrapper blends with page, textarea stays white --- */
|
| 90 |
-
#input_col, #input_col *{
|
| 91 |
-
background: transparent !important;
|
| 92 |
-
}
|
| 93 |
-
#input_col .gr-block, #input_col .gr-panel, #input_col .gr-box, #input_col .gr-group, #input_col .gr-form{
|
| 94 |
-
background: transparent !important;
|
| 95 |
-
box-shadow:none !important;
|
| 96 |
-
border:0 !important;
|
| 97 |
-
}
|
| 98 |
-
#input_box, #input_box > div, #input_box .wrap, #input_box .container{
|
| 99 |
-
background: transparent !important;
|
| 100 |
-
box-shadow:none !important;
|
| 101 |
-
border:0 !important;
|
| 102 |
-
}
|
| 103 |
-
#input_box textarea{
|
| 104 |
-
background:#ffffff !important;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
/* Dataframe columns: keep Orð + Mark single-line */
|
| 108 |
-
.gr-dataframe table td:nth-child(1), .gr-dataframe table th:nth-child(1){
|
| 109 |
-
white-space: nowrap !important; width: 18% !important;
|
| 110 |
-
}
|
| 111 |
-
.gr-dataframe table td:nth-child(2), .gr-dataframe table th:nth-child(2){
|
| 112 |
-
white-space: nowrap !important; width: 18% !important;
|
| 113 |
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
|
| 114 |
-
}
|
| 115 |
-
.gr-dataframe table td:nth-child(3), .gr-dataframe table th:nth-child(3){
|
| 116 |
-
white-space: normal !important; width: 64% !important;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
/* Selected = match Marka/Tag exactly */
|
| 120 |
-
/* Hover = subtle */
|
| 121 |
-
/* Keep selected button color on hover; only lighten UNSELECTED on hover */
|
| 122 |
-
/* Push language buttons fully to the right */
|
| 123 |
-
#results_hdr > .gr-markdown{
|
| 124 |
-
flex:1 1 auto !important;
|
| 125 |
-
}
|
| 126 |
-
/* Results header row: two-column layout, title left, toggle hard-right */
|
| 127 |
-
#results_hdr{
|
| 128 |
-
display:grid !important;
|
| 129 |
-
grid-template-columns: 1fr auto !important;
|
| 130 |
-
align-items:center !important;
|
| 131 |
-
gap:12px !important;
|
| 132 |
-
padding:0 !important;
|
| 133 |
-
margin:0 !important;
|
| 134 |
-
background:transparent !important;
|
| 135 |
-
box-shadow:none !important;
|
| 136 |
-
border:0 !important;
|
| 137 |
-
}
|
| 138 |
-
#results_hdr > .gr-column:first-child{ justify-self:start !important; }
|
| 139 |
-
#results_hdr > .gr-column:last-child{ justify-self:end !important; }
|
| 140 |
-
|
| 141 |
-
/* Language toggle (gr.Radio): style the LABEL as the button (robust across Gradio DOM variants) */
|
| 142 |
-
.lang_toggle{
|
| 143 |
-
background: transparent !important;
|
| 144 |
-
justify-self:end !important;
|
| 145 |
-
}
|
| 146 |
-
.lang_toggle fieldset{
|
| 147 |
-
border:0!important;
|
| 148 |
-
padding:0!important;
|
| 149 |
-
margin:0!important;
|
| 150 |
-
background:transparent!important;
|
| 151 |
-
}
|
| 152 |
-
.lang_toggle .wrap{
|
| 153 |
-
display:flex!important;
|
| 154 |
-
gap:10px!important;
|
| 155 |
-
background:transparent!important;
|
| 156 |
-
padding:0!important;
|
| 157 |
-
margin:0!important;
|
| 158 |
-
}
|
| 159 |
-
.lang_toggle input{
|
| 160 |
-
display:none!important;
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
/* Kill any default Gradio "pill" styling inside */
|
| 164 |
-
.lang_toggle label *{
|
| 165 |
-
background:transparent!important;
|
| 166 |
-
box-shadow:none!important;
|
| 167 |
-
border:0!important;
|
| 168 |
-
}
|
| 169 |
-
|
| 170 |
-
/* The actual button */
|
| 171 |
-
.lang_toggle label{
|
| 172 |
-
display:inline-flex !important;
|
| 173 |
-
align-items:center !important;
|
| 174 |
-
justify-content:center !important;
|
| 175 |
-
cursor:pointer !important;
|
| 176 |
-
user-select:none !important;
|
| 177 |
-
|
| 178 |
-
padding:0.35rem 0.85rem !important;
|
| 179 |
-
font-size:0.95rem !important;
|
| 180 |
-
border-radius:10px !important;
|
| 181 |
-
|
| 182 |
-
border:1px solid var(--primary-600) !important;
|
| 183 |
-
background: var(--primary-200) !important; /* inactive: lighter than #89AFA9 */
|
| 184 |
-
color:#0b1b19 !important; /* black-ish */
|
| 185 |
}
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
border-color: var(--primary-600) !important;
|
| 191 |
color:#0b1b19 !important;
|
| 192 |
}
|
| 193 |
-
|
| 194 |
-
/* Hover: show #89AFA9 (inactive becomes active color on hover) */
|
| 195 |
-
.lang_toggle label:hover{
|
| 196 |
background:#89AFA9 !important;
|
| 197 |
-
border-color:
|
| 198 |
color:#0b1b19 !important;
|
| 199 |
}
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
all: unset;
|
| 214 |
-
display:inline-block;
|
| 215 |
-
cursor:pointer;
|
| 216 |
-
user-select:none;
|
| 217 |
-
padding:0.35rem 0.85rem;
|
| 218 |
-
font-size:0.95rem;
|
| 219 |
-
border-radius:10px;
|
| 220 |
-
border:1px solid var(--primary-600);
|
| 221 |
-
background: transparent; /* same as page */
|
| 222 |
-
color:#0b1b19;
|
| 223 |
-
box-shadow:none!important;
|
| 224 |
-
}
|
| 225 |
-
|
| 226 |
-
/* Selected state (robust selectors) */
|
| 227 |
-
.lang_toggle input:checked ~ span,
|
| 228 |
-
.lang_toggle label:has(input:checked) span{
|
| 229 |
-
background:var(--primary-500)!important;
|
| 230 |
-
border-color:var(--primary-600)!important;
|
| 231 |
-
color:#0b1b19!important;
|
| 232 |
}
|
| 233 |
|
| 234 |
-
/*
|
| 235 |
-
.lang_toggle label:hover input:not(:checked) ~ span,
|
| 236 |
-
.lang_toggle label:hover:not(:has(input:checked)) span{
|
| 237 |
-
background:var(--primary-200)!important;
|
| 238 |
-
}
|
| 239 |
-
/* --- Language buttons (robust: 4 real buttons, show/hide to indicate active) --- */
|
| 240 |
#results_hdr{
|
| 241 |
-
display:
|
| 242 |
-
grid-template-columns: 1fr auto !important;
|
| 243 |
align-items:center !important;
|
| 244 |
gap:12px !important;
|
| 245 |
-
padding:0 !important;
|
| 246 |
-
margin:0 !important;
|
| 247 |
-
background:transparent !important;
|
| 248 |
-
box-shadow:none !important;
|
| 249 |
-
border:0 !important;
|
| 250 |
}
|
|
|
|
| 251 |
#lang_buttons{
|
| 252 |
display:flex !important;
|
| 253 |
gap:10px !important;
|
|
@@ -255,243 +91,11 @@ a{ color:var(--primary-700)!important; }
|
|
| 255 |
align-items:center !important;
|
| 256 |
flex-wrap:nowrap !important;
|
| 257 |
}
|
| 258 |
-
#lang_buttons .gr-button, #lang_buttons button{
|
| 259 |
-
padding:0.35rem 0.85rem !important;
|
| 260 |
-
font-size:0.95rem !important;
|
| 261 |
-
border-radius:10px !important;
|
| 262 |
-
}
|
| 263 |
-
|
| 264 |
-
/* Inactive: lighter than #89AFA9, black text */
|
| 265 |
-
#lang_fo_off, #lang_en_off{
|
| 266 |
-
background:var(--primary-200) !important;
|
| 267 |
-
border-color:var(--primary-600) !important;
|
| 268 |
-
color:#0b1b19 !important;
|
| 269 |
-
}
|
| 270 |
-
/* Hover inactive -> active color (#89AFA9) */
|
| 271 |
-
#lang_fo_off:hover, #lang_en_off:hover{
|
| 272 |
-
background:var(--primary-500) !important;
|
| 273 |
-
border-color:var(--primary-600) !important;
|
| 274 |
-
color:#0b1b19 !important;
|
| 275 |
-
}
|
| 276 |
-
/* Active: ensure black text */
|
| 277 |
-
#lang_fo_on, #lang_en_on{
|
| 278 |
-
color:#0b1b19 !important;
|
| 279 |
-
}
|
| 280 |
-
|
| 281 |
-
/* Keep header transparent, but DON'T nuke button backgrounds */
|
| 282 |
-
#results_hdr, #results_hdr > div{
|
| 283 |
-
background:transparent !important;
|
| 284 |
-
box-shadow:none !important;
|
| 285 |
-
border:0 !important;
|
| 286 |
-
}
|
| 287 |
-
|
| 288 |
-
/* Prevent Gradio from stacking/stretching language buttons */
|
| 289 |
#lang_buttons .gr-button, #lang_buttons button{
|
| 290 |
width:auto !important;
|
| 291 |
min-width:120px !important;
|
| 292 |
flex:0 0 auto !important;
|
| 293 |
}
|
| 294 |
-
|
| 295 |
-
/* Language button colors */
|
| 296 |
-
#lang_buttons .gr-button-primary, #lang_buttons button.primary{
|
| 297 |
-
background:#89AFA9 !important;
|
| 298 |
-
border-color:#6F9992 !important;
|
| 299 |
-
color:#0b1b19 !important;
|
| 300 |
-
}
|
| 301 |
-
#lang_buttons .gr-button-secondary, #lang_buttons button.secondary{
|
| 302 |
-
background:#C6DAD6 !important; /* light green */
|
| 303 |
-
border-color:#6F9992 !important;
|
| 304 |
-
color:#0b1b19 !important;
|
| 305 |
-
}
|
| 306 |
-
#lang_buttons .gr-button-secondary:hover, #lang_buttons button.secondary:hover{
|
| 307 |
-
background:#89AFA9 !important;
|
| 308 |
-
border-color:#6F9992 !important;
|
| 309 |
-
color:#0b1b19 !important;
|
| 310 |
-
}
|
| 311 |
-
@media (prefers-color-scheme: dark){
|
| 312 |
-
:root{
|
| 313 |
-
--page-bg:#0f1214;
|
| 314 |
-
--panel-bg:#151a1e;
|
| 315 |
-
--text:#e7eceb;
|
| 316 |
-
--muted:#b8c3c1;
|
| 317 |
-
--border: rgba(231,236,235,0.18);
|
| 318 |
-
|
| 319 |
-
/* keep your brand, just shift the “inactive” background darker */
|
| 320 |
-
--primary-200:#2a3b38;
|
| 321 |
-
}
|
| 322 |
-
|
| 323 |
-
#btn_tag{
|
| 324 |
-
background: var(--primary-500) !important;
|
| 325 |
-
border-color: var(--primary-600) !important;
|
| 326 |
-
color:#0b1b19 !important;
|
| 327 |
-
}
|
| 328 |
-
#btn_tag:hover{
|
| 329 |
-
background: var(--primary-600) !important;
|
| 330 |
-
}
|
| 331 |
-
|
| 332 |
-
html, body, .gradio-container{
|
| 333 |
-
background: var(--page-bg) !important;
|
| 334 |
-
color: var(--text) !important;
|
| 335 |
-
}
|
| 336 |
-
|
| 337 |
-
body, .gradio-container, .prose, .markdown, label, p, span{
|
| 338 |
-
color: var(--text) !important;
|
| 339 |
-
}
|
| 340 |
-
|
| 341 |
-
.gr-block, .gr-panel, .gr-box, .gr-group, .gr-form{
|
| 342 |
-
background: transparent !important;
|
| 343 |
-
border-color: var(--border) !important;
|
| 344 |
-
}
|
| 345 |
-
|
| 346 |
-
#input_box textarea{
|
| 347 |
-
background: var(--panel-bg) !important;
|
| 348 |
-
color: var(--text) !important;
|
| 349 |
-
border: 1px solid var(--border) !important;
|
| 350 |
-
}
|
| 351 |
-
#input_box textarea::placeholder{
|
| 352 |
-
color: var(--muted) !important;
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
.gr-dataframe table{
|
| 356 |
-
background: var(--panel-bg) !important;
|
| 357 |
-
color: var(--text) !important;
|
| 358 |
-
}
|
| 359 |
-
.gr-dataframe table th,
|
| 360 |
-
.gr-dataframe table td{
|
| 361 |
-
background: var(--panel-bg) !important;
|
| 362 |
-
color: var(--text) !important;
|
| 363 |
-
border-color: var(--border) !important;
|
| 364 |
-
}
|
| 365 |
-
|
| 366 |
-
.gr-accordion, .gr-accordion *{
|
| 367 |
-
border-color: var(--border) !important;
|
| 368 |
-
}
|
| 369 |
-
|
| 370 |
-
a{ color: var(--primary-500) !important; }
|
| 371 |
-
|
| 372 |
-
.gr-button-primary, button.primary, .primary{
|
| 373 |
-
color: #0b1b19 !important;
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
#lang_fo_off, #lang_en_off{
|
| 377 |
-
background: var(--primary-200) !important;
|
| 378 |
-
border-color: var(--primary-600) !important;
|
| 379 |
-
color: var(--text) !important;
|
| 380 |
-
}
|
| 381 |
-
/* ---------- DARK MODE PATCH: fix Gradio component internals ---------- */
|
| 382 |
-
|
| 383 |
-
/* Headings / markdown titles (your “Úrslit”, accordion titles, etc.) */
|
| 384 |
-
.prose h1, .prose h2, .prose h3, .prose h4, .prose strong,
|
| 385 |
-
.gr-markdown h1, .gr-markdown h2, .gr-markdown h3, .gr-markdown h4,
|
| 386 |
-
.gr-markdown, .markdown, .prose {
|
| 387 |
-
color: var(--text) !important;
|
| 388 |
-
}
|
| 389 |
-
|
| 390 |
-
/* Accordion header/button text */
|
| 391 |
-
.gr-accordion summary,
|
| 392 |
-
.gr-accordion summary span,
|
| 393 |
-
.gr-accordion label,
|
| 394 |
-
.gr-accordion button {
|
| 395 |
-
color: var(--text) !important;
|
| 396 |
-
}
|
| 397 |
-
|
| 398 |
-
/* Make accordion header background readable */
|
| 399 |
-
.gr-accordion summary {
|
| 400 |
-
background: var(--panel-bg) !important;
|
| 401 |
-
border: 1px solid var(--border) !important;
|
| 402 |
-
border-radius: 10px !important;
|
| 403 |
-
}
|
| 404 |
-
|
| 405 |
-
/* Dataframe wrapper + all nested table bits */
|
| 406 |
-
.gr-dataframe,
|
| 407 |
-
.gr-dataframe .wrap,
|
| 408 |
-
.gr-dataframe .table-wrap,
|
| 409 |
-
.gr-dataframe table,
|
| 410 |
-
.gr-dataframe thead,
|
| 411 |
-
.gr-dataframe tbody,
|
| 412 |
-
.gr-dataframe tr,
|
| 413 |
-
.gr-dataframe th,
|
| 414 |
-
.gr-dataframe td {
|
| 415 |
-
background: var(--panel-bg) !important;
|
| 416 |
-
color: var(--text) !important;
|
| 417 |
-
border-color: var(--border) !important;
|
| 418 |
-
}
|
| 419 |
-
|
| 420 |
-
/* Fix links inside markdown in dark mode */
|
| 421 |
-
.gr-markdown a, .prose a {
|
| 422 |
-
color: var(--primary-500) !important;
|
| 423 |
-
}
|
| 424 |
-
|
| 425 |
-
/* Make inputs/selects/buttons inherit dark text properly */
|
| 426 |
-
input, textarea, select {
|
| 427 |
-
color: var(--text) !important;
|
| 428 |
-
}
|
| 429 |
-
|
| 430 |
-
/* FORCE your green primary button (Marka/Tag) even if Gradio theme fights back */
|
| 431 |
-
button.primary,
|
| 432 |
-
.gr-button-primary,
|
| 433 |
-
.gr-button.gr-button-primary,
|
| 434 |
-
button[data-testid="button"],
|
| 435 |
-
button:has(span:contains("Marka")),
|
| 436 |
-
button:has(span:contains("Tag")) {
|
| 437 |
-
background: var(--primary-500) !important;
|
| 438 |
-
border-color: var(--primary-600) !important;
|
| 439 |
-
color: #0b1b19 !important;
|
| 440 |
-
}
|
| 441 |
-
button.primary:hover,
|
| 442 |
-
.gr-button-primary:hover,
|
| 443 |
-
.gr-button.gr-button-primary:hover {
|
| 444 |
-
background: var(--primary-600) !important;
|
| 445 |
-
}
|
| 446 |
-
/* --- Dataframe: force readable text everywhere inside --- */
|
| 447 |
-
.gr-dataframe, .gr-dataframe *{
|
| 448 |
-
color: var(--text) !important;
|
| 449 |
-
border-color: var(--border) !important;
|
| 450 |
-
}
|
| 451 |
-
|
| 452 |
-
.gr-dataframe,
|
| 453 |
-
.gr-dataframe .wrap,
|
| 454 |
-
.gr-dataframe .table-wrap,
|
| 455 |
-
.gr-dataframe table,
|
| 456 |
-
.gr-dataframe thead,
|
| 457 |
-
.gr-dataframe tbody,
|
| 458 |
-
.gr-dataframe tr,
|
| 459 |
-
.gr-dataframe th,
|
| 460 |
-
.gr-dataframe td{
|
| 461 |
-
background: var(--panel-bg) !important;
|
| 462 |
-
}
|
| 463 |
-
|
| 464 |
-
/* --- Markdown + headings (Úrslit / Results etc.) --- */
|
| 465 |
-
#results_hdr, #results_hdr *{
|
| 466 |
-
color: var(--text) !important;
|
| 467 |
-
}
|
| 468 |
-
|
| 469 |
-
.gr-markdown, .gr-markdown *{
|
| 470 |
-
color: var(--text) !important;
|
| 471 |
-
}
|
| 472 |
-
|
| 473 |
-
/* --- Accordion header (the clickable bar) --- */
|
| 474 |
-
.gr-accordion summary,
|
| 475 |
-
.gr-accordion summary *{
|
| 476 |
-
color: var(--text) !important;
|
| 477 |
-
}
|
| 478 |
-
|
| 479 |
-
.gr-accordion summary{
|
| 480 |
-
background: var(--panel-bg) !important;
|
| 481 |
-
border: 1px solid var(--border) !important;
|
| 482 |
-
}
|
| 483 |
-
|
| 484 |
-
/* Accordion content area */
|
| 485 |
-
.gr-accordion .wrap,
|
| 486 |
-
.gr-accordion .wrap *{
|
| 487 |
-
color: var(--text) !important;
|
| 488 |
-
}
|
| 489 |
-
@media (forced-colors: active){
|
| 490 |
-
/* Let the OS pick readable colors */
|
| 491 |
-
*{ forced-color-adjust: auto; }
|
| 492 |
-
}
|
| 493 |
-
|
| 494 |
-
}
|
| 495 |
"""
|
| 496 |
|
| 497 |
# ----------------------------
|
|
@@ -784,9 +388,7 @@ def render(rows_state, lang: str):
|
|
| 784 |
out_mean.append([r["word"], tag, expanded_text(vec, lang)])
|
| 785 |
return (pd.DataFrame(out_main, columns=df_cols), pd.DataFrame(out_mean, columns=dfm_cols), build_overview(lang))
|
| 786 |
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
with gr.Blocks(theme=theme, css=CSS, title="Marka") as demo:
|
| 790 |
with gr.Row(equal_height=True):
|
| 791 |
with gr.Column(scale=2, elem_id="input_col"):
|
| 792 |
inp = gr.Textbox(lines=6, placeholder="Skriva her ... / Type here ...", show_label=False, elem_id="input_box")
|
|
@@ -801,7 +403,6 @@ with gr.Blocks(theme=theme, css=CSS, title="Marka") as demo:
|
|
| 801 |
state = gr.State([])
|
| 802 |
lang_state = gr.State("fo")
|
| 803 |
|
| 804 |
-
# Hide results header + toggle until Tag
|
| 805 |
results_hdr = gr.Row(elem_id="results_hdr", visible=True)
|
| 806 |
with results_hdr:
|
| 807 |
results_title = gr.Markdown("### Úrslit / Results")
|
|
@@ -843,11 +444,10 @@ with gr.Blocks(theme=theme, css=CSS, title="Marka") as demo:
|
|
| 843 |
gr.update(value=df_mean),
|
| 844 |
gr.update(value=overview),
|
| 845 |
gr.update(visible=True), # expanded_acc
|
| 846 |
-
#
|
| 847 |
-
gr.update(visible=show_fo),
|
| 848 |
-
gr.update(visible=
|
| 849 |
-
gr.update(visible=show_en),
|
| 850 |
-
gr.update(visible=not show_en), # en_off
|
| 851 |
lang_current,
|
| 852 |
)
|
| 853 |
|
|
@@ -882,7 +482,6 @@ with gr.Blocks(theme=theme, css=CSS, title="Marka") as demo:
|
|
| 882 |
queue=False,
|
| 883 |
)
|
| 884 |
|
| 885 |
-
# Language switch (does NOT rerun the model; just re-renders existing rows)
|
| 886 |
btn_lang_fo_on.click(
|
| 887 |
on_set_fo,
|
| 888 |
inputs=[state],
|
|
|
|
| 35 |
|
| 36 |
MODEL_LINK = "https://huggingface.co/Setur/BRAGD"
|
| 37 |
|
| 38 |
+
# ----------------------------
|
| 39 |
+
# Minimal CSS: ONLY the buttons (and a tiny header layout helper)
|
| 40 |
+
# ----------------------------
|
| 41 |
+
CSS = """
|
| 42 |
+
/* Keep Gradio default styling; only override our buttons. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
#btn_tag, #lang_fo_on, #lang_en_on{
|
| 45 |
+
background:#89AFA9 !important;
|
| 46 |
+
border-color:#6F9992 !important;
|
|
|
|
| 47 |
color:#0b1b19 !important;
|
| 48 |
}
|
| 49 |
+
#btn_tag:hover, #lang_fo_on:hover, #lang_en_on:hover{
|
| 50 |
+
background:#6F9992 !important;
|
| 51 |
+
border-color:#6F9992 !important;
|
| 52 |
+
color:#0b1b19 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
+
#lang_fo_off, #lang_en_off{
|
| 56 |
+
background:#C6DAD6 !important;
|
| 57 |
+
border-color:#6F9992 !important;
|
|
|
|
| 58 |
color:#0b1b19 !important;
|
| 59 |
}
|
| 60 |
+
#lang_fo_off:hover, #lang_en_off:hover{
|
|
|
|
|
|
|
| 61 |
background:#89AFA9 !important;
|
| 62 |
+
border-color:#6F9992 !important;
|
| 63 |
color:#0b1b19 !important;
|
| 64 |
}
|
| 65 |
|
| 66 |
+
/* Dark mode: make the INACTIVE buttons match what you had before (darker, readable) */
|
| 67 |
+
@media (prefers-color-scheme: dark){
|
| 68 |
+
#lang_fo_off, #lang_en_off{
|
| 69 |
+
background:#2a3b38 !important;
|
| 70 |
+
border-color:#6F9992 !important;
|
| 71 |
+
color:#e7eceb !important;
|
| 72 |
+
}
|
| 73 |
+
#lang_fo_off:hover, #lang_en_off:hover{
|
| 74 |
+
background:#89AFA9 !important;
|
| 75 |
+
border-color:#6F9992 !important;
|
| 76 |
+
color:#0b1b19 !important;
|
| 77 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
}
|
| 79 |
|
| 80 |
+
/* Minimal layout so the language buttons stay hard-right like before */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
#results_hdr{
|
| 82 |
+
display:flex !important;
|
|
|
|
| 83 |
align-items:center !important;
|
| 84 |
gap:12px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
+
#results_hdr > .gr-markdown{ flex:1 1 auto !important; }
|
| 87 |
#lang_buttons{
|
| 88 |
display:flex !important;
|
| 89 |
gap:10px !important;
|
|
|
|
| 91 |
align-items:center !important;
|
| 92 |
flex-wrap:nowrap !important;
|
| 93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
#lang_buttons .gr-button, #lang_buttons button{
|
| 95 |
width:auto !important;
|
| 96 |
min-width:120px !important;
|
| 97 |
flex:0 0 auto !important;
|
| 98 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
"""
|
| 100 |
|
| 101 |
# ----------------------------
|
|
|
|
| 388 |
out_mean.append([r["word"], tag, expanded_text(vec, lang)])
|
| 389 |
return (pd.DataFrame(out_main, columns=df_cols), pd.DataFrame(out_mean, columns=dfm_cols), build_overview(lang))
|
| 390 |
|
| 391 |
+
with gr.Blocks(css=CSS, title="Marka") as demo:
|
|
|
|
|
|
|
| 392 |
with gr.Row(equal_height=True):
|
| 393 |
with gr.Column(scale=2, elem_id="input_col"):
|
| 394 |
inp = gr.Textbox(lines=6, placeholder="Skriva her ... / Type here ...", show_label=False, elem_id="input_box")
|
|
|
|
| 403 |
state = gr.State([])
|
| 404 |
lang_state = gr.State("fo")
|
| 405 |
|
|
|
|
| 406 |
results_hdr = gr.Row(elem_id="results_hdr", visible=True)
|
| 407 |
with results_hdr:
|
| 408 |
results_title = gr.Markdown("### Úrslit / Results")
|
|
|
|
| 444 |
gr.update(value=df_mean),
|
| 445 |
gr.update(value=overview),
|
| 446 |
gr.update(visible=True), # expanded_acc
|
| 447 |
+
gr.update(visible=show_fo), # fo_on
|
| 448 |
+
gr.update(visible=not show_fo),# fo_off
|
| 449 |
+
gr.update(visible=show_en), # en_on
|
| 450 |
+
gr.update(visible=not show_en),# en_off
|
|
|
|
| 451 |
lang_current,
|
| 452 |
)
|
| 453 |
|
|
|
|
| 482 |
queue=False,
|
| 483 |
)
|
| 484 |
|
|
|
|
| 485 |
btn_lang_fo_on.click(
|
| 486 |
on_set_fo,
|
| 487 |
inputs=[state],
|