textconvert
Version:
Public library to convert text into many conventions and formats.
45 lines (44 loc) • 1.16 kB
TypeScript
/**
* Supported languages for detection
*/
export declare enum Language {
English = "english",
French = "french",
Spanish = "spanish",
German = "german",
Italian = "italian",
Portuguese = "portuguese",
Dutch = "dutch",
Unknown = "unknown"
}
/**
* Language detection result interface
*/
export interface LanguageDetectionResult {
/**
* The detected language
*/
language: Language;
/**
* Confidence score (0-1) of the detection
*/
confidence: number;
/**
* Scores for each language analyzed
*/
scores: Record<Language, number>;
}
/**
* Detects the most likely language of a given text
*
* @param text The text to analyze
* @param minLength Minimum text length for reliable detection (default: 4)
* @param options Additional options for detection
* @returns Language detection result with confidence score
* @example
* detectLanguage('Bonjour le monde'); // { language: 'French', ... }
*/
export declare function detectLanguage(text: string, minLength?: number, options?: {
maxCharsToAnalyze?: number;
useCache?: boolean;
}): LanguageDetectionResult;