Skip to content

Commit dc6eee1

Browse files
committed
Whole stats series
1 parent 49dbbc2 commit dc6eee1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

app/scripts/components/wordpicture/word-picture-column.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ angular.module("korpApp").component("wordPictureColumn", {
6868
if (changes.limit?.currentValue || changes.items?.currentValue || changes.segment?.currentValue) {
6969
$ctrl.rows = $ctrl.items
7070
.filter((item) => item.stats[$ctrl.segment])
71-
.sort((a, b) => b.stats[$ctrl.segment][$ctrl.sort] - a.stats[$ctrl.segment][$ctrl.sort])
71+
.sort((a, b) => b.stats[$ctrl.segment]![$ctrl.sort] - a.stats[$ctrl.segment]![$ctrl.sort])
7272
.slice(0, Number($ctrl.limit))
7373
}
7474
}
@@ -93,7 +93,7 @@ angular.module("korpApp").component("wordPictureColumn", {
9393
}
9494

9595
$ctrl.onClickExample = function (row) {
96-
$rootScope.kwicTabs.push(new WordpicExampleTask(row.stats[$ctrl.segment].source.join(",")))
96+
$rootScope.kwicTabs.push(new WordpicExampleTask(row.stats[$ctrl.segment]!.source.join(",")))
9797
}
9898
},
9999
],

app/scripts/word-picture.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { isEqual, once, pick } from "lodash"
22
import { Relation } from "./backend/types/relations"
33
import { getWordPictureConfig } from "./settings"
44
import { WordPictureDef, WordPictureDefItem } from "./settings/app-settings.types"
5+
import { fromKeys } from "./util"
56

67
export type WordType = "word" | "lemgram"
78

@@ -44,7 +45,8 @@ export type MatchedRelation = {
4445
otherpos: string
4546
/** Copy of `depextra` if the search word matches `head` – a preposition or other string to show together with the related word */
4647
prefix?: string
47-
stats: Record<string, RelationStat>
48+
/** Measurements and sources for all segments */
49+
stats: Record<string, RelationStat | null>
4850
}
4951

5052
export type RelationStat = Pick<Relation, "freq" | "mi" | "source">
@@ -64,7 +66,10 @@ export class WordPicture {
6466
const { head, headpos, dep, deppos, depextra } = item
6567
const base = {
6668
rel: item.rel,
67-
stats: { [bin]: pick(item, ["freq", "mi", "source"]) },
69+
// Copy item stats to this segment slot, fill rest of series with null.
70+
stats: fromKeys(this.segments, (segment) =>
71+
segment == bin ? pick(item, ["freq", "mi", "source"]) : null,
72+
),
6873
}
6974
// For ordinary word search, include multi-word items beginning with the searched word
7075
const getMatch = (word: string) => (type == "word" ? word.replace(/_.*/, "") : word)
@@ -84,7 +89,6 @@ export class WordPicture {
8489
}
8590

8691
const isItemEqual = (a: MatchedRelation, b: MatchedRelation): boolean => {
87-
// TODO Check correct?
8892
return (
8993
a.rel == b.rel &&
9094
a.other == b.other &&

0 commit comments

Comments
 (0)