v148 · Web APIs · AI
Confidence Meter
The Language Detector API returns a ranked list of language candidates with confidence scores, not just a single winner. Type or paste any text — or pick a sample — and the confidence meter visualises the top 3 candidates as percentage bars, updating live as you type. This reveals how confident the model is, and when texts genuinely ambiguous.
Input text
0 chars
Top language candidates
Enter some text to start detection…
Language Detector API returns ranked candidates with confidence scores (0–1). High confidence (>0.9) means unambiguous; near-equal scores mean genuinely ambiguous text.
// Chrome 148: Language Detector API with confidence scores
const detector = await LanguageDetector.create({
expectedInputLanguages: ['en', 'fr', 'de', 'es', 'zh', 'ja', 'ar']
});
const results = await detector.detect('Bonjour le monde');
// results is an array ordered by confidence (highest first)
results.forEach(r => {
console.log(r.detectedLanguage, r.confidence);
// 'fr' 0.97
// 'it' 0.02
// 'es' 0.01
});
// Confidence thresholds
const topResult = results[0];
if (topResult.confidence > 0.5) {
console.log('Detected:', topResult.detectedLanguage);
} else {
console.log('Ambiguous — confidence too low');
}
see also
- Language Sniffer — basic detection demo
- Multilingual Sorter — sort by language
- Content Router — route by language
- Live Language Badge — per-element badges
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗