New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lingua.Unknown
is not handled appropriately if included in the set of input languages
#7
Comments
Thank you for reporting this @marians. Can you please show me your code which calls the library? When exactly did this error occur? I need more context to find out what's going on. |
The code is not public currently. I'll copy a reduced version of my invocation here. languages := []lingua.Language{
lingua.Albanian,
lingua.Basque,
lingua.Bosnian,
lingua.Bulgarian,
lingua.Chinese,
lingua.Catalan,
lingua.Croatian,
lingua.Czech,
lingua.Danish,
lingua.Dutch,
lingua.English,
lingua.Estonian,
lingua.Finnish,
lingua.French,
lingua.German,
lingua.Greek,
lingua.Hungarian,
lingua.Italian,
lingua.Japanese,
lingua.Latvian,
lingua.Lithuanian,
lingua.Macedonian,
lingua.Polish,
lingua.Portuguese,
lingua.Romanian,
lingua.Serbian,
lingua.Slovak,
lingua.Slovene,
lingua.Spanish,
lingua.Swedish,
lingua.Unknown,
}
detector := lingua.NewLanguageDetectorBuilder().
FromLanguages(languages...).
Build()
// This part is called within a loop for many different text values.
confidenceValues := detector.ComputeLanguageConfidenceValues(text)
if len(confidenceValues) > 0 {
result := confidenceValues[0].Language().IsoCode639_1().String()
} |
Ah, I think I know what's wrong. You are trying to build the language detector by including For the time being, please remove |
Thanks for the info! My expectation (without reading up in this) was that having |
Well, one could guess so. But no, if the language cannot be reliably detected, |
loadJson()
does not handle errors, can cause nil pointer paniclingua.Unknown
is not handled appropriately if included in the set of input languages
I have started testing the library a few days ago and just saw a first nil pointer panic like this:
Seems as if even reading from an embed File can fail at some point.
I'm using
go version go1.17.2 darwin/amd64
.The text was updated successfully, but these errors were encountered: