tycho-components 0.28.6 → 0.28.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/localization/TreeTexts.d.ts +3 -0
- package/dist/configs/localization/TreeTexts.js +3 -0
- package/dist/features/TreeView/TreeView.js +3 -1
- package/dist/features/TreeView/cytoscape/CytoscapeTreeConverter.d.ts +6 -1
- package/dist/features/TreeView/cytoscape/CytoscapeTreeConverter.js +20 -10
- package/dist/features/TreeView/style.scss +5 -0
- package/dist/features/index.d.ts +1 -0
- package/dist/functions/EditionTierUtils.d.ts +1 -0
- package/dist/functions/EditionTierUtils.js +22 -7
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ export declare const TreeTexts: {
|
|
|
10
10
|
'button.search': string;
|
|
11
11
|
'label.syntactic.category': string;
|
|
12
12
|
'label.pos.tag': string;
|
|
13
|
+
'label.token.addTag': string;
|
|
13
14
|
'label.empty.category': string;
|
|
14
15
|
'label.word.value': string;
|
|
15
16
|
};
|
|
@@ -24,6 +25,7 @@ export declare const TreeTexts: {
|
|
|
24
25
|
'button.search': string;
|
|
25
26
|
'label.syntactic.category': string;
|
|
26
27
|
'label.pos.tag': string;
|
|
28
|
+
'label.token.addTag': string;
|
|
27
29
|
'label.empty.category': string;
|
|
28
30
|
'label.word.value': string;
|
|
29
31
|
};
|
|
@@ -37,6 +39,7 @@ export declare const TreeTexts: {
|
|
|
37
39
|
'button.search': string;
|
|
38
40
|
'label.syntactic.category': string;
|
|
39
41
|
'label.pos.tag': string;
|
|
42
|
+
'label.token.addTag': string;
|
|
40
43
|
'label.empty.category': string;
|
|
41
44
|
'label.word.value': string;
|
|
42
45
|
};
|
|
@@ -10,6 +10,7 @@ export const TreeTexts = {
|
|
|
10
10
|
'button.search': 'Search',
|
|
11
11
|
'label.syntactic.category': 'Syntactic Category',
|
|
12
12
|
'label.pos.tag': 'POS Tag',
|
|
13
|
+
'label.token.addTag': 'add tag',
|
|
13
14
|
'label.empty.category': 'Empty Category',
|
|
14
15
|
'label.word.value': 'Word',
|
|
15
16
|
},
|
|
@@ -24,6 +25,7 @@ export const TreeTexts = {
|
|
|
24
25
|
'button.search': 'Buscar',
|
|
25
26
|
'label.syntactic.category': 'Categoria Sintática',
|
|
26
27
|
'label.pos.tag': 'Etiqueta POS',
|
|
28
|
+
'label.token.addTag': 'adicionar etiqueta',
|
|
27
29
|
'label.empty.category': 'Categoria Vazia',
|
|
28
30
|
'label.word.value': 'Palavra',
|
|
29
31
|
},
|
|
@@ -37,6 +39,7 @@ export const TreeTexts = {
|
|
|
37
39
|
'button.search': 'Cerca',
|
|
38
40
|
'label.syntactic.category': 'Categoria Sintattica',
|
|
39
41
|
'label.pos.tag': 'Etichetta POS',
|
|
42
|
+
'label.token.addTag': 'aggiungi etichetta',
|
|
40
43
|
'label.empty.category': 'Categoria Vuota',
|
|
41
44
|
'label.word.value': 'Parola',
|
|
42
45
|
},
|
|
@@ -32,7 +32,9 @@ export default function TreeView({ struct, expression, selector = "canvas-tree",
|
|
|
32
32
|
return;
|
|
33
33
|
let tree;
|
|
34
34
|
try {
|
|
35
|
-
tree = new CytoscapeTreeConverter().execute(struct, showInfo
|
|
35
|
+
tree = new CytoscapeTreeConverter().execute(struct, showInfo, {
|
|
36
|
+
missingPosTagLabel: t('label.token.addTag'),
|
|
37
|
+
});
|
|
36
38
|
}
|
|
37
39
|
catch (e) {
|
|
38
40
|
setInvalid(true);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Struct, Token } from '../../../configs/types/Struct';
|
|
2
2
|
import { CytoscapeTreeCalculation } from './NodeCalculation';
|
|
3
|
+
export type CytoscapeTreeConverterOptions = {
|
|
4
|
+
missingPosTagLabel?: string;
|
|
5
|
+
};
|
|
3
6
|
export default class CytoscapeTreeConverter {
|
|
4
7
|
private ID_SPLITTER;
|
|
5
8
|
private extraInfo;
|
|
6
|
-
|
|
9
|
+
private missingPosTagLabel;
|
|
10
|
+
static formatPosTagLabel(token: Pick<Token, 't' | 'coidx'>, missingPosTagLabel?: string): string;
|
|
11
|
+
execute(struct: Struct, extraInfo: boolean, options?: CytoscapeTreeConverterOptions): CytoscapeTreeCalculation | undefined;
|
|
7
12
|
getLabelLeaf(token: Token): string;
|
|
8
13
|
private splitAttributeValue;
|
|
9
14
|
private validate;
|
|
@@ -4,10 +4,25 @@ export default class CytoscapeTreeConverter {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
this.ID_SPLITTER = '|';
|
|
6
6
|
this.extraInfo = false;
|
|
7
|
+
this.missingPosTagLabel = '';
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
static formatPosTagLabel(token, missingPosTagLabel = '') {
|
|
10
|
+
const tag = token.t?.trim();
|
|
11
|
+
const base = tag
|
|
12
|
+
? tag
|
|
13
|
+
: `<span class="token-tag-missing">${missingPosTagLabel}</span>`;
|
|
14
|
+
let idxLabel = '';
|
|
15
|
+
if (token.coidx) {
|
|
16
|
+
for (const idx of token.coidx) {
|
|
17
|
+
idxLabel += `-${idx.toString()}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return base + idxLabel;
|
|
21
|
+
}
|
|
22
|
+
execute(struct, extraInfo, options) {
|
|
9
23
|
if (!this.validate(struct))
|
|
10
24
|
return undefined;
|
|
25
|
+
this.missingPosTagLabel = options?.missingPosTagLabel ?? '';
|
|
11
26
|
const tree = this.initTree(struct);
|
|
12
27
|
this.extraInfo = extraInfo;
|
|
13
28
|
this.inflate(tree, struct);
|
|
@@ -47,12 +62,7 @@ export default class CytoscapeTreeConverter {
|
|
|
47
62
|
if (!struct.tokens || struct.tokens.length === 0) {
|
|
48
63
|
return false;
|
|
49
64
|
}
|
|
50
|
-
return
|
|
51
|
-
if (token.ec) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return token.t !== undefined && token.t.trim() !== '';
|
|
55
|
-
});
|
|
65
|
+
return true;
|
|
56
66
|
}
|
|
57
67
|
calculatePositions(cytoscape) {
|
|
58
68
|
const converter = new CytoscapePositionCalculator();
|
|
@@ -220,8 +230,8 @@ export default class CytoscapeTreeConverter {
|
|
|
220
230
|
sb.push('-');
|
|
221
231
|
sb.push(`${token.idx}`);
|
|
222
232
|
}
|
|
223
|
-
|
|
224
|
-
|
|
233
|
+
sb.push('+');
|
|
234
|
+
if (token.t?.trim()) {
|
|
225
235
|
sb.push(token.t);
|
|
226
236
|
}
|
|
227
237
|
return sb.join('');
|
|
@@ -322,7 +332,7 @@ export default class CytoscapeTreeConverter {
|
|
|
322
332
|
id,
|
|
323
333
|
data: {
|
|
324
334
|
id,
|
|
325
|
-
label:
|
|
335
|
+
label: CytoscapeTreeConverter.formatPosTagLabel(token, this.missingPosTagLabel),
|
|
326
336
|
token: JSON.parse(JSON.stringify(token)),
|
|
327
337
|
},
|
|
328
338
|
};
|
package/dist/features/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { EMPTY_PARTICIPANT, } from './Participants/types/Participant';
|
|
|
9
9
|
export { default as SentenceView } from './SentenceView';
|
|
10
10
|
export { default as TreeView } from './TreeView';
|
|
11
11
|
export { default as CytoscapeTreeConverter } from './TreeView/cytoscape/CytoscapeTreeConverter';
|
|
12
|
+
export type { CytoscapeTreeConverterOptions } from './TreeView/cytoscape/CytoscapeTreeConverter';
|
|
12
13
|
export { default as SyntreesCytoscape } from './TreeView/cytoscape/SyntreesCytoscape';
|
|
13
14
|
export { default as TreeViewSearch } from './TreeView/TreeViewSearch/TreeViewSearch';
|
|
14
15
|
export type { SearchCriteria } from './TreeView/TreeViewSearch/TreeViewSearch';
|
|
@@ -8,6 +8,7 @@ declare const EditionTierUtils: {
|
|
|
8
8
|
getAbbreviationTiers: (corpus?: Corpus | null) => string[];
|
|
9
9
|
getParserTier: (corpus?: Corpus | null) => EditionTierDefinition | undefined;
|
|
10
10
|
getEditionTierName: (symbol: string) => string;
|
|
11
|
+
getTierLabelKey: (symbol: string) => string;
|
|
11
12
|
getTierLabel: (symbol: string, corpus?: Corpus | null, t?: (key: string) => string) => string;
|
|
12
13
|
isUnderSelected: (selected: string, tier: string, corpus?: Corpus | null) => boolean;
|
|
13
14
|
buildEditionGroups: (corpus?: Corpus | null) => EditionGroup[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_EDITION_TIERS, EditionTiers, StructuralEditionTiers, isStructuralEditionTier, } from '../configs/types/EditionTiers';
|
|
2
2
|
const DEFAULT_SYMBOLS = new Set(DEFAULT_EDITION_TIERS.map((tier) => tier.symbol));
|
|
3
|
+
const isDefaultTierSymbol = (symbol) => DEFAULT_SYMBOLS.has(symbol);
|
|
3
4
|
const getCorpusEditionTiers = (corpus) => {
|
|
4
5
|
if (!corpus?.editionTiers?.length) {
|
|
5
6
|
return DEFAULT_EDITION_TIERS.map((tier) => ({ ...tier }));
|
|
@@ -19,16 +20,30 @@ const getEditionTierName = (symbol) => {
|
|
|
19
20
|
const entry = Object.entries(EditionTiers).find(([, value]) => value === symbol);
|
|
20
21
|
return entry?.[0] || symbol;
|
|
21
22
|
};
|
|
23
|
+
const getTierLabelKey = (symbol) => {
|
|
24
|
+
const key = getEditionTierName(symbol).toLowerCase();
|
|
25
|
+
return `sentence:label.tier.${key}`;
|
|
26
|
+
};
|
|
27
|
+
const usesI18nLabel = (symbol) => isDefaultTierSymbol(symbol) || isStructuralEditionTier(symbol);
|
|
28
|
+
const getStaticFallbackLabel = (symbol) => {
|
|
29
|
+
const defaultDef = DEFAULT_EDITION_TIERS.find((tier) => tier.symbol === symbol);
|
|
30
|
+
if (defaultDef?.label) {
|
|
31
|
+
return defaultDef.label;
|
|
32
|
+
}
|
|
33
|
+
return getEditionTierName(symbol).toLowerCase();
|
|
34
|
+
};
|
|
22
35
|
const getTierLabel = (symbol, corpus, t) => {
|
|
36
|
+
if (usesI18nLabel(symbol)) {
|
|
37
|
+
if (t) {
|
|
38
|
+
return t(getTierLabelKey(symbol));
|
|
39
|
+
}
|
|
40
|
+
return getStaticFallbackLabel(symbol);
|
|
41
|
+
}
|
|
23
42
|
const definition = getCorpusEditionTiers(corpus).find((tier) => tier.symbol === symbol);
|
|
24
|
-
if (definition?.label) {
|
|
43
|
+
if (definition?.label?.trim()) {
|
|
25
44
|
return definition.label;
|
|
26
45
|
}
|
|
27
|
-
|
|
28
|
-
if (t) {
|
|
29
|
-
return t(`sentence:label.tier.${key}`);
|
|
30
|
-
}
|
|
31
|
-
return key;
|
|
46
|
+
return symbol;
|
|
32
47
|
};
|
|
33
48
|
const isUnderSelected = (selected, tier, corpus) => {
|
|
34
49
|
const tiers = getIterateTiers(corpus);
|
|
@@ -97,7 +112,6 @@ const validateEditionTiers = (tiers) => {
|
|
|
97
112
|
}
|
|
98
113
|
return null;
|
|
99
114
|
};
|
|
100
|
-
const isDefaultTierSymbol = (symbol) => DEFAULT_SYMBOLS.has(symbol);
|
|
101
115
|
const getEditionForToken = (token) => {
|
|
102
116
|
if (token.eid)
|
|
103
117
|
return token.edition;
|
|
@@ -122,6 +136,7 @@ const EditionTierUtils = {
|
|
|
122
136
|
getAbbreviationTiers,
|
|
123
137
|
getParserTier,
|
|
124
138
|
getEditionTierName,
|
|
139
|
+
getTierLabelKey,
|
|
125
140
|
getTierLabel,
|
|
126
141
|
isUnderSelected,
|
|
127
142
|
buildEditionGroups,
|