Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caught an IndexError while using detect_multiple_languages_of #98

Closed
Saninsusanin opened this issue Dec 27, 2022 · 1 comment
Closed
Labels
bug Something isn't working
Milestone

Comments

@Saninsusanin
Copy link

Saninsusanin commented Dec 27, 2022

On the test_case:

, Ресторан «ТИНАТИН»

Code fell down with an error:

Traceback (most recent call last):
  File "/home/essential/PycharmProjects/pythonProject/test_unnest.py", line 363, in <module>
    for lang, sentence in detector.detect_multiple_languages_of(text)
  File "/home/essential/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/lingua/detector.py", line 389, in detect_multiple_languages_of
    _merge_adjacent_results(results, mergeable_result_indices)
  File "/home/essential/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/lingua/detector.py", line 114, in _merge_adjacent_results
    end_index=results[i + 1].end_index,
IndexError: list index out of range

Code example:

languages = [Language.ENGLISH, Language.RUSSIAN, Language.UKRAINIAN]
detector = LanguageDetectorBuilder.from_languages(*languages).build()
text = ', Ресторан «ТИНАТИН»'
sentences = [(lang, sentence) for lang, sentence in detector.detect_multiple_languages_of(text)]
@pemistahl pemistahl added the bug Something isn't working label Dec 27, 2022
pemistahl added a commit that referenced this issue Dec 27, 2022
@pemistahl pemistahl added this to the Lingua 1.2.0 milestone Dec 27, 2022
@pemistahl
Copy link
Owner

Thank you @Saninsusanin for reporting this bug. I've just fixed it. Please update Lingua to version 1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants