nodejieba-plus 3.5.8

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.
Files changed (130) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.github/workflows/github_release.yml +61 -0
  3. package/.github/workflows/npm_publish.yml +24 -0
  4. package/.github/workflows/stale-issues.yml +24 -0
  5. package/.github/workflows/test.yml +42 -0
  6. package/.gitmodules +3 -0
  7. package/.npmignore +15 -0
  8. package/CHANGELOG.md +360 -0
  9. package/CONTRIBUTING.md +78 -0
  10. package/LICENSE +21 -0
  11. package/README.md +349 -0
  12. package/binding.gyp +63 -0
  13. package/index.js +77 -0
  14. package/lib/index.cpp +3 -0
  15. package/lib/nodejieba.cpp +218 -0
  16. package/lib/nodejieba.h +28 -0
  17. package/lib/utils.h +47 -0
  18. package/package.json +48 -0
  19. package/submodules/cppjieba/.github/workflows/cmake.yml +51 -0
  20. package/submodules/cppjieba/.github/workflows/stale-issues.yml +24 -0
  21. package/submodules/cppjieba/.gitmodules +3 -0
  22. package/submodules/cppjieba/CHANGELOG.md +305 -0
  23. package/submodules/cppjieba/CMakeLists.txt +42 -0
  24. package/submodules/cppjieba/LICENSE +20 -0
  25. package/submodules/cppjieba/README.md +280 -0
  26. package/submodules/cppjieba/deps/limonp/.github/workflows/cmake.yml +43 -0
  27. package/submodules/cppjieba/deps/limonp/.gitmodules +0 -0
  28. package/submodules/cppjieba/deps/limonp/CHANGELOG.md +160 -0
  29. package/submodules/cppjieba/deps/limonp/CMakeLists.txt +61 -0
  30. package/submodules/cppjieba/deps/limonp/LICENSE +20 -0
  31. package/submodules/cppjieba/deps/limonp/README.md +38 -0
  32. package/submodules/cppjieba/deps/limonp/include/limonp/ArgvContext.hpp +70 -0
  33. package/submodules/cppjieba/deps/limonp/include/limonp/Closure.hpp +206 -0
  34. package/submodules/cppjieba/deps/limonp/include/limonp/Colors.hpp +31 -0
  35. package/submodules/cppjieba/deps/limonp/include/limonp/Condition.hpp +38 -0
  36. package/submodules/cppjieba/deps/limonp/include/limonp/Config.hpp +103 -0
  37. package/submodules/cppjieba/deps/limonp/include/limonp/ForcePublic.hpp +7 -0
  38. package/submodules/cppjieba/deps/limonp/include/limonp/LocalVector.hpp +139 -0
  39. package/submodules/cppjieba/deps/limonp/include/limonp/Logging.hpp +90 -0
  40. package/submodules/cppjieba/deps/limonp/include/limonp/NonCopyable.hpp +21 -0
  41. package/submodules/cppjieba/deps/limonp/include/limonp/StdExtension.hpp +157 -0
  42. package/submodules/cppjieba/deps/limonp/include/limonp/StringUtil.hpp +386 -0
  43. package/submodules/cppjieba/deps/limonp/test/CMakeLists.txt +8 -0
  44. package/submodules/cppjieba/deps/limonp/test/demo.cpp +40 -0
  45. package/submodules/cppjieba/deps/limonp/test/testdata/1.conf +5 -0
  46. package/submodules/cppjieba/deps/limonp/test/testdata/StdExtension.data +3 -0
  47. package/submodules/cppjieba/deps/limonp/test/testdata/dict.gbk +50 -0
  48. package/submodules/cppjieba/deps/limonp/test/testdata/dict.utf8 +50 -0
  49. package/submodules/cppjieba/deps/limonp/test/testdata/io_testfile +2 -0
  50. package/submodules/cppjieba/deps/limonp/test/testdata/jieba.dict.0.1.utf8 +93 -0
  51. package/submodules/cppjieba/deps/limonp/test/testdata/jieba.dict.0.utf8 +93 -0
  52. package/submodules/cppjieba/deps/limonp/test/testdata/jieba.dict.1.utf8 +67 -0
  53. package/submodules/cppjieba/deps/limonp/test/testdata/jieba.dict.2.utf8 +64 -0
  54. package/submodules/cppjieba/deps/limonp/test/unittest/CMakeLists.txt +30 -0
  55. package/submodules/cppjieba/deps/limonp/test/unittest/TArgvContext.cpp +16 -0
  56. package/submodules/cppjieba/deps/limonp/test/unittest/TCastFloat.cpp +19 -0
  57. package/submodules/cppjieba/deps/limonp/test/unittest/TClosure.cpp +85 -0
  58. package/submodules/cppjieba/deps/limonp/test/unittest/TColorPrint.cpp +20 -0
  59. package/submodules/cppjieba/deps/limonp/test/unittest/TConfig.cpp +17 -0
  60. package/submodules/cppjieba/deps/limonp/test/unittest/TLocalVector.cpp +41 -0
  61. package/submodules/cppjieba/deps/limonp/test/unittest/TLogging.cpp +12 -0
  62. package/submodules/cppjieba/deps/limonp/test/unittest/TStdExtension.cpp +95 -0
  63. package/submodules/cppjieba/deps/limonp/test/unittest/TStringUtil.cpp +183 -0
  64. package/submodules/cppjieba/deps/limonp/test/unittest/gtest_main.cpp +39 -0
  65. package/submodules/cppjieba/dict/README.md +31 -0
  66. package/submodules/cppjieba/dict/hmm_model.utf8 +34 -0
  67. package/submodules/cppjieba/dict/idf.utf8 +258826 -0
  68. package/submodules/cppjieba/dict/jieba.dict.utf8 +348982 -0
  69. package/submodules/cppjieba/dict/pos_dict/char_state_tab.utf8 +6653 -0
  70. package/submodules/cppjieba/dict/pos_dict/prob_emit.utf8 +166 -0
  71. package/submodules/cppjieba/dict/pos_dict/prob_start.utf8 +259 -0
  72. package/submodules/cppjieba/dict/pos_dict/prob_trans.utf8 +5222 -0
  73. package/submodules/cppjieba/dict/stop_words.utf8 +1534 -0
  74. package/submodules/cppjieba/dict/user.dict.utf8 +4 -0
  75. package/submodules/cppjieba/include/cppjieba/DictTrie.hpp +381 -0
  76. package/submodules/cppjieba/include/cppjieba/FullSegment.hpp +93 -0
  77. package/submodules/cppjieba/include/cppjieba/HMMModel.hpp +129 -0
  78. package/submodules/cppjieba/include/cppjieba/HMMSegment.hpp +190 -0
  79. package/submodules/cppjieba/include/cppjieba/Jieba.hpp +169 -0
  80. package/submodules/cppjieba/include/cppjieba/KeywordExtractor.hpp +153 -0
  81. package/submodules/cppjieba/include/cppjieba/MPSegment.hpp +137 -0
  82. package/submodules/cppjieba/include/cppjieba/MixSegment.hpp +109 -0
  83. package/submodules/cppjieba/include/cppjieba/PosTagger.hpp +77 -0
  84. package/submodules/cppjieba/include/cppjieba/PreFilter.hpp +54 -0
  85. package/submodules/cppjieba/include/cppjieba/QuerySegment.hpp +89 -0
  86. package/submodules/cppjieba/include/cppjieba/SegmentBase.hpp +48 -0
  87. package/submodules/cppjieba/include/cppjieba/SegmentTagged.hpp +23 -0
  88. package/submodules/cppjieba/include/cppjieba/TextRankExtractor.hpp +190 -0
  89. package/submodules/cppjieba/include/cppjieba/Trie.hpp +200 -0
  90. package/submodules/cppjieba/include/cppjieba/Unicode.hpp +231 -0
  91. package/submodules/cppjieba/test/CMakeLists.txt +4 -0
  92. package/submodules/cppjieba/test/load_test.cpp +54 -0
  93. package/submodules/cppjieba/test/testdata/curl.res +1 -0
  94. package/submodules/cppjieba/test/testdata/extra_dict/jieba.dict.small.utf8 +109750 -0
  95. package/submodules/cppjieba/test/testdata/gbk_dict/hmm_model.gbk +34 -0
  96. package/submodules/cppjieba/test/testdata/gbk_dict/jieba.dict.gbk +348982 -0
  97. package/submodules/cppjieba/test/testdata/jieba.dict.0.1.utf8 +93 -0
  98. package/submodules/cppjieba/test/testdata/jieba.dict.0.utf8 +93 -0
  99. package/submodules/cppjieba/test/testdata/jieba.dict.1.utf8 +67 -0
  100. package/submodules/cppjieba/test/testdata/jieba.dict.2.utf8 +64 -0
  101. package/submodules/cppjieba/test/testdata/load_test.urls +2 -0
  102. package/submodules/cppjieba/test/testdata/review.100 +100 -0
  103. package/submodules/cppjieba/test/testdata/review.100.res +200 -0
  104. package/submodules/cppjieba/test/testdata/server.conf +19 -0
  105. package/submodules/cppjieba/test/testdata/testlines.gbk +9 -0
  106. package/submodules/cppjieba/test/testdata/testlines.utf8 +8 -0
  107. package/submodules/cppjieba/test/testdata/userdict.2.utf8 +1 -0
  108. package/submodules/cppjieba/test/testdata/userdict.english +2 -0
  109. package/submodules/cppjieba/test/testdata/userdict.utf8 +8 -0
  110. package/submodules/cppjieba/test/testdata/weicheng.utf8 +247 -0
  111. package/submodules/cppjieba/test/unittest/CMakeLists.txt +33 -0
  112. package/submodules/cppjieba/test/unittest/gtest_main.cpp +39 -0
  113. package/submodules/cppjieba/test/unittest/jieba_test.cpp +166 -0
  114. package/submodules/cppjieba/test/unittest/keyword_extractor_test.cpp +79 -0
  115. package/submodules/cppjieba/test/unittest/pos_tagger_test.cpp +41 -0
  116. package/submodules/cppjieba/test/unittest/pre_filter_test.cpp +43 -0
  117. package/submodules/cppjieba/test/unittest/segments_test.cpp +256 -0
  118. package/submodules/cppjieba/test/unittest/textrank_test.cpp +86 -0
  119. package/submodules/cppjieba/test/unittest/trie_test.cpp +177 -0
  120. package/submodules/cppjieba/test/unittest/unicode_test.cpp +43 -0
  121. package/test/debug_split +0 -0
  122. package/test/debug_split2 +0 -0
  123. package/test/debug_split3 +0 -0
  124. package/test/load_dict_test.js +14 -0
  125. package/test/missing_binding_test.js +42 -0
  126. package/test/test.js +366 -0
  127. package/test/testdata/userdict.utf8 +1 -0
  128. package/tsconfig.json +59 -0
  129. package/types/index.d.ts +30 -0
  130. package/typescript_demo.ts +38 -0
@@ -0,0 +1,218 @@
1
+ #include "nodejieba.h"
2
+
3
+ #include "utils.h"
4
+
5
+ #include "cppjieba/Jieba.hpp"
6
+ #include "cppjieba/KeywordExtractor.hpp"
7
+ #include "cppjieba/TextRankExtractor.hpp"
8
+
9
+ NodeJieba::NodeJieba(Napi::Env env, Napi::Object exports) {
10
+ DefineAddon(exports, {
11
+ InstanceMethod("load", &NodeJieba::load),
12
+ InstanceMethod("cut", &NodeJieba::cut),
13
+ InstanceMethod("cutAll", &NodeJieba::cutAll),
14
+ InstanceMethod("cutHMM", &NodeJieba::cutHMM),
15
+ InstanceMethod("cutForSearch", &NodeJieba::cutForSearch),
16
+ InstanceMethod("cutSmall", &NodeJieba::cutSmall),
17
+ InstanceMethod("tag", &NodeJieba::tag),
18
+ InstanceMethod("extract", &NodeJieba::extract),
19
+ InstanceMethod("textRankExtract", &NodeJieba::textRankExtract),
20
+ InstanceMethod("insertWord", &NodeJieba::insertWord)
21
+ });
22
+ }
23
+
24
+ Napi::Value NodeJieba::load(const Napi::CallbackInfo& info) {
25
+ if (info.Length() != 5) {
26
+ return Napi::Boolean::New(info.Env(), false);
27
+ }
28
+
29
+ std::string dictPath = info[0].As<Napi::String>();
30
+ std::string modelPath = info[1].As<Napi::String>();
31
+ std::string userDictPath = info[2].As<Napi::String>();
32
+ std::string idfPath = info[3].As<Napi::String>();
33
+ std::string stopWordsPath = info[4].As<Napi::String>();
34
+
35
+ delete _jieba_handle;
36
+ _jieba_handle = new cppjieba::Jieba(dictPath,
37
+ modelPath,
38
+ userDictPath,
39
+ idfPath,
40
+ stopWordsPath);
41
+
42
+ delete _text_rank_extractor_handle;
43
+ _text_rank_extractor_handle = new cppjieba
44
+ ::TextRankExtractor(dictPath,
45
+ modelPath,
46
+ stopWordsPath,
47
+ userDictPath);
48
+
49
+ return Napi::Boolean::New(info.Env(), true);
50
+ }
51
+
52
+ Napi::Value NodeJieba::insertWord(const Napi::CallbackInfo& info) {
53
+ if(info.Length() < 1) {
54
+ return Napi::Boolean::New(info.Env(), false);
55
+ }
56
+ std::string word = info[0].As<Napi::String>();
57
+ std::string tag = "x";
58
+ if(info.Length() > 1) {
59
+ tag = info[1].As<Napi::String>();
60
+ }
61
+
62
+ if( !_jieba_handle ){
63
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
64
+ }
65
+
66
+ if(!_jieba_handle->InsertUserWord(word, tag)) {
67
+ return Napi::Boolean::New(info.Env(), false);
68
+ }
69
+
70
+ return Napi::Boolean::New(info.Env(), true);
71
+ }
72
+
73
+ Napi::Value NodeJieba::cut(const Napi::CallbackInfo& info) {
74
+ if (info.Length() == 0) {
75
+ return Napi::Boolean::New(info.Env(), false);
76
+ }
77
+ std::string sentence = info[0].As<Napi::String>();
78
+ bool useHMM = false;
79
+ if (info.Length() > 1) {
80
+ useHMM = info[1].As<Napi::Boolean>();
81
+ }
82
+
83
+ if( !_jieba_handle ){
84
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
85
+ }
86
+
87
+ std::vector<std::string> words;
88
+ _jieba_handle->Cut(sentence, words, useHMM);
89
+ Napi::Array outArray;
90
+ WrapVector(info.Env(), words, outArray);
91
+ return outArray;
92
+ }
93
+
94
+ Napi::Value NodeJieba::cutHMM(const Napi::CallbackInfo& info) {
95
+ if (info.Length() == 0) {
96
+ return Napi::Boolean::New(info.Env(), false);
97
+ }
98
+ std::string sentence = info[0].As<Napi::String>();
99
+
100
+ if( !_jieba_handle ){
101
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
102
+ }
103
+
104
+ std::vector<std::string> words;
105
+ _jieba_handle->CutHMM(sentence, words);
106
+ Napi::Array outArray;
107
+ WrapVector(info.Env(), words, outArray);
108
+ return outArray;
109
+ }
110
+
111
+ Napi::Value NodeJieba::cutAll(const Napi::CallbackInfo& info) {
112
+ if (info.Length() == 0) {
113
+ return Napi::Boolean::New(info.Env(), false);
114
+ }
115
+ std::string sentence = info[0].As<Napi::String>();
116
+
117
+ if( !_jieba_handle ){
118
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
119
+ }
120
+
121
+ std::vector<std::string> words;
122
+ _jieba_handle->CutAll(sentence, words);
123
+ Napi::Array outArray;
124
+ WrapVector(info.Env(), words, outArray);
125
+ return outArray;
126
+ }
127
+
128
+ Napi::Value NodeJieba::cutForSearch(const Napi::CallbackInfo& info) {
129
+ if (info.Length() == 0) {
130
+ return Napi::Boolean::New(info.Env(), false);
131
+ }
132
+ std::string sentence = info[0].As<Napi::String>();
133
+ bool useHMM = false;
134
+ if (info.Length() > 1) {
135
+ useHMM = info[1].As<Napi::Boolean>();
136
+ }
137
+
138
+ if( !_jieba_handle ){
139
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
140
+ }
141
+
142
+ std::vector<std::string> words;
143
+ _jieba_handle->CutForSearch(sentence, words, useHMM);
144
+ Napi::Array outArray;
145
+ WrapVector(info.Env(), words, outArray);
146
+ return outArray;
147
+ }
148
+
149
+ Napi::Value NodeJieba::cutSmall(const Napi::CallbackInfo& info) {
150
+ if (info.Length() < 2) {
151
+ return Napi::Boolean::New(info.Env(), false);
152
+ }
153
+ std::string sentence = info[0].As<Napi::String>();
154
+ size_t word_len_limit = info[1].As<Napi::Number>().Int32Value();
155
+
156
+ if( !_jieba_handle ){
157
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
158
+ }
159
+
160
+ std::vector<std::string> words;
161
+ _jieba_handle->CutSmall(sentence, words, word_len_limit);
162
+ Napi::Array outArray;
163
+ WrapVector(info.Env(), words, outArray);
164
+ return outArray;
165
+ }
166
+
167
+ Napi::Value NodeJieba::tag(const Napi::CallbackInfo& info) {
168
+ if (info.Length() == 0) {
169
+ return Napi::Boolean::New(info.Env(), false);
170
+ }
171
+ std::string sentence = info[0].As<Napi::String>();
172
+
173
+ if( !_jieba_handle ){
174
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
175
+ }
176
+
177
+ std::vector<std::pair<std::string, std::string> > words;
178
+ _jieba_handle->Tag(sentence, words);
179
+ Napi::Array outArray;
180
+ WrapPairVector(info.Env(), words, outArray);
181
+ return outArray;
182
+ }
183
+
184
+ Napi::Value NodeJieba::extract(const Napi::CallbackInfo& info) {
185
+ if (info.Length() != 2) {
186
+ return Napi::Boolean::New(info.Env(), false);
187
+ }
188
+ std::string sentence = info[0].As<Napi::String>();
189
+ size_t topN = info[1].As<Napi::Number>().Int32Value();
190
+
191
+ if( !_jieba_handle ){
192
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
193
+ }
194
+
195
+ std::vector<std::pair<std::string, double> > words;
196
+ _jieba_handle->extractor.Extract(sentence, words, topN);
197
+ Napi::Array outArray;
198
+ WrapPairVector(info.Env(), words, outArray);
199
+ return outArray;
200
+ }
201
+
202
+ Napi::Value NodeJieba::textRankExtract(const Napi::CallbackInfo& info) {
203
+ if (info.Length() != 2) {
204
+ return Napi::Boolean::New(info.Env(), false);
205
+ }
206
+ std::string sentence = info[0].As<Napi::String>();
207
+ size_t topN = info[1].As<Napi::Number>().Int32Value();
208
+
209
+ if( !_text_rank_extractor_handle ){
210
+ Napi::Error::New(info.Env(), "Before calling any other function you have to call load() first").ThrowAsJavaScriptException();
211
+ }
212
+
213
+ std::vector<std::pair<std::string, double> > words;
214
+ _text_rank_extractor_handle->Extract(sentence, words, topN);
215
+ Napi::Array outArray;
216
+ WrapPairVector(info.Env(), words, outArray);
217
+ return outArray;
218
+ }
@@ -0,0 +1,28 @@
1
+ #ifndef NODEJIBEA_SRC_NODEJIEBA_H
2
+ #define NODEJIBEA_SRC_NODEJIEBA_H
3
+
4
+ #include <napi.h>
5
+
6
+ namespace cppjieba{ class Jieba; class TextRankExtractor; }
7
+
8
+ class NodeJieba : public Napi::Addon<NodeJieba> {
9
+ public:
10
+ NodeJieba(Napi::Env env, Napi::Object exports);
11
+
12
+ private:
13
+ Napi::Value load(const Napi::CallbackInfo& info);
14
+ Napi::Value cut(const Napi::CallbackInfo& info);
15
+ Napi::Value cutAll(const Napi::CallbackInfo& info);
16
+ Napi::Value cutHMM(const Napi::CallbackInfo& info);
17
+ Napi::Value cutForSearch(const Napi::CallbackInfo& info);
18
+ Napi::Value cutSmall(const Napi::CallbackInfo& info);
19
+ Napi::Value tag(const Napi::CallbackInfo& info);
20
+ Napi::Value extract(const Napi::CallbackInfo& info);
21
+ Napi::Value textRankExtract(const Napi::CallbackInfo& info);
22
+ Napi::Value insertWord(const Napi::CallbackInfo& info);
23
+
24
+ cppjieba::Jieba* _jieba_handle{nullptr};
25
+ cppjieba::TextRankExtractor* _text_rank_extractor_handle{nullptr};
26
+ };
27
+
28
+ #endif // NODEJIBEA_SRC_NODEJIEBA_H
package/lib/utils.h ADDED
@@ -0,0 +1,47 @@
1
+ #ifndef NODEJIEBA_SRC_UTLS_H
2
+ #define NODEJIEBA_SRC_UTLS_H
3
+
4
+ #include <string>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ inline void WrapVector(Napi::Env env, std::vector<std::string> &ov, Napi::Array &array) {
9
+ array = Napi::Array::New(env, ov.size());
10
+ for(size_t i = 0; i < ov.size(); i++) {
11
+ array.Set(i, Napi::String::New(env, ov[i]));
12
+ }
13
+ }
14
+
15
+ inline void WrapPairVector(Napi::Env env, std::vector<std::pair<std::string,double> > &ov, Napi::Array &array) {
16
+ array = Napi::Array::New(env, ov.size());
17
+ for(size_t i = 0; i < ov.size(); i++) {
18
+ Napi::Object obj = Napi::Object::New(env);
19
+ Napi::Value k;
20
+ Napi::Value v;
21
+ k = Napi::String::New(env, "word");
22
+ v = Napi::String::New(env, ov[i].first);
23
+ obj.Set(k, v);
24
+ k = Napi::String::New(env, "weight");
25
+ v = Napi::Number::New(env, ov[i].second);
26
+ obj.Set(k, v);
27
+ array.Set(i, obj);
28
+ }
29
+ }
30
+
31
+ inline void WrapPairVector(Napi::Env env, std::vector<std::pair<std::string,std::string> > &ov, Napi::Array &array) {
32
+ array = Napi::Array::New(env, ov.size());
33
+ for(size_t i = 0; i < ov.size(); i++) {
34
+ Napi::Object obj = Napi::Object::New(env);
35
+ Napi::Value k;
36
+ Napi::Value v;
37
+ k = Napi::String::New(env, "word");
38
+ v = Napi::String::New(env, ov[i].first);
39
+ obj.Set(k, v);
40
+ k = Napi::String::New(env, "tag");
41
+ v = Napi::String::New(env, ov[i].second);
42
+ obj.Set(k, v);
43
+ array.Set(i, obj);
44
+ }
45
+ }
46
+
47
+ #endif
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "nodejieba-plus",
3
+ "description": "chinese word segmentation for node",
4
+ "version": "3.5.8",
5
+ "author": "Yanyi Wu <wuyanyi09@foxmail.com>",
6
+ "maintainers": [
7
+ "Yanyi Wu <wuyanyi09@foxmail.com>"
8
+ ],
9
+ "main": "./index.js",
10
+ "typings": "types/index.d.ts",
11
+ "engines": {
12
+ "node": ">= 14.0.0"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "http://github.com/yanyiwu/nodejieba.git"
17
+ },
18
+ "keywords": [
19
+ "chinese",
20
+ "segment",
21
+ "cppjieba",
22
+ "jieba",
23
+ "中文分词",
24
+ "结巴分词"
25
+ ],
26
+ "dependencies": {
27
+ "@mapbox/node-pre-gyp": "^1.0.10",
28
+ "node-addon-api": "^5.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "mocha": "~10.7.3",
32
+ "should": "~13.2.3",
33
+ "typescript": "^5.0.4"
34
+ },
35
+ "scripts": {
36
+ "test": "mocha --timeout 10s -R spec test/test.js && mocha --timeout 10s -R spec test/load_dict_test.js && mocha --timeout 10s -R spec test/missing_binding_test.js",
37
+ "install": "npx @mapbox/node-pre-gyp install --fallback-to-build",
38
+ "rebuild": "npx @mapbox/node-pre-gyp rebuild"
39
+ },
40
+ "binary": {
41
+ "module_name": "nodejieba",
42
+ "module_path": "./build/Release/",
43
+ "host": "https://github.com/yanyiwu/nodejieba/releases/download/",
44
+ "remote_path": "v{version}",
45
+ "package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}-{libc}.tar.gz"
46
+ },
47
+ "license": "MIT"
48
+ }
@@ -0,0 +1,51 @@
1
+ name: CMake
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ env:
8
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
9
+ BUILD_TYPE: Release
10
+
11
+ jobs:
12
+ build:
13
+ # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
14
+ # You can convert this to a matrix build if you need cross-platform coverage.
15
+ # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ matrix:
19
+ os: [
20
+ ubuntu-20.04,
21
+ ubuntu-22.04,
22
+ macos-13,
23
+ macos-14,
24
+ windows-2019,
25
+ windows-2022,
26
+ ]
27
+ cpp_version: [11, 14, 17, 20]
28
+
29
+ steps:
30
+ - name: Check out repository code
31
+ uses: actions/checkout@v2
32
+ with:
33
+ submodules: recursive
34
+
35
+ - name: Configure CMake
36
+ # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
37
+ # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
38
+ # run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
39
+ run: cmake -B ${{github.workspace}}/build -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=${{matrix.cpp_version}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
40
+
41
+ - name: Build
42
+ # Build your program with the given configuration
43
+ # run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
44
+ run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
45
+
46
+ - name: Test
47
+ working-directory: ${{github.workspace}}/build
48
+ # Execute tests defined by the CMake configuration.
49
+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
50
+ run: ctest -C ${{env.BUILD_TYPE}} --verbose
51
+
@@ -0,0 +1,24 @@
1
+ name: Close Stale Issues
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 0 3 * *' # Monthly on the 3rd day of the month at midnight
6
+
7
+ jobs:
8
+ stale:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ issues: write
12
+ pull-requests: write
13
+
14
+ steps:
15
+ - uses: actions/stale@v5
16
+ with:
17
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
18
+ stale-issue-message: 'This issue has not been updated for over 1 year and will be marked as stale. If the issue still exists, please comment or update the issue, otherwise it will be closed after 7 days.'
19
+ close-issue-message: 'This issue has been automatically closed due to inactivity. If the issue still exists, please reopen it.'
20
+ days-before-issue-stale: 365
21
+ days-before-issue-close: 7
22
+ stale-issue-label: 'Stale'
23
+ exempt-issue-labels: 'pinned,security'
24
+ operations-per-run: 100
@@ -0,0 +1,3 @@
1
+ [submodule "deps/limonp"]
2
+ path = deps/limonp
3
+ url = https://github.com/yanyiwu/limonp.git