tycho-components 0.28.7 → 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/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';
|