/** * Effort Score Calculation Algorithms * * Implements the core effort calculation algorithms from the Ruby aac-metrics tool. * These algorithms calculate how difficult it is to access each button based on * distance, visual scanning, grid complexity, and motor planning support. */ /** * Constants for effort score calculation * Values match the Ruby implementation exactly */ export declare const EFFORT_CONSTANTS: { readonly SQRT2: number; readonly BUTTON_SIZE_MULTIPLIER: 0.09; readonly FIELD_SIZE_MULTIPLIER: 0.005; readonly VISUAL_SCAN_MULTIPLIER: 0.015; readonly BOARD_CHANGE_PROCESSING_EFFORT: 1; readonly BOARD_HOME_EFFORT: 1; readonly COMBINED_WORDS_REMEMBERING_EFFORT: 1; readonly DISTANCE_MULTIPLIER: 0.4; readonly DISTANCE_THRESHOLD_TO_SKIP_VISUAL_SCAN: 0.1; readonly SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER: 0.5; readonly SAME_LOCATION_AS_PRIOR_DISCOUNT: 0.1; readonly RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT: 0.5; readonly RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT: 0.5; readonly REUSED_SEMANTIC_FROM_OTHER_BONUS: 0.0025; readonly RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT: 0.33; readonly RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT: 0.33; readonly REUSED_CLONE_FROM_OTHER_BONUS: 0.005; readonly SCAN_STEP_COST: 0.015; readonly SCAN_SELECTION_COST: 0.1; readonly DEFAULT_SCAN_ERROR_RATE: 0.1; readonly SCAN_RETRY_PENALTY: 1; readonly SUGGEST_WORDS_SELECTION_EFFORT: 0.5; readonly TDSNAP_GRAMMAR_OVERLAY_EFFORT: 0.1; }; /** * Calculate button size effort based on grid dimensions * Larger grids require more visual scanning and discrimination * * @param rows - Number of rows in the grid * @param cols - Number of columns in the grid * @returns Button size effort score */ export declare function buttonSizeEffort(rows: number, cols: number): number; /** * Calculate field size effort based on number of visible buttons * More buttons = more visual clutter = higher effort * * @param buttonCount - Number of visible buttons on the board * @returns Field size effort score */ export declare function fieldSizeEffort(buttonCount: number): number; /** * Calculate visual scanning effort * Effort increases with each button that must be scanned before reaching target * * @param priorButtons - Number of buttons visually scanned before target * @returns Visual scan effort score */ export declare function visualScanEffort(priorButtons: number): number; /** * Calculate distance effort from entry point to button center * Uses Euclidean distance normalized by sqrt(2) * * @param x - Button center X coordinate (0-1 normalized) * @param y - Button center Y coordinate (0-1 normalized) * @param entryX - Entry point X coordinate (0-1 normalized, default 1.0 = bottom-right) * @param entryY - Entry point Y coordinate (0-1 normalized, default 1.0 = bottom-right) * @returns Distance effort score */ export declare function distanceEffort(x: number, y: number, entryX?: number, entryY?: number): number; /** * Calculate spelling effort for words not available in the board set * * @param word - The word to spell * @param entryEffort - Effort to reach the spelling/keyboard page * @param perLetterEffort - Average effort per letter on the keyboard * @returns Spelling effort score */ export declare function spellingEffort(word: string, entryEffort?: number, perLetterEffort?: number): number; /** * Calculate effort to access a word via prediction * * When prediction is available, the user: * 1. Navigates to the spelling/keyboard page (entryEffort) * 2. Types first 1-3 letters to trigger predictions * 3. Selects from 1-3 predictions (average selections) * * @param entryEffort - Effort to reach the spelling/keyboard page * @param perLetterEffort - Average effort per letter on the keyboard * @param avgSelections - Average number of predictions to check (default 1.5) * @param lettersToType - Letters to type before prediction appears (default 2) * @returns Prediction effort score */ export declare function predictionEffort(entryEffort?: number, perLetterEffort?: number, avgSelections?: number, lettersToType?: number): number; /** * Calculate base board effort * Combines button size and field size efforts * * @param rows - Number of rows in the grid * @param cols - Number of columns in the grid * @param buttonCount - Number of visible buttons * @returns Base board effort score */ export declare function baseBoardEffort(rows: number, cols: number, buttonCount: number): number; /** * Apply reuse discount based on semantic_id/clone_id frequency * * @param boardEffort - Current board effort * @param reuseDiscount - Calculated reuse discount * @returns Adjusted board effort */ export declare function applyReuseDiscount(boardEffort: number, reuseDiscount: number): number; /** * Calculate button-level effort with motor planning discounts * * @param baseEffort - Base board effort * @param boardPcts - Percentage of links matching semantic_id/clone_id * @param button - Button data * @returns Adjusted button effort */ export declare function calculateButtonEffort(baseEffort: number, boardPcts: { [id: string]: number; }, button: { semantic_id?: string; clone_id?: string; }): number; /** * Calculate distance with motor planning discounts * * @param distance - Raw distance effort * @param boardPcts - Percentage of links matching semantic_id/clone_id * @param button - Button data * @param setPcts - Percentage of boards containing semantic_id/clone_id * @returns Adjusted distance effort */ export declare function calculateDistanceWithDiscounts(distance: number, boardPcts: { [id: string]: number; }, button: { semantic_id?: string; clone_id?: string; }, setPcts: { [id: string]: number; }): number; /** * Check if visual scan should be skipped (button close to previous) * * @param distance - Distance from previous button * @returns True if close enough to skip full visual scan */ export declare function shouldSkipVisualScan(distance: number): boolean; /** * Calculate local scan effort when buttons are close * * @param distance - Distance between buttons * @returns Local scan effort */ export declare function localScanEffort(distance: number): number; /** * Calculate effort for switch scanning * * @param steps - Number of scan steps to reach target * @param selections - Number of switch selections required * @param stepCost - Optional override for scan step cost * @param selectionCost - Optional override for scan selection cost * @returns Scanning effort score */ export declare function scanningEffort(steps: number, selections: number, stepCost?: number, selectionCost?: number): number;