fugashi 1.5.2.dev3__cp314-cp314t-macosx_10_15_universal2.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.
- fugashi/.dylibs/libmecab.2.dylib +0 -0
- fugashi/__init__.py +1 -0
- fugashi/cli.py +50 -0
- fugashi/fugashi.cpython-314t-darwin.so +0 -0
- fugashi-1.5.2.dev3.dist-info/METADATA +165 -0
- fugashi-1.5.2.dev3.dist-info/RECORD +11 -0
- fugashi-1.5.2.dev3.dist-info/WHEEL +6 -0
- fugashi-1.5.2.dev3.dist-info/entry_points.txt +4 -0
- fugashi-1.5.2.dev3.dist-info/licenses/LICENSE +21 -0
- fugashi-1.5.2.dev3.dist-info/licenses/LICENSE.mecab +29 -0
- fugashi-1.5.2.dev3.dist-info/top_level.txt +1 -0
|
Binary file
|
fugashi/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .fugashi import *
|
fugashi/cli.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from fugashi import GenericTagger, Tagger, build_dictionary
|
|
2
|
+
import sys
|
|
3
|
+
import fileinput
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main():
|
|
7
|
+
"""
|
|
8
|
+
This is a simple wrapper for fugashi so you can test it from the command line.
|
|
9
|
+
Like the mecab binary, it treats each line of stdin as one sentence. You can
|
|
10
|
+
pass tagger arguments here too.
|
|
11
|
+
"""
|
|
12
|
+
args = " ".join(sys.argv[1:])
|
|
13
|
+
|
|
14
|
+
# This should work if you specify a different dictionary,
|
|
15
|
+
# but it should also work with the pip unidic.
|
|
16
|
+
# Try the GenericTagger and then try the Unidic tagger.
|
|
17
|
+
try:
|
|
18
|
+
tagger = GenericTagger(args, quiet=True)
|
|
19
|
+
except RuntimeError:
|
|
20
|
+
tagger = Tagger(args)
|
|
21
|
+
|
|
22
|
+
for line in fileinput.input([]):
|
|
23
|
+
print(tagger.parse(line.strip()))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def info():
|
|
27
|
+
"""Print configuration info."""
|
|
28
|
+
args = " ".join(sys.argv[1:])
|
|
29
|
+
try:
|
|
30
|
+
tagger = GenericTagger(args, quiet=True)
|
|
31
|
+
except RuntimeError:
|
|
32
|
+
tagger = Tagger(args)
|
|
33
|
+
# TODO get the fugashi version here too
|
|
34
|
+
print("Fugashi dictionary info:")
|
|
35
|
+
print("-----")
|
|
36
|
+
for di in tagger.dictionary_info:
|
|
37
|
+
for field in "version size charset filename".split():
|
|
38
|
+
print((field + ":").ljust(10), di[field])
|
|
39
|
+
print("-----")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def build_dict():
|
|
43
|
+
"""EXPERIMENTAL A wrapper for MeCab's user dictionary building command.
|
|
44
|
+
|
|
45
|
+
This also defaults to utf8.
|
|
46
|
+
"""
|
|
47
|
+
# TODO simplify using pip-installed dictionaries as base
|
|
48
|
+
args = sys.argv[0] + " -f utf8 -t utf8 " + " ".join(sys.argv[1:])
|
|
49
|
+
print(args)
|
|
50
|
+
build_dictionary(args)
|
|
Binary file
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fugashi
|
|
3
|
+
Version: 1.5.2.dev3
|
|
4
|
+
Summary: Cython MeCab wrapper for fast, pythonic Japanese tokenization.
|
|
5
|
+
Author-email: Paul O'Leary McCann <polm@dampfkraft.com>
|
|
6
|
+
License-Expression: MIT AND BSD-3-Clause
|
|
7
|
+
Project-URL: source, https://github.com/polm/fugashi
|
|
8
|
+
Project-URL: funding, https://github.com/sponsors/polm
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Natural Language :: Japanese
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
15
|
+
Classifier: Programming Language :: Cython
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: LICENSE.mecab
|
|
22
|
+
Provides-Extra: unidic
|
|
23
|
+
Requires-Dist: unidic; extra == "unidic"
|
|
24
|
+
Provides-Extra: unidic-lite
|
|
25
|
+
Requires-Dist: unidic-lite; extra == "unidic-lite"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
[](https://fugashi.streamlit.app)
|
|
29
|
+
[](https://pypi.org/project/fugashi/)
|
|
30
|
+

|
|
31
|
+
[](https://pypi.org/project/fugashi/)
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
# fugashi
|
|
35
|
+
|
|
36
|
+
<img src="https://github.com/polm/fugashi/raw/main/fugashi.png" width=125 height=125 alt="fugashi by Irasutoya" />
|
|
37
|
+
|
|
38
|
+
fugashi is a Cython wrapper for [MeCab](https://taku910.github.io/mecab/), a
|
|
39
|
+
Japanese tokenizer and morphological analysis tool. Wheels are provided for
|
|
40
|
+
Linux, OSX (Intel), and Win64, and UniDic is [easy to install](#installing-a-dictionary).
|
|
41
|
+
|
|
42
|
+
**issueを英語で書く必要はありません。**
|
|
43
|
+
|
|
44
|
+
Check out the [interactive demo][], see the [blog post](https://www.dampfkraft.com/nlp/fugashi.html) for background
|
|
45
|
+
on why fugashi exists and some of the design decisions, or see [this
|
|
46
|
+
guide][guide] for a basic introduction to Japanese tokenization.
|
|
47
|
+
|
|
48
|
+
[guide]: https://www.dampfkraft.com/nlp/how-to-tokenize-japanese.html
|
|
49
|
+
[interactive demo]: https://fugashi.streamlit.app
|
|
50
|
+
|
|
51
|
+
If you are on a platform for which wheels are not provided, you'll need to
|
|
52
|
+
install MeCab first. It's recommended you install [from
|
|
53
|
+
source](https://github.com/taku910/mecab). If you need to build from source on
|
|
54
|
+
Windows, [@chezou's fork](https://github.com/chezou/mecab) is recommended; see
|
|
55
|
+
[issue #44](https://github.com/polm/fugashi/issues/44#issuecomment-954426115)
|
|
56
|
+
for an explanation of the problems with the official repo.
|
|
57
|
+
|
|
58
|
+
Known platforms without wheels:
|
|
59
|
+
|
|
60
|
+
- musl-based distros like alpine [#77](https://github.com/polm/fugashi/issues/77)
|
|
61
|
+
- PowerPC
|
|
62
|
+
- Windows 32bit
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from fugashi import Tagger
|
|
68
|
+
|
|
69
|
+
tagger = Tagger('-Owakati')
|
|
70
|
+
text = "麩菓子は、麩を主材料とした日本の菓子。"
|
|
71
|
+
tagger.parse(text)
|
|
72
|
+
# => '麩 菓子 は 、 麩 を 主材 料 と し た 日本 の 菓子 。'
|
|
73
|
+
for word in tagger(text):
|
|
74
|
+
print(word, word.feature.lemma, word.pos, sep='\t')
|
|
75
|
+
# "feature" is the Unidic feature data as a named tuple
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Installing a Dictionary
|
|
79
|
+
|
|
80
|
+
fugashi requires a dictionary. [UniDic](https://unidic.ninjal.ac.jp/) is
|
|
81
|
+
recommended, and two easy-to-install versions are provided.
|
|
82
|
+
|
|
83
|
+
- [unidic-lite](https://github.com/polm/unidic-lite), a slightly modified version 2.1.2 of Unidic (from 2013) that's relatively small
|
|
84
|
+
- [unidic](https://github.com/polm/unidic-py), the latest UniDic 3.1.0, which is 770MB on disk and requires a separate download step
|
|
85
|
+
|
|
86
|
+
If you just want to make sure things work you can start with `unidic-lite`, but
|
|
87
|
+
for more serious processing `unidic` is recommended. For production use you'll
|
|
88
|
+
generally want to generate your own dictionary too; for details see the [MeCab
|
|
89
|
+
documentation](https://taku910.github.io/mecab/learn.html).
|
|
90
|
+
|
|
91
|
+
To get either of these dictionaries, you can install them directly using `pip`
|
|
92
|
+
or do the below:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
pip install 'fugashi[unidic-lite]'
|
|
96
|
+
|
|
97
|
+
# The full version of UniDic requires a separate download step
|
|
98
|
+
pip install 'fugashi[unidic]'
|
|
99
|
+
python -m unidic download
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For more information on the different MeCab dictionaries available, see [this article](https://www.dampfkraft.com/nlp/japanese-tokenizer-dictionaries.html).
|
|
103
|
+
|
|
104
|
+
## Dictionary Use
|
|
105
|
+
|
|
106
|
+
fugashi is written with the assumption you'll use Unidic to process Japanese,
|
|
107
|
+
but it supports arbitrary dictionaries.
|
|
108
|
+
|
|
109
|
+
If you're using a dictionary besides Unidic you can use the GenericTagger like this:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from fugashi import GenericTagger
|
|
113
|
+
tagger = GenericTagger()
|
|
114
|
+
|
|
115
|
+
# parse can be used as normal
|
|
116
|
+
tagger.parse('something')
|
|
117
|
+
# features from the dictionary can be accessed by field numbers
|
|
118
|
+
for word in tagger(text):
|
|
119
|
+
print(word.surface, word.feature[0])
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
You can also create a dictionary wrapper to get feature information as a named tuple.
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from fugashi import GenericTagger, create_feature_wrapper
|
|
126
|
+
CustomFeatures = create_feature_wrapper('CustomFeatures', 'alpha beta gamma')
|
|
127
|
+
tagger = GenericTagger(wrapper=CustomFeatures)
|
|
128
|
+
for word in tagger.parseToNodeList(text):
|
|
129
|
+
print(word.surface, word.feature.alpha)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Citation
|
|
133
|
+
|
|
134
|
+
If you use fugashi in research, it would be appreciated if you cite this paper. You can read it at [the ACL Anthology](https://www.aclweb.org/anthology/2020.nlposs-1.7/) or [on Arxiv](https://arxiv.org/abs/2010.06858).
|
|
135
|
+
|
|
136
|
+
@inproceedings{mccann-2020-fugashi,
|
|
137
|
+
title = "fugashi, a Tool for Tokenizing {J}apanese in Python",
|
|
138
|
+
author = "McCann, Paul",
|
|
139
|
+
booktitle = "Proceedings of Second Workshop for NLP Open Source Software (NLP-OSS)",
|
|
140
|
+
month = nov,
|
|
141
|
+
year = "2020",
|
|
142
|
+
address = "Online",
|
|
143
|
+
publisher = "Association for Computational Linguistics",
|
|
144
|
+
url = "https://www.aclweb.org/anthology/2020.nlposs-1.7",
|
|
145
|
+
pages = "44--51",
|
|
146
|
+
abstract = "Recent years have seen an increase in the number of large-scale multilingual NLP projects. However, even in such projects, languages with special processing requirements are often excluded. One such language is Japanese. Japanese is written without spaces, tokenization is non-trivial, and while high quality open source tokenizers exist they can be hard to use and lack English documentation. This paper introduces fugashi, a MeCab wrapper for Python, and gives an introduction to tokenizing Japanese.",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
## Alternatives
|
|
150
|
+
|
|
151
|
+
If you have a problem with fugashi feel free to open an issue. However, there
|
|
152
|
+
are some cases where it might be better to use a different library.
|
|
153
|
+
|
|
154
|
+
- If you don't want to deal with installing MeCab at all, try [SudachiPy](https://github.com/WorksApplications/sudachi.rs).
|
|
155
|
+
- If you need to work with Korean, try [pymecab-ko](https://github.com/NoUnique/pymecab-ko) or [KoNLPy](https://konlpy.org/en/latest/).
|
|
156
|
+
|
|
157
|
+
## License and Copyright Notice
|
|
158
|
+
|
|
159
|
+
fugashi is released under the terms of the [MIT license](./LICENSE). Please
|
|
160
|
+
copy it far and wide.
|
|
161
|
+
|
|
162
|
+
fugashi is a wrapper for MeCab, and fugashi wheels include MeCab binaries.
|
|
163
|
+
MeCab is copyrighted free software by Taku Kudo `<taku@chasen.org>` and Nippon
|
|
164
|
+
Telegraph and Telephone Corporation, and is redistributed under the [BSD
|
|
165
|
+
License](./LICENSE.mecab).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
fugashi-1.5.2.dev3.dist-info/RECORD,,
|
|
2
|
+
fugashi-1.5.2.dev3.dist-info/WHEEL,sha256=65gUNPbS3f2aTVAlw4K7IpOE3gqwRvvFMKvMHZZfBm8,143
|
|
3
|
+
fugashi-1.5.2.dev3.dist-info/entry_points.txt,sha256=jV282mMQTVkhqOVFTdm_ZQ03pJndByW2JtrSa_a2Wms,121
|
|
4
|
+
fugashi-1.5.2.dev3.dist-info/top_level.txt,sha256=1CQTgPUFi4hjTQg2nHdIR-oH6EfyXtpLhiUglCmuOoM,8
|
|
5
|
+
fugashi-1.5.2.dev3.dist-info/METADATA,sha256=vqmoeA67uuR_uYp9sP88G2NqQdnmzCONPtag9FLCNAo,7328
|
|
6
|
+
fugashi-1.5.2.dev3.dist-info/licenses/LICENSE,sha256=5LkFbx-2Q0xAeg8Y4DVBmBkFBNfz3rvXTG6heUdwXac,1076
|
|
7
|
+
fugashi-1.5.2.dev3.dist-info/licenses/LICENSE.mecab,sha256=YvSyNFCprUDk24Bj1FwdE8eNB8onya2mLEypwRwfPns,1602
|
|
8
|
+
fugashi/fugashi.cpython-314t-darwin.so,sha256=W2vLnq5zTthlAOr5nwm__AK411epvg1E6G6jdo_8o9o,435904
|
|
9
|
+
fugashi/__init__.py,sha256=WsYoQIj7b2S1O5aXOsyhh4tBmFGLkkZ5rrtHdohAQic,23
|
|
10
|
+
fugashi/cli.py,sha256=tQXqi_8D0c0s7X1MZHyzWwmj7S9SkfaIeMwn53iJRQQ,1505
|
|
11
|
+
fugashi/.dylibs/libmecab.2.dylib,sha256=SdFs5STxn4cA55Izqw7xHkPLC8ojeeQbE_btbKbbdWE,1009472
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Paul O'Leary McCann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2001-2008, Taku Kudo
|
|
2
|
+
Copyright (c) 2004-2008, Nippon Telegraph and Telephone Corporation
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
|
6
|
+
permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above
|
|
9
|
+
copyright notice, this list of conditions and the
|
|
10
|
+
following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above
|
|
13
|
+
copyright notice, this list of conditions and the
|
|
14
|
+
following disclaimer in the documentation and/or other
|
|
15
|
+
materials provided with the distribution.
|
|
16
|
+
|
|
17
|
+
* Neither the name of the Nippon Telegraph and Telegraph Corporation
|
|
18
|
+
nor the names of its contributors may be used to endorse or
|
|
19
|
+
promote products derived from this software without specific
|
|
20
|
+
prior written permission.
|
|
21
|
+
|
|
22
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
23
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
24
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
25
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
27
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
28
|
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
29
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fugashi
|