kotobacore 0.1.11__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.
- kotobacore-0.1.11/LICENSE +201 -0
- kotobacore-0.1.11/PKG-INFO +261 -0
- kotobacore-0.1.11/README.md +225 -0
- kotobacore-0.1.11/kotobacore/__init__.py +45 -0
- kotobacore-0.1.11/kotobacore/_version.py +7 -0
- kotobacore-0.1.11/kotobacore/analyzer.py +182 -0
- kotobacore-0.1.11/kotobacore/cli/__init__.py +0 -0
- kotobacore-0.1.11/kotobacore/cli/main.py +93 -0
- kotobacore-0.1.11/kotobacore/compat/__init__.py +8 -0
- kotobacore-0.1.11/kotobacore/compat/karuizawa_compat.py +85 -0
- kotobacore-0.1.11/kotobacore/dictionary/__init__.py +37 -0
- kotobacore-0.1.11/kotobacore/dictionary/external.py +432 -0
- kotobacore-0.1.11/kotobacore/dictionary/loader.py +432 -0
- kotobacore-0.1.11/kotobacore/emotion/__init__.py +5 -0
- kotobacore-0.1.11/kotobacore/emotion/detector.py +353 -0
- kotobacore-0.1.11/kotobacore/errors.py +19 -0
- kotobacore-0.1.11/kotobacore/intent/__init__.py +5 -0
- kotobacore-0.1.11/kotobacore/intent/classifier.py +66 -0
- kotobacore-0.1.11/kotobacore/normalizer/__init__.py +5 -0
- kotobacore-0.1.11/kotobacore/normalizer/unicode_normalizer.py +44 -0
- kotobacore-0.1.11/kotobacore/output/__init__.py +0 -0
- kotobacore-0.1.11/kotobacore/rag/__init__.py +5 -0
- kotobacore-0.1.11/kotobacore/rag/optimizer.py +166 -0
- kotobacore-0.1.11/kotobacore/resources/dict/Japanese-SNS-Emotion-Examples-v1.txt +547 -0
- kotobacore-0.1.11/kotobacore/resources/dict/emotion.csv +508 -0
- kotobacore-0.1.11/kotobacore/resources/dict/emotion_examples.csv +18 -0
- kotobacore-0.1.11/kotobacore/resources/dict/entity.csv +702 -0
- kotobacore-0.1.11/kotobacore/resources/dict/intent_rules.csv +10 -0
- kotobacore-0.1.11/kotobacore/resources/dict/normalization.csv +22 -0
- kotobacore-0.1.11/kotobacore/resources/dict/slang.csv +204 -0
- kotobacore-0.1.11/kotobacore/resources/dict/stopwords.csv +114 -0
- kotobacore-0.1.11/kotobacore/schema.py +135 -0
- kotobacore-0.1.11/kotobacore/semantic/__init__.py +6 -0
- kotobacore-0.1.11/kotobacore/semantic/builder.py +158 -0
- kotobacore-0.1.11/kotobacore/semantic/chunker.py +334 -0
- kotobacore-0.1.11/kotobacore/tokenizer/__init__.py +19 -0
- kotobacore-0.1.11/kotobacore/tokenizer/base.py +16 -0
- kotobacore-0.1.11/kotobacore/tokenizer/karuizawa_backend.py +98 -0
- kotobacore-0.1.11/kotobacore/tokenizer/token_normalizer.py +842 -0
- kotobacore-0.1.11/kotobacore.egg-info/PKG-INFO +261 -0
- kotobacore-0.1.11/kotobacore.egg-info/SOURCES.txt +59 -0
- kotobacore-0.1.11/kotobacore.egg-info/dependency_links.txt +1 -0
- kotobacore-0.1.11/kotobacore.egg-info/entry_points.txt +2 -0
- kotobacore-0.1.11/kotobacore.egg-info/requires.txt +11 -0
- kotobacore-0.1.11/kotobacore.egg-info/top_level.txt +1 -0
- kotobacore-0.1.11/pyproject.toml +81 -0
- kotobacore-0.1.11/setup.cfg +4 -0
- kotobacore-0.1.11/tests/test_cli.py +61 -0
- kotobacore-0.1.11/tests/test_dictionary.py +152 -0
- kotobacore-0.1.11/tests/test_emotion.py +222 -0
- kotobacore-0.1.11/tests/test_external_dict.py +241 -0
- kotobacore-0.1.11/tests/test_import.py +26 -0
- kotobacore-0.1.11/tests/test_integration.py +154 -0
- kotobacore-0.1.11/tests/test_intent.py +111 -0
- kotobacore-0.1.11/tests/test_normalizer.py +65 -0
- kotobacore-0.1.11/tests/test_rag.py +108 -0
- kotobacore-0.1.11/tests/test_schema.py +62 -0
- kotobacore-0.1.11/tests/test_semantic.py +143 -0
- kotobacore-0.1.11/tests/test_token_normalizer.py +144 -0
- kotobacore-0.1.11/tests/test_tokenizer.py +68 -0
- kotobacore-0.1.11/tests/test_version.py +5 -0
|
@@ -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 Derivative
|
|
95
|
+
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 2026 KotobaCore Project
|
|
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,261 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kotobacore
|
|
3
|
+
Version: 0.1.11
|
|
4
|
+
Summary: Japanese semantic understanding engine for LLM, RAG, SNS analysis, and AI agents
|
|
5
|
+
Author: KotobaCore Project
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ekiyo55/kotobacore
|
|
8
|
+
Project-URL: Repository, https://github.com/ekiyo55/kotobacore
|
|
9
|
+
Project-URL: Issues, https://github.com/ekiyo55/kotobacore/issues
|
|
10
|
+
Project-URL: Demo, https://kotobacore.mooma.style/
|
|
11
|
+
Keywords: japanese,nlp,tokenizer,semantic,rag,llm,emotion-analysis,karuizawa
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: PyYAML>=6.0
|
|
27
|
+
Requires-Dist: typer>=0.12.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.5.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.10.0; extra == "dev"
|
|
33
|
+
Provides-Extra: ui
|
|
34
|
+
Requires-Dist: streamlit>=1.36.0; extra == "ui"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# KotobaCore
|
|
38
|
+
|
|
39
|
+
[](https://github.com/ekiyo55/kotobacore/actions/workflows/ci.yml)
|
|
40
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
41
|
+
[](https://www.python.org/)
|
|
42
|
+
|
|
43
|
+
[English](README_en.md) | **日本語**
|
|
44
|
+
|
|
45
|
+
日本語テキストの意味を構造化データに変換するセマンティックエンジン。
|
|
46
|
+
LLM前処理・RAG・SNS解析・AIエージェント入力に使えます。
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 何ができるか
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from kotobacore import Analyzer
|
|
54
|
+
|
|
55
|
+
result = Analyzer().analyze("クラウドAPIの課金高すぎてしぬw")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
chunks : ["クラウドAPI", "課金高すぎ", "しぬw"]
|
|
60
|
+
emotion : anger / negative (Plutchik: anger+disgust)
|
|
61
|
+
intent : pricing_complaint
|
|
62
|
+
keywords : ["クラウドAPI", "課金"]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
単なるトークナイザーではなく、**感情・意図・RAGキーワードまで一括で返す**のが特徴です。
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## パイプライン
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
入力テキスト
|
|
73
|
+
└─ 正規化 (NFKC / SNS表現保持)
|
|
74
|
+
└─ トークナイズ (外部依存ゼロの内蔵トークナイザー)
|
|
75
|
+
└─ セマンティックチャンク生成
|
|
76
|
+
├─ 感情検出 + Plutchik 8軸マッピング
|
|
77
|
+
├─ 意図分類
|
|
78
|
+
└─ RAGキーワード抽出
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 感情モデル — Plutchik の感情の輪
|
|
84
|
+
|
|
85
|
+
KotobaCore は心理学者 Robert Plutchik が提唱した **8基本感情モデル** をベースにしています。
|
|
86
|
+
怒り・恐れ・喜び・悲しみ・信頼・嫌悪・驚き・期待の8軸で感情を分類し、
|
|
87
|
+
テキストの感情を `primary / polarity / plutchik_axes` として構造化して返します。
|
|
88
|
+
|
|
89
|
+
| Plutchik 軸 | KotobaCore カテゴリ | 例 |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| joy | joy / moved / admiration | 嬉しい, 感動した, 誇らしい |
|
|
92
|
+
| anger | anger / refusal | ムカつく, 無理, 許せない |
|
|
93
|
+
| sadness | sadness / anxiety | 悲しい, 不安, 心配 |
|
|
94
|
+
| surprise | surprise / exaggeration | まじか, やばい, しぬw |
|
|
95
|
+
| anticipation | anticipation / desire | 楽しみ, したい, 欲しい |
|
|
96
|
+
| trust | admiration | 尊い, 信頼, 神対応 |
|
|
97
|
+
| fear | anxiety | 怖い, 恐怖, ゾッとした |
|
|
98
|
+
| disgust | refusal | 最悪, 気持ち悪い, 無理 |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 内蔵辞書
|
|
103
|
+
|
|
104
|
+
KotobaCore の判定は機械学習モデルではなく、**同梱の人手メンテナンス辞書(プレーンな CSV)** に基づきます。
|
|
105
|
+
モデルのダウンロードや学習は不要で、CSV を編集するだけで語彙・ルールを追加・調整できます(`resources/dict/`)。
|
|
106
|
+
|
|
107
|
+
| 辞書ファイル | 件数 | 役割 | 主な列 |
|
|
108
|
+
|---|---:|---|---|
|
|
109
|
+
| `entity.csv` | 701 | 固有表現(人名・ブランド・組織・地名・作品・サービス等)。`aliases` 列で別名表記も認識 | surface, type, normalized, aliases, priority, keep_as_unit |
|
|
110
|
+
| `emotion.csv` | 507 | 感情語。11 カテゴリ(joy / sadness / admiration / refusal / moved / anger / anxiety / exaggeration / anticipation / irritation / agreement)を Plutchik 8 軸へマップ | surface, base_emotion, polarity, intensity, keep_as_unit |
|
|
111
|
+
| `slang.csv` | 203 | SNS・ネットスラング(草 / しぬw / ワロタ 等) | surface, normalized, meaning, emotion, category, intensity, keep_as_unit |
|
|
112
|
+
| `stopwords.csv` | 113 | チャンク・キーワードから除外する助詞・副詞・接続詞 | surface, category |
|
|
113
|
+
| `normalization.csv` | 21 | 表記ゆれ正規化((株) → 株式会社 等) | source, target, type |
|
|
114
|
+
| `intent_rules.csv` | 9 | 意図分類ルール(pricing_complaint / support_request / positive_feedback / negative_feedback / agreement / admiration / desire / question / request) | intent, pattern, score, priority |
|
|
115
|
+
| `emotion_examples.csv` | 17 | 例文ベース感情マッチ(surface 一致しない文の確信度を補強)の手書きシード | surface, base_emotion, plutchik_emotion, polarity, intensity, example |
|
|
116
|
+
| `Japanese-SNS-Emotion-Examples-v1.txt` | 546 語 / 約 2,746 例文 | SNS 感情例文集(喜び・悲しみ・怒り・恐れ・驚き等)。例文ベースの Jaccard 類似度マッチに使用 | word, emotion, intensity, context, examples, emojis |
|
|
117
|
+
|
|
118
|
+
`entity.csv` の内訳は人名 230 / ブランド 140 / 組織 132 / 地名 89 / 作品 59 / サービス 39 ほか。
|
|
119
|
+
|
|
120
|
+
`Japanese-SNS-Emotion-Examples-v1.txt` も `resources/dict/` に同梱され、デフォルトで読み込まれます(外部辞書なしでも例文マッチが効きます)。
|
|
121
|
+
各行の `examples`(「、」区切りの複数例文)が展開され、入力文との bigram Jaccard 類似度で感情の confidence を補強します。
|
|
122
|
+
|
|
123
|
+
### 任意の外部辞書(NRC、非同梱)
|
|
124
|
+
|
|
125
|
+
唯一の **非同梱** 辞書が **NRC Emotion Intensity Lexicon**(約 9,800 語 / 8 Plutchik 感情の強度辞書)です。
|
|
126
|
+
`dic/`(環境変数 `KOTOBACORE_DIC_DIR` で指定)に置くと、内部辞書に無い感情語を **検出語彙として追加** します
|
|
127
|
+
(内部辞書 `lex_weight=1.0` に対し外部は `0.5` の低めの重みで、文学的・稀少語を補完)。**無くても内蔵辞書だけで動作します。**
|
|
128
|
+
|
|
129
|
+
感情の confidence は `lex_weight × 0.5 + ex_sim × 0.3 + intensity × 0.2` で算出され、
|
|
130
|
+
NRC は第1項(検出語彙)、同梱の SNS 例文は第2項(類似度)に効きます。
|
|
131
|
+
|
|
132
|
+
#### NRC 辞書の入手方法
|
|
133
|
+
|
|
134
|
+
> **⚠️ ライセンス注意**: NRC Emotion Intensity Lexicon は **再配布が禁止** されているため本リポジトリには含まれません。
|
|
135
|
+
> 各自で公式ページから入手してください。**非商用の研究用途は無償**ですが、**商用利用には NRC の商用ライセンスが別途必要** です。
|
|
136
|
+
> 利用時は下記の引用と帰属表示が求められます。必ず[公式ページの利用規約](https://saifmohammad.com/WebPages/AffectIntensity.htm)をご自身で確認してください。
|
|
137
|
+
|
|
138
|
+
1. 公式ページ **NRC Emotion/Affect Intensity Lexicon** から辞書を入手します(多言語自動翻訳版に日本語が含まれます)。
|
|
139
|
+
- https://saifmohammad.com/WebPages/AffectIntensity.htm
|
|
140
|
+
2. 日本語訳データを次の **タブ区切り (TSV) 4 列** 形式に整え、`dic/` に配置します。
|
|
141
|
+
```
|
|
142
|
+
English Word<TAB>Emotion<TAB>Emotion-Intensity-Score<TAB>Japanese Word
|
|
143
|
+
```
|
|
144
|
+
- ファイル名: `dic/Japanese-NRC-Emotion-Intensity-Lexicon-v1.txt`
|
|
145
|
+
- `Emotion` は 8 軸(anger / anticipation / disgust / fear / joy / sadness / surprise / trust)
|
|
146
|
+
3. `dic/` の場所は次の順で探索されます: 環境変数 `KOTOBACORE_DIC_DIR` → `<project>/dic` → `<project>/../dic`。
|
|
147
|
+
|
|
148
|
+
**引用(必須)**:
|
|
149
|
+
|
|
150
|
+
```bibtex
|
|
151
|
+
@inproceedings{LREC18-AIL,
|
|
152
|
+
author = {Mohammad, Saif M.},
|
|
153
|
+
title = {Word Affect Intensities},
|
|
154
|
+
booktitle = {Proceedings of the 11th Edition of the Language Resources
|
|
155
|
+
and Evaluation Conference (LREC-2018)},
|
|
156
|
+
year = {2018},
|
|
157
|
+
address = {Miyazaki, Japan}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**帰属表示の例**: "This product makes use of the NRC Emotion Intensity Lexicon, created by Saif M. Mohammad at the National Research Council Canada."
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from kotobacore.dictionary import load_user_bundle
|
|
165
|
+
bundle = load_user_bundle() # 内蔵 seed + 同梱 SNS 例文 + (あれば) dic/ の NRC を統合
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## インストール
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
git clone https://github.com/ekiyo55/kotobacore.git
|
|
174
|
+
cd kotobacore
|
|
175
|
+
python -m venv .venv
|
|
176
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
177
|
+
pip install -e .[dev,ui]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Python API
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from kotobacore import Analyzer
|
|
186
|
+
|
|
187
|
+
result = Analyzer().analyze("クラウドAPIの課金高すぎてしぬw")
|
|
188
|
+
print(result.to_json())
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 出力 JSON 構造
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"chunks": [
|
|
196
|
+
{"id": 0, "text": "クラウドAPI", "type": "service", "score": 0.96},
|
|
197
|
+
{"id": 1, "text": "課金高すぎ", "type": "complaint", "score": 0.88},
|
|
198
|
+
{"id": 2, "text": "しぬw", "type": "slang_emotion","score": 0.88}
|
|
199
|
+
],
|
|
200
|
+
"emotion": {
|
|
201
|
+
"primary": "anger",
|
|
202
|
+
"polarity": "negative",
|
|
203
|
+
"intensity": 0.82,
|
|
204
|
+
"plutchik_axes": ["anger", "disgust"]
|
|
205
|
+
},
|
|
206
|
+
"intent": {"label": "pricing_complaint", "score": 0.85},
|
|
207
|
+
"rag": {
|
|
208
|
+
"keywords": ["クラウドAPI", "課金"],
|
|
209
|
+
"search_query": "クラウドAPI 課金",
|
|
210
|
+
"summary_hint": "pricing complaint about cloud API"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## CLI
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
kotobacore analyze "今日のランチが絶品だった" --pretty
|
|
221
|
+
kotobacore tokenize "東京都に行った"
|
|
222
|
+
kotobacore version
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Demo UI
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
streamlit run tools/demo_ui/streamlit_app.py
|
|
231
|
+
# → http://localhost:8501
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
公開デモ: https://kotobacore.mooma.style/
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 他ライブラリとの比較
|
|
239
|
+
|
|
240
|
+
| ライブラリ | トークナイズ | 感情解析 | 意図分類 | RAGキーワード | 外部依存 |
|
|
241
|
+
|---|:---:|:---:|:---:|:---:|---|
|
|
242
|
+
| MeCab / SudachiPy | ✅ | ❌ | ❌ | ❌ | C++/辞書 |
|
|
243
|
+
| GiNZA (spaCy) | ✅ | ❌ | ❌ | ❌ | spaCy モデル |
|
|
244
|
+
| oseti / asari | ❌ | ポジ/ネガのみ | ❌ | ❌ | 辞書/ML |
|
|
245
|
+
| BERT系 (transformers) | ✅ | ✅ | △ | ❌ | モデル数GB |
|
|
246
|
+
| **KotobaCore** | ✅ | **Plutchik 8軸** | **✅** | **✅** | **ゼロ** |
|
|
247
|
+
|
|
248
|
+
KotobaCoreが埋めているのは「感情・意図・RAGキーワードを一つのパイプラインで構造化JSON化する」領域です。
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## ステータス
|
|
253
|
+
|
|
254
|
+
v0.1.11 pre-alpha。5000例文の品質評価で 感情正確度 95.2% / 極性正確度 96.1% / 意図正確度 68.1%、処理エラー 0件。
|
|
255
|
+
処理速度はサーバー実機で 1文あたり平均 3.77ms(p99 21.83ms、外部依存ゼロ)。149 テスト全 PASS。
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## ライセンス
|
|
260
|
+
|
|
261
|
+
Apache License 2.0
|