Skip to content

Commit

Permalink
Clean up variable names for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaprasad2000 committed Dec 18, 2023
1 parent 0ad4755 commit afcbf99
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions bindings/python/tests/test_iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit afcbf99

Please sign in to comment.