guess(utterance, allowList, limit) { const options = {}; if (utterance.length < 10) { options.minLength = utterance.length; } if (allowList && allowList.length && allowList.length > 0) { options.allowList = this.transformAllowList(allowList); } const scores = Language.detectAll(utterance, options); const result = []; for (let i = 0; i < scores.length; i += 1) { const language = this.languagesAlpha3[scores[i][0]]; if (language) { result.push({ alpha3: language.alpha3, alpha2: language.alpha2, language: language.name, score: scores[i][1], }); if (limit && result.length >= limit) { break; } } } return result; }
guess(utterance, allowList, limit) { const options = {}; if (utterance.length < 10) { options.minLength = utterance.length; } if (allowList && allowList.length && allowList.length > 0) { options.allowList = this.transformAllowList(allowList); } const scores = Language.detectAll(utterance, options); const result = []; for (let i = 0; i < scores.length; i += 1) { const language = this.languagesAlpha3[scores[i][0]]; if (language) { result.push({ alpha3: language.alpha3, alpha2: language.alpha2, language: language.name, score: scores[i][1], }); if (limit && result.length >= limit) { break; } } } return result; }