Spaces:
Running
Running
Tobias Brugger
commited on
Commit
·
5d4b4ba
1
Parent(s):
4336cb2
add color shading for score
Browse files- src/lib/DatasetViewer.svelte +79 -4
src/lib/DatasetViewer.svelte
CHANGED
|
@@ -278,6 +278,25 @@
|
|
| 278 |
return match?.label || "";
|
| 279 |
}
|
| 280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
// Filter comparisons by selected category
|
| 282 |
function getFilteredComparisons(score: EquivalencyScore | null) {
|
| 283 |
if (!score || !score.comparisons) return [];
|
|
@@ -473,7 +492,9 @@
|
|
| 473 |
</span>
|
| 474 |
</span>
|
| 475 |
</span>
|
| 476 |
-
<strong
|
|
|
|
|
|
|
| 477 |
</div>
|
| 478 |
|
| 479 |
{#if score.comparative_law_note}
|
|
@@ -527,7 +548,9 @@
|
|
| 527 |
› {formatCategoryName(comparison.subcategory)}
|
| 528 |
</span>
|
| 529 |
{/if}
|
| 530 |
-
<span
|
|
|
|
|
|
|
| 531 |
>{comparison.similarity_score.toFixed(2)}</span
|
| 532 |
>
|
| 533 |
</div>
|
|
@@ -965,14 +988,66 @@
|
|
| 965 |
|
| 966 |
.comparison-score {
|
| 967 |
margin-left: auto;
|
| 968 |
-
background: #646cff;
|
| 969 |
-
color: white;
|
| 970 |
padding: 0.25rem 0.75rem;
|
| 971 |
border-radius: 12px;
|
| 972 |
font-weight: 600;
|
| 973 |
font-size: 0.9rem;
|
| 974 |
}
|
| 975 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 976 |
.comparison-meta {
|
| 977 |
display: flex;
|
| 978 |
gap: 1rem;
|
|
|
|
| 278 |
return match?.label || "";
|
| 279 |
}
|
| 280 |
|
| 281 |
+
// Return a CSS class name for coloring scores (low/medium/high)
|
| 282 |
+
function getScoreClass(scoreValue: number): string {
|
| 283 |
+
// More fine-grained buckets across the 1.0-5.0 range
|
| 284 |
+
// 1.0 - 1.99 -> very-low
|
| 285 |
+
// 2.0 - 2.49 -> low
|
| 286 |
+
// 2.5 - 2.99 -> medium-low
|
| 287 |
+
// 3.0 - 3.49 -> medium
|
| 288 |
+
// 3.5 - 3.99 -> medium-high
|
| 289 |
+
// 4.0 - 4.49 -> high
|
| 290 |
+
// 4.5 - 5.0+ -> very-high
|
| 291 |
+
if (scoreValue >= 4.5) return "score-very-high";
|
| 292 |
+
if (scoreValue >= 4.0) return "score-high";
|
| 293 |
+
if (scoreValue >= 3.5) return "score-medium-high";
|
| 294 |
+
if (scoreValue >= 3.0) return "score-medium";
|
| 295 |
+
if (scoreValue >= 2.5) return "score-medium-low";
|
| 296 |
+
if (scoreValue >= 2.0) return "score-low";
|
| 297 |
+
return "score-very-low";
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
// Filter comparisons by selected category
|
| 301 |
function getFilteredComparisons(score: EquivalencyScore | null) {
|
| 302 |
if (!score || !score.comparisons) return [];
|
|
|
|
| 492 |
</span>
|
| 493 |
</span>
|
| 494 |
</span>
|
| 495 |
+
<strong class={getScoreClass(score.aggregated_similarity_score)}
|
| 496 |
+
>{score.aggregated_similarity_score.toFixed(2)}</strong
|
| 497 |
+
>
|
| 498 |
</div>
|
| 499 |
|
| 500 |
{#if score.comparative_law_note}
|
|
|
|
| 548 |
› {formatCategoryName(comparison.subcategory)}
|
| 549 |
</span>
|
| 550 |
{/if}
|
| 551 |
+
<span
|
| 552 |
+
class={"comparison-score " +
|
| 553 |
+
getScoreClass(comparison.similarity_score)}
|
| 554 |
>{comparison.similarity_score.toFixed(2)}</span
|
| 555 |
>
|
| 556 |
</div>
|
|
|
|
| 988 |
|
| 989 |
.comparison-score {
|
| 990 |
margin-left: auto;
|
|
|
|
|
|
|
| 991 |
padding: 0.25rem 0.75rem;
|
| 992 |
border-radius: 12px;
|
| 993 |
font-weight: 600;
|
| 994 |
font-size: 0.9rem;
|
| 995 |
}
|
| 996 |
|
| 997 |
+
/* Score color variants */
|
| 998 |
+
.comparison-score.score-high {
|
| 999 |
+
background: #1a7f37;
|
| 1000 |
+
color: white;
|
| 1001 |
+
}
|
| 1002 |
+
.comparison-score.score-medium {
|
| 1003 |
+
background: #d98200;
|
| 1004 |
+
color: white;
|
| 1005 |
+
}
|
| 1006 |
+
.comparison-score.score-low {
|
| 1007 |
+
background: #c33;
|
| 1008 |
+
color: white;
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
.score-high {
|
| 1012 |
+
color: #1a7f37;
|
| 1013 |
+
}
|
| 1014 |
+
.score-medium {
|
| 1015 |
+
color: #d98200;
|
| 1016 |
+
}
|
| 1017 |
+
.score-low {
|
| 1018 |
+
color: #c33;
|
| 1019 |
+
}
|
| 1020 |
+
/* Fine-grained score variants */
|
| 1021 |
+
.comparison-score.score-very-high {
|
| 1022 |
+
background: #0f6b2d;
|
| 1023 |
+
color: white;
|
| 1024 |
+
}
|
| 1025 |
+
.comparison-score.score-medium-high {
|
| 1026 |
+
background: #2e9a44;
|
| 1027 |
+
color: white;
|
| 1028 |
+
}
|
| 1029 |
+
.comparison-score.score-medium-low {
|
| 1030 |
+
background: #f39c12;
|
| 1031 |
+
color: white;
|
| 1032 |
+
}
|
| 1033 |
+
.comparison-score.score-very-low {
|
| 1034 |
+
background: #9b1f1f;
|
| 1035 |
+
color: white;
|
| 1036 |
+
}
|
| 1037 |
+
|
| 1038 |
+
.score-very-high {
|
| 1039 |
+
color: #0f6b2d;
|
| 1040 |
+
}
|
| 1041 |
+
.score-medium-high {
|
| 1042 |
+
color: #2e9a44;
|
| 1043 |
+
}
|
| 1044 |
+
.score-medium-low {
|
| 1045 |
+
color: #f39c12;
|
| 1046 |
+
}
|
| 1047 |
+
.score-very-low {
|
| 1048 |
+
color: #9b1f1f;
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
.comparison-meta {
|
| 1052 |
display: flex;
|
| 1053 |
gap: 1rem;
|