Skip to content

Individual orthographies not detected by CharsetChecker #185

@arialcrime

Description

@arialcrime

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)

from hyperglot.languages import Languages
from hyperglot.checker import CharsetChecker

tag = "srp" # different, but somewhat comparable issue also showed up with "uzn"

char_dict = dict()

for o in Languages()[tag]["orthographies"]:
    if not o["script"] in char_dict:
        char_dict[o["script"]] = ""
    # combine base, aux, and marks into one string to use in checking later
    char_dict[o["script"]] = " ".join([o["base"], o["auxiliary"], o["marks"]])

# go through scripts individually and check for support
for script, characters in char_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 True
all_chars = " ".join([c for s, c in char_dict.items()])
print("ALL", CharsetChecker(all_chars).supports_language(tag))

Hyperglot version: 0.7.1

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions