@willwade/aac-processors 0.0.11 → 0.0.13
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/README.md +44 -41
- package/dist/cli/index.js +7 -0
- package/dist/core/analyze.js +1 -0
- package/dist/core/treeStructure.d.ts +45 -2
- package/dist/core/treeStructure.js +22 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +20 -3
- package/dist/{analytics → optional/analytics}/history.d.ts +15 -4
- package/dist/{analytics → optional/analytics}/history.js +3 -3
- package/dist/optional/analytics/index.d.ts +30 -0
- package/dist/optional/analytics/index.js +78 -0
- package/dist/optional/analytics/metrics/comparison.d.ts +36 -0
- package/dist/optional/analytics/metrics/comparison.js +334 -0
- package/dist/optional/analytics/metrics/core.d.ts +45 -0
- package/dist/optional/analytics/metrics/core.js +575 -0
- package/dist/optional/analytics/metrics/effort.d.ts +147 -0
- package/dist/optional/analytics/metrics/effort.js +211 -0
- package/dist/optional/analytics/metrics/index.d.ts +15 -0
- package/dist/optional/analytics/metrics/index.js +36 -0
- package/dist/optional/analytics/metrics/obl-types.d.ts +93 -0
- package/dist/optional/analytics/metrics/obl-types.js +7 -0
- package/dist/optional/analytics/metrics/obl.d.ts +40 -0
- package/dist/optional/analytics/metrics/obl.js +287 -0
- package/dist/optional/analytics/metrics/sentence.d.ts +49 -0
- package/dist/optional/analytics/metrics/sentence.js +112 -0
- package/dist/optional/analytics/metrics/types.d.ts +157 -0
- package/dist/optional/analytics/metrics/types.js +7 -0
- package/dist/optional/analytics/metrics/vocabulary.d.ts +65 -0
- package/dist/optional/analytics/metrics/vocabulary.js +142 -0
- package/dist/optional/analytics/reference/index.d.ts +51 -0
- package/dist/optional/analytics/reference/index.js +102 -0
- package/dist/optional/analytics/utils/idGenerator.d.ts +59 -0
- package/dist/optional/analytics/utils/idGenerator.js +96 -0
- package/dist/optional/symbolTools.js +13 -16
- package/dist/processors/astericsGridProcessor.d.ts +15 -0
- package/dist/processors/astericsGridProcessor.js +17 -0
- package/dist/processors/gridset/helpers.d.ts +4 -1
- package/dist/processors/gridset/helpers.js +4 -0
- package/dist/processors/gridset/pluginTypes.js +51 -50
- package/dist/processors/gridset/symbolExtractor.js +3 -2
- package/dist/processors/gridset/symbolSearch.js +9 -7
- package/dist/processors/gridsetProcessor.js +82 -20
- package/dist/processors/index.d.ts +1 -0
- package/dist/processors/index.js +5 -3
- package/dist/processors/obfProcessor.js +37 -2
- package/dist/processors/obfsetProcessor.d.ts +26 -0
- package/dist/processors/obfsetProcessor.js +179 -0
- package/dist/processors/snap/helpers.d.ts +5 -1
- package/dist/processors/snap/helpers.js +5 -0
- package/dist/processors/snapProcessor.d.ts +2 -0
- package/dist/processors/snapProcessor.js +184 -5
- package/dist/processors/touchchatProcessor.js +50 -4
- package/dist/types/aac.d.ts +67 -0
- package/dist/types/aac.js +33 -0
- package/dist/validation/gridsetValidator.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effort Score Calculation Algorithms
|
|
3
|
+
*
|
|
4
|
+
* Implements the core effort calculation algorithms from the Ruby aac-metrics tool.
|
|
5
|
+
* These algorithms calculate how difficult it is to access each button based on
|
|
6
|
+
* distance, visual scanning, grid complexity, and motor planning support.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Constants for effort score calculation
|
|
10
|
+
* Values match the Ruby implementation exactly
|
|
11
|
+
*/
|
|
12
|
+
export declare const EFFORT_CONSTANTS: {
|
|
13
|
+
readonly SQRT2: number;
|
|
14
|
+
readonly BUTTON_SIZE_MULTIPLIER: 0.09;
|
|
15
|
+
readonly FIELD_SIZE_MULTIPLIER: 0.005;
|
|
16
|
+
readonly VISUAL_SCAN_MULTIPLIER: 0.015;
|
|
17
|
+
readonly BOARD_CHANGE_PROCESSING_EFFORT: 1;
|
|
18
|
+
readonly BOARD_HOME_EFFORT: 1;
|
|
19
|
+
readonly COMBINED_WORDS_REMEMBERING_EFFORT: 1;
|
|
20
|
+
readonly DISTANCE_MULTIPLIER: 0.4;
|
|
21
|
+
readonly DISTANCE_THRESHOLD_TO_SKIP_VISUAL_SCAN: 0.1;
|
|
22
|
+
readonly SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER: 0.5;
|
|
23
|
+
readonly SAME_LOCATION_AS_PRIOR_DISCOUNT: 0.1;
|
|
24
|
+
readonly RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT: 0.5;
|
|
25
|
+
readonly RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT: 0.5;
|
|
26
|
+
readonly REUSED_SEMANTIC_FROM_OTHER_BONUS: 0.0025;
|
|
27
|
+
readonly RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT: 0.33;
|
|
28
|
+
readonly RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT: 0.33;
|
|
29
|
+
readonly REUSED_CLONE_FROM_OTHER_BONUS: 0.005;
|
|
30
|
+
readonly SCAN_STEP_COST: 0.015;
|
|
31
|
+
readonly SCAN_SELECTION_COST: 0.1;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Calculate button size effort based on grid dimensions
|
|
35
|
+
* Larger grids require more visual scanning and discrimination
|
|
36
|
+
*
|
|
37
|
+
* @param rows - Number of rows in the grid
|
|
38
|
+
* @param cols - Number of columns in the grid
|
|
39
|
+
* @returns Button size effort score
|
|
40
|
+
*/
|
|
41
|
+
export declare function buttonSizeEffort(rows: number, cols: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Calculate field size effort based on number of visible buttons
|
|
44
|
+
* More buttons = more visual clutter = higher effort
|
|
45
|
+
*
|
|
46
|
+
* @param buttonCount - Number of visible buttons on the board
|
|
47
|
+
* @returns Field size effort score
|
|
48
|
+
*/
|
|
49
|
+
export declare function fieldSizeEffort(buttonCount: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate visual scanning effort
|
|
52
|
+
* Effort increases with each button that must be scanned before reaching target
|
|
53
|
+
*
|
|
54
|
+
* @param priorButtons - Number of buttons visually scanned before target
|
|
55
|
+
* @returns Visual scan effort score
|
|
56
|
+
*/
|
|
57
|
+
export declare function visualScanEffort(priorButtons: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* Calculate distance effort from entry point to button center
|
|
60
|
+
* Uses Euclidean distance normalized by sqrt(2)
|
|
61
|
+
*
|
|
62
|
+
* @param x - Button center X coordinate (0-1 normalized)
|
|
63
|
+
* @param y - Button center Y coordinate (0-1 normalized)
|
|
64
|
+
* @param entryX - Entry point X coordinate (0-1 normalized, default 1.0 = bottom-right)
|
|
65
|
+
* @param entryY - Entry point Y coordinate (0-1 normalized, default 1.0 = bottom-right)
|
|
66
|
+
* @returns Distance effort score
|
|
67
|
+
*/
|
|
68
|
+
export declare function distanceEffort(x: number, y: number, entryX?: number, entryY?: number): number;
|
|
69
|
+
/**
|
|
70
|
+
* Calculate spelling effort for words not available in the board set
|
|
71
|
+
* Base cost + per-letter cost
|
|
72
|
+
*
|
|
73
|
+
* @param word - The word to spell
|
|
74
|
+
* @returns Spelling effort score
|
|
75
|
+
*/
|
|
76
|
+
export declare function spellingEffort(word: string): number;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate base board effort
|
|
79
|
+
* Combines button size and field size efforts
|
|
80
|
+
*
|
|
81
|
+
* @param rows - Number of rows in the grid
|
|
82
|
+
* @param cols - Number of columns in the grid
|
|
83
|
+
* @param buttonCount - Number of visible buttons
|
|
84
|
+
* @returns Base board effort score
|
|
85
|
+
*/
|
|
86
|
+
export declare function baseBoardEffort(rows: number, cols: number, buttonCount: number): number;
|
|
87
|
+
/**
|
|
88
|
+
* Apply reuse discount based on semantic_id/clone_id frequency
|
|
89
|
+
*
|
|
90
|
+
* @param boardEffort - Current board effort
|
|
91
|
+
* @param reuseDiscount - Calculated reuse discount
|
|
92
|
+
* @returns Adjusted board effort
|
|
93
|
+
*/
|
|
94
|
+
export declare function applyReuseDiscount(boardEffort: number, reuseDiscount: number): number;
|
|
95
|
+
/**
|
|
96
|
+
* Calculate button-level effort with motor planning discounts
|
|
97
|
+
*
|
|
98
|
+
* @param baseEffort - Base board effort
|
|
99
|
+
* @param boardPcts - Percentage of links matching semantic_id/clone_id
|
|
100
|
+
* @param button - Button data
|
|
101
|
+
* @returns Adjusted button effort
|
|
102
|
+
*/
|
|
103
|
+
export declare function calculateButtonEffort(baseEffort: number, boardPcts: {
|
|
104
|
+
[id: string]: number;
|
|
105
|
+
}, button: {
|
|
106
|
+
semantic_id?: string;
|
|
107
|
+
clone_id?: string;
|
|
108
|
+
}): number;
|
|
109
|
+
/**
|
|
110
|
+
* Calculate distance with motor planning discounts
|
|
111
|
+
*
|
|
112
|
+
* @param distance - Raw distance effort
|
|
113
|
+
* @param boardPcts - Percentage of links matching semantic_id/clone_id
|
|
114
|
+
* @param button - Button data
|
|
115
|
+
* @param setPcts - Percentage of boards containing semantic_id/clone_id
|
|
116
|
+
* @returns Adjusted distance effort
|
|
117
|
+
*/
|
|
118
|
+
export declare function calculateDistanceWithDiscounts(distance: number, boardPcts: {
|
|
119
|
+
[id: string]: number;
|
|
120
|
+
}, button: {
|
|
121
|
+
semantic_id?: string;
|
|
122
|
+
clone_id?: string;
|
|
123
|
+
}, setPcts: {
|
|
124
|
+
[id: string]: number;
|
|
125
|
+
}): number;
|
|
126
|
+
/**
|
|
127
|
+
* Check if visual scan should be skipped (button close to previous)
|
|
128
|
+
*
|
|
129
|
+
* @param distance - Distance from previous button
|
|
130
|
+
* @returns True if close enough to skip full visual scan
|
|
131
|
+
*/
|
|
132
|
+
export declare function shouldSkipVisualScan(distance: number): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Calculate local scan effort when buttons are close
|
|
135
|
+
*
|
|
136
|
+
* @param distance - Distance between buttons
|
|
137
|
+
* @returns Local scan effort
|
|
138
|
+
*/
|
|
139
|
+
export declare function localScanEffort(distance: number): number;
|
|
140
|
+
/**
|
|
141
|
+
* Calculate effort for switch scanning
|
|
142
|
+
*
|
|
143
|
+
* @param steps - Number of scan steps to reach target
|
|
144
|
+
* @param selections - Number of switch selections required
|
|
145
|
+
* @returns Scanning effort score
|
|
146
|
+
*/
|
|
147
|
+
export declare function scanningEffort(steps: number, selections: number): number;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Effort Score Calculation Algorithms
|
|
4
|
+
*
|
|
5
|
+
* Implements the core effort calculation algorithms from the Ruby aac-metrics tool.
|
|
6
|
+
* These algorithms calculate how difficult it is to access each button based on
|
|
7
|
+
* distance, visual scanning, grid complexity, and motor planning support.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EFFORT_CONSTANTS = void 0;
|
|
11
|
+
exports.buttonSizeEffort = buttonSizeEffort;
|
|
12
|
+
exports.fieldSizeEffort = fieldSizeEffort;
|
|
13
|
+
exports.visualScanEffort = visualScanEffort;
|
|
14
|
+
exports.distanceEffort = distanceEffort;
|
|
15
|
+
exports.spellingEffort = spellingEffort;
|
|
16
|
+
exports.baseBoardEffort = baseBoardEffort;
|
|
17
|
+
exports.applyReuseDiscount = applyReuseDiscount;
|
|
18
|
+
exports.calculateButtonEffort = calculateButtonEffort;
|
|
19
|
+
exports.calculateDistanceWithDiscounts = calculateDistanceWithDiscounts;
|
|
20
|
+
exports.shouldSkipVisualScan = shouldSkipVisualScan;
|
|
21
|
+
exports.localScanEffort = localScanEffort;
|
|
22
|
+
exports.scanningEffort = scanningEffort;
|
|
23
|
+
/**
|
|
24
|
+
* Constants for effort score calculation
|
|
25
|
+
* Values match the Ruby implementation exactly
|
|
26
|
+
*/
|
|
27
|
+
exports.EFFORT_CONSTANTS = {
|
|
28
|
+
SQRT2: Math.sqrt(2),
|
|
29
|
+
BUTTON_SIZE_MULTIPLIER: 0.09,
|
|
30
|
+
FIELD_SIZE_MULTIPLIER: 0.005,
|
|
31
|
+
VISUAL_SCAN_MULTIPLIER: 0.015,
|
|
32
|
+
BOARD_CHANGE_PROCESSING_EFFORT: 1.0,
|
|
33
|
+
BOARD_HOME_EFFORT: 1.0,
|
|
34
|
+
COMBINED_WORDS_REMEMBERING_EFFORT: 1.0,
|
|
35
|
+
DISTANCE_MULTIPLIER: 0.4,
|
|
36
|
+
DISTANCE_THRESHOLD_TO_SKIP_VISUAL_SCAN: 0.1,
|
|
37
|
+
SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER: 0.5,
|
|
38
|
+
SAME_LOCATION_AS_PRIOR_DISCOUNT: 0.1,
|
|
39
|
+
RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT: 0.5,
|
|
40
|
+
RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT: 0.5,
|
|
41
|
+
REUSED_SEMANTIC_FROM_OTHER_BONUS: 0.0025,
|
|
42
|
+
RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT: 0.33,
|
|
43
|
+
RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT: 0.33,
|
|
44
|
+
REUSED_CLONE_FROM_OTHER_BONUS: 0.005,
|
|
45
|
+
SCAN_STEP_COST: 0.015, // Matches visual scan multiplier
|
|
46
|
+
SCAN_SELECTION_COST: 0.1, // Cost of a switch selection
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Calculate button size effort based on grid dimensions
|
|
50
|
+
* Larger grids require more visual scanning and discrimination
|
|
51
|
+
*
|
|
52
|
+
* @param rows - Number of rows in the grid
|
|
53
|
+
* @param cols - Number of columns in the grid
|
|
54
|
+
* @returns Button size effort score
|
|
55
|
+
*/
|
|
56
|
+
function buttonSizeEffort(rows, cols) {
|
|
57
|
+
return exports.EFFORT_CONSTANTS.BUTTON_SIZE_MULTIPLIER * ((rows + cols) / 2);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Calculate field size effort based on number of visible buttons
|
|
61
|
+
* More buttons = more visual clutter = higher effort
|
|
62
|
+
*
|
|
63
|
+
* @param buttonCount - Number of visible buttons on the board
|
|
64
|
+
* @returns Field size effort score
|
|
65
|
+
*/
|
|
66
|
+
function fieldSizeEffort(buttonCount) {
|
|
67
|
+
return exports.EFFORT_CONSTANTS.FIELD_SIZE_MULTIPLIER * buttonCount;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Calculate visual scanning effort
|
|
71
|
+
* Effort increases with each button that must be scanned before reaching target
|
|
72
|
+
*
|
|
73
|
+
* @param priorButtons - Number of buttons visually scanned before target
|
|
74
|
+
* @returns Visual scan effort score
|
|
75
|
+
*/
|
|
76
|
+
function visualScanEffort(priorButtons) {
|
|
77
|
+
return priorButtons * exports.EFFORT_CONSTANTS.VISUAL_SCAN_MULTIPLIER;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Calculate distance effort from entry point to button center
|
|
81
|
+
* Uses Euclidean distance normalized by sqrt(2)
|
|
82
|
+
*
|
|
83
|
+
* @param x - Button center X coordinate (0-1 normalized)
|
|
84
|
+
* @param y - Button center Y coordinate (0-1 normalized)
|
|
85
|
+
* @param entryX - Entry point X coordinate (0-1 normalized, default 1.0 = bottom-right)
|
|
86
|
+
* @param entryY - Entry point Y coordinate (0-1 normalized, default 1.0 = bottom-right)
|
|
87
|
+
* @returns Distance effort score
|
|
88
|
+
*/
|
|
89
|
+
function distanceEffort(x, y, entryX = 1.0, entryY = 1.0) {
|
|
90
|
+
const distance = Math.sqrt(Math.pow(x - entryX, 2) + Math.pow(y - entryY, 2));
|
|
91
|
+
return (distance / exports.EFFORT_CONSTANTS.SQRT2) * exports.EFFORT_CONSTANTS.DISTANCE_MULTIPLIER;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calculate spelling effort for words not available in the board set
|
|
95
|
+
* Base cost + per-letter cost
|
|
96
|
+
*
|
|
97
|
+
* @param word - The word to spell
|
|
98
|
+
* @returns Spelling effort score
|
|
99
|
+
*/
|
|
100
|
+
function spellingEffort(word) {
|
|
101
|
+
return 10 + word.length * 2.5;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Calculate base board effort
|
|
105
|
+
* Combines button size and field size efforts
|
|
106
|
+
*
|
|
107
|
+
* @param rows - Number of rows in the grid
|
|
108
|
+
* @param cols - Number of columns in the grid
|
|
109
|
+
* @param buttonCount - Number of visible buttons
|
|
110
|
+
* @returns Base board effort score
|
|
111
|
+
*/
|
|
112
|
+
function baseBoardEffort(rows, cols, buttonCount) {
|
|
113
|
+
const sizeEffort = buttonSizeEffort(rows, cols);
|
|
114
|
+
const fieldEffort = fieldSizeEffort(buttonCount);
|
|
115
|
+
return sizeEffort + fieldEffort;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Apply reuse discount based on semantic_id/clone_id frequency
|
|
119
|
+
*
|
|
120
|
+
* @param boardEffort - Current board effort
|
|
121
|
+
* @param reuseDiscount - Calculated reuse discount
|
|
122
|
+
* @returns Adjusted board effort
|
|
123
|
+
*/
|
|
124
|
+
function applyReuseDiscount(boardEffort, reuseDiscount) {
|
|
125
|
+
return Math.max(0, boardEffort - reuseDiscount);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Calculate button-level effort with motor planning discounts
|
|
129
|
+
*
|
|
130
|
+
* @param baseEffort - Base board effort
|
|
131
|
+
* @param boardPcts - Percentage of links matching semantic_id/clone_id
|
|
132
|
+
* @param button - Button data
|
|
133
|
+
* @returns Adjusted button effort
|
|
134
|
+
*/
|
|
135
|
+
function calculateButtonEffort(baseEffort, boardPcts, button) {
|
|
136
|
+
let buttonEffort = baseEffort;
|
|
137
|
+
// Apply discounts for semantic_id
|
|
138
|
+
if (button.semantic_id && boardPcts[button.semantic_id]) {
|
|
139
|
+
const discount = exports.EFFORT_CONSTANTS.SAME_LOCATION_AS_PRIOR_DISCOUNT / boardPcts[button.semantic_id];
|
|
140
|
+
buttonEffort = Math.min(buttonEffort, buttonEffort * discount);
|
|
141
|
+
}
|
|
142
|
+
// Apply discounts for clone_id
|
|
143
|
+
if (button.clone_id && boardPcts[button.clone_id]) {
|
|
144
|
+
const discount = exports.EFFORT_CONSTANTS.SAME_LOCATION_AS_PRIOR_DISCOUNT / boardPcts[button.clone_id];
|
|
145
|
+
buttonEffort = Math.min(buttonEffort, buttonEffort * discount);
|
|
146
|
+
}
|
|
147
|
+
return buttonEffort;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Calculate distance with motor planning discounts
|
|
151
|
+
*
|
|
152
|
+
* @param distance - Raw distance effort
|
|
153
|
+
* @param boardPcts - Percentage of links matching semantic_id/clone_id
|
|
154
|
+
* @param button - Button data
|
|
155
|
+
* @param setPcts - Percentage of boards containing semantic_id/clone_id
|
|
156
|
+
* @returns Adjusted distance effort
|
|
157
|
+
*/
|
|
158
|
+
function calculateDistanceWithDiscounts(distance, boardPcts, button, setPcts) {
|
|
159
|
+
let adjustedDistance = distance;
|
|
160
|
+
// Apply semantic_id discounts
|
|
161
|
+
if (button.semantic_id) {
|
|
162
|
+
if (boardPcts[button.semantic_id]) {
|
|
163
|
+
const discount = exports.EFFORT_CONSTANTS.SAME_LOCATION_AS_PRIOR_DISCOUNT / boardPcts[button.semantic_id];
|
|
164
|
+
adjustedDistance = Math.min(adjustedDistance, adjustedDistance * discount);
|
|
165
|
+
}
|
|
166
|
+
else if (setPcts[button.semantic_id]) {
|
|
167
|
+
const discount = exports.EFFORT_CONSTANTS.RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT / setPcts[button.semantic_id];
|
|
168
|
+
adjustedDistance = Math.min(adjustedDistance, adjustedDistance * discount);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Apply clone_id discounts
|
|
172
|
+
if (button.clone_id) {
|
|
173
|
+
if (boardPcts[button.clone_id]) {
|
|
174
|
+
const discount = exports.EFFORT_CONSTANTS.SAME_LOCATION_AS_PRIOR_DISCOUNT / boardPcts[button.clone_id];
|
|
175
|
+
adjustedDistance = Math.min(adjustedDistance, adjustedDistance * discount);
|
|
176
|
+
}
|
|
177
|
+
else if (setPcts[button.clone_id]) {
|
|
178
|
+
const discount = exports.EFFORT_CONSTANTS.RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT / setPcts[button.clone_id];
|
|
179
|
+
adjustedDistance = Math.min(adjustedDistance, adjustedDistance * discount);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return adjustedDistance;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Check if visual scan should be skipped (button close to previous)
|
|
186
|
+
*
|
|
187
|
+
* @param distance - Distance from previous button
|
|
188
|
+
* @returns True if close enough to skip full visual scan
|
|
189
|
+
*/
|
|
190
|
+
function shouldSkipVisualScan(distance) {
|
|
191
|
+
return distance < exports.EFFORT_CONSTANTS.DISTANCE_THRESHOLD_TO_SKIP_VISUAL_SCAN;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Calculate local scan effort when buttons are close
|
|
195
|
+
*
|
|
196
|
+
* @param distance - Distance between buttons
|
|
197
|
+
* @returns Local scan effort
|
|
198
|
+
*/
|
|
199
|
+
function localScanEffort(distance) {
|
|
200
|
+
return distance * exports.EFFORT_CONSTANTS.SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Calculate effort for switch scanning
|
|
204
|
+
*
|
|
205
|
+
* @param steps - Number of scan steps to reach target
|
|
206
|
+
* @param selections - Number of switch selections required
|
|
207
|
+
* @returns Scanning effort score
|
|
208
|
+
*/
|
|
209
|
+
function scanningEffort(steps, selections) {
|
|
210
|
+
return (steps * exports.EFFORT_CONSTANTS.SCAN_STEP_COST + selections * exports.EFFORT_CONSTANTS.SCAN_SELECTION_COST);
|
|
211
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AAC Metrics Module
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive metrics analysis for AAC board sets including:
|
|
5
|
+
* - Effort score calculation with motor planning
|
|
6
|
+
* - Vocabulary coverage analysis
|
|
7
|
+
* - Sentence construction evaluation
|
|
8
|
+
* - Comparative analysis between board sets
|
|
9
|
+
*/
|
|
10
|
+
export { MetricsCalculator } from './core';
|
|
11
|
+
export { VocabularyAnalyzer } from './vocabulary';
|
|
12
|
+
export { SentenceAnalyzer } from './sentence';
|
|
13
|
+
export { ComparisonAnalyzer } from './comparison';
|
|
14
|
+
export * from './types';
|
|
15
|
+
export * from './effort';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AAC Metrics Module
|
|
4
|
+
*
|
|
5
|
+
* Comprehensive metrics analysis for AAC board sets including:
|
|
6
|
+
* - Effort score calculation with motor planning
|
|
7
|
+
* - Vocabulary coverage analysis
|
|
8
|
+
* - Sentence construction evaluation
|
|
9
|
+
* - Comparative analysis between board sets
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ComparisonAnalyzer = exports.SentenceAnalyzer = exports.VocabularyAnalyzer = exports.MetricsCalculator = void 0;
|
|
27
|
+
var core_1 = require("./core");
|
|
28
|
+
Object.defineProperty(exports, "MetricsCalculator", { enumerable: true, get: function () { return core_1.MetricsCalculator; } });
|
|
29
|
+
var vocabulary_1 = require("./vocabulary");
|
|
30
|
+
Object.defineProperty(exports, "VocabularyAnalyzer", { enumerable: true, get: function () { return vocabulary_1.VocabularyAnalyzer; } });
|
|
31
|
+
var sentence_1 = require("./sentence");
|
|
32
|
+
Object.defineProperty(exports, "SentenceAnalyzer", { enumerable: true, get: function () { return sentence_1.SentenceAnalyzer; } });
|
|
33
|
+
var comparison_1 = require("./comparison");
|
|
34
|
+
Object.defineProperty(exports, "ComparisonAnalyzer", { enumerable: true, get: function () { return comparison_1.ComparisonAnalyzer; } });
|
|
35
|
+
__exportStar(require("./types"), exports);
|
|
36
|
+
__exportStar(require("./effort"), exports);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .obl (Open Board Logging) File Format Types
|
|
3
|
+
*
|
|
4
|
+
* Based on the .obl specification for AAC logging.
|
|
5
|
+
*/
|
|
6
|
+
export interface OblAction {
|
|
7
|
+
action: string;
|
|
8
|
+
destination_board_id?: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
modification_type?: string;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface OblEventBase {
|
|
14
|
+
id: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
type: 'button' | 'action' | 'utterance' | 'note' | 'other' | string;
|
|
17
|
+
locale?: string;
|
|
18
|
+
geo?: [number, number, number?];
|
|
19
|
+
location_id?: string;
|
|
20
|
+
modeling?: boolean;
|
|
21
|
+
system?: string;
|
|
22
|
+
window_width?: number;
|
|
23
|
+
window_height?: number;
|
|
24
|
+
percent_x?: number;
|
|
25
|
+
percent_y?: number;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
export interface OblButtonEvent extends OblEventBase {
|
|
29
|
+
type: 'button';
|
|
30
|
+
label: string;
|
|
31
|
+
spoken: boolean;
|
|
32
|
+
button_id?: string;
|
|
33
|
+
board_id?: string;
|
|
34
|
+
vocalization?: string;
|
|
35
|
+
image_url?: string;
|
|
36
|
+
actions?: OblAction[];
|
|
37
|
+
}
|
|
38
|
+
export interface OblActionEvent extends OblEventBase {
|
|
39
|
+
type: 'action';
|
|
40
|
+
action: string;
|
|
41
|
+
destination_board_id?: string;
|
|
42
|
+
text?: string;
|
|
43
|
+
modification_type?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface OblUtteranceEvent extends OblEventBase {
|
|
46
|
+
type: 'utterance';
|
|
47
|
+
text: string;
|
|
48
|
+
buttons?: Array<{
|
|
49
|
+
id?: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
board_id?: string;
|
|
52
|
+
vocalization?: string;
|
|
53
|
+
action?: string;
|
|
54
|
+
text?: string;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
export interface OblNoteEvent extends OblEventBase {
|
|
58
|
+
type: 'note';
|
|
59
|
+
text: string;
|
|
60
|
+
author_name?: string;
|
|
61
|
+
author_email?: string;
|
|
62
|
+
author_url?: string;
|
|
63
|
+
}
|
|
64
|
+
export type OblEvent = OblButtonEvent | OblActionEvent | OblUtteranceEvent | OblNoteEvent | OblEventBase;
|
|
65
|
+
export interface OblSession {
|
|
66
|
+
id: string;
|
|
67
|
+
type: 'log' | string;
|
|
68
|
+
started: string;
|
|
69
|
+
ended: string;
|
|
70
|
+
device_id?: string;
|
|
71
|
+
locale?: string;
|
|
72
|
+
anonymizations?: string[];
|
|
73
|
+
events: OblEvent[];
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
}
|
|
76
|
+
export interface OblFile {
|
|
77
|
+
format: 'open-board-log-0.1' | string;
|
|
78
|
+
user_id: string;
|
|
79
|
+
user_name?: string;
|
|
80
|
+
source?: string;
|
|
81
|
+
locale?: string;
|
|
82
|
+
anonymized?: boolean;
|
|
83
|
+
license?: {
|
|
84
|
+
type: string;
|
|
85
|
+
copyright_notice_url?: string;
|
|
86
|
+
source_url?: string;
|
|
87
|
+
author_name?: string;
|
|
88
|
+
author_url?: string;
|
|
89
|
+
author_email?: string;
|
|
90
|
+
};
|
|
91
|
+
sessions: OblSession[];
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { OblFile } from './obl-types';
|
|
2
|
+
import { HistoryEntry } from '../history';
|
|
3
|
+
/**
|
|
4
|
+
* .obl (Open Board Logging) Utility
|
|
5
|
+
*
|
|
6
|
+
* Provides parsing and generation support for the .obl format.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OblUtil {
|
|
9
|
+
/**
|
|
10
|
+
* Parse an OBL JSON string.
|
|
11
|
+
* Handles the optional /* notice * / at the start of the file.
|
|
12
|
+
*/
|
|
13
|
+
static parse(json: string): OblFile;
|
|
14
|
+
/**
|
|
15
|
+
* Stringify an OBL file object.
|
|
16
|
+
* Optionally adds the recommended notice comment.
|
|
17
|
+
*/
|
|
18
|
+
static stringify(obl: OblFile, includeNotice?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Convert an OBL file to internal HistoryEntry format.
|
|
21
|
+
*/
|
|
22
|
+
static toHistoryEntries(obl: OblFile): HistoryEntry[];
|
|
23
|
+
/**
|
|
24
|
+
* Convert HistoryEntries to an OBL file object.
|
|
25
|
+
*/
|
|
26
|
+
static fromHistoryEntries(entries: HistoryEntry[], userId: string, source?: string): OblFile;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* .obl Anonymization Utility
|
|
30
|
+
*/
|
|
31
|
+
export declare class OblAnonymizer {
|
|
32
|
+
/**
|
|
33
|
+
* Apply anonymization to an OBL file.
|
|
34
|
+
*/
|
|
35
|
+
static anonymize(obl: OblFile, types: string[]): OblFile;
|
|
36
|
+
private static applyTimestampShift;
|
|
37
|
+
private static applyGeolocationMasking;
|
|
38
|
+
private static applyUrlStripping;
|
|
39
|
+
private static applyNameMasking;
|
|
40
|
+
}
|