UNPKG

@neuroequality/neuroadapt-core

Version:

Core sensory, cognitive, and preference management for NeuroAdapt SDK

102 lines (101 loc) 3.15 kB
import { EventEmitter } from 'eventemitter3'; import { CognitivePreferences } from '../preferences/schemas.js'; /** * Cognitive load tiers based on calculated scores */ export type CognitiveTier = 'low' | 'moderate' | 'high'; /** * Adaptation strategies for different cognitive load situations */ export type AdaptationStrategy = 'chunk' | 'offerBreak' | 'simplifyLanguage'; /** * Events emitted by CognitiveLoadEngine */ export interface CognitiveLoadEvents { 'load-score': (data: { score: number; tier: CognitiveTier; context?: string; }) => void; 'strategy-suggested': (strategy: AdaptationStrategy, context: string) => void; 'adaptation-applied': (strategy: AdaptationStrategy, result: string) => void; } /** * Text metrics for cognitive load calculation */ export interface TextMetrics { wordCount: number; sentenceCount: number; averageWordsPerSentence: number; complexWords: number; readingTimeEstimate: number; fleschScore: number; denseSections: string[]; } /** * Configuration for cognitive load analysis */ export interface CognitiveLoadConfig { preferences: CognitivePreferences; sessionMemory?: boolean; adaptationThreshold?: number; } /** * Adaptation strategy function type */ export type StrategyFunction = (text: string, context?: string) => string; /** * CognitiveLoadEngine analyzes text and user interactions to detect * cognitive overload and suggest appropriate adaptations */ export declare class CognitiveLoadEngine extends EventEmitter<CognitiveLoadEvents> { private readonly preferences; private readonly sessionMemory; private readonly strategies; private readonly memoryEnabled; private readonly adaptationThreshold; constructor(config: CognitiveLoadConfig); /** * Analyze text and calculate cognitive load score */ analyzeText(text: string, context?: string): TextMetrics; /** * Estimate reading time for given text based on user preferences */ readingTimeEstimate(text: string): number; /** * Identify dense sections that may cause cognitive overload */ denseSections(text: string): string[]; /** * Apply adaptation strategy to text */ applyStrategy(strategy: AdaptationStrategy, text: string, context?: string): string; /** * Register a custom adaptation strategy */ registerStrategy(name: AdaptationStrategy, fn: StrategyFunction): void; /** * Clear session memory */ clearMemory(): void; /** * Get current cognitive load tier based on score */ getCognitiveTier(score: number): CognitiveTier; private calculateTextMetrics; private calculateCognitiveScore; private adjustForPreferences; private suggestAdaptation; private initializeStrategies; private getReadingSpeed; private getComplexityFactor; private countWords; private splitIntoSentences; private countComplexWords; private isComplexWord; private countSyllables; private isDenseSentence; private calculateFleschScore; } //# sourceMappingURL=load-engine.d.ts.map