@willwade/aac-processors 0.2.5 → 0.2.6

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.
@@ -804,6 +804,10 @@ export class MetricsCalculator {
804
804
  }
805
805
  if (!parentMetrics)
806
806
  return;
807
+ // Build set of original Suggest Words predictions (from Prediction.PredictThis).
808
+ // These require an extra confirmation tap from the user. Smart grammar
809
+ // morphology outcomes are generated automatically and need no extra tap.
810
+ const suggestWordsSet = new Set((btn.parameters?.predictions || []).map((w) => w.toLowerCase()));
807
811
  // Calculate effort for each word form
808
812
  btn.predictions.forEach((wordForm, index) => {
809
813
  const wordFormLower = wordForm.toLowerCase();
@@ -816,8 +820,14 @@ export class MetricsCalculator {
816
820
  // Using similar logic to button scanning effort
817
821
  const predictionPriorItems = predictionRowIndex * predictionsGridCols + predictionColIndex;
818
822
  const predictionSelectionEffort = visualScanEffort(predictionPriorItems);
819
- // Word form effort = parent button's cumulative effort + selection effort
820
- const wordFormEffort = parentMetrics.effort + predictionSelectionEffort;
823
+ // Add confirmation cost for Suggest Words outcomes only.
824
+ // Suggest Words requires an explicit tap on the prediction bar,
825
+ // while smart grammar morphology forms are auto-generated (no extra tap).
826
+ const suggestWordsConfirmation = suggestWordsSet.has(wordFormLower)
827
+ ? EFFORT_CONSTANTS.SUGGEST_WORDS_SELECTION_EFFORT
828
+ : 0;
829
+ // Word form effort = parent button's cumulative effort + selection effort + confirmation
830
+ const wordFormEffort = parentMetrics.effort + predictionSelectionEffort + suggestWordsConfirmation;
821
831
  // Check if this word already exists as a regular button
822
832
  const existingBtn = existingLabels.get(wordFormLower);
823
833
  // If word exists and has lower or equal effort, skip the word form
@@ -838,9 +848,10 @@ export class MetricsCalculator {
838
848
  semantic_id: parentMetrics.semantic_id,
839
849
  clone_id: parentMetrics.clone_id,
840
850
  temporary_home_id: parentMetrics.temporary_home_id,
841
- is_word_form: true, // Mark this as a word form metric
842
- parent_button_id: btn.id, // Track parent button
843
- parent_button_label: parentMetrics.label, // Track parent label
851
+ is_word_form: true,
852
+ is_suggest_words: suggestWordsSet.has(wordFormLower) || undefined,
853
+ parent_button_id: btn.id,
854
+ parent_button_label: parentMetrics.label,
844
855
  };
845
856
  wordFormMetrics.push(wordFormBtn);
846
857
  existingLabels.set(wordFormLower, wordFormBtn);
@@ -31,6 +31,7 @@ export const EFFORT_CONSTANTS = {
31
31
  SCAN_SELECTION_COST: 0.1, // Cost of a switch selection
32
32
  DEFAULT_SCAN_ERROR_RATE: 0.1, // 10% chance of missing a selection
33
33
  SCAN_RETRY_PENALTY: 1.0, // Cost multiplier for a full loop retry
34
+ SUGGEST_WORDS_SELECTION_EFFORT: 0.5, // Extra tap to confirm a Suggest Words prediction
34
35
  };
35
36
  /**
36
37
  * Calculate button size effort based on grid dimensions
@@ -807,6 +807,10 @@ class MetricsCalculator {
807
807
  }
808
808
  if (!parentMetrics)
809
809
  return;
810
+ // Build set of original Suggest Words predictions (from Prediction.PredictThis).
811
+ // These require an extra confirmation tap from the user. Smart grammar
812
+ // morphology outcomes are generated automatically and need no extra tap.
813
+ const suggestWordsSet = new Set((btn.parameters?.predictions || []).map((w) => w.toLowerCase()));
810
814
  // Calculate effort for each word form
811
815
  btn.predictions.forEach((wordForm, index) => {
812
816
  const wordFormLower = wordForm.toLowerCase();
@@ -819,8 +823,14 @@ class MetricsCalculator {
819
823
  // Using similar logic to button scanning effort
820
824
  const predictionPriorItems = predictionRowIndex * predictionsGridCols + predictionColIndex;
821
825
  const predictionSelectionEffort = (0, effort_1.visualScanEffort)(predictionPriorItems);
822
- // Word form effort = parent button's cumulative effort + selection effort
823
- const wordFormEffort = parentMetrics.effort + predictionSelectionEffort;
826
+ // Add confirmation cost for Suggest Words outcomes only.
827
+ // Suggest Words requires an explicit tap on the prediction bar,
828
+ // while smart grammar morphology forms are auto-generated (no extra tap).
829
+ const suggestWordsConfirmation = suggestWordsSet.has(wordFormLower)
830
+ ? effort_1.EFFORT_CONSTANTS.SUGGEST_WORDS_SELECTION_EFFORT
831
+ : 0;
832
+ // Word form effort = parent button's cumulative effort + selection effort + confirmation
833
+ const wordFormEffort = parentMetrics.effort + predictionSelectionEffort + suggestWordsConfirmation;
824
834
  // Check if this word already exists as a regular button
825
835
  const existingBtn = existingLabels.get(wordFormLower);
826
836
  // If word exists and has lower or equal effort, skip the word form
@@ -841,9 +851,10 @@ class MetricsCalculator {
841
851
  semantic_id: parentMetrics.semantic_id,
842
852
  clone_id: parentMetrics.clone_id,
843
853
  temporary_home_id: parentMetrics.temporary_home_id,
844
- is_word_form: true, // Mark this as a word form metric
845
- parent_button_id: btn.id, // Track parent button
846
- parent_button_label: parentMetrics.label, // Track parent label
854
+ is_word_form: true,
855
+ is_suggest_words: suggestWordsSet.has(wordFormLower) || undefined,
856
+ parent_button_id: btn.id,
857
+ parent_button_label: parentMetrics.label,
847
858
  };
848
859
  wordFormMetrics.push(wordFormBtn);
849
860
  existingLabels.set(wordFormLower, wordFormBtn);
@@ -31,6 +31,7 @@ export declare const EFFORT_CONSTANTS: {
31
31
  readonly SCAN_SELECTION_COST: 0.1;
32
32
  readonly DEFAULT_SCAN_ERROR_RATE: 0.1;
33
33
  readonly SCAN_RETRY_PENALTY: 1;
34
+ readonly SUGGEST_WORDS_SELECTION_EFFORT: 0.5;
34
35
  };
35
36
  /**
36
37
  * Calculate button size effort based on grid dimensions
@@ -47,6 +47,7 @@ exports.EFFORT_CONSTANTS = {
47
47
  SCAN_SELECTION_COST: 0.1, // Cost of a switch selection
48
48
  DEFAULT_SCAN_ERROR_RATE: 0.1, // 10% chance of missing a selection
49
49
  SCAN_RETRY_PENALTY: 1.0, // Cost multiplier for a full loop retry
50
+ SUGGEST_WORDS_SELECTION_EFFORT: 0.5, // Extra tap to confirm a Suggest Words prediction
50
51
  };
51
52
  /**
52
53
  * Calculate button size effort based on grid dimensions
@@ -19,6 +19,7 @@ export interface ButtonMetrics {
19
19
  comp_level?: number;
20
20
  comp_effort?: number;
21
21
  is_word_form?: boolean;
22
+ is_suggest_words?: boolean;
22
23
  parent_button_id?: string;
23
24
  parent_button_label?: string;
24
25
  pos?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "A comprehensive TypeScript library for processing AAC (Augmentative and Alternative Communication) file formats with translation support",
5
5
  "main": "dist/index.js",
6
6
  "browser": "dist/browser/index.browser.js",