/** * Language Detector - Main detection class */ import type { DetectionResult, ModelData, ModelSize } from '../types'; /** * Options for setAllowedLanguages */ export interface AllowedLanguagesOptions { /** * When true, only computes probabilities for allowed languages (faster). * When false (default), computes all probabilities to detect "neither" case. * @default false */ fastMode?: boolean; } export declare class LanguageDetector { private _vectorizer; private _classifier; private _loaded; private _config; private _allowedLanguages; private _fastMode; constructor(); get isLoaded(): boolean; get supportedLanguages(): string[]; /** * Get the currently allowed languages for detection * Returns null if all languages are allowed */ get allowedLanguages(): string[] | null; /** * Get whether fast mode is enabled * Fast mode skips "neither" detection for better performance */ get fastMode(): boolean; /** * Limit detection to specific languages only * When set, the detector will only return one of these languages * @param languages - Array of language codes to allow (e.g., ['en', 'es']) * @param options - Optional settings * @param options.fastMode - When true, skips "neither" detection for ~3x speedup (default: false) * @returns this for chaining */ setAllowedLanguages(languages: string[], options?: AllowedLanguagesOptions): this; /** * Clear language restrictions, allowing all supported languages * Also resets fastMode to false * @returns this for chaining */ clearAllowedLanguages(): this; /** * Load model from JSON data */ loadModel(modelData: ModelData): this; /** * Load model from file path */ loadFromFile(filePath: string): this; /** * Detect language of text */ detect(text: string | null | undefined): DetectionResult; /** * Detect language for multiple texts */ detectBatch(texts: string[]): DetectionResult[]; /** * Ensure model is loaded before detection */ private _ensureModelLoaded; /** * ML-based detection with slang override/fallback */ private _detectWithML; } /** * Resolve the bundled model path for a given size. * Works whether running from source (models/) or installed (dist/models/). */ export declare function getModelPath(size?: ModelSize): string; /** * Get or create a detector instance for the given model size. * Uses the bundled model from the package's own models/ directory. */ export declare function getDetector(size?: ModelSize): LanguageDetector; /** * Get or create a detector instance from an explicit file path. * @deprecated Pass a ModelSize instead: getDetector('large') */ export declare function getDetector(modelPath: string): LanguageDetector; /** * Reset singleton instances (useful for testing). * Pass a size to reset only that instance, or omit to reset all. */ export declare function resetDetector(size?: ModelSize): void; //# sourceMappingURL=detector.d.ts.map