Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /ai/language_detection/detector.https.tentative.window.html - WPT Dashboard Interop Dashboard
// META: title=Detect english
'use strict';
promise_test(async t => {
const detector = await ai.languageDetector.create();
const results = await detector.detect("this string is in English");
// "en" should be highest confidence.
assert_equals(results[0].detectedLanguage, "en");
// Results should be from high to low confidence.
for (let i = 0; i < results.length - 1; i++) {
assert_greater_than_equal(results[i].confidence, results[i + 1].confidence);
}
});