Skip to content

Commit 73c06af

Browse files
committed
adding morphology to TDSnap and fixing morphology to Metrics for Grid3
1 parent 13e485e commit 73c06af

11 files changed

Lines changed: 1000 additions & 49 deletions

File tree

src/core/treeStructure.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class AACButton {
175175
};
176176

177177
// Extended properties for advanced platforms
178-
contentType?: 'Normal' | 'AutoContent' | 'Workspace' | 'LiveCell';
178+
contentType?: 'Normal' | 'AutoContent' | 'Workspace' | 'LiveCell' | 'Inflector' | 'Prediction';
179179
contentSubType?: string;
180180
image?: string;
181181
resolvedImageEntry?: string; // normalized zip path to resolved image, if present
@@ -255,7 +255,7 @@ export class AACButton {
255255
metadata?: string;
256256
};
257257
style?: AACStyle;
258-
contentType?: 'Normal' | 'AutoContent' | 'Workspace' | 'LiveCell';
258+
contentType?: 'Normal' | 'AutoContent' | 'Workspace' | 'LiveCell' | 'Inflector' | 'Prediction';
259259
contentSubType?: string;
260260
image?: string;
261261
resolvedImageEntry?: string;

src/index.node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ export * as Validation from './validation';
3131
// Metrics namespace (pageset analytics)
3232
export * as Metrics from './metrics';
3333

34-
// Node-only morphology utilities (Grid 3 verbs parser)
34+
// Node-only morphology utilities (Grid 3 verbs parser, TDSnap lexicon parser)
3535
export { Grid3VerbsParser } from './utilities/analytics/morphology/grid3VerbsParser';
36+
export { TDSnapLexiconParser } from './utilities/analytics/morphology/tdsnapLexiconParser';
3637
export { WordFormGenerator } from './utilities/analytics/morphology/wordFormGenerator';
3738

3839
// Processor namespaces (platform-specific utilities)

src/processors/snapProcessor.ts

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ class SnapProcessor extends BaseProcessor {
422422
buttonColumns.has('BackgroundColor') ? 'b.BackgroundColor' : 'NULL AS BackgroundColor',
423423
buttonColumns.has('NavigatePageId') ? 'b.NavigatePageId' : 'NULL AS NavigatePageId',
424424
buttonColumns.has('ContentType') ? 'b.ContentType' : 'NULL AS ContentType',
425+
buttonColumns.has('SerializedContentTypeHandler')
426+
? 'b.SerializedContentTypeHandler'
427+
: 'NULL AS SerializedContentTypeHandler',
425428
];
426429

427430
if (this.loadAudio) {
@@ -672,23 +675,61 @@ class SnapProcessor extends BaseProcessor {
672675
};
673676
}
674677

678+
let snapContentType: string | undefined;
679+
let snapContentSubType: string | undefined;
680+
let snapGrammarPos: string | undefined;
681+
let snapGrammarHandler: string | undefined;
682+
683+
if (btnRow.ContentType === 1) {
684+
snapContentType = 'AutoContent';
685+
snapContentSubType = 'Prediction';
686+
} else if (btnRow.ContentType === 3 && btnRow.SerializedContentTypeHandler) {
687+
snapContentType = 'Inflector';
688+
snapGrammarHandler = String(btnRow.SerializedContentTypeHandler);
689+
const colonIdx = snapGrammarHandler.indexOf(':');
690+
if (colonIdx !== -1) {
691+
const subtype = snapGrammarHandler.substring(colonIdx + 1).split(',')[0];
692+
snapContentSubType = subtype;
693+
const {
694+
TDSnapLexiconParser,
695+
} = require('../utilities/analytics/morphology/tdsnapLexiconParser');
696+
snapGrammarPos = TDSnapLexiconParser.tagToPos(subtype);
697+
}
698+
}
699+
675700
const button = new AACButton({
676701
id: String(btnRow.Id),
677702
label: btnRow.Label || (btnRow.ContentType === 1 ? '[Prediction]' : ''),
678703
message:
679704
btnRow.Message || (btnRow.ContentType === 1 ? '[Prediction]' : btnRow.Label || ''),
680705
targetPageId: targetPageUniqueId,
681706
semanticAction: semanticAction,
682-
contentType: btnRow.ContentType === 1 ? 'AutoContent' : undefined,
683-
contentSubType: btnRow.ContentType === 1 ? 'Prediction' : undefined,
707+
contentType: snapContentType as AACButton['contentType'],
708+
contentSubType: snapContentSubType,
684709
audioRecording: audioRecording,
685710
visibility: mapSnapVisibility(btnRow.Visible as number),
686711
semantic_id: btnRow.LibrarySymbolId
687712
? `snap_symbol_${btnRow.LibrarySymbolId}`
688-
: undefined, // Extract semantic_id from LibrarySymbolId
713+
: undefined,
689714
image: buttonImage,
690715
resolvedImageEntry: buttonImage,
691-
parameters: Object.keys(buttonParameters).length > 0 ? buttonParameters : undefined,
716+
parameters: {
717+
...(Object.keys(buttonParameters).length > 0 ? buttonParameters : {}),
718+
...(snapGrammarHandler
719+
? {
720+
grammar: {
721+
handler: snapGrammarHandler,
722+
category: snapGrammarHandler.substring(
723+
0,
724+
snapGrammarHandler.indexOf(':') !== -1
725+
? snapGrammarHandler.indexOf(':')
726+
: snapGrammarHandler.length
727+
),
728+
subtype: snapContentSubType,
729+
},
730+
}
731+
: {}),
732+
},
692733
style: {
693734
backgroundColor: btnRow.BackgroundColor
694735
? `#${btnRow.BackgroundColor.toString(16)}`
@@ -702,6 +743,10 @@ class SnapProcessor extends BaseProcessor {
702743
},
703744
});
704745

746+
if (snapGrammarPos) {
747+
button.pos = snapGrammarPos;
748+
}
749+
705750
// Add to the intended parent page
706751
const parentPage = tree.getPage(parentUniqueId);
707752
if (parentPage) {

src/types/aac.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export interface AACButton {
9292
metadata?: string;
9393
};
9494
// Extended properties for advanced platforms
95-
contentType?: 'Normal' | 'AutoContent' | 'Workspace' | 'LiveCell';
95+
contentType?: 'Normal' | 'AutoContent' | 'Workspace' | 'LiveCell' | 'Inflector' | 'Prediction';
9696
contentSubType?: string;
9797
image?: string;
9898
resolvedImageEntry?: string; // normalized zip path to resolved image, if present

0 commit comments

Comments
 (0)