You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might very well be that I am misunderstanding/misusing something, but I think there is something odd about hyperglot’s CharsetChecker when it comes to Serbian.
Somehow it does not detect support for the individual orthographies. It only comes back True when both Latin and Cyrillic is supported.
Should I be approaching this somehow differently?
Is there a way for me to get the individual orthographies return True in this case?
Thanks for your help!
Here is some sample code to illustrate the issue I ran into:
(disclaimer: hyperglot feeding itself is for demostration purposes only here)
fromhyperglot.languagesimportLanguagesfromhyperglot.checkerimportCharsetCheckertag="srp"# different, but somewhat comparable issue also showed up with "uzn"char_dict=dict()
foroinLanguages()[tag]["orthographies"]:
ifnoto["script"] inchar_dict:
char_dict[o["script"]] =""# combine base, aux, and marks into one string to use in checking laterchar_dict[o["script"]] =" ".join([o["base"], o["auxiliary"], o["marks"]])
# go through scripts individually and check for supportforscript, charactersinchar_dict.items():
print(script.upper(), CharsetChecker(characters).supports_language(tag)) # check_all_orthographies=False does not change things here# Combining all characters across scripts returns Trueall_chars=" ".join([cfors, cinchar_dict.items()])
print("ALL", CharsetChecker(all_chars).supports_language(tag))
Hyperglot version: 0.7.1
The text was updated successfully, but these errors were encountered:
This is expected behavior, the logic being that both Cyrillic and Latin are indeed required to faithfully support Serbian (see wiki). It is my understanding that either script is valid and it is up to the publisher/media which they use. While Serbian can be written with either script, it is our interpretation that to claim support for Serbian as a whole, both scripts are required. There are only a few cases of such a requirement in the entire database, but where it is, this is intentional. Of course, feel free to debate this decision. :)
preferred_as_group (optional, defaults to false) will combine all orthographies of this language. When used, a language is detected as supported only if all its orthographies with this attribute are supported. This is used for Serbian to require both Cyrillic-script and Latin-script orthographies to be supported and for Japanese to require Hiragana, Katakana, and Kanji orthographies to be supported.
And for Serbian in particular it is set here and here.
It might very well be that I am misunderstanding/misusing something, but I think there is something odd about hyperglot’s CharsetChecker when it comes to Serbian.
Somehow it does not detect support for the individual orthographies. It only comes back True when both Latin and Cyrillic is supported.
Should I be approaching this somehow differently?
Is there a way for me to get the individual orthographies return True in this case?
Thanks for your help!
Here is some sample code to illustrate the issue I ran into:
(disclaimer: hyperglot feeding itself is for demostration purposes only here)
Hyperglot version: 0.7.1
The text was updated successfully, but these errors were encountered: