Spaces:
Running
Running
Tobias Brugger
commited on
Commit
·
902e217
1
Parent(s):
694d55c
add config to handle variables
Browse files- src/lib/DatasetViewer.svelte +10 -37
- src/lib/config.ts +48 -0
src/lib/DatasetViewer.svelte
CHANGED
|
@@ -2,40 +2,13 @@
|
|
| 2 |
import { fetchAllRows } from "./huggingfaceApi";
|
| 3 |
import type { TermDefinition, EquivalencyScore } from "./types";
|
| 4 |
import { marked } from "marked";
|
|
|
|
| 5 |
|
| 6 |
-
//
|
| 7 |
-
const availableJurisdictions =
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
// Hardcoded configuration
|
| 13 |
-
const dataset = import.meta.env.VITE_HUGGINGFACE_ORG + "/structured-answers";
|
| 14 |
-
const scoresDataset =
|
| 15 |
-
import.meta.env.VITE_HUGGINGFACE_ORG + "/equivalency-scores";
|
| 16 |
-
|
| 17 |
-
// Direct translations dictionary (English -> Swedish)
|
| 18 |
-
const directTranslations: Record<string, string> = {
|
| 19 |
-
"proximate cause": "adekvat kausalitet",
|
| 20 |
-
"articles of association": "bolagsordning",
|
| 21 |
-
bylaws: "bolagsordning",
|
| 22 |
-
condominium: "bostadrätt",
|
| 23 |
-
"cooperative apartment": "bostadrätt",
|
| 24 |
-
"company name": "firma",
|
| 25 |
-
company: "firma",
|
| 26 |
-
"dispose of": "förfoga över",
|
| 27 |
-
"rights of first refusal": "hembud",
|
| 28 |
-
"implied consent": "konkludent handlande",
|
| 29 |
-
"aiding and abetting": "medverkande",
|
| 30 |
-
"trading prohibition": "näringsförbud",
|
| 31 |
-
"affiliated company": "närstående bolag",
|
| 32 |
-
molestation: "ofredande",
|
| 33 |
-
"dismiss on the merits": "ogilla",
|
| 34 |
-
"the rule of contra proferentem": "oklarhetsregeln",
|
| 35 |
-
"joinder of parties": "processgemenskap",
|
| 36 |
-
"ultimate facts": "rättsfakta",
|
| 37 |
-
"apparent authority": "ställningsfullmakt",
|
| 38 |
-
};
|
| 39 |
|
| 40 |
// Create bidirectional lookup map (both English->Swedish and Swedish->English)
|
| 41 |
const translationMap = new Map<string, string>();
|
|
@@ -45,8 +18,8 @@
|
|
| 45 |
});
|
| 46 |
|
| 47 |
// Form inputs
|
| 48 |
-
let jurisdiction1 = $state(
|
| 49 |
-
let jurisdiction2 = $state(
|
| 50 |
|
| 51 |
// Data state
|
| 52 |
let data1 = $state<TermDefinition[]>([]);
|
|
@@ -62,8 +35,8 @@
|
|
| 62 |
let selectedCategory = $state<string>("All");
|
| 63 |
|
| 64 |
// Track previous values to detect changes
|
| 65 |
-
let prevJurisdiction1 = $state(
|
| 66 |
-
let prevJurisdiction2 = $state(
|
| 67 |
|
| 68 |
// Reload when jurisdictions change (but not on initial mount)
|
| 69 |
$effect(() => {
|
|
|
|
| 2 |
import { fetchAllRows } from "./huggingfaceApi";
|
| 3 |
import type { TermDefinition, EquivalencyScore } from "./types";
|
| 4 |
import { marked } from "marked";
|
| 5 |
+
import { config, getDatasetName } from "./config";
|
| 6 |
|
| 7 |
+
// Configuration from centralized config
|
| 8 |
+
const availableJurisdictions = config.jurisdictions;
|
| 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>();
|
|
|
|
| 18 |
});
|
| 19 |
|
| 20 |
// Form inputs
|
| 21 |
+
let jurisdiction1 = $state<string>(config.defaults.jurisdiction1);
|
| 22 |
+
let jurisdiction2 = $state<string>(config.defaults.jurisdiction2);
|
| 23 |
|
| 24 |
// Data state
|
| 25 |
let data1 = $state<TermDefinition[]>([]);
|
|
|
|
| 35 |
let selectedCategory = $state<string>("All");
|
| 36 |
|
| 37 |
// Track previous values to detect changes
|
| 38 |
+
let prevJurisdiction1 = $state<string>(config.defaults.jurisdiction1);
|
| 39 |
+
let prevJurisdiction2 = $state<string>(config.defaults.jurisdiction2);
|
| 40 |
|
| 41 |
// Reload when jurisdictions change (but not on initial mount)
|
| 42 |
$effect(() => {
|
src/lib/config.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Application configuration
|
| 2 |
+
export const config = {
|
| 3 |
+
api: {
|
| 4 |
+
huggingfaceOrg: import.meta.env.VITE_HUGGINGFACE_ORG || "",
|
| 5 |
+
structuredAnswersDataset: "structured-answers",
|
| 6 |
+
equivalencyScoresDataset: "equivalency-scores",
|
| 7 |
+
},
|
| 8 |
+
|
| 9 |
+
jurisdictions: [
|
| 10 |
+
{ code: "en-us", label: "English (US)" },
|
| 11 |
+
{ code: "sv-se", label: "Swedish (SE)" },
|
| 12 |
+
],
|
| 13 |
+
|
| 14 |
+
defaults: {
|
| 15 |
+
jurisdiction1: "en-us",
|
| 16 |
+
jurisdiction2: "sv-se",
|
| 17 |
+
},
|
| 18 |
+
|
| 19 |
+
// Direct translations dictionary (English -> Swedish)
|
| 20 |
+
directTranslations: {
|
| 21 |
+
"proximate cause": "adekvat kausalitet",
|
| 22 |
+
"articles of association": "bolagsordning",
|
| 23 |
+
bylaws: "bolagsordning",
|
| 24 |
+
condominium: "bostadrätt",
|
| 25 |
+
"cooperative apartment": "bostadrätt",
|
| 26 |
+
"company name": "firma",
|
| 27 |
+
company: "firma",
|
| 28 |
+
"dispose of": "förfoga över",
|
| 29 |
+
"rights of first refusal": "hembud",
|
| 30 |
+
"implied consent": "konkludent handlande",
|
| 31 |
+
"aiding and abetting": "medverkande",
|
| 32 |
+
"trading prohibition": "näringsförbud",
|
| 33 |
+
"affiliated company": "närstående bolag",
|
| 34 |
+
molestation: "ofredande",
|
| 35 |
+
"dismiss on the merits": "ogilla",
|
| 36 |
+
"the rule of contra proferentem": "oklarhetsregeln",
|
| 37 |
+
"joinder of parties": "processgemenskap",
|
| 38 |
+
"ultimate facts": "rättsfakta",
|
| 39 |
+
"apparent authority": "ställningsfullmakt",
|
| 40 |
+
},
|
| 41 |
+
} as const;
|
| 42 |
+
|
| 43 |
+
// Helper to build dataset names
|
| 44 |
+
export function getDatasetName(
|
| 45 |
+
datasetType: "structured-answers" | "equivalency-scores"
|
| 46 |
+
): string {
|
| 47 |
+
return `${config.api.huggingfaceOrg}/${datasetType}`;
|
| 48 |
+
}
|