tycho-components 0.2.6-SNAPSHOT-3 → 0.2.6-SNAPSHOT-5

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.
@@ -82,7 +82,9 @@ export default function TreeView({ struct, expression, selector = 'canvas-tree',
82
82
  struct.tokens.forEach((token) => {
83
83
  if (!token.ec) {
84
84
  const leafId = token.p?.toString();
85
- const newLabel = new CytoscapeTreeConverter().getLabelLeaf.call({ extraInfo }, token);
85
+ const converter = new CytoscapeTreeConverter();
86
+ converter['extraInfo'] = extraInfo;
87
+ const newLabel = converter.getLabelLeaf(token);
86
88
  thisCy.$id(leafId).data('label', newLabel);
87
89
  }
88
90
  });
@@ -24,6 +24,18 @@ const defaultStylesheet = [
24
24
  cursor: 'pointer',
25
25
  },
26
26
  },
27
+ {
28
+ selector: 'node.chunk',
29
+ style: {
30
+ content: 'data(label)',
31
+ },
32
+ },
33
+ {
34
+ selector: 'node.empty',
35
+ style: {
36
+ content: 'data(label)',
37
+ },
38
+ },
27
39
  {
28
40
  selector: 'node.highlight',
29
41
  style: {
@@ -5,6 +5,7 @@ export default class CytoscapeTreeConverter {
5
5
  private extraInfo;
6
6
  execute(struct: Struct, extraInfo: boolean): CytoscapeTreeCalculation | undefined;
7
7
  getLabelLeaf(token: Token): string;
8
+ private splitAttributeValue;
8
9
  private validate;
9
10
  private calculatePositions;
10
11
  private checkLastTokenPosition;
@@ -17,6 +17,7 @@ export default class CytoscapeTreeConverter {
17
17
  data: n.data,
18
18
  position: n.position,
19
19
  id: n.id,
20
+ classes: n.data.token ? 'token' : 'chunk',
20
21
  })),
21
22
  edges: tree.edges,
22
23
  root: {
@@ -29,12 +30,16 @@ export default class CytoscapeTreeConverter {
29
30
  getLabelLeaf(token) {
30
31
  if (this.extraInfo && token.attributes) {
31
32
  const attrLines = Object.values(token.attributes)
32
- .map((v) => v)
33
+ .map((v) => token.split ? this.splitAttributeValue(v, token.split.idx) : v)
33
34
  .join('<br/>');
34
35
  return `<span class="token-value">${token.v}</span><span class="token-attributes">${attrLines}</span>`;
35
36
  }
36
37
  return `<span class="token-value">${token.v}</span>`;
37
38
  }
39
+ splitAttributeValue(attr, idx) {
40
+ const splits = attr.split('+');
41
+ return splits[idx] ? splits[idx] : '';
42
+ }
38
43
  validate(struct) {
39
44
  if (!struct.chunks || struct.chunks.length === 0) {
40
45
  return false;
@@ -246,7 +251,7 @@ export default class CytoscapeTreeConverter {
246
251
  const token = struct.tokens.find((t) => t.p === i);
247
252
  if (!token)
248
253
  continue;
249
- this.convertToken(tree, token);
254
+ this.convertToken(tree, struct, token);
250
255
  }
251
256
  return tree;
252
257
  }
@@ -261,7 +266,7 @@ export default class CytoscapeTreeConverter {
261
266
  return chunk1.f - chunk2.f;
262
267
  });
263
268
  }
264
- convertToken(tree, token) {
269
+ convertToken(tree, struct, token) {
265
270
  if (token.ec)
266
271
  return;
267
272
  let id = this.generateTokenId(token);
@@ -281,6 +286,13 @@ export default class CytoscapeTreeConverter {
281
286
  target: tag.id,
282
287
  },
283
288
  });
289
+ // replicate the attributes in all splits
290
+ if (token.split && !token.split.v) {
291
+ const prevToken = struct.tokens.find((t) => t.p === token.p - 1);
292
+ if (prevToken && prevToken.attributes) {
293
+ token.attributes = prevToken.attributes;
294
+ }
295
+ }
284
296
  id = this.generateLeafId(token);
285
297
  const word = {
286
298
  id,
@@ -10,5 +10,6 @@ type NodeCalculation = {
10
10
  position?: Position;
11
11
  parent?: NodeCalculation;
12
12
  children?: NodeCalculation[];
13
+ classes?: string;
13
14
  };
14
15
  export default NodeCalculation;
@@ -35,7 +35,7 @@ const init = ({ selector, tree, dagre = false, stylesheet = defaultStylesheet, w
35
35
  });
36
36
  cy.ready(() => {
37
37
  if (!cy._htmlLabelsApplied) {
38
- const nodesToLabel = cy.nodes().not('.eh-handle');
38
+ const nodesToLabel = cy.nodes('.token');
39
39
  // @ts-ignore (no types)
40
40
  cy.nodeHtmlLabel([
41
41
  {
@@ -2,3 +2,4 @@ import { Struct } from '../../configs/types/Struct';
2
2
  export declare const structWithMorphemes: Struct;
3
3
  export declare const structNotParsed: Struct;
4
4
  export declare const structWithEditionTiers: Struct;
5
+ export declare const structWithMorphemesAndSplitters: Struct;
@@ -1133,3 +1133,167 @@ export const structWithEditionTiers = {
1133
1133
  page: '9cb4ac0a-63e9-44ec-9a02-0d66cf027623',
1134
1134
  status: 'DONE',
1135
1135
  };
1136
+ export const structWithMorphemesAndSplitters = {
1137
+ uid: '075fd4a6-24f0-11e5-9df9-0015c53587a5',
1138
+ tokens: [
1139
+ {
1140
+ splits: [
1141
+ {
1142
+ v: 'me',
1143
+ fn: false,
1144
+ },
1145
+ {
1146
+ v: 'i',
1147
+ },
1148
+ {
1149
+ v: 'ni',
1150
+ },
1151
+ {
1152
+ v: 'wa',
1153
+ },
1154
+ ],
1155
+ split: {
1156
+ v: 'miniwa',
1157
+ t: 'C+D',
1158
+ idx: 0,
1159
+ },
1160
+ attributes: {
1161
+ 'gloss-br': 'que + ele',
1162
+ },
1163
+ p: 1,
1164
+ v: 'me@',
1165
+ t: 'C',
1166
+ l: 1,
1167
+ },
1168
+ {
1169
+ split: {
1170
+ idx: 1,
1171
+ },
1172
+ p: 2,
1173
+ v: '@iniwa',
1174
+ t: 'D',
1175
+ l: 3,
1176
+ },
1177
+ {
1178
+ attributes: {
1179
+ 'gloss-br': 'que',
1180
+ },
1181
+ p: 3,
1182
+ v: 'me',
1183
+ t: 'C',
1184
+ l: 4,
1185
+ },
1186
+ {
1187
+ splits: [
1188
+ {
1189
+ v: 'God',
1190
+ t: 'Abs',
1191
+ },
1192
+ {
1193
+ v: 'apoa',
1194
+ t: 'v',
1195
+ },
1196
+ {
1197
+ v: 'Gen',
1198
+ t: 'Val',
1199
+ },
1200
+ {
1201
+ v: 'Gegi',
1202
+ t: 'Der',
1203
+ },
1204
+ ],
1205
+ attributes: {
1206
+ 'gloss-br': 'nosso guerreiro',
1207
+ },
1208
+ p: 4,
1209
+ v: 'ǥodapoaǥeneǥegi',
1210
+ t: 'N$',
1211
+ l: 6,
1212
+ },
1213
+ {
1214
+ attributes: {
1215
+ 'gloss-br': 'diz que',
1216
+ },
1217
+ p: 5,
1218
+ v: 'one',
1219
+ t: 'EV',
1220
+ l: 0,
1221
+ },
1222
+ {
1223
+ attributes: {
1224
+ 'gloss-br': 'barrigudo',
1225
+ },
1226
+ p: 6,
1227
+ v: 'agelaxaǥa',
1228
+ t: 'ADJ',
1229
+ l: 0,
1230
+ },
1231
+ {
1232
+ splits: [
1233
+ {
1234
+ v: 'joanaGa',
1235
+ fn: true,
1236
+ },
1237
+ {
1238
+ v: 'idaaGe',
1239
+ },
1240
+ ],
1241
+ attributes: {
1242
+ 'gloss-br': 'foi mesmo assim',
1243
+ },
1244
+ p: 7,
1245
+ v: 'joaniGidaaGee',
1246
+ t: 'T+ADV',
1247
+ l: 0,
1248
+ },
1249
+ ],
1250
+ chunks: [
1251
+ {
1252
+ i: 1,
1253
+ f: 7,
1254
+ t: 'IP-MAT',
1255
+ l: 0,
1256
+ },
1257
+ {
1258
+ i: 1,
1259
+ f: 4,
1260
+ t: 'CP-me',
1261
+ l: 1,
1262
+ },
1263
+ {
1264
+ i: 2,
1265
+ f: 4,
1266
+ t: 'IP-SUB',
1267
+ l: 2,
1268
+ },
1269
+ {
1270
+ i: 2,
1271
+ f: 4,
1272
+ t: 'NP',
1273
+ l: 3,
1274
+ },
1275
+ {
1276
+ i: 3,
1277
+ f: 4,
1278
+ t: 'CP-me',
1279
+ l: 4,
1280
+ },
1281
+ {
1282
+ i: 4,
1283
+ f: 4,
1284
+ t: 'IP-SUB',
1285
+ l: 5,
1286
+ },
1287
+ {
1288
+ i: 4,
1289
+ f: 4,
1290
+ t: 'NP',
1291
+ l: 6,
1292
+ },
1293
+ ],
1294
+ corpus: 'C12',
1295
+ document: 'D309',
1296
+ page: 'P35',
1297
+ status: 'AUTO',
1298
+ parsed: '2025-09-21T17:27:38.388+00:00',
1299
+ };
@@ -1,5 +1,6 @@
1
- export type SentenceStatus = 'DONE' | 'TODO' | 'IGNORE' | 'TAGGED' | 'REVIEW' | 'ERROR';
1
+ export type SentenceStatus = 'AUTO' | 'DONE' | 'TODO' | 'IGNORE' | 'TAGGED' | 'REVIEW' | 'ERROR';
2
2
  export declare const SentenceStatusNames: {
3
+ AUTO: string;
3
4
  DONE: string;
4
5
  TODO: string;
5
6
  IGNORE: string;
@@ -1,4 +1,5 @@
1
1
  export const SentenceStatusNames = {
2
+ AUTO: 'sentence.status.auto',
2
3
  DONE: 'sentence.status.done',
3
4
  TODO: 'sentence.status.todo',
4
5
  IGNORE: 'sentence.status.ignore',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.2.6-SNAPSHOT-3",
4
+ "version": "0.2.6-SNAPSHOT-5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {