Spaces:
Running
Running
Tobias Brugger
commited on
Commit
·
337d881
1
Parent(s):
ffdd6af
add comparison to interface
Browse files- src/lib/DatasetViewer.svelte +121 -2
- src/lib/types.ts +12 -0
src/lib/DatasetViewer.svelte
CHANGED
|
@@ -10,8 +10,8 @@
|
|
| 10 |
];
|
| 11 |
|
| 12 |
// Hardcoded configuration
|
| 13 |
-
const dataset = import.meta.env.
|
| 14 |
-
const scoresDataset = import.meta.env.
|
| 15 |
|
| 16 |
// Direct translations dictionary (English -> Swedish)
|
| 17 |
const directTranslations: Record<string, string> = {
|
|
@@ -293,6 +293,34 @@
|
|
| 293 |
</div>
|
| 294 |
</div>
|
| 295 |
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
</div>
|
| 297 |
{:else}
|
| 298 |
<div class="similarity-score no-score">
|
|
@@ -582,4 +610,95 @@
|
|
| 582 |
color: #666;
|
| 583 |
font-style: italic;
|
| 584 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
</style>
|
|
|
|
| 10 |
];
|
| 11 |
|
| 12 |
// Hardcoded configuration
|
| 13 |
+
const dataset = import.meta.env.VITE_HUGGINGFACE_ORG + '/structured-answers';
|
| 14 |
+
const scoresDataset = import.meta.env.VITE_HUGGINGFACE_ORG + '/equivalency-scores';
|
| 15 |
|
| 16 |
// Direct translations dictionary (English -> Swedish)
|
| 17 |
const directTranslations: Record<string, string> = {
|
|
|
|
| 293 |
</div>
|
| 294 |
</div>
|
| 295 |
{/if}
|
| 296 |
+
|
| 297 |
+
{#if score.comparisons && score.comparisons.length > 0}
|
| 298 |
+
<div class="comparisons-section">
|
| 299 |
+
<h4>Detailed Comparisons</h4>
|
| 300 |
+
<div class="comparisons-list">
|
| 301 |
+
{#each score.comparisons as comparison}
|
| 302 |
+
<div class="comparison-item">
|
| 303 |
+
<div class="comparison-header">
|
| 304 |
+
<span class="comparison-category">{comparison.category}</span>
|
| 305 |
+
{#if comparison.subcategory}
|
| 306 |
+
<span class="comparison-subcategory"> › {comparison.subcategory}</span>
|
| 307 |
+
{/if}
|
| 308 |
+
<span class="comparison-score">{comparison.similarity_score.toFixed(2)}</span>
|
| 309 |
+
</div>
|
| 310 |
+
<div class="comparison-meta">
|
| 311 |
+
<span class="comparison-weight">Weight: {comparison.weight.toFixed(2)}</span>
|
| 312 |
+
<span class="comparison-weighted-score">Weighted Score: {comparison.weighted_similarity_score.toFixed(2)}</span>
|
| 313 |
+
</div>
|
| 314 |
+
{#if comparison.reasoning}
|
| 315 |
+
<div class="comparison-reasoning">
|
| 316 |
+
<strong>Reasoning:</strong> {comparison.reasoning}
|
| 317 |
+
</div>
|
| 318 |
+
{/if}
|
| 319 |
+
</div>
|
| 320 |
+
{/each}
|
| 321 |
+
</div>
|
| 322 |
+
</div>
|
| 323 |
+
{/if}
|
| 324 |
</div>
|
| 325 |
{:else}
|
| 326 |
<div class="similarity-score no-score">
|
|
|
|
| 610 |
color: #666;
|
| 611 |
font-style: italic;
|
| 612 |
}
|
| 613 |
+
|
| 614 |
+
/* Comparisons section styling */
|
| 615 |
+
.comparisons-section {
|
| 616 |
+
margin-top: 1.5rem;
|
| 617 |
+
padding-top: 1.5rem;
|
| 618 |
+
border-top: 1px solid #e0e0e0;
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
.comparisons-section h4 {
|
| 622 |
+
margin: 0 0 1rem 0;
|
| 623 |
+
color: #555;
|
| 624 |
+
font-size: 1rem;
|
| 625 |
+
font-weight: 600;
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
.comparisons-list {
|
| 629 |
+
display: flex;
|
| 630 |
+
flex-direction: column;
|
| 631 |
+
gap: 1rem;
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
.comparison-item {
|
| 635 |
+
background: #f9f9f9;
|
| 636 |
+
border: 1px solid #e0e0e0;
|
| 637 |
+
border-radius: 6px;
|
| 638 |
+
padding: 1rem;
|
| 639 |
+
transition: box-shadow 0.2s;
|
| 640 |
+
}
|
| 641 |
+
|
| 642 |
+
.comparison-item:hover {
|
| 643 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
.comparison-header {
|
| 647 |
+
display: flex;
|
| 648 |
+
align-items: center;
|
| 649 |
+
gap: 0.5rem;
|
| 650 |
+
margin-bottom: 0.5rem;
|
| 651 |
+
flex-wrap: wrap;
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
.comparison-category {
|
| 655 |
+
font-weight: 600;
|
| 656 |
+
color: #646cff;
|
| 657 |
+
font-size: 0.95rem;
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
.comparison-subcategory {
|
| 661 |
+
color: #666;
|
| 662 |
+
font-size: 0.9rem;
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
.comparison-score {
|
| 666 |
+
margin-left: auto;
|
| 667 |
+
background: #646cff;
|
| 668 |
+
color: white;
|
| 669 |
+
padding: 0.25rem 0.75rem;
|
| 670 |
+
border-radius: 12px;
|
| 671 |
+
font-weight: 600;
|
| 672 |
+
font-size: 0.9rem;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
.comparison-meta {
|
| 676 |
+
display: flex;
|
| 677 |
+
gap: 1rem;
|
| 678 |
+
margin-bottom: 0.5rem;
|
| 679 |
+
font-size: 0.85rem;
|
| 680 |
+
color: #666;
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
.comparison-weight,
|
| 684 |
+
.comparison-weighted-score {
|
| 685 |
+
background: #f0f0f0;
|
| 686 |
+
padding: 0.25rem 0.5rem;
|
| 687 |
+
border-radius: 4px;
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
.comparison-reasoning {
|
| 691 |
+
margin-top: 0.5rem;
|
| 692 |
+
padding: 0.75rem;
|
| 693 |
+
background: white;
|
| 694 |
+
border-left: 3px solid #646cff;
|
| 695 |
+
border-radius: 4px;
|
| 696 |
+
font-size: 0.9rem;
|
| 697 |
+
line-height: 1.5;
|
| 698 |
+
color: #444;
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
.comparison-reasoning strong {
|
| 702 |
+
color: #333;
|
| 703 |
+
}
|
| 704 |
</style>
|
src/lib/types.ts
CHANGED
|
@@ -79,9 +79,21 @@ export interface ComparisonState {
|
|
| 79 |
selectedTerm2: string | null;
|
| 80 |
}
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
export interface EquivalencyScore {
|
| 83 |
term_j1: string;
|
| 84 |
term_j2: string;
|
| 85 |
aggregated_similarity_score: number;
|
| 86 |
comparative_law_note: string;
|
|
|
|
| 87 |
}
|
|
|
|
| 79 |
selectedTerm2: string | null;
|
| 80 |
}
|
| 81 |
|
| 82 |
+
export interface Comparison {
|
| 83 |
+
term_j1: string;
|
| 84 |
+
term_j2: string;
|
| 85 |
+
category: string;
|
| 86 |
+
subcategory: string;
|
| 87 |
+
similarity_score: number;
|
| 88 |
+
reasoning: string;
|
| 89 |
+
weight: number;
|
| 90 |
+
weighted_similarity_score: number;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
export interface EquivalencyScore {
|
| 94 |
term_j1: string;
|
| 95 |
term_j2: string;
|
| 96 |
aggregated_similarity_score: number;
|
| 97 |
comparative_law_note: string;
|
| 98 |
+
comparisons?: Comparison[];
|
| 99 |
}
|