@willwade/aac-processors 0.0.14 → 0.0.16

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.
Files changed (53) hide show
  1. package/README.md +58 -10
  2. package/dist/applePanels.d.ts +6 -0
  3. package/dist/applePanels.js +13 -0
  4. package/dist/astericsGrid.d.ts +6 -0
  5. package/dist/astericsGrid.js +13 -0
  6. package/dist/core/treeStructure.d.ts +1 -0
  7. package/dist/dot.d.ts +6 -0
  8. package/dist/dot.js +13 -0
  9. package/dist/excel.d.ts +6 -0
  10. package/dist/excel.js +13 -0
  11. package/dist/gridset.d.ts +17 -0
  12. package/dist/gridset.js +130 -0
  13. package/dist/index.d.ts +23 -2
  14. package/dist/index.js +36 -7
  15. package/dist/obf.d.ts +7 -0
  16. package/dist/obf.js +15 -0
  17. package/dist/obfset.d.ts +6 -0
  18. package/dist/obfset.js +13 -0
  19. package/dist/opml.d.ts +6 -0
  20. package/dist/opml.js +13 -0
  21. package/dist/processors/gridset/commands.js +15 -0
  22. package/dist/processors/gridset/pluginTypes.js +4 -4
  23. package/dist/processors/gridsetProcessor.d.ts +4 -0
  24. package/dist/processors/gridsetProcessor.js +315 -47
  25. package/dist/processors/index.d.ts +8 -18
  26. package/dist/processors/index.js +9 -175
  27. package/dist/processors/snapProcessor.js +105 -9
  28. package/dist/processors/touchchatProcessor.js +33 -13
  29. package/dist/snap.d.ts +7 -0
  30. package/dist/snap.js +24 -0
  31. package/dist/touchchat.d.ts +7 -0
  32. package/dist/touchchat.js +16 -0
  33. package/dist/translation.d.ts +13 -0
  34. package/dist/translation.js +21 -0
  35. package/dist/types/aac.d.ts +13 -3
  36. package/dist/types/aac.js +6 -2
  37. package/dist/utilities/analytics/metrics/comparison.d.ts +1 -0
  38. package/dist/utilities/analytics/metrics/comparison.js +52 -24
  39. package/dist/utilities/analytics/metrics/core.d.ts +7 -2
  40. package/dist/utilities/analytics/metrics/core.js +327 -197
  41. package/dist/utilities/analytics/metrics/effort.d.ts +8 -3
  42. package/dist/utilities/analytics/metrics/effort.js +10 -5
  43. package/dist/utilities/analytics/metrics/sentence.js +17 -4
  44. package/dist/utilities/analytics/metrics/types.d.ts +39 -0
  45. package/dist/utilities/analytics/metrics/vocabulary.js +1 -1
  46. package/dist/utilities/analytics/reference/index.js +12 -1
  47. package/dist/utilities/translation/translationProcessor.d.ts +2 -1
  48. package/dist/utilities/translation/translationProcessor.js +5 -2
  49. package/dist/validation.d.ts +13 -0
  50. package/dist/validation.js +28 -0
  51. package/package.json +58 -4
  52. package/dist/utilities/screenshotConverter.d.ts +0 -69
  53. package/dist/utilities/screenshotConverter.js +0 -453
package/dist/types/aac.js CHANGED
@@ -7,7 +7,7 @@ exports.CellScanningOrder = exports.ScanningSelectionMethod = void 0;
7
7
  */
8
8
  var ScanningSelectionMethod;
9
9
  (function (ScanningSelectionMethod) {
10
- /** Automatically advance through items at timed intervals */
10
+ /** Automatically advance through items at timed intervals (1 Switch) */
11
11
  ScanningSelectionMethod["AutoScan"] = "AutoScan";
12
12
  /** Automatic scanning with overscan (two-stage scanning) */
13
13
  ScanningSelectionMethod["AutoScanWithOverscan"] = "AutoScanWithOverscan";
@@ -15,8 +15,12 @@ var ScanningSelectionMethod;
15
15
  ScanningSelectionMethod["HoldToAdvance"] = "HoldToAdvance";
16
16
  /** Hold to advance with overscan */
17
17
  ScanningSelectionMethod["HoldToAdvanceWithOverscan"] = "HoldToAdvanceWithOverscan";
18
- /** Tap switch to advance, tap again to select */
18
+ /** Tap switch to advance, tap again to select (Automatic) */
19
19
  ScanningSelectionMethod["TapToAdvance"] = "TapToAdvance";
20
+ /** Tap switch to advance, another switch to select (2 Switch Step Scan) */
21
+ ScanningSelectionMethod["StepScan2Switch"] = "StepScan2Switch";
22
+ /** Tap switch 1 to advance, tap switch 1 again to select (1 Switch Step Scan) */
23
+ ScanningSelectionMethod["StepScan1Switch"] = "StepScan1Switch";
20
24
  })(ScanningSelectionMethod || (exports.ScanningSelectionMethod = ScanningSelectionMethod = {}));
21
25
  /**
22
26
  * Cell scanning order patterns
@@ -10,6 +10,7 @@ export declare class ComparisonAnalyzer {
10
10
  private sentenceAnalyzer;
11
11
  private referenceLoader;
12
12
  constructor();
13
+ private normalize;
13
14
  /**
14
15
  * Compare two board sets
15
16
  */
@@ -16,25 +16,33 @@ class ComparisonAnalyzer {
16
16
  this.sentenceAnalyzer = new sentence_1.SentenceAnalyzer();
17
17
  this.referenceLoader = new index_1.ReferenceLoader();
18
18
  }
19
+ normalize(word) {
20
+ return word
21
+ .toLowerCase()
22
+ .trim()
23
+ .replace(/[.?!,]/g, '');
24
+ }
19
25
  /**
20
26
  * Compare two board sets
21
27
  */
22
28
  compare(targetResult, compareResult, options) {
23
29
  // Create base result from target
24
30
  const baseResult = { ...targetResult };
25
- // Create word maps
31
+ // Create word maps with normalized keys
26
32
  const targetWords = new Map();
27
33
  targetResult.buttons.forEach((btn) => {
28
- const existing = targetWords.get(btn.label);
34
+ const key = this.normalize(btn.label);
35
+ const existing = targetWords.get(key);
29
36
  if (!existing || btn.effort < existing.effort) {
30
- targetWords.set(btn.label, btn);
37
+ targetWords.set(key, btn);
31
38
  }
32
39
  });
33
40
  const compareWords = new Map();
34
41
  compareResult.buttons.forEach((btn) => {
35
- const existing = compareWords.get(btn.label);
42
+ const key = this.normalize(btn.label);
43
+ const existing = compareWords.get(key);
36
44
  if (!existing || btn.effort < existing.effort) {
37
- compareWords.set(btn.label, btn);
45
+ compareWords.set(key, btn);
38
46
  }
39
47
  });
40
48
  // Find missing/extra/overlapping words
@@ -62,7 +70,8 @@ class ComparisonAnalyzer {
62
70
  overlappingWords.sort((a, b) => a.localeCompare(b));
63
71
  // Add comparison metrics to buttons
64
72
  const enrichedButtons = targetResult.buttons.map((btn) => {
65
- const compBtn = compareWords.get(btn.label);
73
+ const key = this.normalize(btn.label);
74
+ const compBtn = compareWords.get(key);
66
75
  return {
67
76
  ...btn,
68
77
  comp_level: compBtn?.level,
@@ -124,8 +133,9 @@ class ComparisonAnalyzer {
124
133
  let targetCovered = 0;
125
134
  let compareCovered = 0;
126
135
  list.words.forEach((word) => {
127
- const targetBtn = targetWords.get(word);
128
- const compareBtn = compareWords.get(word);
136
+ const key = this.normalize(word);
137
+ const targetBtn = targetWords.get(key);
138
+ const compareBtn = compareWords.get(key);
129
139
  if (targetBtn) {
130
140
  targetCovered++;
131
141
  targetTotal += targetBtn.effort;
@@ -140,6 +150,9 @@ class ComparisonAnalyzer {
140
150
  list: list.words,
141
151
  average_effort: targetCovered > 0 ? targetTotal / targetCovered : 0,
142
152
  comp_effort: compareCovered > 0 ? compareTotal / compareCovered : 0,
153
+ target_covered: targetCovered,
154
+ compare_covered: compareCovered,
155
+ total_words: list.words.length,
143
156
  };
144
157
  });
145
158
  // Analyze missing from specific lists
@@ -147,7 +160,8 @@ class ComparisonAnalyzer {
147
160
  coreLists.forEach((list) => {
148
161
  const listMissing = [];
149
162
  list.words.forEach((word) => {
150
- if (!targetWords.has(word)) {
163
+ const key = this.normalize(word);
164
+ if (!targetWords.has(key)) {
151
165
  listMissing.push(word);
152
166
  }
153
167
  });
@@ -172,6 +186,13 @@ class ComparisonAnalyzer {
172
186
  comp_words: compareResult.total_words,
173
187
  comp_grid: compareResult.grid,
174
188
  comp_effort_score: this.calculateEffortScore(compareResult),
189
+ comp_spelling_effort_base: compareResult.spelling_effort_base,
190
+ comp_spelling_effort_per_letter: compareResult.spelling_effort_per_letter,
191
+ comp_spelling_page_id: compareResult.spelling_page_id,
192
+ has_dynamic_prediction: targetResult.has_dynamic_prediction,
193
+ prediction_page_id: targetResult.prediction_page_id,
194
+ comp_has_dynamic_prediction: compareResult.has_dynamic_prediction,
195
+ comp_prediction_page_id: compareResult.prediction_page_id,
175
196
  // Vocabulary comparison
176
197
  missing_words: missingWords,
177
198
  extra_words: extraWords,
@@ -196,19 +217,21 @@ class ComparisonAnalyzer {
196
217
  * Calculate CARE component scores
197
218
  */
198
219
  calculateCareComponents(targetResult, compareResult, _overlappingWords) {
199
- // Create word maps
220
+ // Create word maps with normalized keys
200
221
  const targetWords = new Map();
201
222
  targetResult.buttons.forEach((btn) => {
202
- const existing = targetWords.get(btn.label);
223
+ const key = this.normalize(btn.label);
224
+ const existing = targetWords.get(key);
203
225
  if (!existing || btn.effort < existing.effort) {
204
- targetWords.set(btn.label, btn);
226
+ targetWords.set(key, btn);
205
227
  }
206
228
  });
207
229
  const compareWords = new Map();
208
230
  compareResult.buttons.forEach((btn) => {
209
- const existing = compareWords.get(btn.label);
231
+ const key = this.normalize(btn.label);
232
+ const existing = compareWords.get(key);
210
233
  if (!existing || btn.effort < existing.effort) {
211
- compareWords.set(btn.label, btn);
234
+ compareWords.set(key, btn);
212
235
  }
213
236
  });
214
237
  // Load reference data
@@ -223,9 +246,10 @@ class ComparisonAnalyzer {
223
246
  list.words.forEach((word) => allCoreWords.add(word.toLowerCase()));
224
247
  });
225
248
  allCoreWords.forEach((word) => {
226
- if (targetWords.has(word))
249
+ const key = this.normalize(word);
250
+ if (targetWords.has(key))
227
251
  coreCount++;
228
- if (compareWords.has(word))
252
+ if (compareWords.has(key))
229
253
  compCoreCount++;
230
254
  });
231
255
  // Calculate sentence construction effort
@@ -234,8 +258,9 @@ class ComparisonAnalyzer {
234
258
  let sentenceWordCount = 0;
235
259
  sentences.forEach((words) => {
236
260
  words.forEach((word) => {
237
- const targetBtn = targetWords.get(word);
238
- const compareBtn = compareWords.get(word);
261
+ const key = this.normalize(word);
262
+ const targetBtn = targetWords.get(key);
263
+ const compareBtn = compareWords.get(key);
239
264
  if (targetBtn) {
240
265
  sentenceEffort += targetBtn.effort;
241
266
  }
@@ -258,8 +283,9 @@ class ComparisonAnalyzer {
258
283
  let compFringeCount = 0;
259
284
  let commonFringeCount = 0;
260
285
  fringe.forEach((word) => {
261
- const inTarget = targetWords.has(word);
262
- const inCompare = compareWords.has(word);
286
+ const key = this.normalize(word);
287
+ const inTarget = targetWords.has(key);
288
+ const inCompare = compareWords.has(key);
263
289
  if (inTarget)
264
290
  fringeCount++;
265
291
  if (inCompare)
@@ -285,8 +311,9 @@ class ComparisonAnalyzer {
285
311
  const fringe = this.referenceLoader.loadFringe();
286
312
  const result = [];
287
313
  fringe.forEach((word) => {
288
- const targetBtn = targetWords.get(word);
289
- const compareBtn = compareWords.get(word);
314
+ const key = this.normalize(word);
315
+ const targetBtn = targetWords.get(key);
316
+ const compareBtn = compareWords.get(key);
290
317
  if (targetBtn) {
291
318
  result.push({
292
319
  word,
@@ -305,8 +332,9 @@ class ComparisonAnalyzer {
305
332
  const fringe = this.referenceLoader.loadFringe();
306
333
  const result = [];
307
334
  fringe.forEach((word) => {
308
- const targetBtn = targetWords.get(word);
309
- const compareBtn = compareWords.get(word);
335
+ const key = this.normalize(word);
336
+ const targetBtn = targetWords.get(key);
337
+ const compareBtn = compareWords.get(key);
310
338
  if (targetBtn && compareBtn) {
311
339
  result.push({
312
340
  word,
@@ -7,16 +7,21 @@
7
7
  * Based on: aac-metrics/lib/aac-metrics/metrics.rb
8
8
  */
9
9
  import { AACTree } from '../../../core/treeStructure';
10
- import { MetricsResult } from './types';
10
+ import { MetricsOptions, MetricsResult } from './types';
11
11
  export declare class MetricsCalculator {
12
12
  private locale;
13
13
  /**
14
14
  * Main analysis function - calculates metrics for an AAC tree
15
15
  *
16
16
  * @param tree - The AAC tree to analyze
17
+ * @param options - Optional configuration for metrics calculation
17
18
  * @returns Complete metrics result
18
19
  */
19
- analyze(tree: AACTree): MetricsResult;
20
+ analyze(tree: AACTree, options?: MetricsOptions): MetricsResult;
21
+ /**
22
+ * Identify keyboard/spelling page and calculate base/avg effort
23
+ */
24
+ private identifySpellingMetrics;
20
25
  /**
21
26
  * Build reference maps for semantic_id and clone_id frequencies
22
27
  */