jntajis-python 0.2.0__cp314-cp314-win_amd64.whl
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/__init__.py +129 -0
- jntajis/_jntajis.cp314-win_amd64.pyd +4 -0
- jntajis/_jntajis.h +704511 -0
- jntajis/_jntajis.pyi +19 -0
- jntajis/_jntajis.pyx +1157 -0
- jntajis/_version.py +24 -0
- jntajis/gen.py +850 -0
- jntajis/py.typed +0 -0
- jntajis/pythoncapi_compat_shim.h +20 -0
- jntajis/xlsx_parser/__init__.py +1 -0
- jntajis/xlsx_parser/parser.py +591 -0
- jntajis/xlsx_parser/xmlutils.py +332 -0
- jntajis_python-0.2.0.dist-info/METADATA +119 -0
- jntajis_python-0.2.0.dist-info/RECORD +16 -0
- jntajis_python-0.2.0.dist-info/WHEEL +4 -0
- jntajis_python-0.2.0.dist-info/licenses/LICENSE +29 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import functools
|
|
3
|
+
import typing
|
|
4
|
+
from xml.parsers import expat
|
|
5
|
+
|
|
6
|
+
XMLDeclHandler = typing.Callable[[str, typing.Optional[str], int], None]
|
|
7
|
+
XMLStartDoctypeDeclHandler = typing.Callable[
|
|
8
|
+
[str, typing.Optional[str], typing.Optional[str], bool], None
|
|
9
|
+
]
|
|
10
|
+
XMLEndDoctypeDeclHandler = typing.Callable[[], None]
|
|
11
|
+
XMLElementDeclHandler = typing.Callable[
|
|
12
|
+
[str, typing.Tuple[int, int, typing.Optional[str], typing.Tuple[typing.Any, ...]]],
|
|
13
|
+
None,
|
|
14
|
+
]
|
|
15
|
+
XMLAttlistDeclHandler = typing.Callable[[str, str, str, typing.Optional[str], bool], None]
|
|
16
|
+
XMLStartElementHandler = typing.Callable[
|
|
17
|
+
[str, typing.Union[typing.Dict[str, str], typing.Sequence[typing.Tuple[str, str]]]],
|
|
18
|
+
None,
|
|
19
|
+
]
|
|
20
|
+
XMLEndElementHandler = typing.Callable[[str], None]
|
|
21
|
+
XMLProcessingInstructionHandler = typing.Callable[[str, str], None]
|
|
22
|
+
XMLCharacterDataHandler = typing.Callable[[str], None]
|
|
23
|
+
XMLUnparsedEntityDeclHandler = typing.Callable[
|
|
24
|
+
[str, typing.Optional[str], str, typing.Optional[str], str], None
|
|
25
|
+
]
|
|
26
|
+
XMLEntityDeclHandler = typing.Callable[
|
|
27
|
+
[
|
|
28
|
+
str,
|
|
29
|
+
bool,
|
|
30
|
+
typing.Optional[str],
|
|
31
|
+
typing.Optional[str],
|
|
32
|
+
str,
|
|
33
|
+
typing.Optional[str],
|
|
34
|
+
typing.Optional[str],
|
|
35
|
+
],
|
|
36
|
+
None,
|
|
37
|
+
]
|
|
38
|
+
XMLNotationDeclHandler = typing.Callable[
|
|
39
|
+
[str, typing.Optional[str], str, typing.Optional[str]], None
|
|
40
|
+
]
|
|
41
|
+
XMLStartNamespaceDeclHandler = typing.Callable[[str, str], None]
|
|
42
|
+
XMLEndNamespaceDeclHandler = typing.Callable[[str], None]
|
|
43
|
+
XMLCommentHandler = typing.Callable[[str], None]
|
|
44
|
+
XMLStartCdataSectionHandler = typing.Callable[[], None]
|
|
45
|
+
XMLEndCdataSectionHandler = typing.Callable[[], None]
|
|
46
|
+
XMLDefaultHandler = typing.Callable[[str], None]
|
|
47
|
+
XMLDefaultHandlerExpand = typing.Callable[[str], None]
|
|
48
|
+
XMLNotStandaloneHandler = typing.Callable[[], bool]
|
|
49
|
+
XMLExternalEntityRefHandler = typing.Callable[
|
|
50
|
+
[str, typing.Optional[str], typing.Optional[str], typing.Optional[str]], bool
|
|
51
|
+
]
|
|
52
|
+
EventPuller = typing.Callable[[], typing.Iterable[typing.Any]]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class XMLParserHandlers(typing.NamedTuple):
|
|
56
|
+
xml_decl_handler: typing.Optional[XMLDeclHandler] = None
|
|
57
|
+
start_doctype_decl_handler: typing.Optional[XMLStartDoctypeDeclHandler] = None
|
|
58
|
+
end_doctype_decl_handler: typing.Optional[XMLEndDoctypeDeclHandler] = None
|
|
59
|
+
element_decl_handler: typing.Optional[XMLElementDeclHandler] = None
|
|
60
|
+
attlist_decl_handler: typing.Optional[XMLAttlistDeclHandler] = None
|
|
61
|
+
start_element_handler: typing.Optional[XMLStartElementHandler] = None
|
|
62
|
+
end_element_handler: typing.Optional[XMLEndElementHandler] = None
|
|
63
|
+
processing_instruction_handler: typing.Optional[XMLProcessingInstructionHandler] = None
|
|
64
|
+
character_data_handler: typing.Optional[XMLCharacterDataHandler] = None
|
|
65
|
+
unparsed_entity_decl_handler: typing.Optional[XMLUnparsedEntityDeclHandler] = None
|
|
66
|
+
entity_decl_handler: typing.Optional[XMLEntityDeclHandler] = None
|
|
67
|
+
notation_decl_handler: typing.Optional[XMLNotationDeclHandler] = None
|
|
68
|
+
start_namespace_decl_handler: typing.Optional[XMLStartNamespaceDeclHandler] = None
|
|
69
|
+
end_namespace_decl_handler: typing.Optional[XMLEndNamespaceDeclHandler] = None
|
|
70
|
+
comment_handler: typing.Optional[XMLCommentHandler] = None
|
|
71
|
+
start_cdata_section_handler: typing.Optional[XMLStartCdataSectionHandler] = None
|
|
72
|
+
end_cdata_section_handler: typing.Optional[XMLEndCdataSectionHandler] = None
|
|
73
|
+
default_handler: typing.Optional[XMLDefaultHandler] = None
|
|
74
|
+
default_handler_expand: typing.Optional[XMLDefaultHandlerExpand] = None
|
|
75
|
+
not_standalone_handler: typing.Optional[XMLNotStandaloneHandler] = None
|
|
76
|
+
external_entity_ref_handler: typing.Optional[XMLExternalEntityRefHandler] = None
|
|
77
|
+
pull_events: typing.Optional[EventPuller] = None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
XMLParserHandlersFactory = typing.Callable[[expat.XMLParserType], XMLParserHandlers]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def create_parser(
|
|
84
|
+
f: XMLParserHandlersFactory,
|
|
85
|
+
) -> typing.Tuple[expat.XMLParserType, typing.Optional[EventPuller]]:
|
|
86
|
+
parser = expat.ParserCreate(namespace_separator="\n")
|
|
87
|
+
|
|
88
|
+
handlers = f(parser)
|
|
89
|
+
|
|
90
|
+
if handlers.xml_decl_handler is not None:
|
|
91
|
+
parser.XmlDeclHandler = handlers.xml_decl_handler
|
|
92
|
+
|
|
93
|
+
if handlers.start_doctype_decl_handler is not None:
|
|
94
|
+
parser.StartDoctypeDeclHandler = handlers.start_doctype_decl_handler
|
|
95
|
+
|
|
96
|
+
if handlers.end_doctype_decl_handler is not None:
|
|
97
|
+
parser.EndDoctypeDeclHandler = handlers.end_doctype_decl_handler
|
|
98
|
+
|
|
99
|
+
if handlers.element_decl_handler is not None:
|
|
100
|
+
parser.ElementDeclHandler = handlers.element_decl_handler
|
|
101
|
+
|
|
102
|
+
if handlers.attlist_decl_handler is not None:
|
|
103
|
+
parser.AttlistDeclHandler = handlers.attlist_decl_handler
|
|
104
|
+
|
|
105
|
+
if handlers.start_element_handler is not None:
|
|
106
|
+
parser.StartElementHandler = handlers.start_element_handler
|
|
107
|
+
|
|
108
|
+
if handlers.end_element_handler is not None:
|
|
109
|
+
parser.EndElementHandler = handlers.end_element_handler
|
|
110
|
+
|
|
111
|
+
if handlers.processing_instruction_handler is not None:
|
|
112
|
+
parser.ProcessingInstructionHandler = handlers.processing_instruction_handler
|
|
113
|
+
|
|
114
|
+
if handlers.character_data_handler is not None:
|
|
115
|
+
parser.CharacterDataHandler = handlers.character_data_handler
|
|
116
|
+
|
|
117
|
+
if handlers.unparsed_entity_decl_handler is not None:
|
|
118
|
+
parser.UnparsedEntityDeclHandler = handlers.unparsed_entity_decl_handler
|
|
119
|
+
|
|
120
|
+
if handlers.entity_decl_handler is not None:
|
|
121
|
+
parser.EntityDeclHandler = handlers.entity_decl_handler
|
|
122
|
+
|
|
123
|
+
if handlers.notation_decl_handler is not None:
|
|
124
|
+
parser.NotationDeclHandler = handlers.notation_decl_handler
|
|
125
|
+
|
|
126
|
+
if handlers.start_namespace_decl_handler is not None:
|
|
127
|
+
parser.StartNamespaceDeclHandler = handlers.start_namespace_decl_handler
|
|
128
|
+
|
|
129
|
+
if handlers.end_namespace_decl_handler is not None:
|
|
130
|
+
parser.EndNamespaceDeclHandler = handlers.end_namespace_decl_handler
|
|
131
|
+
|
|
132
|
+
if handlers.comment_handler is not None:
|
|
133
|
+
parser.CommentHandler = handlers.comment_handler
|
|
134
|
+
|
|
135
|
+
if handlers.start_cdata_section_handler is not None:
|
|
136
|
+
parser.StartCdataSectionHandler = handlers.start_cdata_section_handler
|
|
137
|
+
|
|
138
|
+
if handlers.end_cdata_section_handler is not None:
|
|
139
|
+
parser.EndCdataSectionHandler = handlers.end_cdata_section_handler
|
|
140
|
+
|
|
141
|
+
if handlers.default_handler is not None:
|
|
142
|
+
parser.DefaultHandler = handlers.default_handler
|
|
143
|
+
|
|
144
|
+
if handlers.default_handler_expand is not None:
|
|
145
|
+
parser.DefaultHandlerExpand = handlers.default_handler_expand
|
|
146
|
+
|
|
147
|
+
if handlers.not_standalone_handler is not None:
|
|
148
|
+
parser.NotStandaloneHandler = handlers.not_standalone_handler
|
|
149
|
+
|
|
150
|
+
if handlers.external_entity_ref_handler is not None:
|
|
151
|
+
parser.ExternalEntityRefHandler = handlers.external_entity_ref_handler
|
|
152
|
+
|
|
153
|
+
return parser, handlers.pull_events
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def read_xml(
|
|
157
|
+
s: typing.IO[bytes],
|
|
158
|
+
f: XMLParserHandlersFactory,
|
|
159
|
+
):
|
|
160
|
+
parser, _ = create_parser(f)
|
|
161
|
+
while True:
|
|
162
|
+
c = s.read(4096)
|
|
163
|
+
if not c:
|
|
164
|
+
break
|
|
165
|
+
parser.Parse(c, False)
|
|
166
|
+
parser.Parse("", True)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def read_xml_incremental(
|
|
170
|
+
s: typing.IO[bytes],
|
|
171
|
+
f: XMLParserHandlersFactory,
|
|
172
|
+
) -> typing.Iterator[typing.Any]:
|
|
173
|
+
parser, event_puller = create_parser(f)
|
|
174
|
+
if event_puller is None:
|
|
175
|
+
raise ValueError("no event puller provided")
|
|
176
|
+
while True:
|
|
177
|
+
c = s.read(4096)
|
|
178
|
+
if not c:
|
|
179
|
+
break
|
|
180
|
+
parser.Parse(c, False)
|
|
181
|
+
yield from event_puller()
|
|
182
|
+
parser.Parse("", True)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
T1 = typing.TypeVar("T1")
|
|
186
|
+
T2 = typing.TypeVar("T2")
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def wrap_start_element_handler(
|
|
190
|
+
h: typing.Callable[[T1, str, str, typing.OrderedDict[str, str]], T2],
|
|
191
|
+
) -> typing.Callable[
|
|
192
|
+
[
|
|
193
|
+
T1,
|
|
194
|
+
str,
|
|
195
|
+
typing.Union[
|
|
196
|
+
typing.Dict[str, str],
|
|
197
|
+
typing.Sequence[typing.Tuple[str, str]],
|
|
198
|
+
],
|
|
199
|
+
],
|
|
200
|
+
T2,
|
|
201
|
+
]:
|
|
202
|
+
@functools.wraps(h)
|
|
203
|
+
def _(
|
|
204
|
+
self: T1,
|
|
205
|
+
name: str,
|
|
206
|
+
attlist: typing.Union[typing.Dict[str, str], typing.Sequence[typing.Tuple[str, str]]],
|
|
207
|
+
) -> T2:
|
|
208
|
+
ns, _, ln = name.partition("\n")
|
|
209
|
+
if ln == "":
|
|
210
|
+
ln = ns
|
|
211
|
+
ns = ""
|
|
212
|
+
return h(self, ns, ln, typing.OrderedDict[str, str](attlist))
|
|
213
|
+
|
|
214
|
+
return _
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class InvalidXMLDocumentError(Exception):
|
|
218
|
+
path: typing.Tuple[str, ...]
|
|
219
|
+
column: int
|
|
220
|
+
line: int
|
|
221
|
+
reason: str
|
|
222
|
+
|
|
223
|
+
@property
|
|
224
|
+
def message(self):
|
|
225
|
+
return f"{self.reason} at line {self.line} column {self.column} (/{'/'.join(self.path)})"
|
|
226
|
+
|
|
227
|
+
def __str__(self):
|
|
228
|
+
return self.message
|
|
229
|
+
|
|
230
|
+
def __init__(self, path: typing.Tuple[str, ...], column: int, line: int, reason: str):
|
|
231
|
+
super().__init__()
|
|
232
|
+
self.path = path
|
|
233
|
+
self.column = column
|
|
234
|
+
self.line = line
|
|
235
|
+
self.reason = reason
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class Handlers(metaclass=abc.ABCMeta):
|
|
239
|
+
@abc.abstractmethod
|
|
240
|
+
def start_element(
|
|
241
|
+
self,
|
|
242
|
+
name: str,
|
|
243
|
+
attlist: typing.Union[typing.Dict[str, str], typing.Sequence[typing.Tuple[str, str]]],
|
|
244
|
+
) -> typing.Optional["Handlers"]: ... # pragma: nocover
|
|
245
|
+
|
|
246
|
+
@abc.abstractmethod
|
|
247
|
+
def end_element(self, name: str) -> typing.Optional["Handlers"]: ... # pragma: nocover
|
|
248
|
+
|
|
249
|
+
@abc.abstractmethod
|
|
250
|
+
def cdata(self, data: str) -> typing.Optional["Handlers"]: ... # pragma: nocover
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
class HandlersBase(Handlers):
|
|
254
|
+
outer: typing.Optional["HandlersBase"]
|
|
255
|
+
parser: expat.XMLParserType
|
|
256
|
+
path: typing.Tuple[str, ...]
|
|
257
|
+
|
|
258
|
+
def raise_invalid_xml_document_error(self, reason: str) -> InvalidXMLDocumentError:
|
|
259
|
+
return InvalidXMLDocumentError(
|
|
260
|
+
self.path,
|
|
261
|
+
self.parser.CurrentColumnNumber,
|
|
262
|
+
self.parser.CurrentLineNumber,
|
|
263
|
+
reason,
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
def raise_unexpected_element(
|
|
267
|
+
self, expected: typing.Union[str, typing.Sequence[str]], actual: str
|
|
268
|
+
) -> InvalidXMLDocumentError:
|
|
269
|
+
_expected: str
|
|
270
|
+
if isinstance(expected, str):
|
|
271
|
+
_expected = expected
|
|
272
|
+
else:
|
|
273
|
+
if len(expected) > 1:
|
|
274
|
+
_expected = ", ".join(expected[:-1]) + ", or " + expected[-1]
|
|
275
|
+
else:
|
|
276
|
+
_expected = expected[0]
|
|
277
|
+
return InvalidXMLDocumentError(
|
|
278
|
+
self.path,
|
|
279
|
+
self.parser.CurrentColumnNumber,
|
|
280
|
+
self.parser.CurrentLineNumber,
|
|
281
|
+
f"unexpected element found: expecting {_expected}, got {actual}",
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
def next(self, h: typing.Type["HandlersBase"], ln: str) -> "HandlersBase":
|
|
285
|
+
return h(outer=self, ln=ln)
|
|
286
|
+
|
|
287
|
+
def _post_init(self) -> None:
|
|
288
|
+
pass
|
|
289
|
+
|
|
290
|
+
def __init__(
|
|
291
|
+
self,
|
|
292
|
+
*,
|
|
293
|
+
outer: typing.Optional["HandlersBase"] = None,
|
|
294
|
+
parser: typing.Optional[expat.XMLParserType] = None,
|
|
295
|
+
ln: typing.Optional[str] = None,
|
|
296
|
+
) -> None:
|
|
297
|
+
self.outer = outer
|
|
298
|
+
if outer is not None:
|
|
299
|
+
self.parser = outer.parser
|
|
300
|
+
assert ln is not None
|
|
301
|
+
self.path = outer.path + (ln,)
|
|
302
|
+
else:
|
|
303
|
+
assert parser is not None
|
|
304
|
+
self.parser = parser
|
|
305
|
+
self.path = (ln,) if ln is not None else ()
|
|
306
|
+
self._post_init()
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class HandlerShim:
|
|
310
|
+
_impl: Handlers
|
|
311
|
+
|
|
312
|
+
def start_element(
|
|
313
|
+
self,
|
|
314
|
+
name: str,
|
|
315
|
+
attlist: typing.Union[typing.Dict[str, str], typing.Sequence[typing.Tuple[str, str]]],
|
|
316
|
+
) -> None:
|
|
317
|
+
impl = self._impl.start_element(name, attlist)
|
|
318
|
+
if impl is not None:
|
|
319
|
+
self._impl = impl
|
|
320
|
+
|
|
321
|
+
def end_element(self, name: str) -> None:
|
|
322
|
+
impl = self._impl.end_element(name)
|
|
323
|
+
if impl is not None:
|
|
324
|
+
self._impl = impl
|
|
325
|
+
|
|
326
|
+
def cdata(self, data: str) -> None:
|
|
327
|
+
impl = self._impl.cdata(data)
|
|
328
|
+
if impl is not None:
|
|
329
|
+
self._impl = impl
|
|
330
|
+
|
|
331
|
+
def __init__(self, impl: Handlers) -> None:
|
|
332
|
+
self._impl = impl
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: jntajis-python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A fast character conversion and transliteration library based on the scheme defined for Japan National Tax Agency's corporate number system.
|
|
5
|
+
Project-URL: Homepage, https://github.com/opencollector/jntajis-python
|
|
6
|
+
Author-email: "Open Collector, inc." <info@opencollector.co.jp>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: JIS,Japanese,Unicode,conversion,encoding,transliteration
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
|
|
17
|
+
Classifier: Topic :: Text Processing :: Filters
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: click>=8.3; extra == 'dev'
|
|
21
|
+
Requires-Dist: jinja2>=3; extra == 'dev'
|
|
22
|
+
Requires-Dist: mypy>=1.19; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest>=6.2; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
25
|
+
Requires-Dist: sphinx-rtd-theme>=0.5; extra == 'dev'
|
|
26
|
+
Requires-Dist: sphinx>=4; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# jntajis-python
|
|
30
|
+
|
|
31
|
+
Documentation: https://jntajis-python.readthedocs.io/
|
|
32
|
+
|
|
33
|
+
## What's JNTAJIS-python?
|
|
34
|
+
|
|
35
|
+
JNTAJIS-python is a transliteration library, specifically designed for dealing with three different character sets; JIS X 0208, JIS X 0213, and Unicode.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import jntajis
|
|
39
|
+
|
|
40
|
+
print(jntajis.mj_shrink_candidates("髙島屋", jntajis.MJShrinkSchemeCombo.JIS_INCORPORATION_UCS_UNIFICATION_RULE)) # outputs ["高島屋", "髙島屋"]
|
|
41
|
+
print(jntajis.jnta_shrink_translit("麴町")) # outputs "麹町"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
To that end, this library refers to three different character tables; MJ character table, MJ shrink conversion map, and NTA shrink conversion map.
|
|
45
|
+
|
|
46
|
+
The MJ character table (*MJ文字一覧表*) defines a vast set of kanji (*漢字*) characters used in information processing of Japanese texts initially developed by Information-technology Promotion Agency.
|
|
47
|
+
|
|
48
|
+
The MJ shrink conversion map (*MJ縮退マップ*) was also developed alongside for the sake of interoperability between MJ-aware systems and systems based on Unicode, which is used to transliterate complex, less-frequently-used character variants to commonly-used, more-used ones.
|
|
49
|
+
|
|
50
|
+
The NTA shrink conversion map (*国税庁JIS縮退マップ*) was developed by Japan National Tax Agency to canonicalize user inputs for its corporation number search service provided as a public web API. This maps JIS level 3 and 4 characters to JIS level 1 and 2 characters (i.e. characters defined in JIS X 0208.) Note that not all level 3 and level 4 characters have level 1 and 2 counterparts. Also note that some of level 3 and 4 characters don't map to a single character one by each. Instead, they map to sequences of two or more characters.
|
|
51
|
+
|
|
52
|
+
The table below shows some examples of transliteration by the MJ character table suite and NTA shrink conversion map.
|
|
53
|
+
|
|
54
|
+
| Glyph | MJ code | Unicode | JIS X 0213 | Glyph\* | MJ code\* | JIS X 0208\* | Transliterator |
|
|
55
|
+
| ----- | ------- | ------- | ---------- | ------ | ------- | ---------- | -------------- |
|
|
56
|
+
|  | MJ014031 | U+68C3 | 2-14-90 |  | MJ014007 | 1-45-92 | MJ / JNTA |
|
|
57
|
+
|  | MJ030196 | U+FA11 | 1-47-82 |  | MJ010541 | 1-26-74 | MJ / JNTA |
|
|
58
|
+
|  | MJ028902 | U+9AD9 | N/A |  | MJ028901 | 1-25-66 | MJ |
|
|
59
|
+
|
|
60
|
+
The conversion schematics is shown below:
|
|
61
|
+
|
|
62
|
+

|
|
63
|
+
|
|
64
|
+
* JNTA transliteration
|
|
65
|
+
|
|
66
|
+
As every JIS X 0213 characters maps to its Unicode counterpart, the conversion is done only with the single JNTA character mappings table.
|
|
67
|
+
|
|
68
|
+
* MJ transliteration
|
|
69
|
+
|
|
70
|
+
Transliteration is done in two phases:
|
|
71
|
+
|
|
72
|
+
1. Conversion from Unicode to MJ character mappings.
|
|
73
|
+
|
|
74
|
+
While not all characters in the MJ characters table map to Unicode, each MJ code has different shrink mappings. Because of this, the transliterator tries to convert Unicode codepoints to MJ codes first.
|
|
75
|
+
|
|
76
|
+
2. Transliteration by MJ shrink mappings.
|
|
77
|
+
|
|
78
|
+
The transliteration result as a string isn't necessarily single as some MJ codes have more than one transliteration candidate. This happens because a) a Unicode codepoint may map to multiple MJ codes and b) multiple transliteration schemes are designated to a single MJ code.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Relationship between Unicode, MJ character mappings, JIS X 0213, and JIS X 0208 can be depicted as follows:
|
|
82
|
+
|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
The source code except `src/jntajis/_jntajis.h` is published under the BSD 3-clause license.
|
|
88
|
+
|
|
89
|
+
`src/jntajis/_jntajis.h` contains the data from the following entities:
|
|
90
|
+
|
|
91
|
+
* JIS shrink conversion mappings (国税庁: JIS縮退マップ)
|
|
92
|
+
|
|
93
|
+
Publisher: National Tax Agency
|
|
94
|
+
|
|
95
|
+
Author: National Tax Agency
|
|
96
|
+
|
|
97
|
+
Source: https://www.houjin-bangou.nta.go.jp/download/
|
|
98
|
+
|
|
99
|
+
License: CC BY 4.0
|
|
100
|
+
|
|
101
|
+
* MJ character table (文字情報技術促進協議会: MJ文字一覧表)
|
|
102
|
+
|
|
103
|
+
Publisher: Character Information Technology Promotion Council (CITPC)
|
|
104
|
+
|
|
105
|
+
Author: Information-technology Promotion Agency (IPA)
|
|
106
|
+
|
|
107
|
+
Source: https://moji.or.jp/mojikiban/mjlist/
|
|
108
|
+
|
|
109
|
+
License: CC BY-SA 2.1 JP
|
|
110
|
+
|
|
111
|
+
* MJ shrink conversion mappings (文字情報技術促進協議会: MJ縮退マップ)
|
|
112
|
+
|
|
113
|
+
Publisher: Character Information Technology Promotion Council (CITPC)
|
|
114
|
+
|
|
115
|
+
Author: Information-technology Promotion Agency (IPA)
|
|
116
|
+
|
|
117
|
+
Source: https://moji.or.jp/mojikiban/map/
|
|
118
|
+
|
|
119
|
+
License: CC BY-SA 2.1 JP
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
jntajis/__init__.py,sha256=LcI-DG49GAip8wHv7eS94xO5IfAsV47Go6-cNXPzz3A,4443
|
|
2
|
+
jntajis/_jntajis.h,sha256=oTeWX5MdyqQJE0UatVDINgefymx7Pj1qUYPJ0myZwds,14991616
|
|
3
|
+
jntajis/_jntajis.pyi,sha256=q8HJp4GLEXowjRgaZmAQakUheZXr8gmhQ3dvakqHDBE,739
|
|
4
|
+
jntajis/_jntajis.pyx,sha256=Mf6BtNyXmDpAykeO86yR-hfdpWkoJAXtxnu5eXBIoVE,37913
|
|
5
|
+
jntajis/_version.py,sha256=o6nU15H7_jYvnYZsCLRJwBDn9I0-eYfK25Ic000d910,544
|
|
6
|
+
jntajis/gen.py,sha256=x-WdQCwhpL2JtAbwH8rFPwBhxrt-e4FKWZRSRpLt4V8,25225
|
|
7
|
+
jntajis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
jntajis/pythoncapi_compat_shim.h,sha256=2JW8vNUdCW6m2rSLth3M09z6C7P7PwNzytN2rwETWTo,620
|
|
9
|
+
jntajis/xlsx_parser/__init__.py,sha256=MQvJJBx66hXH0pq2WREKljeipdxIJdDjmMBdN7IkeVg,45
|
|
10
|
+
jntajis/xlsx_parser/parser.py,sha256=MTtMV7r0eDxCVgr24ypqR8YfMKXRrQHRH4Gs6cHPRNw,17161
|
|
11
|
+
jntajis/xlsx_parser/xmlutils.py,sha256=bhM3EtBnJXwydaF4k6OrU6ICabhh-fkrvY1aN7Vktr8,11836
|
|
12
|
+
jntajis/_jntajis.cp314-win_amd64.pyd,sha256=ZiQdAXua4ple3cZVwmVt_OOskat1_ew_IYqHfzclHCo,135675904
|
|
13
|
+
jntajis_python-0.2.0.dist-info/METADATA,sha256=cI6fIEK70CG8Nj1fZexiTykPwNnxzh8uBI0nhQkNeBM,6043
|
|
14
|
+
jntajis_python-0.2.0.dist-info/WHEEL,sha256=cRYvDPRpknMD5laH6P2-Qz17Z3WQ40djK6tHp-z71do,97
|
|
15
|
+
jntajis_python-0.2.0.dist-info/licenses/LICENSE,sha256=ZKCAxWL4BvFvsYWpLPra_QYQnl4PB6PCIRkyUAl6OBI,1523
|
|
16
|
+
jntajis_python-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2021 Open Collector, Inc.
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are
|
|
7
|
+
met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
in the documentation and/or other materials provided with the
|
|
14
|
+
distribution.
|
|
15
|
+
* Neither the name of Open Collector, Inc. nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|