Spaces:
Running
Running
Tobias Brugger
commited on
Commit
·
5d2f4d1
1
Parent(s):
3e97cdf
add score string + legend
Browse files- src/lib/DatasetViewer.svelte +131 -0
- src/lib/config.ts +10 -0
src/lib/DatasetViewer.svelte
CHANGED
|
@@ -9,6 +9,7 @@
|
|
| 9 |
const dataset = getDatasetName("structured-answers");
|
| 10 |
const scoresDataset = getDatasetName("equivalency-scores");
|
| 11 |
const directTranslations = config.directTranslations;
|
|
|
|
| 12 |
|
| 13 |
// Create bidirectional lookup map (both English->Swedish and Swedish->English)
|
| 14 |
const translationMap = new Map<string, string>();
|
|
@@ -230,6 +231,18 @@
|
|
| 230 |
return Array.from(categories).sort();
|
| 231 |
}
|
| 232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
// Filter comparisons by selected category
|
| 234 |
function getFilteredComparisons(score: EquivalencyScore | null) {
|
| 235 |
if (!score || !score.comparisons) return [];
|
|
@@ -362,8 +375,42 @@
|
|
| 362 |
<div class="similarity-score">
|
| 363 |
<h3>Equivalency Score</h3>
|
| 364 |
<div class="score-display">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
<strong>{score.aggregated_similarity_score.toFixed(2)}</strong>
|
| 366 |
</div>
|
|
|
|
| 367 |
{#if score.comparative_law_note}
|
| 368 |
<div class="comparative-note">
|
| 369 |
<div class="markdown-content">
|
|
@@ -621,6 +668,16 @@
|
|
| 621 |
text-align: center;
|
| 622 |
}
|
| 623 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 624 |
.score-display strong {
|
| 625 |
display: block;
|
| 626 |
font-size: 3rem;
|
|
@@ -628,6 +685,80 @@
|
|
| 628 |
font-weight: 600;
|
| 629 |
}
|
| 630 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
.comparative-note {
|
| 632 |
margin-top: 1.5rem;
|
| 633 |
padding-top: 1.5rem;
|
|
|
|
| 9 |
const dataset = getDatasetName("structured-answers");
|
| 10 |
const scoresDataset = getDatasetName("equivalency-scores");
|
| 11 |
const directTranslations = config.directTranslations;
|
| 12 |
+
const equivalencyScoreLabels = config.equivalencyScoreLabels;
|
| 13 |
|
| 14 |
// Create bidirectional lookup map (both English->Swedish and Swedish->English)
|
| 15 |
const translationMap = new Map<string, string>();
|
|
|
|
| 231 |
return Array.from(categories).sort();
|
| 232 |
}
|
| 233 |
|
| 234 |
+
// Get label for equivalency score based on configured ranges
|
| 235 |
+
function getScoreLabel(scoreValue: number): string {
|
| 236 |
+
const match = equivalencyScoreLabels.find(
|
| 237 |
+
(range) => scoreValue >= range.min && scoreValue < range.max
|
| 238 |
+
);
|
| 239 |
+
// Handle edge case for max score (5.0)
|
| 240 |
+
if (!match && scoreValue >= 5.0) {
|
| 241 |
+
return equivalencyScoreLabels[equivalencyScoreLabels.length - 1].label;
|
| 242 |
+
}
|
| 243 |
+
return match?.label || "";
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
// Filter comparisons by selected category
|
| 247 |
function getFilteredComparisons(score: EquivalencyScore | null) {
|
| 248 |
if (!score || !score.comparisons) return [];
|
|
|
|
| 375 |
<div class="similarity-score">
|
| 376 |
<h3>Equivalency Score</h3>
|
| 377 |
<div class="score-display">
|
| 378 |
+
<span class="score-label">
|
| 379 |
+
{getScoreLabel(score.aggregated_similarity_score)}
|
| 380 |
+
<!-- Info icon with tooltip -->
|
| 381 |
+
<span class="info-tooltip">
|
| 382 |
+
<svg
|
| 383 |
+
class="info-icon"
|
| 384 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 385 |
+
width="16"
|
| 386 |
+
height="16"
|
| 387 |
+
viewBox="0 0 24 24"
|
| 388 |
+
fill="none"
|
| 389 |
+
stroke="currentColor"
|
| 390 |
+
stroke-width="2"
|
| 391 |
+
stroke-linecap="round"
|
| 392 |
+
stroke-linejoin="round"
|
| 393 |
+
>
|
| 394 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 395 |
+
<line x1="12" y1="16" x2="12" y2="12"></line>
|
| 396 |
+
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
| 397 |
+
</svg>
|
| 398 |
+
<span class="tooltip-content">
|
| 399 |
+
<strong>Score Legend (1 – 5)</strong>
|
| 400 |
+
{#each equivalencyScoreLabels as range}
|
| 401 |
+
<span class="tooltip-row">
|
| 402 |
+
<span class="tooltip-range"
|
| 403 |
+
>{range.min.toFixed(2)}–{range.max.toFixed(2)}</span
|
| 404 |
+
>
|
| 405 |
+
<span>{range.label}</span>
|
| 406 |
+
</span>
|
| 407 |
+
{/each}
|
| 408 |
+
</span>
|
| 409 |
+
</span>
|
| 410 |
+
</span>
|
| 411 |
<strong>{score.aggregated_similarity_score.toFixed(2)}</strong>
|
| 412 |
</div>
|
| 413 |
+
|
| 414 |
{#if score.comparative_law_note}
|
| 415 |
<div class="comparative-note">
|
| 416 |
<div class="markdown-content">
|
|
|
|
| 668 |
text-align: center;
|
| 669 |
}
|
| 670 |
|
| 671 |
+
.score-display .score-label {
|
| 672 |
+
display: block;
|
| 673 |
+
font-size: 1.1rem;
|
| 674 |
+
color: #555;
|
| 675 |
+
font-weight: 500;
|
| 676 |
+
margin-bottom: 0.25rem;
|
| 677 |
+
text-transform: uppercase;
|
| 678 |
+
letter-spacing: 0.05em;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
.score-display strong {
|
| 682 |
display: block;
|
| 683 |
font-size: 3rem;
|
|
|
|
| 685 |
font-weight: 600;
|
| 686 |
}
|
| 687 |
|
| 688 |
+
/* Info Tooltip Styles */
|
| 689 |
+
.info-tooltip {
|
| 690 |
+
position: relative;
|
| 691 |
+
display: inline-flex;
|
| 692 |
+
align-items: center;
|
| 693 |
+
margin-left: 0.35rem;
|
| 694 |
+
cursor: help;
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
.info-icon {
|
| 698 |
+
color: #888;
|
| 699 |
+
vertical-align: middle;
|
| 700 |
+
transition: color 0.2s;
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
.info-tooltip:hover .info-icon {
|
| 704 |
+
color: #646cff;
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
.tooltip-content {
|
| 708 |
+
display: none;
|
| 709 |
+
position: absolute;
|
| 710 |
+
bottom: calc(100% + 8px);
|
| 711 |
+
left: 50%;
|
| 712 |
+
transform: translateX(-50%);
|
| 713 |
+
background: #333;
|
| 714 |
+
color: white;
|
| 715 |
+
padding: 0.75rem 1rem;
|
| 716 |
+
border-radius: 6px;
|
| 717 |
+
font-size: 0.8rem;
|
| 718 |
+
white-space: nowrap;
|
| 719 |
+
z-index: 100;
|
| 720 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
| 721 |
+
text-transform: none;
|
| 722 |
+
letter-spacing: normal;
|
| 723 |
+
text-align: left;
|
| 724 |
+
}
|
| 725 |
+
|
| 726 |
+
.tooltip-content::after {
|
| 727 |
+
content: "";
|
| 728 |
+
position: absolute;
|
| 729 |
+
top: 100%;
|
| 730 |
+
left: 50%;
|
| 731 |
+
transform: translateX(-50%);
|
| 732 |
+
border: 6px solid transparent;
|
| 733 |
+
border-top-color: #333;
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
.info-tooltip:hover .tooltip-content {
|
| 737 |
+
display: block;
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
.tooltip-content strong {
|
| 741 |
+
display: block;
|
| 742 |
+
font-size: 0.85rem;
|
| 743 |
+
margin-bottom: 0.5rem;
|
| 744 |
+
color: #fff;
|
| 745 |
+
border-bottom: 1px solid #555;
|
| 746 |
+
padding-bottom: 0.4rem;
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
.tooltip-row {
|
| 750 |
+
display: flex;
|
| 751 |
+
gap: 0.75rem;
|
| 752 |
+
padding: 0.2rem 0;
|
| 753 |
+
font-weight: normal;
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
.tooltip-range {
|
| 757 |
+
font-family: monospace;
|
| 758 |
+
color: #a5a8ff;
|
| 759 |
+
min-width: 70px;
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
.comparative-note {
|
| 763 |
margin-top: 1.5rem;
|
| 764 |
padding-top: 1.5rem;
|
src/lib/config.ts
CHANGED
|
@@ -38,6 +38,16 @@ export const config = {
|
|
| 38 |
"ultimate facts": "rättsfakta",
|
| 39 |
"apparent authority": "ställningsfullmakt",
|
| 40 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
} as const;
|
| 42 |
|
| 43 |
// Helper to build dataset names
|
|
|
|
| 38 |
"ultimate facts": "rättsfakta",
|
| 39 |
"apparent authority": "ställningsfullmakt",
|
| 40 |
},
|
| 41 |
+
|
| 42 |
+
// Equivalency score labels based on score ranges
|
| 43 |
+
// Score is on a scale of 1-5
|
| 44 |
+
equivalencyScoreLabels: [
|
| 45 |
+
{ min: 1.0, max: 1.75, label: "Very Low Equivalency" },
|
| 46 |
+
{ min: 1.75, max: 2.5, label: "Low Equivalency" },
|
| 47 |
+
{ min: 2.5, max: 3.25, label: "Medium Equivalency" },
|
| 48 |
+
{ min: 3.25, max: 4.0, label: "High Equivalency" },
|
| 49 |
+
{ min: 4.0, max: 5.0, label: "Very High Equivalency" },
|
| 50 |
+
],
|
| 51 |
} as const;
|
| 52 |
|
| 53 |
// Helper to build dataset names
|