diff --git a/bindings/python/tests/test_iterators.py b/bindings/python/tests/test_iterators.py index f97803a7..5e58448e 100644 --- a/bindings/python/tests/test_iterators.py +++ b/bindings/python/tests/test_iterators.py @@ -9,32 +9,36 @@ def test_iterators(service, models): target = response.target text = target.text - sen_iter_tgt = iterators.sentences(target) - word_iter_global = iterators.words(target) + sentences = iterators.sentences(target) + words = iterators.words(target) sentence_count = target.sentence_count() - for sentence_idx, word_iter in zip(range(sentence_count), sen_iter_tgt): + for sentence_idx, word_iter in zip(range(sentence_count), sentences): word_count = target.word_count(sentence_idx) for word_idx, word in zip(range(word_count), word_iter.words()): - expected_text_range = target.word_as_range(sentence_idx, word_idx) - reconstructed_text_range = word.range() + expected_range = target.word_as_range(sentence_idx, word_idx) + expected_word = text[expected_range.begin:expected_range.end] # For Sentence Iterator and Word Iterator - assert expected_text_range.begin == reconstructed_text_range.begin - assert expected_text_range.end == reconstructed_text_range.end + # Range + reconstructed = word.range() - expected_word = text[expected_text_range.begin:expected_text_range.end] - reconstructed_word = word.surface() + assert expected_range.begin == reconstructed.begin + assert expected_range.end == reconstructed.end - assert expected_word == reconstructed_word - - word_global = next(word_iter_global) - - reconstructed_text_range_glob = word_global.range() - reconstructed_word_glob = word_global.surface() + # Word + reconstructed = word.surface() + assert expected_word == reconstructed # For Global Word Iterator - assert expected_text_range.begin == reconstructed_text_range_glob.begin - assert expected_text_range.end == reconstructed_text_range_glob.end - assert expected_word == reconstructed_word_glob + word_global = next(words) + + # Range + reconstructed = word_global.range() + assert expected_range.begin == reconstructed.begin + assert expected_range.end == reconstructed.end + + # Word + reconstructed = word_global.surface() + assert expected_word == reconstructed