Skip to content

Commit

Permalink
Fix serious bug + add new test against it
Browse files Browse the repository at this point in the history
  • Loading branch information
Vuizur committed May 9, 2023
1 parent a090f08 commit 84feb91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions russian_text_stresser/russian_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def write_stressed_word(word: str, stressed_dict_word: str):
# This is needed because some canonical words are incorrect in the database
if char == "ё" or char == "Ё":
yo_in_wrd = word[index]
if yo_in_wrd == "е":
if yo_in_wrd == "е" or yo_in_wrd == "ё":
result_word += "ё"
elif yo_in_wrd == "Е":
elif yo_in_wrd == "Е" or yo_in_wrd == "Ё":
result_word += "Ё"
index += 1
elif char != "\u0301":
Expand Down
6 changes: 6 additions & 0 deletions russian_text_stresser/word_stress_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def test_bylo(self):
self.assertEqual(
self.stresser.stress_text("Это было давно."), "Э́то бы́ло давно́."
)

def test_yo_retaining(self):
self.assertEqual(
self.stresser.stress_text("Значит, спорить по этому поводу совершенно ни к чему, — твёрдо заключил Гарри."),
"Зна́чит, спо́рить по э́тому по́воду соверше́нно ни к чему́, — твёрдо заключи́л Га́рри.",
)

# SO FAR FAILING TESTS
def test_vselennaya(self):
Expand Down

0 comments on commit 84feb91

Please sign in to comment.