diff --git a/ja_timex/number_normalizer.py b/ja_timex/number_normalizer.py index 03043f1..c24cc67 100644 --- a/ja_timex/number_normalizer.py +++ b/ja_timex/number_normalizer.py @@ -2,13 +2,13 @@ from dataclasses import dataclass from typing import List, Tuple -import mojimoji - zero = {"零": 0} +zen2han = {"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9} char2int = {"〇": 0, "一": 1, "二": 2, "三": 3, "四": 4, "五": 5, "六": 6, "七": 7, "八": 8, "九": 9} char2power_allow_head = {"十": 1, "百": 2, "千": 3} char2power = {"万": 4, "億": 8, "兆": 12, "京": 16, "垓": 20} char_int_table = str.maketrans({k: str(v) for k, v in char2int.items()}) +zen_han_table = str.maketrans({k: str(v) for k, v in zen2han.items()}) @dataclass @@ -133,7 +133,7 @@ def _normalize_zen_to_han(self, text: str) -> str: Returns: str: 半角に正規化した文字列 """ - text = mojimoji.zen_to_han(text, kana=False, ascii=False) + text = text.translate(zen_han_table) # 数字の間にはいる,や.の全角文字を半角にする re_match = re.search("[0-9][,.][0-9]", text) diff --git a/poetry.lock b/poetry.lock index 0c78c7e..8790aae 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1011,28 +1011,6 @@ files = [ {file = "mkdocs_material_extensions-1.3.tar.gz", hash = "sha256:f0446091503acb110a7cab9349cbc90eeac51b58d1caa92a704a81ca1e24ddbd"}, ] -[[package]] -name = "mojimoji" -version = "0.0.11" -description = "A fast converter between Japanese hankaku and zenkaku characters" -optional = false -python-versions = "*" -files = [ - {file = "mojimoji-0.0.11-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:b86ee36240e77a414f796630cf3c80acef4e9528277769d1851d00b94af1cc98"}, - {file = "mojimoji-0.0.11-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:3d3756f60754ee95847f419f48246a68271d9024c5296d298054229403804002"}, - {file = "mojimoji-0.0.11-cp35-cp35m-win_amd64.whl", hash = "sha256:e257176fe55332ac5dc69735270840b36738a82f1dda3383758a6f36b5918fb6"}, - {file = "mojimoji-0.0.11-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:ece991b6529dddb91ae5035dcf3b62b486af675d4ec94fc3ecf7872b66f3df88"}, - {file = "mojimoji-0.0.11-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:b7a1fe5726ad7036b096d44e7d014ceac174aec718199e19c6c6d1c2a757f6b9"}, - {file = "mojimoji-0.0.11-cp36-cp36m-win_amd64.whl", hash = "sha256:ae2fcb9fa35f5890ba888780c9d445074717ef988c3171a058f002cd0f3933f4"}, - {file = "mojimoji-0.0.11-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:e551bb3be777643e2e1f7bc40db4d57baedaa6dac6c7875d9a926ffe66b67fb1"}, - {file = "mojimoji-0.0.11-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:642c5e8642fa53c9556cd4c880e09438786dd955c32c7ce5fa2693e16914cdb6"}, - {file = "mojimoji-0.0.11-cp37-cp37m-win_amd64.whl", hash = "sha256:029c5d2646c8ab36bef61abe26ed6bc698f7ffb6a744d82fafd86e233d6669a2"}, - {file = "mojimoji-0.0.11-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:2fb18323ffae39391d77c77b27ed675cbf6e49e10f884ceaf8399be7ca7e0dc5"}, - {file = "mojimoji-0.0.11-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:ea9c3d0c37ae7a8e494cb9681dae404de4599d4218e5b5d13c009ab1856d6409"}, - {file = "mojimoji-0.0.11-cp38-cp38-win_amd64.whl", hash = "sha256:304681e2d99db69c552e1e36992cb41b967b46abd1720c1826f9dec678491d56"}, - {file = "mojimoji-0.0.11.tar.gz", hash = "sha256:adef094e1bfd961e40c1fbd2d4664da1be2426d5b31884e27394226af15d50b5"}, -] - [[package]] name = "mypy" version = "1.6.0" diff --git a/pyproject.toml b/pyproject.toml index fbf7340..4055eb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.8.1" -mojimoji = "^0.0.11" pendulum = "^2.1.2" [tool.poetry.group.dev.dependencies]