neologdn 0.5.1__cp38-cp38-win_amd64.whl → 0.5.4__cp38-cp38-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.

Potentially problematic release.


This version of neologdn might be problematic. Click here for more details.

@@ -0,0 +1,421 @@
1
+ Metadata-Version: 2.1
2
+ Name: neologdn
3
+ Version: 0.5.4
4
+ Summary: Japanese text normalizer for mecab-neologd
5
+ Author-email: Yukino Ikegami <yknikgm@gmail.com>
6
+ Maintainer-email: Yukino Ikegami <yknikgm@gmail.com>
7
+ License: Apache License
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
183
+
184
+ APPENDIX: How to apply the Apache License to your work.
185
+
186
+ To apply the Apache License to your work, attach the following
187
+ boilerplate notice, with the fields enclosed by brackets "{}"
188
+ replaced with your own identifying information. (Don't include
189
+ the brackets!) The text should be enclosed in the appropriate
190
+ comment syntax for the file format. We also recommend that a
191
+ file or class name and description of purpose be included on the
192
+ same "printed page" as the copyright notice for easier
193
+ identification within third-party archives.
194
+
195
+ Copyright 2015 Yukino Ikegami
196
+
197
+ Licensed under the Apache License, Version 2.0 (the "License");
198
+ you may not use this file except in compliance with the License.
199
+ You may obtain a copy of the License at
200
+
201
+ http://www.apache.org/licenses/LICENSE-2.0
202
+
203
+ Unless required by applicable law or agreed to in writing, software
204
+ distributed under the License is distributed on an "AS IS" BASIS,
205
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
206
+ See the License for the specific language governing permissions and
207
+ limitations under the License.
208
+
209
+
210
+ Project-URL: Homepage, https://github.com/ikegami-yukino/neologdn
211
+ Project-URL: Repository, https://github.com/ikegami-yukino/neologdn.git
212
+ Keywords: MeCab,NEologd,japanese,textpreprocessing,JapaneseText
213
+ Classifier: Development Status :: 4 - Beta
214
+ Classifier: Intended Audience :: Science/Research
215
+ Classifier: Intended Audience :: Developers
216
+ Classifier: Natural Language :: Japanese
217
+ Classifier: License :: OSI Approved :: Apache Software License
218
+ Classifier: Programming Language :: Cython
219
+ Classifier: Programming Language :: Python
220
+ Classifier: Programming Language :: Python :: 3
221
+ Classifier: Programming Language :: Python :: 3.8
222
+ Classifier: Programming Language :: Python :: 3.9
223
+ Classifier: Programming Language :: Python :: 3.10
224
+ Classifier: Programming Language :: Python :: 3.11
225
+ Classifier: Programming Language :: Python :: 3.12
226
+ Classifier: Programming Language :: Python :: 3.13
227
+ Classifier: Topic :: Text Processing :: Linguistic
228
+ Classifier: Topic :: Text Processing
229
+ Description-Content-Type: text/markdown
230
+ License-File: LICENSE
231
+
232
+ # neologdn
233
+
234
+ [![PyPI Downloads](https://static.pepy.tech/badge/neologdn)](https://pepy.tech/projects/neologdn)![PyPI - Version](https://img.shields.io/pypi/v/neologdn)![PyPI - Python Version](https://img.shields.io/pypi/pyversions/neologdn)![PyPI - License](https://img.shields.io/pypi/l/neologdn)
235
+
236
+ neologdn is a Japanese text normalizer for [mecab-neologd](https://github.com/neologd/mecab-ipadic-neologd).
237
+
238
+ The normalization is based on the neologd's rules:
239
+ https://github.com/neologd/mecab-ipadic-neologd/wiki/Regexp.ja
240
+
241
+ And also some optional features are added.
242
+
243
+ Contributions are welcome!
244
+
245
+ NOTE: Installing this module requires C++11 compiler.
246
+
247
+ ## Installation
248
+
249
+ ```sh
250
+ pip install neologdn
251
+ ```
252
+
253
+ If setuptools is not installed, you must install it:
254
+
255
+ ```sh
256
+ pip install setuptools
257
+ ```
258
+
259
+ If you encountered the following error:
260
+
261
+ ```sh
262
+ ERROR: Could not find a version that satisfies the requirement setuptools (from versions: none)
263
+ ```
264
+
265
+ Then execute the following commands to may solve this error:
266
+
267
+ ```sh
268
+ pip install wheel
269
+ pip install --no-build-isolation neologdn
270
+ ```
271
+
272
+ ## Usage
273
+
274
+ ```python
275
+ import neologdn
276
+ neologdn.normalize("ハンカクカナ")
277
+ # => 'ハンカクカナ'
278
+ neologdn.normalize("全角記号!?@#")
279
+ # => '全角記号!?@#'
280
+ neologdn.normalize("全角記号例外「・」")
281
+ # => '全角記号例外「・」'
282
+ neologdn.normalize("長音短縮ウェーーーーイ")
283
+ # => '長音短縮ウェーイ'
284
+ neologdn.normalize("チルダ削除ウェ~∼∾〜〰~イ")
285
+ # => 'チルダ削除ウェイ'
286
+ neologdn.normalize("いろんなハイフン˗֊‐‑‒–⁃⁻₋−")
287
+ # => 'いろんなハイフン-'
288
+ neologdn.normalize("   PRML  副 読 本   ")
289
+ # => 'PRML副読本'
290
+ neologdn.normalize(" Natural Language Processing ")
291
+ # => 'Natural Language Processing'
292
+ neologdn.normalize("かわいいいいいいいいい", repeat=6)
293
+ # => 'かわいいいいいい'
294
+ neologdn.normalize("無駄無駄無駄無駄ァ", repeat=1)
295
+ # => '無駄ァ'
296
+ neologdn.normalize("1995〜2001年", tilde="normalize")
297
+ # => '1995~2001年'
298
+ neologdn.normalize("1995~2001年", tilde="normalize_zenkaku")
299
+ # => '1995〜2001年'
300
+ neologdn.normalize("1995〜2001年", tilde="ignore") # Don't convert tilde
301
+ # => '1995〜2001年'
302
+ neologdn.normalize("1995〜2001年", tilde="remove")
303
+ # => '19952001年'
304
+ neologdn.normalize("1995〜2001年") # Default parameter
305
+ # => '19952001年'
306
+ ```
307
+
308
+
309
+ ## Benchmark
310
+
311
+ ```python
312
+
313
+ # Sample code from
314
+ # https://github.com/neologd/mecab-ipadic-neologd/wiki/Regexp.ja#python-written-by-hideaki-t--overlast
315
+ import normalize_neologd
316
+
317
+ %timeit normalize(normalize_neologd.normalize_neologd)
318
+ # => 9.55 s ± 29.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
319
+
320
+ import neologdn
321
+ %timeit normalize(neologdn.normalize)
322
+ # => 6.66 s ± 35.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
323
+ ```
324
+
325
+ neologdn is about x1.43 faster than sample code.
326
+
327
+ details are described as the below notebook:
328
+ https://github.com/ikegami-yukino/neologdn/blob/master/benchmark/benchmark.ipynb
329
+
330
+ ## License
331
+
332
+ Apache Software License.
333
+
334
+ ## CHANGES
335
+
336
+ ### 0.5.4 (2025-03-15)
337
+
338
+ - Support Python 3.13
339
+ - Fix tilde loss after latin and whitespace (Many thanks @a-lucky)
340
+
341
+ ### 0.5.3 (2024-05-03)
342
+
343
+ - Support Python 3.12
344
+
345
+ ### 0.5.2 (2023-08-03)
346
+
347
+ - Support Python 3.10 and 3.11 (Many thanks @polm)
348
+
349
+ ### 0.5.1 (2021-05-02)
350
+
351
+ - Improve performance of shorten_repeat function (Many thanks @yskn67)
352
+ - Add tilde option to normalize function
353
+
354
+ ### 0.4 (2018-12-06)
355
+
356
+ - Add shorten_repeat function, which shortening contiguous substring. For example: neologdn.normalize("無駄無駄無駄無駄ァ", repeat=1) -> 無駄ァ
357
+
358
+ ### 0.3.2 (2018-05-17)
359
+
360
+ - Add option for suppression removal of spaces between Japanese characters
361
+
362
+ ### 0.2.2 (2018-03-10)
363
+
364
+ - Fix bug (daku-ten & handaku-ten)
365
+ - Support mac osx 10.13 (Many thanks @r9y9)
366
+
367
+ ### 0.2.1 (2017-01-23)
368
+
369
+ - Fix bug (Check if a previous character of daku-ten character is in maps) (Many thanks @unnonouno)
370
+
371
+ ### 0.2 (2016-04-12)
372
+
373
+ - Add lengthened expression (repeating character) threshold
374
+
375
+ ### 0.1.2 (2016-03-29)
376
+
377
+ - Fix installation bug
378
+
379
+ ### 0.1.1.1 (2016-03-19)
380
+
381
+ - Support Windows
382
+ - Explicitly specify to -std=c++11 in build (Many thanks @id774)
383
+
384
+ ### 0.1.1 (2015-10-10)
385
+
386
+ Initial release.
387
+
388
+ ## Contribution
389
+
390
+ Contributions are welcome! See: https://github.com/ikegami-yukino/neologdn/blob/master/.github/CONTRIBUTING.md
391
+
392
+ ## Cited by
393
+
394
+ ### Book
395
+
396
+ - 山本 和英. テキスト処理の要素技術. 近代科学者. P.41. 2021.
397
+
398
+ ### Blog
399
+
400
+ - 【ライブラリ紹介】テキスト正規化ライブラリ neologdn: https://diatonic.codes/blog/neologdn/
401
+ - 日本語テキストの前処理:neologdn、大文字小文字、Unicode正規化 - tuttieee’s blog: https://tuttieee.hatenablog.com/entry/ja-nlp-preprocess
402
+ - ▲本日の関数==neologdn.normalize()== - TPTブログ: https://ds-blog.tbtech.co.jp/entry/2020/05/11/%E2%96%B2%E6%9C%AC%E6%97%A5%E3%81%AE%E9%96%A2%E6%95%B0%3D%3Dneologdn_normalize%28%29%3D%3D
403
+ - NLPについて学ぶ: https://zenn.dev/panyoriokome/scraps/d67f68ab50c0c1
404
+ - テキスト正規化用PythonライブラリをMATLABからコール #Python - Qiita: https://qiita.com/aoimidori/items/ab5a4383b5a7bb307bad
405
+ - 自然言語処理の前処理手順をPythonコード付きでご紹介 | AI活用・AI導入事例の紹介 | AI活用・AI導入事例の紹介: https://www.matrixflow.net/case-study/75/
406
+ - pythonによる日本語前処理備忘録 | DATUM STUDIO株式会社: https://datumstudio.jp/blog/python%E3%81%AB%E3%82%88%E3%82%8B%E6%97%A5%E6%9C%AC%E8%AA%9E%E5%89%8D%E5%87%A6%E7%90%86%E5%82%99%E5%BF%98%E9%8C%B2/
407
+ - 前処理、前処理、そして、前処理 (自然言語処理:日本語編)|narudesu: https://note.com/narudesu/n/na35de30a583a
408
+ - ショートカットキーでneologd.normalize: https://scrapbox.io/nishio/%E3%82%B7%E3%83%A7%E3%83%BC%E3%83%88%E3%82%AB%E3%83%83%E3%83%88%E3%82%AD%E3%83%BC%E3%81%A7neologd.normalize
409
+ - Pythonで自然言語処理を行うための環境構築 #Python - Qiita: https://qiita.com/lawyer_alpaca/items/86b0deda984170203467
410
+ - Python normalize Examples: https://python.hotexamples.com/examples/neologdn/-/normalize/python-normalize-function-examples.html
411
+ - 株式会社ししまろ (ch-4) 潜在的ディリクレ配分(LDA)によるchABSAデータセットの分析: https://shishimaro.co.jp/blog/ai/538
412
+ - 形態素解析前の日本語文書の前処理 (Python) - け日記: https://ohke.hateblo.jp/entry/2019/02/09/141500
413
+ - 人工知能に言語を理解させる!?自然言語処理に重要なデータの前処理をPythonで徹底解説 | AI研究所: https://ai-kenkyujo.com/programming/make-ai-understand-the-language/
414
+ - 最新wikipediaを反映したMeCabユーザー辞書を作る - NEologd拡張 | ぷらこめ: https://purakome.net/mecab/addwiki/
415
+ - 【自然言語処理入門】文に対してストップワードと正規化から処理を施す | マイナビエンジニアブログ: https://engineerblog.mynavi.jp/technology/nlp_stopword/
416
+ - 表記統一 [自然言語処理の餅屋]: https://www.jnlp.org/nlp/%E6%A0%A1%E6%AD%A3/%E8%A1%A8%E8%A8%98%E7%B5%B1%E4%B8%80
417
+ - Pytorchを使ってテキスト生成モデルのT5を構築 〜Transformersでの転移学習による手軽な実践〜 - 見習いデータサイエンティストの隠れ家: https://www.dskomei.com/entry/2021/09/28/110016
418
+ - 象と散歩: Goolge Colabでお手軽テキストマイニング(日本語前処理): https://walking-elephant.blogspot.com/2023/07/text-mining-normalized.html
419
+ - 【Pythonで自然言語処理(NLP)を実装してみよう!】学ぶべき知識についても徹底解説! - ベトナムオフショア開発の最前線 by Mattock inc.: https://mattock.jp/blog/artificial-intelligence/nlp/lets-implement-nlp-in-python/
420
+ - tools [Digital Humanities Japan: Resource Wiki]: https://dhjapan.org/wiki/doku.php?id=tools
421
+ - Pythonで現代の季語を調べてみた | Aidemy | 10秒で始めるAIプログラミング学習サービスAidemy[アイデミー]: https://aidemy.net/magazine/703/
@@ -0,0 +1,7 @@
1
+ neologdn.cp38-win_amd64.pyd,sha256=GHRRsaEqsTb0RpUDD6Y-MeGXhh6ITYStPUqMoxuCkF4,88064
2
+ test_neologdn.py,sha256=oDSKmoYoBX936r4gX95LlnoWFmCZqvwl9VTF6B08QVw,4294
3
+ neologdn-0.5.4.dist-info/LICENSE,sha256=by4ifwXxhgMhU4eP1DMM7g-VdtQb2JQSNm0cUfpZjHQ,11547
4
+ neologdn-0.5.4.dist-info/METADATA,sha256=WEsOlrJ4O1jMjhCNZkiKhY-Fu6WuLq5XTL42ZTbWDoE,22625
5
+ neologdn-0.5.4.dist-info/WHEEL,sha256=2M046GvC9RLU1f1TWyM-2sB7cRKLhAC7ucAFK8l8f24,99
6
+ neologdn-0.5.4.dist-info/top_level.txt,sha256=XGtMNw_2PR189vP77p1xUQJXwncy446J_D6El6_H0-A,23
7
+ neologdn-0.5.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.36.2)
2
+ Generator: setuptools (75.3.2)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp38-cp38-win_amd64
5
5
 
@@ -0,0 +1,2 @@
1
+ neologdn
2
+ test_neologdn
Binary file
test_neologdn.py ADDED
@@ -0,0 +1,64 @@
1
+ # encoding: utf8
2
+ from __future__ import unicode_literals
3
+ import unittest
4
+ from neologdn import normalize, shorten_repeat
5
+
6
+
7
+ class TestNeologdn(unittest.TestCase):
8
+
9
+ def test_normalize(self):
10
+ self.assertEqual(normalize('0'), '0')
11
+ self.assertEqual(normalize('ハンカク'), 'ハンカク')
12
+ self.assertEqual(normalize('o₋o'), 'o-o')
13
+ self.assertEqual(normalize('majika━'), 'majikaー')
14
+ self.assertEqual(normalize('わ〰い'), 'わい')
15
+ self.assertEqual(normalize('スーパーーーー'), 'スーパー')
16
+ self.assertEqual(normalize('!#'), '!#')
17
+ self.assertEqual(normalize('ゼンカク スペース'), 'ゼンカクスペース')
18
+ self.assertEqual(normalize('お お'), 'おお')
19
+ self.assertEqual(normalize(' おお'), 'おお')
20
+ self.assertEqual(normalize('おお '), 'おお')
21
+ self.assertEqual(normalize('検索 エンジン 自作 入門 を 買い ました!!!'),\
22
+ '検索エンジン自作入門を買いました!!!')
23
+ self.assertEqual(normalize('アルゴリズム C'), 'アルゴリズムC')
24
+ self.assertEqual(normalize('   PRML  副 読 本   '), 'PRML副読本')
25
+ self.assertEqual(normalize('Coding the Matrix'), 'Coding the Matrix')
26
+ self.assertEqual(normalize('南アルプスの 天然水 Sparking Lemon レモン一絞り'),\
27
+ '南アルプスの天然水Sparking Lemonレモン一絞り')
28
+ self.assertEqual(normalize('南アルプスの 天然水- Sparking* Lemon+ レモン一絞り'),\
29
+ '南アルプスの天然水- Sparking*Lemon+レモン一絞り')
30
+ self.assertEqual(normalize('パパ'), 'パパ')
31
+ self.assertEqual(normalize('a˗֊‐‑‒–⁃⁻₋−'), 'a-')
32
+ self.assertEqual(normalize('あ﹣-ー—―─━ー'), 'あー')
33
+ self.assertEqual(normalize('チルダ~∼∾〜〰~'), 'チルダ')
34
+ self.assertEqual(normalize('う゛ぽ'), 'ゔぽ')
35
+
36
+ def test_shorten_repeat(self):
37
+ self.assertEqual(shorten_repeat('うまああああああああああああい', 7, 0), 'うまあああああああい')
38
+ self.assertEqual(shorten_repeat('かわいいいいいるい', 6, 0), 'かわいいいいいるい')
39
+ self.assertEqual(shorten_repeat('オラオラオラオラーッ', 2, 0), 'オラオラーッ')
40
+ self.assertEqual(shorten_repeat('無駄無駄無駄無駄ァ', 1, 0), '無駄ァ')
41
+ self.assertEqual(shorten_repeat('隣の客はよく柿食う客だ、隣の客はよく柿食う客だ、隣の客はよく柿食う客だ、言えた!', 1, 0),
42
+ '隣の客はよく柿食う客だ、言えた!')
43
+ self.assertEqual(shorten_repeat('隣の客はよく柿食う客だ、隣の客はよく柿食う客だ、隣の客はよく柿食う客だ、言えた!', 1, 11),
44
+ '隣の客はよく柿食う客だ、隣の客はよく柿食う客だ、隣の客はよく柿食う客だ、言えた!')
45
+
46
+ def test_suppress_removal_of_spaces_between_Japanese(self):
47
+ self.assertEqual(normalize('巴 マミ', remove_space=False), '巴 マミ')
48
+
49
+ def test_handling_tilde(self):
50
+ self.assertEqual(normalize('1467〜1487年', tilde='normalize'), '1467~1487年')
51
+ self.assertEqual(normalize('1467~1487年', tilde='normalize_zenkaku'), '1467〜1487年')
52
+ self.assertEqual(normalize('1467〜1487年', tilde='ignore'), '1467〜1487年')
53
+ self.assertEqual(normalize('1467〜1487年', tilde='remove'), '14671487年')
54
+ self.assertEqual(normalize('1467〜1487年'), '14671487年')
55
+
56
+ def test_tilde_boundary_handling(self):
57
+ self.assertEqual(normalize('A ˗あ'), 'A -あ')
58
+ self.assertEqual(normalize('A ーあ'), 'A ーあ')
59
+ self.assertEqual(normalize('A ~あ', tilde='normalize'), 'A ~あ')
60
+ self.assertEqual(normalize('A ~あ', tilde='normalize_zenkaku'), 'A 〜あ')
61
+ self.assertEqual(normalize('A ~あ'), 'Aあ')
62
+
63
+ if __name__ == '__main__':
64
+ unittest.main()
@@ -1,187 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: neologdn
3
- Version: 0.5.1
4
- Summary: Japanese text normalizer for mecab-neologd
5
- Home-page: http://github.com/ikegami-yukino/neologdn
6
- Author: Yukino Ikegami
7
- Author-email: yknikgm@gmail.com
8
- License: Apache Software License
9
- Keywords: japanese,MeCab
10
- Platform: UNKNOWN
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Natural Language :: Japanese
14
- Classifier: License :: OSI Approved :: Apache Software License
15
- Classifier: Programming Language :: Cython
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.6
19
- Classifier: Programming Language :: Python :: 3.7
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
- Classifier: Topic :: Text Processing :: Linguistic
23
-
24
- neologdn
25
- ===========
26
-
27
- |travis| |pyversion| |version| |license|
28
-
29
- neologdn is a Japanese text normalizer for `mecab-neologd <https://github.com/neologd/mecab-ipadic-neologd>`_.
30
-
31
- The normalization is based on the neologd's rules:
32
- https://github.com/neologd/mecab-ipadic-neologd/wiki/Regexp.ja
33
-
34
-
35
- Contributions are welcome!
36
-
37
- NOTE: Installing this module requires C++11 compiler.
38
-
39
- Installation
40
- ------------
41
-
42
- ::
43
-
44
- $ pip install neologdn
45
-
46
- Usage
47
- -----
48
-
49
- .. code:: python
50
-
51
- import neologdn
52
- neologdn.normalize("ハンカクカナ")
53
- # => 'ハンカクカナ'
54
- neologdn.normalize("全角記号!?@#")
55
- # => '全角記号!?@#'
56
- neologdn.normalize("全角記号例外「・」")
57
- # => '全角記号例外「・」'
58
- neologdn.normalize("長音短縮ウェーーーーイ")
59
- # => '長音短縮ウェーイ'
60
- neologdn.normalize("チルダ削除ウェ~∼∾〜〰~イ")
61
- # => 'チルダ削除ウェイ'
62
- neologdn.normalize("いろんなハイフン˗֊‐‑‒–⁃⁻₋−")
63
- # => 'いろんなハイフン-'
64
- neologdn.normalize("   PRML  副 読 本   ")
65
- # => 'PRML副読本'
66
- neologdn.normalize(" Natural Language Processing ")
67
- # => 'Natural Language Processing'
68
- neologdn.normalize("かわいいいいいいいいい", repeat=6)
69
- # => 'かわいいいいいい'
70
- neologdn.normalize("無駄無駄無駄無駄ァ", repeat=1)
71
- # => '無駄ァ'
72
- neologdn.normalize("1995〜2001年", tilde="normalize")
73
- # => '1995~2001年'
74
- neologdn.normalize("1995~2001年", tilde="normalize_zenkaku")
75
- # => '1995〜2001年'
76
- neologdn.normalize("1995〜2001年", tilde="ignore") # Don't convert tilde
77
- # => '1995〜2001年'
78
- neologdn.normalize("1995〜2001年", tilde="remove")
79
- # => '19952001年'
80
- neologdn.normalize("1995〜2001年") # Default parameter
81
- # => '19952001年'
82
-
83
-
84
- Benchmark
85
- ----------
86
-
87
- .. code:: python
88
-
89
- # Sample code from
90
- # https://github.com/neologd/mecab-ipadic-neologd/wiki/Regexp.ja#python-written-by-hideaki-t--overlast
91
- import normalize_neologd
92
-
93
- %timeit normalize(normalize_neologd.normalize_neologd)
94
- # => 1 loop, best of 3: 18.3 s per loop
95
-
96
-
97
- import neologdn
98
- %timeit normalize(neologdn.normalize)
99
- # => 1 loop, best of 3: 9.05 s per loop
100
-
101
-
102
- neologdn is about x2 faster than sample code.
103
-
104
- details are described as the below notebook:
105
- https://github.com/ikegami-yukino/neologdn/blob/master/benchmark/benchmark.ipynb
106
-
107
-
108
- License
109
- -------
110
-
111
- Apache Software License.
112
-
113
-
114
- Contribution
115
- ------------
116
-
117
- Contributions are welcome! See: https://github.com/ikegami-yukino/neologdn/blob/master/.github/CONTRIBUTING.md
118
-
119
-
120
- .. |travis| image:: https://travis-ci.org/ikegami-yukino/neologdn.svg?branch=master
121
- :target: https://travis-ci.org/ikegami-yukino/neologdn
122
- :alt: travis-ci.org
123
-
124
- .. |version| image:: https://img.shields.io/pypi/v/neologdn.svg
125
- :target: http://pypi.python.org/pypi/neologdn/
126
- :alt: latest version
127
-
128
- .. |pyversion| image:: https://img.shields.io/pypi/pyversions/neologdn.svg
129
-
130
- .. |license| image:: https://img.shields.io/pypi/l/neologdn.svg
131
- :target: http://pypi.python.org/pypi/neologdn/
132
- :alt: license
133
-
134
-
135
-
136
- CHANGES
137
- ========
138
-
139
- 0.5.1 (2021-05-02)
140
- ----------------------------
141
-
142
- - Improve performance of shorten_repeat function (Many thanks @yskn67)
143
- - Add tilde option to normalize function
144
-
145
- 0.4 (2018-12-06)
146
- ----------------------------
147
-
148
- - Add shorten_repeat function, which shortening contiguous substring. For example: neologdn.normalize("無駄無駄無駄無駄ァ", repeat=1) -> 無駄ァ
149
-
150
- 0.3.2 (2018-05-17)
151
- ----------------------------
152
-
153
- - Add option for suppression removal of spaces between Japanese characters
154
-
155
- 0.2.2 (2018-03-10)
156
- ----------------------------
157
-
158
- - Fix bug (daku-ten & handaku-ten)
159
- - Support mac osx 10.13 (Many thanks @r9y9)
160
-
161
- 0.2.1 (2017-01-23)
162
- ----------------------------
163
-
164
- - Fix bug (Check if a previous character of daku-ten character is in maps) (Many thanks @unnonouno)
165
-
166
- 0.2 (2016-04-12)
167
- ----------------------------
168
-
169
- - Add lengthened expression (repeating character) threshold
170
-
171
- 0.1.2 (2016-03-29)
172
- ----------------------------
173
-
174
- - Fix installation bug
175
-
176
- 0.1.1.1 (2016-03-19)
177
- ----------------------------
178
-
179
- - Support Windows
180
- - Explicitly specify to -std=c++11 in build (Many thanks @id774)
181
-
182
- 0.1.1 (2015-10-10)
183
- ----------------------------
184
-
185
- Initial release.
186
-
187
-
@@ -1,6 +0,0 @@
1
- neologdn.cp38-win_amd64.pyd,sha256=0mXBIkz8_FHRV1u_CYKNYdQfrQWT1b8kmwUFqQDPn-I,87040
2
- neologdn-0.5.1.dist-info/LICENSE,sha256=by4ifwXxhgMhU4eP1DMM7g-VdtQb2JQSNm0cUfpZjHQ,11547
3
- neologdn-0.5.1.dist-info/METADATA,sha256=h1tDuRQHCFhMqGLkBNDAkuXCKQEKSOQ4keAfvuk1hL8,5213
4
- neologdn-0.5.1.dist-info/WHEEL,sha256=HLtxc_HoM-kGM7FPJVPSnTt0Nv2G3fZEAjT3ICdG8uY,100
5
- neologdn-0.5.1.dist-info/top_level.txt,sha256=lzaJi2z9LzYyyKzSzM8ZW85oXgUIXZRCKd629uxKRg8,9
6
- neologdn-0.5.1.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- neologdn