nbsplitter 1.0.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.
@@ -0,0 +1,31 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ deploy:
12
+ runs-on: ubuntu-latest
13
+ environment: pypi
14
+ permissions:
15
+ id-token: write
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v7
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v7
21
+ with:
22
+ python-version: "3.x"
23
+ cache: "pip"
24
+ - name: Install Hatch
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install hatch
28
+ - name: Build package
29
+ run: hatch build
30
+ - name: Publish package to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,4 @@
1
+ /.venv/
2
+ __pycache__/
3
+
4
+ *.xml
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: nbsplitter
3
+ Version: 1.0.0
4
+ Project-URL: Source, https://github.com/balusulapalemsaikoushik/nbsplitter
5
+ Author-email: Sai Koushik Balusulapalem <balusulapalem.saikoushik@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: grapheme,japanese,kanji
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Operating System :: Microsoft
12
+ Classifier: Operating System :: POSIX
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Text Processing
21
+ Classifier: Topic :: Text Processing :: Linguistic
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: jaconv
24
+ Requires-Dist: sudachidict-full
25
+ Requires-Dist: sudachipy
26
+ Description-Content-Type: text/markdown
27
+
28
+ # nbsplitter
29
+
30
+ A tool for splitting Japanese text into graphemes (i.e. the smallest unit of written text that preserves pronunciation).
31
+
32
+ ## Context
33
+
34
+ Splitting Japanese graphemes as defined here isn't exactly a straightforward task. Ignoring kana (since each character neatly maps to a single pronunciation), there are quite a few nuances to consider: each individual kanji has several possible readings, certain groupings of kanji must be considered unique graphemes because their pronunciations aren't obtainable by merely combining individual kanji readings, and so on. This package elegantly handles the vast majority of these exceptions under the hood and exposes a single interface for splitting graphemes as desired.
35
+
36
+ ## Usage
37
+
38
+ ```pycon
39
+ >>> from nbsplitter import split_graphemes
40
+ >>> graphemes = split_graphemes("東大和市")
41
+ >>> print(graphemes.surface())
42
+ ['東', '大和', '市']
43
+ >>> print(graphemes.reading_form())
44
+ ['ヒガシ', 'ヤマト', 'シ']
45
+ ```
46
+
47
+ ## Known Limitations
48
+
49
+ ### Inability to differentiate between rendaku and arbitrary unvoiced-to-voiced consonant changes
50
+
51
+ As noted in the documentation below, the splitter algorithm cannot definitively distinguish between examples of true rendaku and multi-kanji graphemes whose second component appears to be read as the voiced equivalent of one of its standalone readings. For example, consider the output below:
52
+
53
+ ```python
54
+ graphemes = split_graphemes("富士", split_rendaku=True)
55
+ print(graphemes.reading_form())
56
+ # Output: ['フ', 'ジ'] <-- WRONG: should be ['フジ']
57
+ ```
58
+
59
+ This occurs because the kanji 士 can be read as シ, so the algorithm interprets the ジ found in the grapheme's actual reading as an intentional change in voicing (i.e. rendaku) when in practice the grapheme 富士 cannot be split (although this may reveal a thing or two about historical changes in pronunciation, I wouldn't say it's particularly useful for parsing modern Japanese).
60
+
61
+ If this behavior is undesirable, simply disable the option to split graphemes affected by rendaku, at the cost of compound words such as 船橋 being treated as a single grapheme. May be fixed in a future update.
62
+
63
+ ## API Reference
64
+
65
+ <!--[[[cog
66
+ from inspect import getmembers, isclass, isfunction
67
+ import cog
68
+ from docstring_parser import parse
69
+ import nbsplitter
70
+
71
+ def outl_func(doc):
72
+ cog.outl(doc.short_description)
73
+ if doc.long_description:
74
+ cog.outl()
75
+ cog.outl(doc.long_description)
76
+ if doc.params:
77
+ cog.outl()
78
+ cog.outl("Args:")
79
+ for param in doc.params:
80
+ cog.outl(f"* **{param.arg_name}**: {param.description}")
81
+ if doc.returns:
82
+ cog.outl()
83
+ cog.outl("Returns:")
84
+ cog.outl(f"* {doc.returns.description}")
85
+
86
+ def outl_member(name, member, parent=None):
87
+ if not name.startswith("_") and (doc := member.__doc__):
88
+ heading = f"### {name}" if parent is None else f"#### {parent}.{name}"
89
+ is_function = isfunction(member)
90
+ if is_function:
91
+ heading += "()"
92
+ doc = parse(doc)
93
+ cog.outl(heading)
94
+ cog.outl()
95
+ { True: outl_func, False: cog.outl }[is_function](doc)
96
+ cog.outl()
97
+
98
+ for name, member in getmembers(nbsplitter):
99
+ outl_member(name, member)
100
+ if isclass(member):
101
+ for child_name, child_member in getmembers(member):
102
+ outl_member(child_name, child_member, parent=name)
103
+ ]]]-->
104
+ ### Grapheme
105
+
106
+ A single grapheme.
107
+
108
+ Represents the smallest unit of written text that maintains its intended
109
+ pronunciation. Can either be a single character or a multi-character
110
+ compound with a distinct pronunciation (see
111
+ https://en.wikipedia.org/wiki/Kanji#Special_readings).
112
+
113
+
114
+ #### Grapheme.reading_form()
115
+
116
+ The reading form of this grapheme (in katakana).
117
+
118
+ #### Grapheme.surface()
119
+
120
+ The original Japanese form of this grapheme.
121
+
122
+ ### GraphemeList
123
+
124
+ A list of graphemes.
125
+
126
+ #### GraphemeList.reading_form()
127
+
128
+ A list containing every grapheme's reading form (in katakana).
129
+
130
+ #### GraphemeList.surface()
131
+
132
+ A list containing every grapheme's original Japanese form.
133
+
134
+ ### split_graphemes()
135
+
136
+ Splits Japanese text into graphemes.
137
+
138
+ Args:
139
+ * **japanese**: The text to be split.
140
+ * **split_rendaku**: NOT RECOMMENDED: Use only if intending on verifying
141
+ graphemes later on. This option may interpret compounds whose
142
+ latter parts happen to be the voiced equivalents of unvoiced
143
+ counterparts as examples of rendaku when they should not be
144
+ considered as such. If True latter parts of a multi-kanji compound
145
+ affected by rendaku (see https://en.wikipedia.org/wiki/Rendaku) are
146
+ treated as separate graphemes.
147
+
148
+ Returns:
149
+ * A GraphemeList representing the split text.
150
+
151
+ <!--[[[end]]]-->
152
+
153
+ ## Acknowledgements
154
+
155
+ This package relies on [KANJIDIC](https://www.edrdg.org/wiki/index.php/KANJIDIC_Project) dictionary files. These files are property of the [Electronic Dictionary Research and Development Group (EDRDG)](https://www.edrdg.org/) and are used in accordance with the Group's [license](https://www.edrdg.org/edrdg/licence.html).
@@ -0,0 +1,128 @@
1
+ # nbsplitter
2
+
3
+ A tool for splitting Japanese text into graphemes (i.e. the smallest unit of written text that preserves pronunciation).
4
+
5
+ ## Context
6
+
7
+ Splitting Japanese graphemes as defined here isn't exactly a straightforward task. Ignoring kana (since each character neatly maps to a single pronunciation), there are quite a few nuances to consider: each individual kanji has several possible readings, certain groupings of kanji must be considered unique graphemes because their pronunciations aren't obtainable by merely combining individual kanji readings, and so on. This package elegantly handles the vast majority of these exceptions under the hood and exposes a single interface for splitting graphemes as desired.
8
+
9
+ ## Usage
10
+
11
+ ```pycon
12
+ >>> from nbsplitter import split_graphemes
13
+ >>> graphemes = split_graphemes("東大和市")
14
+ >>> print(graphemes.surface())
15
+ ['東', '大和', '市']
16
+ >>> print(graphemes.reading_form())
17
+ ['ヒガシ', 'ヤマト', 'シ']
18
+ ```
19
+
20
+ ## Known Limitations
21
+
22
+ ### Inability to differentiate between rendaku and arbitrary unvoiced-to-voiced consonant changes
23
+
24
+ As noted in the documentation below, the splitter algorithm cannot definitively distinguish between examples of true rendaku and multi-kanji graphemes whose second component appears to be read as the voiced equivalent of one of its standalone readings. For example, consider the output below:
25
+
26
+ ```python
27
+ graphemes = split_graphemes("富士", split_rendaku=True)
28
+ print(graphemes.reading_form())
29
+ # Output: ['フ', 'ジ'] <-- WRONG: should be ['フジ']
30
+ ```
31
+
32
+ This occurs because the kanji 士 can be read as シ, so the algorithm interprets the ジ found in the grapheme's actual reading as an intentional change in voicing (i.e. rendaku) when in practice the grapheme 富士 cannot be split (although this may reveal a thing or two about historical changes in pronunciation, I wouldn't say it's particularly useful for parsing modern Japanese).
33
+
34
+ If this behavior is undesirable, simply disable the option to split graphemes affected by rendaku, at the cost of compound words such as 船橋 being treated as a single grapheme. May be fixed in a future update.
35
+
36
+ ## API Reference
37
+
38
+ <!--[[[cog
39
+ from inspect import getmembers, isclass, isfunction
40
+ import cog
41
+ from docstring_parser import parse
42
+ import nbsplitter
43
+
44
+ def outl_func(doc):
45
+ cog.outl(doc.short_description)
46
+ if doc.long_description:
47
+ cog.outl()
48
+ cog.outl(doc.long_description)
49
+ if doc.params:
50
+ cog.outl()
51
+ cog.outl("Args:")
52
+ for param in doc.params:
53
+ cog.outl(f"* **{param.arg_name}**: {param.description}")
54
+ if doc.returns:
55
+ cog.outl()
56
+ cog.outl("Returns:")
57
+ cog.outl(f"* {doc.returns.description}")
58
+
59
+ def outl_member(name, member, parent=None):
60
+ if not name.startswith("_") and (doc := member.__doc__):
61
+ heading = f"### {name}" if parent is None else f"#### {parent}.{name}"
62
+ is_function = isfunction(member)
63
+ if is_function:
64
+ heading += "()"
65
+ doc = parse(doc)
66
+ cog.outl(heading)
67
+ cog.outl()
68
+ { True: outl_func, False: cog.outl }[is_function](doc)
69
+ cog.outl()
70
+
71
+ for name, member in getmembers(nbsplitter):
72
+ outl_member(name, member)
73
+ if isclass(member):
74
+ for child_name, child_member in getmembers(member):
75
+ outl_member(child_name, child_member, parent=name)
76
+ ]]]-->
77
+ ### Grapheme
78
+
79
+ A single grapheme.
80
+
81
+ Represents the smallest unit of written text that maintains its intended
82
+ pronunciation. Can either be a single character or a multi-character
83
+ compound with a distinct pronunciation (see
84
+ https://en.wikipedia.org/wiki/Kanji#Special_readings).
85
+
86
+
87
+ #### Grapheme.reading_form()
88
+
89
+ The reading form of this grapheme (in katakana).
90
+
91
+ #### Grapheme.surface()
92
+
93
+ The original Japanese form of this grapheme.
94
+
95
+ ### GraphemeList
96
+
97
+ A list of graphemes.
98
+
99
+ #### GraphemeList.reading_form()
100
+
101
+ A list containing every grapheme's reading form (in katakana).
102
+
103
+ #### GraphemeList.surface()
104
+
105
+ A list containing every grapheme's original Japanese form.
106
+
107
+ ### split_graphemes()
108
+
109
+ Splits Japanese text into graphemes.
110
+
111
+ Args:
112
+ * **japanese**: The text to be split.
113
+ * **split_rendaku**: NOT RECOMMENDED: Use only if intending on verifying
114
+ graphemes later on. This option may interpret compounds whose
115
+ latter parts happen to be the voiced equivalents of unvoiced
116
+ counterparts as examples of rendaku when they should not be
117
+ considered as such. If True latter parts of a multi-kanji compound
118
+ affected by rendaku (see https://en.wikipedia.org/wiki/Rendaku) are
119
+ treated as separate graphemes.
120
+
121
+ Returns:
122
+ * A GraphemeList representing the split text.
123
+
124
+ <!--[[[end]]]-->
125
+
126
+ ## Acknowledgements
127
+
128
+ This package relies on [KANJIDIC](https://www.edrdg.org/wiki/index.php/KANJIDIC_Project) dictionary files. These files are property of the [Electronic Dictionary Research and Development Group (EDRDG)](https://www.edrdg.org/) and are used in accordance with the Group's [license](https://www.edrdg.org/edrdg/licence.html).
@@ -0,0 +1,40 @@
1
+ import gzip
2
+ from pathlib import Path
3
+ import shutil
4
+
5
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
6
+ from hatchling.metadata.plugin.interface import MetadataHookInterface
7
+ import urllib.request
8
+
9
+
10
+ KANJIDIC2_URL = "https://www.edrdg.org/kanjidic/kanjidic2.xml.gz"
11
+ KANJIDIC2_FILENAME = "kanjidic2.xml"
12
+
13
+
14
+ class CustomBuildHook(BuildHookInterface):
15
+ def initialize(self, version: str, build_data: dict):
16
+ data_dir = Path(self.root) / "src" / "nbsplitter" / "data"
17
+ data_dir.mkdir(parents=True, exist_ok=True)
18
+ dict_file = data_dir / KANJIDIC2_FILENAME
19
+ if not dict_file.exists():
20
+ with urllib.request.urlopen(KANJIDIC2_URL) as response:
21
+ with gzip.GzipFile(fileobj=response) as gz_file:
22
+ with open(dict_file, "wb") as out_file:
23
+ shutil.copyfileobj(gz_file, out_file)
24
+
25
+
26
+ class CustomMetadataHook(MetadataHookInterface):
27
+ def update(self, metadata: dict):
28
+ requirements_file = Path(self.root) / "requirements.in"
29
+ if requirements_file.exists():
30
+ dependencies = []
31
+ with open(requirements_file, "rt") as file:
32
+ for line in file:
33
+ line = line.strip()
34
+ if (
35
+ line
36
+ and (not line.startswith("#"))
37
+ and (not line.startswith("-"))
38
+ ):
39
+ dependencies.append(line)
40
+ metadata["dependencies"] = dependencies
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "nbsplitter"
7
+ version = "1.0.0"
8
+ authors = [
9
+ { "name"="Sai Koushik Balusulapalem", email="balusulapalem.saikoushik@gmail.com" },
10
+ ]
11
+ requires-python = ">=3.9"
12
+ license = "Apache-2.0"
13
+ readme = "README.md"
14
+ keywords = ["japanese", "grapheme", "kanji"]
15
+ classifiers = [
16
+ "Intended Audience :: Developers",
17
+ "Operating System :: MacOS",
18
+ "Operating System :: Microsoft",
19
+ "Operating System :: POSIX",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Topic :: Text Processing",
28
+ "Topic :: Text Processing :: Linguistic",
29
+ ]
30
+
31
+ dynamic = ["dependencies"]
32
+
33
+ [project.urls]
34
+ Source = "https://github.com/balusulapalemsaikoushik/nbsplitter"
35
+
36
+ [tool.hatch.build.hooks.custom]
37
+ path = "hatch_build.py"
38
+
39
+ [tool.hatch.metadata.hooks.custom]
40
+ path = "hatch_build.py"
41
+
42
+ [tool.hatch.build]
43
+ ignore-vcs = true
44
+
45
+ [tool.hatch.build.targets.wheel]
46
+ packages = ["src/nbsplitter"]
@@ -0,0 +1,3 @@
1
+ jaconv
2
+ sudachipy
3
+ sudachidict_full
@@ -0,0 +1,3 @@
1
+ """A tool for splitting Japanese text into graphemes."""
2
+
3
+ from .graphemes import Grapheme, GraphemeList, split_graphemes