nitotm / efficient-language-detector-js

Fast and accurate natural language detection. Detector written in Javascript. Nito-ELD, ELD.
Apache License 2.0
37 stars 5 forks source link

Wrong charset detection when limitting the subsets #2

Closed albertmir closed 1 day ago

albertmir commented 1 week ago

Hi! Right now some charsets seem not to be supported when subsets are limitted. For example:

const langSubset = ['en', 'es'];
console.log(eld.detect('Cześć! Jak się masz?').language);
console.log(eld.detect('नमस्कार! अहांक कोना छी?').language);

Throws an error:

file:///Users/myusername/app/node_modules/eld/src/languageDetector.js:62
    language = languageData.langCodes[results[0][0]]
                                                ^

TypeError: Cannot read properties of undefined (reading '0')
    at Object.detect (file:///Users/myusername/app/node_modules/eld/src/languageDetector.js:62:49)

Thanks!

nitotm commented 6 days ago

Fixed. I did NOT rebuild the minified files.