| 1 |
From: YOKOTA Hiroshi <[email protected]> |
| 2 |
Date: Mon, 6 Apr 2026 08:21:17 +0900 |
| 3 |
Subject: Use system dictionary data for pykakasi |
| 4 |
|
| 5 |
Upstream Calibre uses own path for pykakasi dictionary data. |
| 6 |
|
| 7 |
Forwarded: not-needed |
| 8 |
--- |
| 9 |
src/calibre/ebooks/unihandecode/jadecoder.py | 33 ---------------------------- |
| 10 |
1 file changed, 33 deletions(-) |
| 11 |
|
| 12 |
diff --git a/src/calibre/ebooks/unihandecode/jadecoder.py b/src/calibre/ebooks/unihandecode/jadecoder.py |
| 13 |
index e731e58..48dcf30 100644 |
| 14 |
--- a/src/calibre/ebooks/unihandecode/jadecoder.py |
| 15 |
+++ b/src/calibre/ebooks/unihandecode/jadecoder.py |
| 16 |
@@ -14,7 +14,6 @@ This functionality is owned by Kakasi Japanese processing engine. |
| 17 |
Copyright (c) 2010 Hiroshi Miura |
| 18 |
""" |
| 19 |
|
| 20 |
-import pickle |
| 21 |
import re |
| 22 |
import warnings |
| 23 |
from importlib.resources import files |
| 24 |
@@ -29,38 +28,6 @@ from calibre.ebooks.unihandecode.unicodepoints import CODEPOINTS |
| 25 |
from calibre.ebooks.unihandecode.unidecoder import Unidecoder |
| 26 |
|
| 27 |
|
| 28 |
-# pykakasi uses paths for its dictionaries rather than using the |
| 29 |
-# Traversable API of importlib.resources so we have to hack around it, sigh. |
| 30 |
-# https://codeberg.org/miurahr/pykakasi/pulls/174 |
| 31 |
-def dictdata(dbfile: str): |
| 32 |
- t = files('pykakasi') |
| 33 |
- q = t.joinpath('data').joinpath(dbfile) |
| 34 |
- return q.read_bytes() |
| 35 |
- |
| 36 |
- |
| 37 |
-def jisyo_init(self, dictname): |
| 38 |
- self._dict = pickle.loads(dictdata(dictname)) |
| 39 |
- |
| 40 |
- |
| 41 |
-def itaiji_init(self): |
| 42 |
- if self._itaijidict is None: |
| 43 |
- with self._lock: |
| 44 |
- if self._itaijidict is None: |
| 45 |
- self._itaijidict = pickle.loads(dictdata(Configurations.jisyo_itaiji)) |
| 46 |
- |
| 47 |
- |
| 48 |
-def kanwa_init(self): |
| 49 |
- if self._jisyo_table is None: |
| 50 |
- with self._lock: |
| 51 |
- if self._jisyo_table is None: |
| 52 |
- self._jisyo_table = pickle.loads(dictdata(Configurations.jisyo_kanwa)) |
| 53 |
- |
| 54 |
- |
| 55 |
-Jisyo.__init__ = jisyo_init |
| 56 |
-Itaiji.__init__ = itaiji_init |
| 57 |
-Kanwa.__init__ = kanwa_init |
| 58 |
- |
| 59 |
- |
| 60 |
class Jadecoder(Unidecoder): |
| 61 |
def __init__(self): |
| 62 |
self.codepoints = CODEPOINTS.copy() |