cppjieba_rb 0.4.1 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +21 -0
- data/.github/workflows/linting.yml +30 -0
- data/.github/workflows/release.yml +42 -0
- data/.github/workflows/tests.yml +47 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +45 -0
- data/.ruby-version +1 -0
- data/.yamllint +35 -0
- data/CHANGELOG.md +17 -0
- data/Gemfile +11 -0
- data/README.md +5 -5
- data/Rakefile +16 -7
- data/cppjieba_rb.gemspec +46 -33
- data/ext/cppjieba/.github/workflows/cmake.yml +52 -0
- data/ext/cppjieba/.github/workflows/stale-issues.yml +24 -0
- data/ext/cppjieba/.gitmodules +3 -0
- data/ext/cppjieba/{ChangeLog.md → CHANGELOG.md} +50 -1
- data/ext/cppjieba/CMakeLists.txt +11 -14
- data/ext/cppjieba/LICENSE +20 -0
- data/ext/cppjieba/README.md +9 -18
- data/ext/cppjieba/deps/limonp/.github/workflows/cmake.yml +43 -0
- data/ext/cppjieba/deps/limonp/.gitignore +9 -0
- data/ext/cppjieba/deps/limonp/CHANGELOG.md +160 -0
- data/ext/cppjieba/deps/limonp/CMakeLists.txt +61 -0
- data/ext/cppjieba/deps/limonp/LICENSE +20 -0
- data/ext/cppjieba/deps/limonp/README.md +38 -0
- data/ext/cppjieba/deps/limonp/{LocalVector.hpp → include/limonp/LocalVector.hpp} +3 -3
- data/ext/cppjieba/deps/limonp/{Logging.hpp → include/limonp/Logging.hpp} +17 -3
- data/ext/cppjieba/deps/limonp/{StringUtil.hpp → include/limonp/StringUtil.hpp} +31 -10
- data/ext/cppjieba/deps/limonp/test/CMakeLists.txt +8 -0
- data/ext/cppjieba/deps/limonp/test/demo.cpp +40 -0
- data/ext/cppjieba/deps/limonp/test/testdata/1.conf +5 -0
- data/ext/cppjieba/deps/limonp/test/testdata/StdExtension.data +3 -0
- data/ext/cppjieba/deps/limonp/test/testdata/dict.gbk +50 -0
- data/ext/cppjieba/deps/limonp/test/testdata/dict.utf8 +50 -0
- data/ext/cppjieba/deps/limonp/test/testdata/io_testfile +2 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.1.utf8 +93 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.utf8 +93 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.1.utf8 +67 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.2.utf8 +64 -0
- data/ext/cppjieba/deps/limonp/test/unittest/CMakeLists.txt +30 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TArgvContext.cpp +16 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TCastFloat.cpp +19 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TClosure.cpp +85 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TColorPrint.cpp +20 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TConfig.cpp +17 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TLocalVector.cpp +41 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TLogging.cpp +12 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TStdExtension.cpp +95 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TStringUtil.cpp +183 -0
- data/ext/cppjieba/include/cppjieba/DictTrie.hpp +9 -0
- data/ext/cppjieba/include/cppjieba/Jieba.hpp +4 -0
- data/ext/cppjieba/include/cppjieba/Trie.hpp +27 -1
- data/ext/cppjieba/test/CMakeLists.txt +4 -3
- data/ext/cppjieba/test/unittest/CMakeLists.txt +16 -7
- data/ext/cppjieba_rb/extconf.rb +11 -6
- data/ext/cppjieba_rb/internal.cc +1 -1
- data/lib/cppjieba_rb/segment.rb +4 -1
- data/lib/cppjieba_rb/version.rb +3 -1
- data/lib/cppjieba_rb.rb +12 -5
- data/test/test_keyword.rb +8 -8
- data/test/test_segment.rb +14 -10
- data/test/test_stop_word_filter.rb +5 -3
- data/test/test_tagging.rb +5 -2
- metadata +63 -140
- data/.travis.yml +0 -30
- data/ext/cppjieba/.travis.yml +0 -21
- data/ext/cppjieba/README_EN.md +0 -115
- data/ext/cppjieba/appveyor.yml +0 -32
- data/ext/cppjieba/deps/CMakeLists.txt +0 -1
- data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
- data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
- data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
- data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
- data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
- data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
- data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
- data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
- data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
- data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
- data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
- data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
- data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
- data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
- data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
- data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
- data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
- data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
- data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
- data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
- data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
- data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
- data/ext/cppjieba/test/demo.cpp +0 -80
- /data/ext/cppjieba/deps/{gtest/src/.deps/.dirstamp → limonp/.gitmodules} +0 -0
- /data/ext/cppjieba/deps/limonp/{ArgvContext.hpp → include/limonp/ArgvContext.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Closure.hpp → include/limonp/Closure.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Colors.hpp → include/limonp/Colors.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Condition.hpp → include/limonp/Condition.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Config.hpp → include/limonp/Config.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{ForcePublic.hpp → include/limonp/ForcePublic.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{NonCopyable.hpp → include/limonp/NonCopyable.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{StdExtension.hpp → include/limonp/StdExtension.hpp} +0 -0
- /data/ext/cppjieba/deps/{gtest/src/gtest_main.cc → limonp/test/unittest/gtest_main.cpp} +0 -0
@@ -1,233 +0,0 @@
|
|
1
|
-
// Copyright 2003 Google Inc.
|
2
|
-
// All rights reserved.
|
3
|
-
//
|
4
|
-
// Redistribution and use in source and binary forms, with or without
|
5
|
-
// modification, are permitted provided that the following conditions are
|
6
|
-
// met:
|
7
|
-
//
|
8
|
-
// * Redistributions of source code must retain the above copyright
|
9
|
-
// notice, this list of conditions and the following disclaimer.
|
10
|
-
// * Redistributions in binary form must reproduce the above
|
11
|
-
// copyright notice, this list of conditions and the following disclaimer
|
12
|
-
// in the documentation and/or other materials provided with the
|
13
|
-
// distribution.
|
14
|
-
// * Neither the name of Google Inc. nor the names of its
|
15
|
-
// contributors may be used to endorse or promote products derived from
|
16
|
-
// this software without specific prior written permission.
|
17
|
-
//
|
18
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
//
|
30
|
-
// Authors: Dan Egnor (egnor@google.com)
|
31
|
-
//
|
32
|
-
// A "smart" pointer type with reference tracking. Every pointer to a
|
33
|
-
// particular object is kept on a circular linked list. When the last pointer
|
34
|
-
// to an object is destroyed or reassigned, the object is deleted.
|
35
|
-
//
|
36
|
-
// Used properly, this deletes the object when the last reference goes away.
|
37
|
-
// There are several caveats:
|
38
|
-
// - Like all reference counting schemes, cycles lead to leaks.
|
39
|
-
// - Each smart pointer is actually two pointers (8 bytes instead of 4).
|
40
|
-
// - Every time a pointer is assigned, the entire list of pointers to that
|
41
|
-
// object is traversed. This class is therefore NOT SUITABLE when there
|
42
|
-
// will often be more than two or three pointers to a particular object.
|
43
|
-
// - References are only tracked as long as linked_ptr<> objects are copied.
|
44
|
-
// If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
|
45
|
-
// will happen (double deletion).
|
46
|
-
//
|
47
|
-
// A good use of this class is storing object references in STL containers.
|
48
|
-
// You can safely put linked_ptr<> in a vector<>.
|
49
|
-
// Other uses may not be as good.
|
50
|
-
//
|
51
|
-
// Note: If you use an incomplete type with linked_ptr<>, the class
|
52
|
-
// *containing* linked_ptr<> must have a constructor and destructor (even
|
53
|
-
// if they do nothing!).
|
54
|
-
//
|
55
|
-
// Bill Gibbons suggested we use something like this.
|
56
|
-
//
|
57
|
-
// Thread Safety:
|
58
|
-
// Unlike other linked_ptr implementations, in this implementation
|
59
|
-
// a linked_ptr object is thread-safe in the sense that:
|
60
|
-
// - it's safe to copy linked_ptr objects concurrently,
|
61
|
-
// - it's safe to copy *from* a linked_ptr and read its underlying
|
62
|
-
// raw pointer (e.g. via get()) concurrently, and
|
63
|
-
// - it's safe to write to two linked_ptrs that point to the same
|
64
|
-
// shared object concurrently.
|
65
|
-
// TODO(wan@google.com): rename this to safe_linked_ptr to avoid
|
66
|
-
// confusion with normal linked_ptr.
|
67
|
-
|
68
|
-
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
69
|
-
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
70
|
-
|
71
|
-
#include <stdlib.h>
|
72
|
-
#include <assert.h>
|
73
|
-
|
74
|
-
#include "gtest/internal/gtest-port.h"
|
75
|
-
|
76
|
-
namespace testing {
|
77
|
-
namespace internal {
|
78
|
-
|
79
|
-
// Protects copying of all linked_ptr objects.
|
80
|
-
GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
|
81
|
-
|
82
|
-
// This is used internally by all instances of linked_ptr<>. It needs to be
|
83
|
-
// a non-template class because different types of linked_ptr<> can refer to
|
84
|
-
// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
|
85
|
-
// So, it needs to be possible for different types of linked_ptr to participate
|
86
|
-
// in the same circular linked list, so we need a single class type here.
|
87
|
-
//
|
88
|
-
// DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
|
89
|
-
class linked_ptr_internal {
|
90
|
-
public:
|
91
|
-
// Create a new circle that includes only this instance.
|
92
|
-
void join_new() {
|
93
|
-
next_ = this;
|
94
|
-
}
|
95
|
-
|
96
|
-
// Many linked_ptr operations may change p.link_ for some linked_ptr
|
97
|
-
// variable p in the same circle as this object. Therefore we need
|
98
|
-
// to prevent two such operations from occurring concurrently.
|
99
|
-
//
|
100
|
-
// Note that different types of linked_ptr objects can coexist in a
|
101
|
-
// circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
|
102
|
-
// linked_ptr<Derived2>). Therefore we must use a single mutex to
|
103
|
-
// protect all linked_ptr objects. This can create serious
|
104
|
-
// contention in production code, but is acceptable in a testing
|
105
|
-
// framework.
|
106
|
-
|
107
|
-
// Join an existing circle.
|
108
|
-
// L < g_linked_ptr_mutex
|
109
|
-
void join(linked_ptr_internal const* ptr) {
|
110
|
-
MutexLock lock(&g_linked_ptr_mutex);
|
111
|
-
|
112
|
-
linked_ptr_internal const* p = ptr;
|
113
|
-
while (p->next_ != ptr) p = p->next_;
|
114
|
-
p->next_ = this;
|
115
|
-
next_ = ptr;
|
116
|
-
}
|
117
|
-
|
118
|
-
// Leave whatever circle we're part of. Returns true if we were the
|
119
|
-
// last member of the circle. Once this is done, you can join() another.
|
120
|
-
// L < g_linked_ptr_mutex
|
121
|
-
bool depart() {
|
122
|
-
MutexLock lock(&g_linked_ptr_mutex);
|
123
|
-
|
124
|
-
if (next_ == this) return true;
|
125
|
-
linked_ptr_internal const* p = next_;
|
126
|
-
while (p->next_ != this) p = p->next_;
|
127
|
-
p->next_ = next_;
|
128
|
-
return false;
|
129
|
-
}
|
130
|
-
|
131
|
-
private:
|
132
|
-
mutable linked_ptr_internal const* next_;
|
133
|
-
};
|
134
|
-
|
135
|
-
template <typename T>
|
136
|
-
class linked_ptr {
|
137
|
-
public:
|
138
|
-
typedef T element_type;
|
139
|
-
|
140
|
-
// Take over ownership of a raw pointer. This should happen as soon as
|
141
|
-
// possible after the object is created.
|
142
|
-
explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
|
143
|
-
~linked_ptr() { depart(); }
|
144
|
-
|
145
|
-
// Copy an existing linked_ptr<>, adding ourselves to the list of references.
|
146
|
-
template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
|
147
|
-
linked_ptr(linked_ptr const& ptr) { // NOLINT
|
148
|
-
assert(&ptr != this);
|
149
|
-
copy(&ptr);
|
150
|
-
}
|
151
|
-
|
152
|
-
// Assignment releases the old value and acquires the new.
|
153
|
-
template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
|
154
|
-
depart();
|
155
|
-
copy(&ptr);
|
156
|
-
return *this;
|
157
|
-
}
|
158
|
-
|
159
|
-
linked_ptr& operator=(linked_ptr const& ptr) {
|
160
|
-
if (&ptr != this) {
|
161
|
-
depart();
|
162
|
-
copy(&ptr);
|
163
|
-
}
|
164
|
-
return *this;
|
165
|
-
}
|
166
|
-
|
167
|
-
// Smart pointer members.
|
168
|
-
void reset(T* ptr = NULL) {
|
169
|
-
depart();
|
170
|
-
capture(ptr);
|
171
|
-
}
|
172
|
-
T* get() const { return value_; }
|
173
|
-
T* operator->() const { return value_; }
|
174
|
-
T& operator*() const { return *value_; }
|
175
|
-
|
176
|
-
bool operator==(T* p) const { return value_ == p; }
|
177
|
-
bool operator!=(T* p) const { return value_ != p; }
|
178
|
-
template <typename U>
|
179
|
-
bool operator==(linked_ptr<U> const& ptr) const {
|
180
|
-
return value_ == ptr.get();
|
181
|
-
}
|
182
|
-
template <typename U>
|
183
|
-
bool operator!=(linked_ptr<U> const& ptr) const {
|
184
|
-
return value_ != ptr.get();
|
185
|
-
}
|
186
|
-
|
187
|
-
private:
|
188
|
-
template <typename U>
|
189
|
-
friend class linked_ptr;
|
190
|
-
|
191
|
-
T* value_;
|
192
|
-
linked_ptr_internal link_;
|
193
|
-
|
194
|
-
void depart() {
|
195
|
-
if (link_.depart()) delete value_;
|
196
|
-
}
|
197
|
-
|
198
|
-
void capture(T* ptr) {
|
199
|
-
value_ = ptr;
|
200
|
-
link_.join_new();
|
201
|
-
}
|
202
|
-
|
203
|
-
template <typename U> void copy(linked_ptr<U> const* ptr) {
|
204
|
-
value_ = ptr->get();
|
205
|
-
if (value_)
|
206
|
-
link_.join(&ptr->link_);
|
207
|
-
else
|
208
|
-
link_.join_new();
|
209
|
-
}
|
210
|
-
};
|
211
|
-
|
212
|
-
template<typename T> inline
|
213
|
-
bool operator==(T* ptr, const linked_ptr<T>& x) {
|
214
|
-
return ptr == x.get();
|
215
|
-
}
|
216
|
-
|
217
|
-
template<typename T> inline
|
218
|
-
bool operator!=(T* ptr, const linked_ptr<T>& x) {
|
219
|
-
return ptr != x.get();
|
220
|
-
}
|
221
|
-
|
222
|
-
// A function to convert T* into linked_ptr<T>
|
223
|
-
// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation
|
224
|
-
// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
|
225
|
-
template <typename T>
|
226
|
-
linked_ptr<T> make_linked_ptr(T* ptr) {
|
227
|
-
return linked_ptr<T>(ptr);
|
228
|
-
}
|
229
|
-
|
230
|
-
} // namespace internal
|
231
|
-
} // namespace testing
|
232
|
-
|
233
|
-
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|