Skip to content

Commit 9703bdb

Browse files
committed
Use pymorphy3 instead of pymorphy2
1 parent 9fa6f67 commit 9703bdb

File tree

5 files changed

+66
-35
lines changed

5 files changed

+66
-35
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: ["3.8", "3.9", "3.10"] # Not 3.11 yet, because pymorphy2 is not updated to 3.11
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1616

1717
steps:
1818
- uses: actions/checkout@v4

changetext/utils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import re
22
from typing import Iterable, Iterator, List, Optional, Set, Tuple, Union, cast
33

4-
import pymorphy2
5-
from pymorphy2.analyzer import Parse
6-
from pymorphy2.tagset import OpencorporaTag
4+
import pymorphy3
5+
from pymorphy3.analyzer import Parse
6+
from pymorphy3.tagset import OpencorporaTag
77

8-
morph = pymorphy2.MorphAnalyzer()
8+
morph = pymorphy3.MorphAnalyzer()
99
unwanted_tags = ("Name", "Surn", "Infr")
1010

1111

1212
def custom_parse(word: str) -> List[Parse]:
1313
if word.lower().startswith("адамантин"):
14-
return morph.parse(word) # Pymorphy2 thinks that adamantine is a surname and treats it properly
14+
return morph.parse(word) # Pymorphy thinks that adamantine is a surname and treats it properly
1515

1616
return [p for p in morph.parse(word) if all(tag not in p.tag for tag in unwanted_tags)]
1717

@@ -390,7 +390,7 @@ def pm_gender(parse: Parse) -> str:
390390
else:
391391
gender = tag.gender
392392

393-
return str(gender) # explicitly convert to a string any internal types returned from pymorphy2
393+
return str(gender) # explicitly convert to a string any internal types returned from pymorphy
394394

395395

396396
def get_gender(obj: str, known_tags: Union[None, str, Set[str]] = None) -> Optional[str]:

poetry.lock

+57-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.toml

-2
This file was deleted.

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ authors = ["insolor <[email protected]>"]
66
license = "MIT"
77

88
[tool.poetry.dependencies]
9-
python = "^3.8"
10-
pymorphy2 = "^0.9.1"
9+
python = "^3.9"
10+
pymorphy3 = "^2.0.2"
1111

1212
[tool.poetry.group.dev.dependencies]
1313
flake8 = "^5.0.4"

0 commit comments

Comments
 (0)