Skip to content

Commit fe13e5d

Browse files
committed
Mere fix/dictionary-partly-yoficated-word-lookup into master
2 parents bd7c82f + 3f628d7 commit fe13e5d

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- [ ] feature: add lint option
1414
- [ ] feature: add replacement stats
1515

16+
## [0.1.1] — 2025-03-02
17+
### Fixed
18+
19+
- fix: dictionary word lookup for party yoficated words, e.g. `четырЕхзвЁздный`, `четырЁхзвЕздный`
20+
1621
## [0.1.0] — 2025-02-16
1722

1823
`md.language.yofication` package initial version
@@ -71,4 +76,5 @@ Initial release
7176

7277
</details>
7378

79+
[0.1.1]: https://github.com/md-py/md.language.yofication/releases/tag/0.1.1
7480
[0.1.0]: https://github.com/md-py/md.language.yofication/releases/tag/0.1.0

lib/md/language/yofication/_yofication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ def __init__(self, dictionary: DictionaryType) -> None:
120120
self._dictionary[ye_word.lower()] = yo_word.lower()
121121

122122
def find(self, word: str) -> typing.Optional[str]:
123-
return self._dictionary.get(word, None)
123+
return self._dictionary.get(word.replace('ё', 'е'), None)
124124

125125
def has(self, word: str) -> bool:
126-
return word in self._dictionary
126+
return word.replace('ё', 'е') in self._dictionary
127127

128128

129129
class RegularExpressionYoficate(YoficateInterface):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def create_zip():
1616
create_zip()
1717
setuptools.setup(
1818
name='md.language.yofication',
19-
version='0.1.0',
19+
version='0.1.1',
2020
description='A Russian text yoficator (ёфикатор)',
2121
long_description=long_description,
2222
long_description_content_type='text/markdown',

tests/md/language/yofication/test_yofication.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ def test_has(self) -> None:
2727
assert mapping_dictionary.has(word='трехмерный') is True
2828
assert mapping_dictionary.has(word='четырехзвездный') is False
2929

30+
def test_find_partly_yoficated(self) -> None:
31+
# arrange
32+
dictionary = {'четырехзвездный': 'четырёхзвёздный'}
33+
34+
# act
35+
mapping_dictionary = md.language.yofication.MappingDictionary(dictionary=dictionary)
36+
37+
# assert
38+
assert mapping_dictionary.find(word='четырёхзвёздный') == 'четырёхзвёздный'
39+
assert mapping_dictionary.find(word='четырехзвёздный') == 'четырёхзвёздный'
40+
assert mapping_dictionary.find(word='четырёхзвездный') == 'четырёхзвёздный'
41+
assert mapping_dictionary.find(word='четырехзвездный') == 'четырёхзвёздный'
42+
43+
def test_has_partly_yoficated(self) -> None:
44+
# arrange
45+
dictionary = {'четырехзвездный': 'четырёхзвёздный'}
46+
47+
# act
48+
mapping_dictionary = md.language.yofication.MappingDictionary(dictionary=dictionary)
49+
50+
# assert
51+
assert mapping_dictionary.has(word='четырёхзвёздный') is True
52+
assert mapping_dictionary.has(word='четырехзвёздный') is True
53+
assert mapping_dictionary.has(word='четырёхзвездный') is True
54+
assert mapping_dictionary.has(word='четырехзвездный') is True
55+
3056

3157
class TestRegularExpressionYoficate(unittest.TestCase):
3258
def test_word(self) -> None:

0 commit comments

Comments
 (0)