From f39a6096909a24ef45cd99d438673c013700e79e Mon Sep 17 00:00:00 2001 From: tpdn <747311+tpdn@users.noreply.github.com> Date: Sat, 28 Oct 2023 10:40:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?mojimoji=E3=82=92=E4=BD=BF=E3=82=8F?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=BD=A2=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ja_timex/number_normalizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ja_timex/number_normalizer.py b/ja_timex/number_normalizer.py index 2afe160..acbf98d 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 @@ -134,7 +134,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) From 7b7391b202dc177946e559b30643c976a38bc7ed Mon Sep 17 00:00:00 2001 From: tpdn <747311+tpdn@users.noreply.github.com> Date: Sat, 28 Oct 2023 10:41:49 +0900 Subject: [PATCH 2/2] =?UTF-8?q?mojimoji=E3=82=92=E5=AE=8C=E5=85=A8?= =?UTF-8?q?=E6=92=A4=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 23 ----------------------- pyproject.toml | 1 - 2 files changed, 24 deletions(-) diff --git a/poetry.lock b/poetry.lock index 465cffa..0720511 100644 --- a/poetry.lock +++ b/poetry.lock @@ -695,14 +695,6 @@ category = "dev" optional = false python-versions = ">=3.6" -[[package]] -name = "mojimoji" -version = "0.0.11" -description = "A fast converter between Japanese hankaku and zenkaku characters" -category = "main" -optional = false -python-versions = "*" - [[package]] name = "mypy" version = "0.910" @@ -1970,21 +1962,6 @@ mkdocs-material-extensions = [ {file = "mkdocs-material-extensions-1.0.3.tar.gz", hash = "sha256:bfd24dfdef7b41c312ede42648f9eb83476ea168ec163b613f9abd12bbfddba2"}, {file = "mkdocs_material_extensions-1.0.3-py3-none-any.whl", hash = "sha256:a82b70e533ce060b2a5d9eb2bc2e1be201cf61f901f93704b4acf6e3d5983a44"}, ] -mojimoji = [ - {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"}, -] mypy = [ {file = "mypy-0.910-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:a155d80ea6cee511a3694b108c4494a39f42de11ee4e61e72bc424c490e46457"}, {file = "mypy-0.910-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:b94e4b785e304a04ea0828759172a15add27088520dc7e49ceade7834275bedb"}, diff --git a/pyproject.toml b/pyproject.toml index 00eeef1..e23d7b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.7.1" -mojimoji = "^0.0.11" pendulum = "^2.1.2" [tool.poetry.dev-dependencies]