CalebKoster/Translation_Note_Alignment
0
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