From 2134eb842bfdf80c264b1eeeb5e6cbd3d0bc8b02 Mon Sep 17 00:00:00 2001 From: Ren Tatsumoto Date: Tue, 6 Aug 2024 10:36:31 +0300 Subject: [PATCH] fix full width to half width numbers --- merge_notes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/merge_notes.py b/merge_notes.py index f451649..7681848 100644 --- a/merge_notes.py +++ b/merge_notes.py @@ -4,8 +4,8 @@ import itertools import re import unicodedata -from typing import Any from collections.abc import Sequence, Iterator, Iterable +from typing import Any from anki import collection from anki.cards import Card, CardId @@ -25,6 +25,8 @@ # Utils ###################################################################### +NUMBERS = str.maketrans("0123456789", "0123456789") + def strip_html(s: str) -> str: return strip_html_media(s).strip() @@ -38,7 +40,7 @@ def strip_punctuation(s: str) -> str: def full_width_to_half_width(s: str) -> str: - return unicodedata.normalize("NFKC", s) + return unicodedata.normalize("NFKC", s).translate(NUMBERS) def remove_furigana(s: str):