CoolFace
Apppublic

CalebKoster/Translation_Note_Alignment

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
LanguageTool.py14 linesDownload Raw Back to root
1from langdetect import detect2import pycountry3import langid4 5class Lang:6    def __init__(self, text, options=None):7        if options:8            langid.set_languages(options) # ISO 639-1 codes9            self.lang_code, _ = langid.classify(text)10        else:11            self.lang_code = detect(text[:1000])12        13        14        self.lang_name = pycountry.languages.get(alpha_2=self.lang_code).name