react-native-jieba 0.4.0 → 0.4.1
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.
- package/cpp/cppjieba/CHANGELOG.md +18 -0
- package/cpp/cppjieba/LICENSE +20 -0
- package/cpp/cppjieba/README.md +288 -0
- package/cpp/cppjieba/deps/limonp/CHANGELOG.md +175 -0
- package/cpp/cppjieba/deps/limonp/LICENSE +20 -0
- package/cpp/cppjieba/deps/limonp/README.md +43 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/ArgvContext.hpp +70 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/Closure.hpp +206 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/Colors.hpp +31 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/Condition.hpp +38 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/Config.hpp +103 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/ForcePublic.hpp +7 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/LocalVector.hpp +139 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/Logging.hpp +92 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/NonCopyable.hpp +21 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/StdExtension.hpp +157 -0
- package/cpp/cppjieba/deps/limonp/include/limonp/StringUtil.hpp +386 -0
- package/cpp/cppjieba/dict/README.md +62 -0
- package/cpp/cppjieba/dict/hmm_model.utf8 +34 -0
- package/cpp/cppjieba/dict/idf.utf8 +258826 -0
- package/cpp/cppjieba/dict/jieba.dict.utf8 +348982 -0
- package/cpp/cppjieba/dict/stop_words.utf8 +1534 -0
- package/cpp/cppjieba/dict/user.dict.utf8 +3 -0
- package/cpp/cppjieba/include/cppjieba/DictTrie.hpp +322 -0
- package/cpp/cppjieba/include/cppjieba/FullSegment.hpp +94 -0
- package/cpp/cppjieba/include/cppjieba/HMMModel.hpp +131 -0
- package/cpp/cppjieba/include/cppjieba/HMMSegment.hpp +211 -0
- package/cpp/cppjieba/include/cppjieba/Jieba.hpp +169 -0
- package/cpp/cppjieba/include/cppjieba/KeywordExtractor.hpp +152 -0
- package/cpp/cppjieba/include/cppjieba/MPSegment.hpp +137 -0
- package/cpp/cppjieba/include/cppjieba/MixSegment.hpp +109 -0
- package/cpp/cppjieba/include/cppjieba/PosTagger.hpp +77 -0
- package/cpp/cppjieba/include/cppjieba/PreFilter.hpp +54 -0
- package/cpp/cppjieba/include/cppjieba/QuerySegment.hpp +89 -0
- package/cpp/cppjieba/include/cppjieba/SegmentBase.hpp +46 -0
- package/cpp/cppjieba/include/cppjieba/SegmentTagged.hpp +23 -0
- package/cpp/cppjieba/include/cppjieba/TextRankExtractor.hpp +192 -0
- package/cpp/cppjieba/include/cppjieba/Trie.hpp +200 -0
- package/cpp/cppjieba/include/cppjieba/Unicode.hpp +231 -0
- package/cpp/cppjieba/include/cppjieba/UnicodeFile.hpp +68 -0
- package/package.json +3 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## v5.6.7
|
|
4
|
+
|
|
5
|
+
+ docs: document dictionary file formats
|
|
6
|
+
+ test: add `了解` segmentation regression coverage
|
|
7
|
+
+ test: replace copyrighted benchmark test data with synthetic text
|
|
8
|
+
|
|
9
|
+
## v5.6.6
|
|
10
|
+
|
|
11
|
+
+ fix: add `习总书记` to the main dictionary for the reported `和习` segmentation case
|
|
12
|
+
+ chore: remove stray `韩玉鉴赏` entry from the default user dictionary
|
|
13
|
+
|
|
14
|
+
## v5.6.5
|
|
15
|
+
|
|
16
|
+
+ deps: upgrade limonp to v1.0.2
|
|
17
|
+
|
|
18
|
+
Older release history is preserved in git tags.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
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, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# CppJieba
|
|
2
|
+
|
|
3
|
+
[](https://github.com/yanyiwu/cppjieba/actions/workflows/cmake.yml)
|
|
4
|
+
[](http://yanyiwu.com/)
|
|
5
|
+
[](https://github.com/yanyiwu/cppjieba)
|
|
6
|
+
[](http://yanyiwu.com/work/2015/06/14/jieba-series-performance-test.html)
|
|
7
|
+
[](https://github.com/yanyiwu/cppjieba/releases)
|
|
8
|
+
|
|
9
|
+
## 简介
|
|
10
|
+
|
|
11
|
+
CppJieba是"结巴(Jieba)"中文分词的C++版本
|
|
12
|
+
|
|
13
|
+
### 主要特点
|
|
14
|
+
|
|
15
|
+
- 🚀 高性能:经过线上环境验证的稳定性和性能表现
|
|
16
|
+
- 📦 易集成:源代码以头文件形式提供 (`include/cppjieba/*.hpp`),包含即可使用
|
|
17
|
+
- 🔍 多种分词模式:支持精确模式、全模式、搜索引擎模式等
|
|
18
|
+
- 📚 自定义词典:支持用户自定义词典,支持多词典路径(使用'|'或';'分隔)
|
|
19
|
+
- 💻 跨平台:支持 Linux、macOS、Windows 操作系统
|
|
20
|
+
- 🌈 UTF-8编码:原生支持 UTF-8 编码的中文处理
|
|
21
|
+
|
|
22
|
+
## 快速开始
|
|
23
|
+
|
|
24
|
+
### 环境要求
|
|
25
|
+
|
|
26
|
+
- C++ 编译器:
|
|
27
|
+
- g++ (推荐 4.1 以上版本)
|
|
28
|
+
- 或 clang++
|
|
29
|
+
- cmake (推荐 2.6 以上版本)
|
|
30
|
+
|
|
31
|
+
### 安装步骤
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
git clone https://github.com/yanyiwu/cppjieba.git
|
|
35
|
+
cd cppjieba
|
|
36
|
+
git submodule init
|
|
37
|
+
git submodule update
|
|
38
|
+
mkdir build
|
|
39
|
+
cd build
|
|
40
|
+
cmake ..
|
|
41
|
+
make
|
|
42
|
+
|
|
43
|
+
make test
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Benchmark
|
|
47
|
+
|
|
48
|
+
项目提供了一个用于本地性能对比的 benchmark 目标:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
make benchmark
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
它会构建并运行 `test/benchmark.cpp`,输出以下指标:
|
|
55
|
+
|
|
56
|
+
- `DictTrieLoad`: 词典加载耗时,以及可用时的进程 RSS 内存占用
|
|
57
|
+
- `HMMModelLoad`: HMM 模型加载耗时,以及可用时的进程 RSS 内存占用
|
|
58
|
+
- `MPCut`: `MPSegment` 对基准文本的分词吞吐
|
|
59
|
+
- `MixCut`: `MixSegment` 对基准文本的分词吞吐
|
|
60
|
+
- `DictFind`: 词典查找吞吐
|
|
61
|
+
|
|
62
|
+
这个 benchmark 主要用于本地修改前后的性能回归和对比,不作为默认测试的一部分。
|
|
63
|
+
|
|
64
|
+
## 使用示例
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
./demo
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
结果示例:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
[demo] Cut With HMM
|
|
74
|
+
他/来到/了/网易/杭研/大厦
|
|
75
|
+
[demo] Cut Without HMM
|
|
76
|
+
他/来到/了/网易/杭/研/大厦
|
|
77
|
+
我来到北京清华大学
|
|
78
|
+
[demo] CutAll
|
|
79
|
+
我/来到/北京/清华/清华大学/华大/大学
|
|
80
|
+
小明硕士毕业于中国科学院计算所,后在日本京都大学深造
|
|
81
|
+
[demo] CutForSearch
|
|
82
|
+
小明/硕士/毕业/于/中国/科学/学院/科学院/中国科学院/计算/计算所/,/后/在/日本/京都/大学/日本京都大学/深造
|
|
83
|
+
[demo] Insert User Word
|
|
84
|
+
男默/女泪
|
|
85
|
+
男默女泪
|
|
86
|
+
[demo] CutForSearch Word With Offset
|
|
87
|
+
[{"word": "小明", "offset": 0}, {"word": "硕士", "offset": 6}, {"word": "毕业", "offset": 12}, {"word": "于", "offset": 18}, {"word": "中国", "offset": 21}, {"word": "科学", "offset": 27}, {"word": "学院", "offset": 30}, {"word": "科学院", "offset": 27}, {"word": "中国科学院", "offset": 21}, {"word": "计算", "offset": 36}, {"word": "计算所", "offset": 36}, {"word": ",", "offset": 45}, {"word": "后", "offset": 48}, {"word": "在", "offset": 51}, {"word": "日本", "offset": 54}, {"word": "京都", "offset": 60}, {"word": "大学", "offset": 66}, {"word": "日本京都大学", "offset": 54}, {"word": "深造", "offset": 72}]
|
|
88
|
+
[demo] Tagging
|
|
89
|
+
我是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。
|
|
90
|
+
[我:r, 是:v, 拖拉机:n, 学院:n, 手扶拖拉机:n, 专业:n, 的:uj, 。:x, 不用:v, 多久:m, ,:x, 我:r, 就:d, 会:v, 升职:v, 加薪:nr, ,:x, 当上:t, CEO:eng, ,:x, 走上:v, 人生:n, 巅峰:n, 。:x]
|
|
91
|
+
[demo] Keyword Extraction
|
|
92
|
+
我是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。
|
|
93
|
+
[{"word": "CEO", "offset": [93], "weight": 11.7392}, {"word": "升职", "offset": [72], "weight": 10.8562}, {"word": "加薪", "offset": [78], "weight": 10.6426}, {"word": "手扶拖拉机", "offset": [21], "weight": 10.0089}, {"word": "巅峰", "offset": [111], "weight": 9.49396}]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
For more details, please see [demo](https://github.com/yanyiwu/cppjieba-demo).
|
|
97
|
+
|
|
98
|
+
### 分词结果示例
|
|
99
|
+
|
|
100
|
+
**MPSegment**
|
|
101
|
+
|
|
102
|
+
Output:
|
|
103
|
+
```
|
|
104
|
+
我来到北京清华大学
|
|
105
|
+
我/来到/北京/清华大学
|
|
106
|
+
|
|
107
|
+
他来到了网易杭研大厦
|
|
108
|
+
他/来到/了/网易/杭/研/大厦
|
|
109
|
+
|
|
110
|
+
小明硕士毕业于中国科学院计算所,后在日本京都大学深造
|
|
111
|
+
小/明/硕士/毕业/于/中国科学院/计算所/,/后/在/日本京都大学/深造
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**HMMSegment**
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
我来到北京清华大学
|
|
119
|
+
我来/到/北京/清华大学
|
|
120
|
+
|
|
121
|
+
他来到了网易杭研大厦
|
|
122
|
+
他来/到/了/网易/杭/研大厦
|
|
123
|
+
|
|
124
|
+
小明硕士毕业于中国科学院计算所,后在日本京都大学深造
|
|
125
|
+
小明/硕士/毕业于/中国/科学院/计算所/,/后/在/日/本/京/都/大/学/深/造
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**MixSegment**
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
我来到北京清华大学
|
|
133
|
+
我/来到/北京/清华大学
|
|
134
|
+
|
|
135
|
+
他来到了网易杭研大厦
|
|
136
|
+
他/来到/了/网易/杭研/大厦
|
|
137
|
+
|
|
138
|
+
小明硕士毕业于中国科学院计算所,后在日本京都大学深造
|
|
139
|
+
小明/硕士/毕业/于/中国科学院/计算所/,/后/在/日本京都大学/深造
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**FullSegment**
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
我来到北京清华大学
|
|
147
|
+
我/来到/北京/清华/清华大学/华大/大学
|
|
148
|
+
|
|
149
|
+
他来到了网易杭研大厦
|
|
150
|
+
他/来到/了/网易/杭/研/大厦
|
|
151
|
+
|
|
152
|
+
小明硕士毕业于中国科学院计算所,后在日本京都大学深造
|
|
153
|
+
小/明/硕士/毕业/于/中国/中国科学院/科学/科学院/学院/计算/计算所/,/后/在/日本/日本京都大学/京都/京都大学/大学/深造
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**QuerySegment**
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
我来到北京清华大学
|
|
161
|
+
我/来到/北京/清华/清华大学/华大/大学
|
|
162
|
+
|
|
163
|
+
他来到了网易杭研大厦
|
|
164
|
+
他/来到/了/网易/杭研/大厦
|
|
165
|
+
|
|
166
|
+
小明硕士毕业于中国科学院计算所,后在日本京都大学深造
|
|
167
|
+
小明/硕士/毕业/于/中国/中国科学院/科学/科学院/学院/计算所/,/后/在/中国/中国科学院/科学/科学院/学院/日本/日本京都大学/京都/京都大学/大学/深造
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
以上依次是MP,HMM,Mix三种方法的效果。
|
|
172
|
+
|
|
173
|
+
可以看出效果最好的是Mix,也就是融合MP和HMM的切词算法。即可以准确切出词典已有的词,又可以切出像"杭研"这样的未登录词。
|
|
174
|
+
|
|
175
|
+
Full方法切出所有字典里的词语。
|
|
176
|
+
|
|
177
|
+
Query方法先使用Mix方法切词,对于切出来的较长的词再使用Full方法。
|
|
178
|
+
|
|
179
|
+
### 自定义用户词典
|
|
180
|
+
|
|
181
|
+
自定义词典示例请看`dict/user.dict.utf8`。
|
|
182
|
+
|
|
183
|
+
用户词典支持以下三种格式,每行一条,列之间用空格分隔:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
词语
|
|
187
|
+
词语 词性
|
|
188
|
+
词语 词频 词性
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- `1` 列: 只提供词语,词频使用默认值,词性为空。
|
|
192
|
+
- `2` 列: 当前解释为 `词语 词性`,词频仍使用默认值。
|
|
193
|
+
- `3` 列: 解释为 `词语 词频 词性`。
|
|
194
|
+
- 多个用户词典文件可以用 `|` 或 `;` 连接后一起传入。
|
|
195
|
+
- 不支持行内注释或额外的列。
|
|
196
|
+
|
|
197
|
+
主词典 `dict/jieba.dict.utf8` 的格式固定为三列:
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
词语 词频 词性
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
其中:
|
|
204
|
+
|
|
205
|
+
- `词频` 在加载时会被转换成对数权重,供概率分词使用。
|
|
206
|
+
- 用户词典如果未显式提供词频,会使用主词典统计出来的默认权重;默认策略是中位数权重。
|
|
207
|
+
- `词性` 在代码中只是原样保存的字符串,没有内置枚举校验;主词典当前实际使用了 `55` 种 tag,例如 `n`、`v`、`nr`、`ns`、`nz`、`x`、`eng` 等。
|
|
208
|
+
|
|
209
|
+
没有使用自定义用户词典时的结果:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
令狐冲/是/云/计算/行业/的/专家
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
使用自定义用户词典时的结果:
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
令狐冲/是/云计算/行业/的/专家
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 关键词抽取
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
我是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。
|
|
225
|
+
["CEO:11.7392", "升职:10.8562", "加薪:10.6426", "手扶拖拉机:10.0089", "巅峰:9.49396"]
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
For more details, please see [demo](https://github.com/yanyiwu/cppjieba-demo).
|
|
229
|
+
|
|
230
|
+
### 词性标注
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
我是蓝翔技工拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上总经理,出任CEO,迎娶白富美,走上人生巅峰。
|
|
234
|
+
["我:r", "是:v", "拖拉机:n", "学院:n", "手扶拖拉机:n", "专业:n", "的:uj", "。:x", "不用:v", "多久:m", ",:x", "我:r", "就:d", "会:v", "升职:v", "加薪:nr", ",:x", "当上:t", "CEO:eng", ",:x", "走上:v", "人生:n", "巅峰:n", "。:x"]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
For more details, please see [demo](https://github.com/yanyiwu/cppjieba-demo).
|
|
238
|
+
|
|
239
|
+
支持自定义词性。
|
|
240
|
+
比如在(`dict/user.dict.utf8`)增加一行
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
蓝翔 nz
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
结果如下:
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
["我:r", "是:v", "蓝翔:nz", "技工:n", "拖拉机:n", "学院:n", "手扶拖拉机:n", "专业:n", "的:uj", "。:x", "不用:v", "多久:m", ",:x", "我:r", "就:d", "会:v", "升职:v", "加薪:nr", ",:x", "当:t", "上:f", "总经理:n", ",:x", "出任:v", "CEO:eng", ",:x", "迎娶:v", "白富美:x", ",:x", "走上:v", "人生:n", "巅峰:n", "。:x"]
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## 其它词典资料分享
|
|
253
|
+
|
|
254
|
+
+ [dict.367W.utf8] iLife(562193561 at qq.com)
|
|
255
|
+
|
|
256
|
+
## 生态系统
|
|
257
|
+
|
|
258
|
+
CppJieba 已经被广泛应用于各种编程语言的分词实现中:
|
|
259
|
+
|
|
260
|
+
- [GoJieba](https://github.com/yanyiwu/gojieba) - Go 语言版本
|
|
261
|
+
- [NodeJieba](https://github.com/yanyiwu/nodejieba) - Node.js 版本
|
|
262
|
+
- [CJieba](https://github.com/yanyiwu/cjieba) - C 语言版本
|
|
263
|
+
- [jiebaR](https://github.com/qinwf/jiebaR) - R 语言版本
|
|
264
|
+
- [exjieba](https://github.com/falood/exjieba) - Erlang 版本
|
|
265
|
+
- [jieba_rb](https://github.com/altkatz/jieba_rb) - Ruby 版本
|
|
266
|
+
- [iosjieba](https://github.com/yanyiwu/iosjieba) - iOS 版本
|
|
267
|
+
- [phpjieba](https://github.com/jonnywang/phpjieba) - PHP 版本
|
|
268
|
+
- [perl5-jieba](https://metacpan.org/pod/distribution/Lingua-ZH-Jieba/lib/Lingua/ZH/Jieba.pod) - Perl 版本
|
|
269
|
+
|
|
270
|
+
### 应用项目
|
|
271
|
+
|
|
272
|
+
- [simhash](https://github.com/yanyiwu/simhash) - 中文文档相似度计算
|
|
273
|
+
- [pg_jieba](https://github.com/jaiminpan/pg_jieba) - PostgreSQL 分词插件
|
|
274
|
+
- [gitbook-plugin-search-pro](https://plugins.gitbook.com/plugin/search-pro) - Gitbook 中文搜索插件
|
|
275
|
+
- [ngx_http_cppjieba_module](https://github.com/yanyiwu/ngx_http_cppjieba_module) - Nginx 分词插件
|
|
276
|
+
- [OpenCC](https://github.com/byvoid/OpenCC) - OpenCC 中的 jieba 分词插件
|
|
277
|
+
|
|
278
|
+
## 贡献指南
|
|
279
|
+
|
|
280
|
+
我们欢迎各种形式的贡献,包括但不限于:
|
|
281
|
+
|
|
282
|
+
- 提交问题和建议
|
|
283
|
+
- 改进文档
|
|
284
|
+
- 提交代码修复
|
|
285
|
+
- 添加新功能
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
如果您觉得 CppJieba 对您有帮助,欢迎 star ⭐️ 支持项目!
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## v1.0.2
|
|
4
|
+
|
|
5
|
+
+ [fix][Logging] Avoid release-mode unused variable warning while keeping `tmNow` initialization path intact
|
|
6
|
+
+ [CI] Remove `macos-13` from CMake matrix to prevent long queued jobs
|
|
7
|
+
+ [CI] Upgrade `actions/checkout` from `v4` to `v5`
|
|
8
|
+
|
|
9
|
+
## v1.0.1
|
|
10
|
+
|
|
11
|
+
+ [CI] Update GitHub Actions configurations
|
|
12
|
+
- Add stale issues workflow
|
|
13
|
+
- Update checkout action from v2 to v4
|
|
14
|
+
- Update macOS test environments (remove macOS-12, add macOS-15)
|
|
15
|
+
+ [dep] Update googletest to release-1.12.1
|
|
16
|
+
+ [doc] Add build instructions to README.md
|
|
17
|
+
|
|
18
|
+
## v1.0.0
|
|
19
|
+
|
|
20
|
+
+ rm thread pool demo
|
|
21
|
+
+ deleted: include/limonp/BlockingQueue.hpp
|
|
22
|
+
+ deleted: include/limonp/BoundedBlockingQueue.hpp
|
|
23
|
+
+ deleted: include/limonp/BoundedQueue.hpp
|
|
24
|
+
+ deleted: include/limonp/MutexLock.hpp
|
|
25
|
+
+ deleted: include/limonp/Thread.hpp
|
|
26
|
+
+ deleted: include/limonp/ThreadPool.hpp
|
|
27
|
+
+ deleted: test/unittest/TBlockingQueue.cpp
|
|
28
|
+
+ deleted: test/unittest/TBoundedQueue.cpp
|
|
29
|
+
+ deleted: test/unittest/TMutexLock.cpp
|
|
30
|
+
+ deleted: test/unittest/TThread.cpp
|
|
31
|
+
+ deleted: test/unittest/TThreadPool.cpp
|
|
32
|
+
+ rm FileLock
|
|
33
|
+
+ rm Md5.hpp
|
|
34
|
+
|
|
35
|
+
## v0.9.0
|
|
36
|
+
|
|
37
|
+
+ [c++20] compatibility
|
|
38
|
+
+ [c++17] compatibility
|
|
39
|
+
|
|
40
|
+
## v0.8.1
|
|
41
|
+
|
|
42
|
+
+ [CI] fix windows gtest thread link error
|
|
43
|
+
+ [submodule] rm test/googletest
|
|
44
|
+
+ [CMake] FetchContent googletest
|
|
45
|
+
+ [CMake] required 3.5 -> 3.14
|
|
46
|
+
|
|
47
|
+
## v0.8.0
|
|
48
|
+
|
|
49
|
+
+ [StringUtil] Fix windows assert typo
|
|
50
|
+
+ [CMake] find_package(Threads REQUIRED); target_link_libraries(... Threads::Threads)
|
|
51
|
+
+ [CMAKE][CI] windows: 2019,2022
|
|
52
|
+
+ [CMAKE][CI] matrix.build_type[Release, Debug]
|
|
53
|
+
+ [unittest] disable #TMd5.cpp
|
|
54
|
+
+ [unittest] disable #TFileLock.cpp
|
|
55
|
+
+ [unittest] disable #TBoundedQueue.cpp
|
|
56
|
+
+ [unittest] disable #TMutexLock.cpp
|
|
57
|
+
+ [unittest] disable #TBlockingQueue.cpp
|
|
58
|
+
+ [unittest] disable #TThread.cpp
|
|
59
|
+
+ [unittest] disable #TThreadPool.cpp
|
|
60
|
+
|
|
61
|
+
## v0.7.2
|
|
62
|
+
|
|
63
|
+
+ [CI] ubuntu version from 20 to 22, macos version from 12 to 14
|
|
64
|
+
+ [test/unittes] uint->size_t
|
|
65
|
+
+ [googletest] v1.6.0->v1.10.0
|
|
66
|
+
+ [CMake] version required 3.0 -> 3.5
|
|
67
|
+
|
|
68
|
+
## v0.7.1
|
|
69
|
+
|
|
70
|
+
+ [CMake] fix CMAKE_CXX_STANDARD passed from github/actions and [c++11, c++14] only
|
|
71
|
+
|
|
72
|
+
## v0.7.0
|
|
73
|
+
|
|
74
|
+
+ [CI] Added os.macos and cpp_version=[c++98, c++03, c++11, c++14, c++17, c++20]
|
|
75
|
+
+ [git submodule] Added googletest-release-v1.6.0
|
|
76
|
+
|
|
77
|
+
## v0.6.7
|
|
78
|
+
|
|
79
|
+
+ Merged [pr35](https://github.com/yanyiwu/limonp/pull/35)
|
|
80
|
+
+ Merged [pr33](https://github.com/yanyiwu/limonp/pull/33)
|
|
81
|
+
+ Merged [pr32](https://github.com/yanyiwu/limonp/pull/32)
|
|
82
|
+
|
|
83
|
+
## v0.6.6
|
|
84
|
+
|
|
85
|
+
+ Merged [pr-31 To be compatible with cpp17 and later, use lambda instead of std::not1 & std::bind2nd #31](https://github.com/yanyiwu/limonp/pull/31)
|
|
86
|
+
|
|
87
|
+
## v0.6.5
|
|
88
|
+
|
|
89
|
+
+ Merged [pr-25 Update cmake.yml](https://github.com/yanyiwu/limonp/pull/25)
|
|
90
|
+
+ Merged [pr-26 fix license for end of line sequence and remove useless signature](https://github.com/yanyiwu/limonp/pull/26)
|
|
91
|
+
+ Merged [pr-27 Update cmake.yml](https://github.com/yanyiwu/limonp/pull/27)
|
|
92
|
+
+ Merged [pr-28 add a target to be ready to support installation](https://github.com/yanyiwu/limonp/pull/28)
|
|
93
|
+
+ Merged [pr-29 Installable by cmake](https://github.com/yanyiwu/limonp/pull/29)
|
|
94
|
+
+ Merged [pr-30 Replace localtime with localtime_s on Windows and localtime_r on Linux](https://github.com/yanyiwu/limonp/pull/30)
|
|
95
|
+
|
|
96
|
+
## v0.6.4
|
|
97
|
+
|
|
98
|
+
+ merge [fixup gcc8 warnings](https://github.com/yanyiwu/gojieba/pull/70)
|
|
99
|
+
|
|
100
|
+
## v0.6.3
|
|
101
|
+
|
|
102
|
+
+ remove compiler conplained macro
|
|
103
|
+
|
|
104
|
+
## v0.6.2
|
|
105
|
+
|
|
106
|
+
+ merge [pr-18](https://github.com/yanyiwu/limonp/pull/18/files)
|
|
107
|
+
|
|
108
|
+
## v0.6.1
|
|
109
|
+
|
|
110
|
+
add Specialized template for vector<string>
|
|
111
|
+
|
|
112
|
+
when it is `vector<string>`, print like this: ["hello", "world"]; (special case)
|
|
113
|
+
when it is `vector<int>`, print like this: [1, 10, 1000]; (common cases)
|
|
114
|
+
|
|
115
|
+
## v0.6.0
|
|
116
|
+
|
|
117
|
+
+ remove Trim out of Split.
|
|
118
|
+
|
|
119
|
+
## v0.5.6
|
|
120
|
+
|
|
121
|
+
+ fix hidden trouble.
|
|
122
|
+
|
|
123
|
+
## v0.5.5
|
|
124
|
+
|
|
125
|
+
+ macro name LOG and CHECK in Logging.hpp is so easy to confict with other lib, so I have to rename them to XLOG and XCHECK for avoiding those macro name conflicts.
|
|
126
|
+
|
|
127
|
+
## v0.5.4
|
|
128
|
+
|
|
129
|
+
+ add ForcePublic.hpp
|
|
130
|
+
+ Add Utf8ToUnicode32 and Unicode32ToUtf8 in StringUtil.hpp
|
|
131
|
+
|
|
132
|
+
## v0.5.3
|
|
133
|
+
|
|
134
|
+
+ Fix incompatibility problem about 'time.h' in Windows.
|
|
135
|
+
|
|
136
|
+
## v0.5.2
|
|
137
|
+
|
|
138
|
+
+ Fix incompatibility problem about `enum {INFO ...}` name conflicts in Windows .
|
|
139
|
+
+ So from this version begin: the compile flags: `-DLOGGING_LEVEL=WARNING` must be changed to `-DLOGGING_LEVEL=LL_WARNING`
|
|
140
|
+
|
|
141
|
+
## v0.5.1
|
|
142
|
+
|
|
143
|
+
+ add `ThreadPool::Stop()` to wait util all the threads finished.
|
|
144
|
+
If Stop() has not been called, it will be called when the ThreadPool destructing.
|
|
145
|
+
|
|
146
|
+
## v0.5.0
|
|
147
|
+
|
|
148
|
+
+ Reorganized directories: include/ -> include/limonp/ ... and so on.
|
|
149
|
+
+ Add `NewClosure` in Closure.hpp, 0~3 arguments have been supported.
|
|
150
|
+
+ Update ThreadPool, use `NewClosure` instead of `CreateTask`
|
|
151
|
+
|
|
152
|
+
## v0.4.1
|
|
153
|
+
|
|
154
|
+
+ `CHECK(exp) << "log message"` supported;
|
|
155
|
+
|
|
156
|
+
## v0.4.0
|
|
157
|
+
|
|
158
|
+
+ add test/demo.cc as example.
|
|
159
|
+
+ move `print` macro to StdExtension.hpp
|
|
160
|
+
+ BigChange: rewrite `log` module, use `LOG(INFO) << "xxx" ` instead `LogInfo` .
|
|
161
|
+
+ remove HandyMacro.hpp, add CHECK in Logging.hpp instead.
|
|
162
|
+
|
|
163
|
+
## v0.3.0
|
|
164
|
+
|
|
165
|
+
+ remove 'MysqlClient.hpp', 'InitOnOff.hpp', 'CastFloat.hpp'
|
|
166
|
+
+ add 'Closure.hpp'
|
|
167
|
+
+ uniform code style
|
|
168
|
+
|
|
169
|
+
## v0.2.0
|
|
170
|
+
|
|
171
|
+
+ `namespace limonp`, not `Limonp` .
|
|
172
|
+
|
|
173
|
+
## v0.1.0
|
|
174
|
+
|
|
175
|
+
+ Basic functions
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
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, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# limonp
|
|
2
|
+
|
|
3
|
+
[](https://github.com/yanyiwu/limonp/actions/workflows/cmake.yml)
|
|
4
|
+
[](http://yanyiwu.com/)
|
|
5
|
+
[](https://github.com/yanyiwu/limonp)
|
|
6
|
+
[](https://github.com/yanyiwu/limonp/releases)
|
|
7
|
+
[](http://yanyiwu.mit-license.org)
|
|
8
|
+
|
|
9
|
+
## Introduction
|
|
10
|
+
|
|
11
|
+
`C++` headers(hpp) with Python style.
|
|
12
|
+
|
|
13
|
+
## Feature
|
|
14
|
+
|
|
15
|
+
+ linking is a annoying thing, so I write these source code in headers file(`*.hpp`), you can use them only with `#include "xx.hpp"`, without linking *.a or *.so .
|
|
16
|
+
|
|
17
|
+
**`no linking , no hurts`**
|
|
18
|
+
|
|
19
|
+
## Build
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
mkdir build
|
|
23
|
+
cmake ..
|
|
24
|
+
make
|
|
25
|
+
|
|
26
|
+
make test
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
|
|
31
|
+
See Details in `test/demo.cpp`
|
|
32
|
+
|
|
33
|
+
## Cases
|
|
34
|
+
|
|
35
|
+
1. [CppJieba]
|
|
36
|
+
|
|
37
|
+
## Contact
|
|
38
|
+
|
|
39
|
+
+ i@yanyiwu.com
|
|
40
|
+
|
|
41
|
+
[CppJieba]:https://github.com/yanyiwu/cppjieba.git
|
|
42
|
+
[muduo]:https://github.com/chenshuo/muduo.git
|
|
43
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/************************************
|
|
2
|
+
* file enc : ascii
|
|
3
|
+
* author : wuyanyi09@gmail.com
|
|
4
|
+
************************************/
|
|
5
|
+
|
|
6
|
+
#ifndef LIMONP_ARGV_FUNCTS_H
|
|
7
|
+
#define LIMONP_ARGV_FUNCTS_H
|
|
8
|
+
|
|
9
|
+
#include <set>
|
|
10
|
+
#include <sstream>
|
|
11
|
+
#include "StringUtil.hpp"
|
|
12
|
+
|
|
13
|
+
namespace limonp {
|
|
14
|
+
|
|
15
|
+
using namespace std;
|
|
16
|
+
|
|
17
|
+
class ArgvContext {
|
|
18
|
+
public :
|
|
19
|
+
ArgvContext(int argc, const char* const * argv) {
|
|
20
|
+
for(int i = 0; i < argc; i++) {
|
|
21
|
+
if(StartsWith(argv[i], "-")) {
|
|
22
|
+
if(i + 1 < argc && !StartsWith(argv[i + 1], "-")) {
|
|
23
|
+
mpss_[argv[i]] = argv[i+1];
|
|
24
|
+
i++;
|
|
25
|
+
} else {
|
|
26
|
+
sset_.insert(argv[i]);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
args_.push_back(argv[i]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
~ArgvContext() {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
friend ostream& operator << (ostream& os, const ArgvContext& args);
|
|
37
|
+
string operator [](size_t i) const {
|
|
38
|
+
if(i < args_.size()) {
|
|
39
|
+
return args_[i];
|
|
40
|
+
}
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
string operator [](const string& key) const {
|
|
44
|
+
map<string, string>::const_iterator it = mpss_.find(key);
|
|
45
|
+
if(it != mpss_.end()) {
|
|
46
|
+
return it->second;
|
|
47
|
+
}
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
bool HasKey(const string& key) const {
|
|
52
|
+
if(mpss_.find(key) != mpss_.end() || sset_.find(key) != sset_.end()) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
vector<string> args_;
|
|
60
|
+
map<string, string> mpss_;
|
|
61
|
+
set<string> sset_;
|
|
62
|
+
}; // class ArgvContext
|
|
63
|
+
|
|
64
|
+
inline ostream& operator << (ostream& os, const ArgvContext& args) {
|
|
65
|
+
return os<<args.args_<<args.mpss_<<args.sset_;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} // namespace limonp
|
|
69
|
+
|
|
70
|
+
#endif
|