Skip to content

Commit

Permalink
Improve language detection process.
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-plus committed Feb 29, 2024
1 parent 658e7c4 commit 2321ad0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions openlrc/prompter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ def check_format(self, messages, content):
translation_chunks[-2].extend(translation_chunks[-1])
translation_chunks.pop()

translated_langs = [self.lan_detector.detect_language_of(' '.join(chunk)).name.lower()
for chunk in translation_chunks]
translated_langs = [self.lan_detector.detect_language_of(' '.join(chunk)) for chunk in translation_chunks]
translated_langs = [lang.name.lower() for lang in translated_langs if lang]

if not translated_langs:
# Cant detect language
return True

# get the most common language
translated_lang = max(set(translated_langs), key=translated_langs.count)
Expand Down

0 comments on commit 2321ad0

Please sign in to comment.