jntajis-python 0.0.17__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/.agents/docs/ARCHITECTURE.md +8 -4
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/.agents/docs/IMPLEMENTATION.md +21 -14
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/.gitignore +4 -2
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/PKG-INFO +4 -2
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/source/api.rst +26 -3
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pyproject.toml +10 -7
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/__init__.py +11 -2
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/_jntajis.h +87537 -87536
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/_jntajis.pyi +4 -2
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/_jntajis.pyx +152 -109
- jntajis_python-0.2.0/src/jntajis/_version.py +24 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/gen.py +10 -3
- jntajis_python-0.0.17/src/jntajis/_version.py +0 -34
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/LICENSE +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/README.md +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/.gitignore +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/Makefile +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/make.bat +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/source/_static/images/mj-jnta.svg +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/source/_static/images/relationships-character-mappings.svg +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/source/conf.py +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/source/index.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/docs/source/license.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/Makefile +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/api.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/changelog.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/conf.py +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/index.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/links.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/make.bat +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/tests.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/upgrade.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/pythoncapi-compat/docs/users.rst +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/py.typed +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/pythoncapi_compat_shim.h +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/xlsx_parser/__init__.py +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/xlsx_parser/parser.py +0 -0
- {jntajis_python-0.0.17 → jntajis_python-0.2.0}/src/jntajis/xlsx_parser/xmlutils.py +0 -0
|
@@ -52,7 +52,7 @@ External data sources are downloaded and processed into a single generated C hea
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
- **JNTA Excel** (`jissyukutaimap1_0_0.xlsx`): NTA shrink conversion map. Downloaded from NTA.
|
|
55
|
-
- **MJ Excel** (`mji.
|
|
55
|
+
- **MJ Excel** (`mji.00602.xlsx`): MJ character table. Downloaded from CITPC/IPA.
|
|
56
56
|
- **MJ Shrink JSON** (`MJShrinkMap.1.2.0.json`): MJ shrink conversion map. Downloaded from CITPC/IPA.
|
|
57
57
|
|
|
58
58
|
`gen.py` uses a custom `xlsx_parser` to read the Excel files, processes the data into optimized lookup structures, and renders `_jntajis.h` via a Jinja2 template. The generated header contains:
|
|
@@ -68,11 +68,15 @@ External data sources are downloaded and processed into a single generated C hea
|
|
|
68
68
|
`_jntajis.pyx` is a Cython file compiled into a C extension module. It:
|
|
69
69
|
|
|
70
70
|
- Includes `_jntajis.h` via `cdef extern` to access the generated lookup tables
|
|
71
|
-
- Uses CPython
|
|
71
|
+
- Uses CPython low-level APIs (`PyUnicodeWriter`, `PyBytesWriter` via `pythoncapi-compat`, `PyUnicode_READ`, etc.) directly for high-performance string construction
|
|
72
72
|
- Compiles with safety checks disabled (`boundscheck=False`, `wraparound=False`, `cdivision=True`)
|
|
73
73
|
|
|
74
74
|
The build process is: `_jntajis.pyx` + `_jntajis.h` --> Cython --> `_jntajis.c` --> C compiler --> `_jntajis.so`.
|
|
75
75
|
|
|
76
|
+
### Free-threaded CPython (3.14t)
|
|
77
|
+
|
|
78
|
+
The extension declares `freethreading_compatible=True` (requires Cython >= 3.1), so importing it does not re-enable the GIL. The lookup tables in `_jntajis.h` are read-only, and the module-level functions keep all mutable state in stack-local contexts over immutable `str`/`bytes` inputs, so they need no locking. `IncrementalEncoder` is the only object with shared mutable state (the lookahead buffer `la`/`lal`), so every method takes a per-instance `cython.critical_section`. `tests/test_free_threading.py` checks that the GIL stays disabled after import and stress-tests concurrent use.
|
|
79
|
+
|
|
76
80
|
### 3. Runtime API
|
|
77
81
|
|
|
78
82
|
The public API is exposed via `__init__.py` which re-exports from the Cython extension:
|
|
@@ -80,7 +84,7 @@ The public API is exposed via `__init__.py` which re-exports from the Cython ext
|
|
|
80
84
|
| Symbol | Type | Description |
|
|
81
85
|
|--------|------|-------------|
|
|
82
86
|
| `jnta_encode()` | function | Unicode -> JIS byte sequence |
|
|
83
|
-
| `jnta_decode()` | function | JIS byte sequence -> Unicode |
|
|
87
|
+
| `jnta_decode()` | function | JIS byte sequence -> Unicode (validated per `ConversionMode`) |
|
|
84
88
|
| `jnta_shrink_translit()` | function | JNTA shrink transliteration (Unicode -> Unicode) |
|
|
85
89
|
| `mj_shrink_candidates()` | function | MJ-based shrink transliteration candidates |
|
|
86
90
|
| `IncrementalEncoder` | class | Stateful encoder (codec-compatible) |
|
|
@@ -146,7 +150,7 @@ The XML parsing framework in `xmlutils.py` provides:
|
|
|
146
150
|
## CI/CD
|
|
147
151
|
|
|
148
152
|
- **Trigger** (`main.yml`): On PR open, push to main, or version tag push (`v*`)
|
|
149
|
-
- **Lint & Test** (`tests.yml`):
|
|
153
|
+
- **Lint & Test** (`tests.yml`): ruff + mypy, then tests on 3.10-3.14 and free-threaded 3.14t (the 3.14t job runs pytest directly instead of `hatch test`)
|
|
150
154
|
- **Wheels** (`wheels.yml`): cibuildwheel across Ubuntu, Windows, macOS (11/12/13), excluding PyPy. Only runs on tag push.
|
|
151
155
|
|
|
152
156
|
## Documentation
|
|
@@ -21,12 +21,12 @@ Three source data files are read:
|
|
|
21
21
|
- Extracts secondary Unicode mappings from memo fields via regex
|
|
22
22
|
|
|
23
23
|
2. **`read_mj_excel_file()`** parses the MJ character table Excel:
|
|
24
|
-
- Extracts MJ code, corresponding UCS, implemented UCS, IVS pairs (Moji_Joho collection + SVS)
|
|
24
|
+
- Extracts MJ code, corresponding UCS, implemented UCS (kept as `MJMapping.iu`), IVS pairs (Moji_Joho collection + SVS)
|
|
25
25
|
- Builds `UIVSPair` tuples (Unicode codepoint + variation selector number)
|
|
26
26
|
- Tracks max variant count across all entries
|
|
27
27
|
|
|
28
28
|
3. **`read_mj_shrink_file()`** parses the MJ shrink map JSON:
|
|
29
|
-
- Reads target Unicode codepoints for each of the 4 shrink schemes
|
|
29
|
+
- Reads target Unicode codepoints for each of the 4 shrink schemes, sorted by code point so that the output is reproducible
|
|
30
30
|
- Groups by source MJ code
|
|
31
31
|
|
|
32
32
|
### Data Structure Construction
|
|
@@ -78,7 +78,7 @@ All safety checks are disabled for performance. `embedsignature=True` embeds Pyt
|
|
|
78
78
|
|
|
79
79
|
- **`JNTAJISIncrementalEncoderContext`**: Per-call context wrapping the encoder + `_PyBytesWriter` for output construction
|
|
80
80
|
|
|
81
|
-
- **`JNTAJISShrinkingTransliteratorContext`**: Per-call context for `jnta_shrink_translit`, using `
|
|
81
|
+
- **`JNTAJISShrinkingTransliteratorContext`**: Per-call context for `jnta_shrink_translit`, using `PyUnicodeWriter` for output
|
|
82
82
|
|
|
83
83
|
- **`MJShrinkCandidates`**: Manages cartesian product enumeration for `mj_shrink_candidates`
|
|
84
84
|
|
|
@@ -104,15 +104,22 @@ All safety checks are disabled for performance. `embedsignature=True` embeds Pyt
|
|
|
104
104
|
|
|
105
105
|
### Decoding Flow (`jnta_decode`)
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
`jnta_decode(encoding, in_, conv_mode=SISO, replacement=None)` validates the input against the conversion mode it was encoded with. The behavior is aligned with the Rust port (`jntajis-rs`), except that reserved codes may be replaced as in the Go port (`jntajis-go`).
|
|
108
|
+
|
|
109
|
+
1. Create a `PyUnicodeWriter`
|
|
108
110
|
2. Parse byte pairs as JIS row+column codes
|
|
109
|
-
3. Handle
|
|
111
|
+
3. Handle SO (0x0E, primary plane) / SI (0x0F, extended plane) shift bytes in SISO mode only; other modes reject them
|
|
110
112
|
4. Look up `tx_mappings[jis]` to get Unicode codepoint(s)
|
|
111
|
-
5.
|
|
113
|
+
5. Reserved code: write `replacement` if given, otherwise raise `UnicodeDecodeError`
|
|
114
|
+
6. JISX0208 mode: reject characters whose class is not level 1/2 kanji or JIS X 0208 non-kanji
|
|
115
|
+
7. JISX0208_TRANSLIT mode: write `tx_us[]` for JIS X 0213 characters (level 3/4, JIS X 0213 non-kanji) that have a transliteration
|
|
116
|
+
8. Otherwise write 1 or 2 Unicode codepoints per JIS code
|
|
117
|
+
|
|
118
|
+
`UnicodeDecodeError` ranges: the pair (2 bytes) for reserved / rejected codes, the first byte alone when the second byte of a pair is out of range, and the offending byte for invalid single bytes and an incomplete trailing byte.
|
|
112
119
|
|
|
113
120
|
### JNTA Shrink Transliteration (`jnta_shrink_translit`)
|
|
114
121
|
|
|
115
|
-
1.
|
|
122
|
+
1. Create a `PyUnicodeWriter`
|
|
116
123
|
2. For each Unicode codepoint: use `sm_uni_to_jis_mapping()` to find JIS code
|
|
117
124
|
3. If the JIS code maps to a level 3/4 or non-kanji-extended character with a transliteration entry: output the transliterated form (`tx_us[]`)
|
|
118
125
|
4. Otherwise: output the original Unicode codepoint(s) from `us[]`
|
|
@@ -126,12 +133,12 @@ This is the most complex function. It:
|
|
|
126
133
|
2. For each input character (possibly with trailing IVS):
|
|
127
134
|
a. Look up `urange_to_mj_mappings` to find candidate `MJMapping` entries
|
|
128
135
|
b. If IVS present: filter to exact IVS match
|
|
129
|
-
c. If no IVS: collect all non-IVS variants
|
|
130
|
-
d. For each matching MJ code, look up `mj_shrink_mappings` and collect target Unicode codepoints per selected scheme (combo bitmask)
|
|
136
|
+
c. If no IVS: collect all non-IVS variants, then narrow them down to the canonical one (the `MJMapping` whose `iu`, i.e. 実装したUCS, equals the character) unless `INCLUDE_VARIANTS` (16) is set in combo
|
|
137
|
+
d. For each matching MJ code, look up `mj_shrink_mappings` and collect target Unicode codepoints per selected scheme (combo bitmask), skipping the input character itself (but not the targets following it; the result must not depend on the order of the targets)
|
|
131
138
|
e. Also include the original Unicode variants from the MJ mapping itself
|
|
132
139
|
f. If no candidates: keep the original character
|
|
133
140
|
3. Enumerate the cartesian product of per-character candidates (up to `limit`) using carry-based iteration
|
|
134
|
-
4. Build result strings using `
|
|
141
|
+
4. Build result strings using `PyUnicodeWriter`
|
|
135
142
|
|
|
136
143
|
### Binary Search Pattern
|
|
137
144
|
|
|
@@ -146,7 +153,7 @@ The extension directly uses CPython internal APIs for zero-copy string access:
|
|
|
146
153
|
- `PyUnicode_KIND()`: Get the internal storage width (1/2/4 byte)
|
|
147
154
|
- `PyUnicode_DATA()`: Get raw buffer pointer
|
|
148
155
|
- `PyUnicode_READ()`: Read a codepoint at an index
|
|
149
|
-
- `
|
|
156
|
+
- `PyUnicodeWriter` / `PyBytesWriter`: Buffer builders that handle memory allocation and string compaction. These are public APIs from CPython 3.14 / 3.15 respectively, backported to older versions by the vendored `pythoncapi-compat` (plus `pythoncapi_compat_shim.h` for `PyBytesWriter_Prepare`). The writer is heap-allocated and freed by `*_Finish()` / `*_Discard()`, so it must not be touched afterwards. The private `_PyUnicodeWriter` API, deprecated in 3.14, is no longer used.
|
|
150
157
|
|
|
151
158
|
This makes the code CPython-specific and incompatible with other Python implementations.
|
|
152
159
|
|
|
@@ -188,7 +195,7 @@ Layered handler hierarchy for each XML document:
|
|
|
188
195
|
|
|
189
196
|
- **`ConversionMode`** (`IntEnum`): SISO=0, MEN1=1, JISX0208=2, JISX0208_TRANSLIT=3
|
|
190
197
|
- **`MJShrinkScheme`** (`IntEnum`): Four MJ shrink scheme identifiers (0-3)
|
|
191
|
-
- **`MJShrinkSchemeCombo`** (`IntFlag`): Bitmask flags (1, 2, 4, 8) for combining MJ shrink schemes
|
|
198
|
+
- **`MJShrinkSchemeCombo`** (`IntFlag`): Bitmask flags (1, 2, 4, 8) for combining MJ shrink schemes, plus `INCLUDE_VARIANTS` (16)
|
|
192
199
|
|
|
193
200
|
The Cython extension symbols are imported with a `try/except ImportError` guard so the package can be imported even when the native extension is not built (e.g. for documentation generation).
|
|
194
201
|
|
|
@@ -206,9 +213,9 @@ The Cython extension symbols are imported with a `try/except ImportError` guard
|
|
|
206
213
|
Defines the data pipeline with proper dependency tracking:
|
|
207
214
|
|
|
208
215
|
```
|
|
209
|
-
_jntajis.h <-- gen.py + jissyukutaimap1_0_0.xlsx + mji.
|
|
216
|
+
_jntajis.h <-- gen.py + jissyukutaimap1_0_0.xlsx + mji.00602.xlsx + MJShrinkMap.1.2.0.json
|
|
210
217
|
jissyukutaimap1_0_0.xlsx <-- syukutaimap1_0_0.zip (curl from NTA)
|
|
211
|
-
mji.
|
|
218
|
+
mji.00602.xlsx <-- curl from moji.or.jp
|
|
212
219
|
MJShrinkMap.1.2.0.json <-- MJShrinkMapVer.1.2.0.zip (curl from CITPC)
|
|
213
220
|
```
|
|
214
221
|
|
|
@@ -146,11 +146,13 @@ jissyukutaimap1_0_0.xlsx
|
|
|
146
146
|
syukutaimap1_0_0.zip
|
|
147
147
|
MJShrinkMap.1.2.0.json
|
|
148
148
|
MJShrinkMapVer.1.2.0.zip
|
|
149
|
-
mji.
|
|
150
|
-
mji.00601.xlsx
|
|
149
|
+
mji.00602.xlsx
|
|
151
150
|
|
|
152
151
|
# hatch-vcs generated version file
|
|
153
152
|
src/jntajis/_version.py
|
|
154
153
|
|
|
155
154
|
# automatically generated C source
|
|
156
155
|
src/jntajis/_jntajis.c
|
|
156
|
+
|
|
157
|
+
# Temporary directory used by the coding agent
|
|
158
|
+
.agents/tmp
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: jntajis-python
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A fast character conversion and transliteration library based on the scheme defined for Japan National Tax Agency's corporate number system.
|
|
5
5
|
Project-URL: Homepage, https://github.com/opencollector/jntajis-python
|
|
6
6
|
Author-email: "Open Collector, inc." <info@opencollector.co.jp>
|
|
@@ -12,6 +12,8 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
|
|
15
17
|
Classifier: Topic :: Text Processing :: Filters
|
|
16
18
|
Requires-Python: >=3.10
|
|
17
19
|
Provides-Extra: dev
|
|
@@ -10,7 +10,7 @@ JNTA converter functions and classes
|
|
|
10
10
|
|
|
11
11
|
.. py:attribute:: SISO
|
|
12
12
|
|
|
13
|
-
Instructs it to encode the given string into JIS X 0213 with the
|
|
13
|
+
Instructs it to encode the given string into JIS X 0213 with the shift bytes ``\x0f`` (SI) and ``\x0e`` (SO) selecting the extended plane (men 2) and the primary plane (men 1) respectively. Note that this is the reverse of the ISO 2022 convention, where SO shifts out to the alternate set.
|
|
14
14
|
|
|
15
15
|
.. py:attribute:: MEN1
|
|
16
16
|
|
|
@@ -33,12 +33,23 @@ JNTA converter functions and classes
|
|
|
33
33
|
:param int conv_mode: The conversion mode. For the possible values, refer to :py:class:`ConversionMode`.
|
|
34
34
|
:return: The encoded JIS character sequence.
|
|
35
35
|
|
|
36
|
-
.. py:function:: jnta_decode(encoding, in_)
|
|
36
|
+
.. py:function:: jnta_decode(encoding, in_, conv_mode=ConversionMode.SISO, replacement=None)
|
|
37
37
|
|
|
38
38
|
Decode a given JIS character sequence into a Unicode string.
|
|
39
39
|
|
|
40
|
+
``conv_mode`` gives the conversion mode that ``in_`` is expected to have been encoded with, and the input is validated accordingly:
|
|
41
|
+
|
|
42
|
+
* :py:attr:`ConversionMode.SISO`: the plane selection bytes are honored; ``\x0f`` selects the extended plane (men 2) and ``\x0e`` the primary plane (men 1). Decoding starts in the primary plane.
|
|
43
|
+
* :py:attr:`ConversionMode.MEN1`: only the primary plane is accepted, and the plane selection bytes are rejected.
|
|
44
|
+
* :py:attr:`ConversionMode.JISX0208`: in addition, characters that are not part of JIS X 0208 are rejected.
|
|
45
|
+
* :py:attr:`ConversionMode.JISX0208_TRANSLIT`: as with ``MEN1``, but JIS X 0213 characters are decoded into their transliterated forms.
|
|
46
|
+
|
|
47
|
+
Reserved codes, which have no corresponding Unicode character, are decoded into ``replacement`` if it is given. Any other malformed or rejected input always raises ``UnicodeDecodeError``.
|
|
48
|
+
|
|
40
49
|
:param str encoding: The encoding name that is to appear in ``UnicodeDecodeError``.
|
|
41
50
|
:param bytes in_: The encoded JIS characters.
|
|
51
|
+
:param ConversionMode conv_mode: The conversion mode.
|
|
52
|
+
:param Optional[str] replacement: The string to substitute for reserved codes, or ``None`` to raise ``UnicodeDecodeError`` for them.
|
|
42
53
|
:return: The decoded Unicode string.
|
|
43
54
|
|
|
44
55
|
.. py:class:: IncrementalEncoder(encoding, conv_mode)
|
|
@@ -90,6 +101,18 @@ The MJ shrink conversion map (*MJ縮退マップ*) was also developed alongside
|
|
|
90
101
|
|
|
91
102
|
Instructs it to transliterate the given characters according to the Family Register Act (戸籍法) and related MOJ notices (*法務省戸籍法関連通達・通知*.)
|
|
92
103
|
|
|
104
|
+
.. py:attribute:: INCLUDE_VARIANTS
|
|
105
|
+
|
|
106
|
+
Not a scheme but a flag. Several MJ glyphs can share a code point, but a character without a variation selector stands for one of them: the glyph whose *実装したUCS* is that character. By default, only that glyph's shrink mappings are used. With this flag, the shrink mappings of all the MJ glyphs that correspond to the character are taken into account as well.
|
|
107
|
+
|
|
108
|
+
.. code-block:: python
|
|
109
|
+
|
|
110
|
+
family = jntajis.MJShrinkSchemeCombo.MOJ_FAMILY_REGISTER_ACT_RELATED_NOTICE
|
|
111
|
+
jntajis.mj_shrink_candidates("寿", family) # ["寿"]
|
|
112
|
+
jntajis.mj_shrink_candidates("寿", family | jntajis.MJShrinkSchemeCombo.INCLUDE_VARIANTS) # ["壽", "寿"]
|
|
113
|
+
|
|
114
|
+
Data that went through a plain code point, such as names in a database, may have lost which glyph was meant. To match it against 戸籍 data, you probably want this flag.
|
|
115
|
+
|
|
93
116
|
.. py:function:: mj_shrink_candidates(in_, combo, limit=100)
|
|
94
117
|
|
|
95
118
|
:param str in_: The string to transliterate.
|
|
@@ -101,7 +124,7 @@ The MJ shrink conversion map (*MJ縮退マップ*) was also developed alongside
|
|
|
101
124
|
Transliteration based on NTA shrink mappings
|
|
102
125
|
--------------------------------------------
|
|
103
126
|
|
|
104
|
-
.. py:function:: jnta_shrink_translit(in_, replacement="\
|
|
127
|
+
.. py:function:: jnta_shrink_translit(in_, replacement="\ufffd", passthrough=False)
|
|
105
128
|
|
|
106
129
|
Transliterate a Unicode string according to the NTA shrink mappings.
|
|
107
130
|
|
|
@@ -3,7 +3,7 @@ requires = [
|
|
|
3
3
|
"hatchling",
|
|
4
4
|
"hatch-cython>=0.5.0",
|
|
5
5
|
"hatch-vcs",
|
|
6
|
-
"Cython>=3.
|
|
6
|
+
"Cython>=3.1.0",
|
|
7
7
|
]
|
|
8
8
|
build-backend = "hatchling.build"
|
|
9
9
|
|
|
@@ -23,6 +23,8 @@ classifiers = [
|
|
|
23
23
|
"Programming Language :: Python :: 3.11",
|
|
24
24
|
"Programming Language :: Python :: 3.12",
|
|
25
25
|
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Programming Language :: Python :: Free Threading :: 2 - Beta",
|
|
26
28
|
"Topic :: Text Processing :: Filters",
|
|
27
29
|
]
|
|
28
30
|
dynamic = ["version"]
|
|
@@ -57,7 +59,7 @@ dependencies = ["hatch-cython>=0.5.0"]
|
|
|
57
59
|
src = "jntajis"
|
|
58
60
|
includes = ["pythoncapi-compat", "src/jntajis"]
|
|
59
61
|
compile_py = false
|
|
60
|
-
directives = { language_level = 3, cdivision = true, boundscheck = false, wraparound = false, embedsignature = true }
|
|
62
|
+
directives = { language_level = 3, cdivision = true, boundscheck = false, wraparound = false, embedsignature = true, freethreading_compatible = true }
|
|
61
63
|
|
|
62
64
|
[tool.hatch.build.targets.sdist]
|
|
63
65
|
include = [
|
|
@@ -87,28 +89,29 @@ fix = ["ruff format {args:src}", "ruff check --fix {args:src}"]
|
|
|
87
89
|
check = ["ruff format --check {args:src}", "ruff check {args:src}", "mypy -p jntajis"]
|
|
88
90
|
|
|
89
91
|
[tool.hatch.envs.wheels]
|
|
90
|
-
dependencies = ["cibuildwheel>=
|
|
92
|
+
dependencies = ["cibuildwheel>=3.1"]
|
|
91
93
|
detached = true
|
|
92
94
|
|
|
93
95
|
[tool.hatch.envs.wheels.scripts]
|
|
94
96
|
build = ["cibuildwheel --output-dir {args:dist}"]
|
|
95
97
|
|
|
96
98
|
[[tool.hatch.envs.hatch-test.matrix]]
|
|
97
|
-
python = ["3.13", "3.12", "3.11", "3.10"]
|
|
99
|
+
python = ["3.14", "3.13", "3.12", "3.11", "3.10"]
|
|
98
100
|
|
|
99
101
|
[tool.mypy]
|
|
100
102
|
files = "src/"
|
|
101
103
|
|
|
102
104
|
[tool.cibuildwheel]
|
|
103
|
-
build = ["cp310-*", "cp311-*", "cp312-*", "cp313-*"]
|
|
105
|
+
build = ["cp310-*", "cp311-*", "cp312-*", "cp313-*", "cp314-*", "cp314t-*"]
|
|
104
106
|
# skip = "pp*"
|
|
105
107
|
|
|
106
108
|
[tool.cibuildwheel.linux]
|
|
107
|
-
before-build = "find
|
|
109
|
+
before-build = "find {project} -iname '*.so' | xargs rm -f"
|
|
108
110
|
|
|
109
111
|
[tool.cibuildwheel.windows]
|
|
110
112
|
before-build = "DEL /S /Q *.pyd"
|
|
113
|
+
repair-wheel-command = "python {project}/tools/repack_wheel.py {wheel} {dest_dir}"
|
|
111
114
|
|
|
112
115
|
[tool.cibuildwheel.macos]
|
|
113
116
|
archs = ["universal2"]
|
|
114
|
-
before-build = "find
|
|
117
|
+
before-build = "find {project} -iname '*.so' | xargs rm -f "
|
|
@@ -64,8 +64,9 @@ class ConversionMode(enum.IntEnum):
|
|
|
64
64
|
SISO = 0
|
|
65
65
|
"""
|
|
66
66
|
Instructs the encoder to encode the given string into JIS X 0213 with the
|
|
67
|
-
|
|
68
|
-
plane
|
|
67
|
+
shift bytes ``\x0f`` (SI) and ``\x0e`` (SO) selecting the extended plane
|
|
68
|
+
(men 2) and the primary plane (men 1) respectively. Note that this is the
|
|
69
|
+
reverse of the ISO 2022 convention, where SO shifts out to the alternate set.
|
|
69
70
|
"""
|
|
70
71
|
MEN1 = 1
|
|
71
72
|
"""
|
|
@@ -118,3 +119,11 @@ class MJShrinkSchemeCombo(enum.IntFlag):
|
|
|
118
119
|
Family Register Act (戸籍法) and related MOJ notices
|
|
119
120
|
(法務省戸籍法関連通達・通知.)
|
|
120
121
|
"""
|
|
122
|
+
INCLUDE_VARIANTS = 16
|
|
123
|
+
"""
|
|
124
|
+
Not a scheme but a flag. A character without a variation selector
|
|
125
|
+
normally stands for its canonical MJ glyph alone (the one whose
|
|
126
|
+
実装したUCS is that character). With this flag, the shrink mappings of
|
|
127
|
+
all the MJ glyphs that correspond to the character are taken into
|
|
128
|
+
account as well.
|
|
129
|
+
"""
|