Skip to content

Commit 07bf13e

Browse files
committed
cache distribution to json (and functional approach)
1 parent d70cade commit 07bf13e

83 files changed

Lines changed: 893 additions & 875 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:24.3.0-bookworm-slim AS build
1+
FROM node:24.4.1-bookworm-slim AS build
22
COPY . .
33
RUN npm ci && npm run build
44

client/components.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ declare module 'vue' {
3232
GCard: typeof import('./src/components/GCard.vue')['default']
3333
GCheckBox: typeof import('./src/components/input/GCheckBox.vue')['default']
3434
GForm: typeof import('./src/components/input/GForm.vue')['default']
35-
GFormHorizontal: typeof import('./src/components/input/GFormHorizontal.vue')['default']
3635
GInfo: typeof import('./src/components/GInfo.vue')['default']
3736
GInput: typeof import('./src/components/input/GInput.vue')['default']
3837
GModal: typeof import('./src/components/modals/GModal.vue')['default']
39-
GNav: typeof import('./src/components/links/GNav.vue')['default']
4038
GNumber: typeof import('./src/components/input/GNumber.vue')['default']
4139
GSelect: typeof import('./src/components/input/GSelect.vue')['default']
4240
GSpinner: typeof import('./src/components/GSpinner.vue')['default']
@@ -62,8 +60,8 @@ declare module 'vue' {
6260
RouterView: typeof import('vue-router')['RouterView']
6361
SingleTermComparisonTable: typeof import('./src/components/tables/SingleTermComparisonTable.vue')['default']
6462
TagsetSelect: typeof import('./src/components/input/TagsetSelect.vue')['default']
63+
TypeTokenModal: typeof import('./src/components/modals/TypeTokenModal.vue')['default']
6564
UploadDocuments: typeof import('./src/components/input/UploadDocuments.vue')['default']
6665
UserList: typeof import('./src/components/modals/corpus/UserList.vue')['default']
67-
VariantsModal: typeof import('./src/components/modals/VariantsModal.vue')['default']
6866
}
6967
}

client/package-lock.json

Lines changed: 319 additions & 248 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@
99
"update": "npm-check-updates -u && npm install"
1010
},
1111
"dependencies": {
12-
"@primeuix/themes": "^1.2.1",
13-
"@vueuse/core": "^13.5.0",
14-
"@vueuse/router": "^13.5.0",
15-
"axios": "^1.10.0",
12+
"@primeuix/themes": "^1.2.2",
13+
"@vueuse/core": "^13.6.0",
14+
"@vueuse/router": "^13.6.0",
15+
"axios": "^1.11.0",
1616
"content-disposition": "^0.5.4",
1717
"pinia": "^3.0.3",
1818
"primevue": "^4.3.6",
1919
"safe-buffer": "^5.2.1",
20-
"vue": "^3.5.17",
20+
"vue": "^3.5.18",
2121
"vue-router": "^4.5.1"
2222
},
2323
"devDependencies": {
2424
"@rollup/plugin-yaml": "^4.1.2",
2525
"@tsconfig/node24": "^24.0.1",
2626
"@types/content-disposition": "^0.5.9",
27-
"@types/node": "^24.0.12",
28-
"@vitejs/plugin-vue": "^6.0.0",
27+
"@types/node": "^24.1.0",
28+
"@vitejs/plugin-vue": "^6.0.1",
2929
"@vue/eslint-config-prettier": "^10.2.0",
3030
"@vue/eslint-config-typescript": "^14.6.0",
3131
"@vue/tsconfig": "^0.7.0",
32-
"eslint": "^9.30.1",
32+
"eslint": "^9.32.0",
3333
"eslint-plugin-vue": "^10.3.0",
34-
"jiti": "^2.4.2",
35-
"npm-check-updates": "^18.0.1",
34+
"jiti": "^2.5.1",
35+
"npm-check-updates": "^18.0.2",
3636
"prettier": "^3.6.2",
3737
"sass-embedded": "^1.89.2",
3838
"typescript": "~5.8.3",
3939
"unplugin-auto-import": "^19.3.0",
4040
"unplugin-vue-components": "^28.8.0",
41-
"vite": "^7.0.3",
41+
"vite": "^7.0.6",
4242
"vite-plugin-node-polyfills": "^0.24.0",
43-
"vite-plugin-vue-devtools": "^7.7.7"
43+
"vite-plugin-vue-devtools": "^8.0.0"
4444
}
4545
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<GModal @hide="$emit('hide')">
3+
<GTable :columns :items sortColumn="count">
4+
<template #title>
5+
Types of lemma <i>{{ typeToken?.lemma }}</i> and group <i>{{ typeToken?.group }}</i>
6+
</template>
7+
8+
<template #help>
9+
This is an overview of all types belonging to the chosen lemma &mdash; grouped annotation pair.
10+
</template>
11+
</GTable>
12+
</GModal>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import type { TypeToken } from "@/types/evaluation/distribution"
17+
import type { Column } from "@/types/ui/table"
18+
19+
const { typeToken } = defineProps<{ typeToken: TypeToken }>()
20+
21+
const columns: Column<TypeToken>[] = [{ key: "type" }, { key: "count" }]
22+
const items = computed(() => Object.entries(typeToken.tokens).map(([type, count]) => ({ type, count })))
23+
</script>

client/src/components/modals/VariantsModal.vue

Lines changed: 0 additions & 37 deletions
This file was deleted.

client/src/stores/evaluation/distribution.ts

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
// Libraries & stores
2-
3-
import * as API from "@/api/evaluation"
41
import { distributionPath } from "@/api/evaluation"
52
import { useAxios } from "@/api/useAxios"
63
import stores from "@/stores"
7-
import * as Utils from "@/stores/evaluation/utils"
8-
// API & types
9-
// API & types
10-
import type { UUID } from "@/types/corpora"
11-
import type { DistributionWrapper } from "@/types/evaluation"
4+
import type { TypeToken, Distribution } from "@/types/evaluation/distribution"
125
import type { SelectOption } from "@/types/ui/select"
136

14-
// Allows for Object.keys(distribution.table), which dislikes null.
15-
const defaultDistribution = () => ({ distribution: {} }) as DistributionWrapper
16-
17-
/**
18-
* Stores and fetches the term frequency distribution.
19-
*/
7+
/** Stores and fetches the term frequency distribution. */
208
const useDistribution = defineStore("distribution", () => {
219
// Fields
2210
const { hypothesisId } = storeToRefs(stores.useJobSelection())
@@ -26,30 +14,14 @@ const useDistribution = defineStore("distribution", () => {
2614
return distributionPath(corpusId.value)
2715
})
2816

29-
const { loading, data: distributions } = useAxios<Record<string, DistributionWrapper>>(
30-
url,
31-
{},
32-
{ hypothesis: hypothesisId.value },
33-
)
17+
const { loading, data: distributions } = useAxios<Record<string, Distribution>>(url, undefined, {
18+
hypothesis: hypothesisId.value,
19+
})
3420

35-
const distribution = computed(() => distributions.value?.[selectedDistribution.value] ?? defaultDistribution())
21+
const distribution = computed<TypeToken[]>(() => distributions.value?.[selectedDistribution.value])
3622
const selectedDistribution = ref<string>()
37-
const distributionOptions = computed<SelectOption[]>(
38-
() => {
39-
if (!distributions.value) {
40-
return []
41-
}
42-
return Object.keys(distributions.value).map((x) => ({ value: x, text: x }))
43-
},
44-
{ immediate: true },
45-
)
46-
const posses = computed(() => {
47-
// A bit hacky using Object.entries, but .map throws on undefined.
48-
return Object.entries(distribution.value?.distribution)
49-
?.map((x) => x[1].pos)
50-
.filter((val, ind, arr) => arr.indexOf(val) === ind) // unique values
51-
.sort()
52-
})
23+
const distributionOptions = computed<SelectOption[]>(() => Object.keys(distributions.value || {}).map((x) => ({ value: x, text: x })))
24+
const posses = computed<string[]>(() => [...new Set(Object.values(distribution.value || {}).map((t: TypeToken) => t.group))].sort())
5325
// Exports
5426
return {
5527
// Fields

client/src/types/evaluation.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@ export type ConfusionWrapper = {
77
referenceLastModified: number
88
}
99

10-
// Distribution
11-
export type DistributionWrapper = {
12-
corpus_uuid: string
13-
coveredAlphabeticChars: number
14-
coveredChars: number
15-
distribution: Distribution[]
16-
generated: number
17-
hypothesis: string
18-
modified: number
19-
totalAlphabeticChars: number
20-
totalChars: number
21-
trimmed: boolean
22-
}
23-
24-
export type Distribution = { lemma: string; pos: string; count: number; literals: { [literal: string]: number } }
25-
2610
// Metrics
2711
export type Metrics = {
2812
global: MetricsRow
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type Distribution = Record<string, TypeToken[]>
2+
export type TypeToken = { lemma: string; group: string; count: number; tokens: Record<string, number> }

0 commit comments

Comments
 (0)