wowool-sdk-cpp 3.5.6__tar.gz → 3.6.3__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.
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/PKG-INFO +2 -2
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/pre_setup.py +3 -1
- wowool_sdk_cpp-3.6.3/sdk_version.txt +1 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/setup.py +6 -2
- wowool_sdk_cpp-3.6.3/version.txt +1 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/native/core/wowool_sdk.cpp +334 -351
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/package/lib/wowool_plugin.py +6 -3
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/package/lib/wowool_sdk.py +6 -4
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/PKG-INFO +2 -2
- wowool_sdk_cpp-3.5.6/sdk_version.txt +0 -1
- wowool_sdk_cpp-3.5.6/version.txt +0 -1
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/MANIFEST.in +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/common_setup.py +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/install_requires.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/install_requires_wowool.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/long_description.md +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/pyproject.toml +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/setup.cfg +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/plugin/wowool_plugin.cpp +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/plugin/wowool_plugin.hpp +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/SOURCES.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/dependency_links.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/not-zip-safe +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wowool-sdk-cpp
|
|
3
|
-
Version: 3.
|
|
4
|
-
Summary: Wowool NLP Toolkit C++ SDK Python Bindings
|
|
3
|
+
Version: 3.6.3
|
|
4
|
+
Summary: Wowool NLP Toolkit C++ SDK Python Bindings, (use nlp-wowool-sdk instead if you want the Python SDK)
|
|
5
5
|
Author: Wowool
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
@@ -147,7 +147,8 @@ def prep_build_setup(wow_stage: Path):
|
|
|
147
147
|
|
|
148
148
|
platform_name = platform.system()
|
|
149
149
|
if "Windows" == platform_name:
|
|
150
|
-
icu_files = ["
|
|
150
|
+
icu_files = ["icudt77.dll", "icuuc77.dll"]
|
|
151
|
+
icu_lib_folder = stage_bin_folder
|
|
151
152
|
elif "Darwin" == platform_name:
|
|
152
153
|
icu_files = ["libicudata.dylib", "libicuuc.dylib"]
|
|
153
154
|
else:
|
|
@@ -196,6 +197,7 @@ def prep_build_setup(wow_stage: Path):
|
|
|
196
197
|
|
|
197
198
|
for fn in icu_files:
|
|
198
199
|
target_fn = package_lib_folder / fn
|
|
200
|
+
logger.info(f"!!!!! COPY ICU {icu_lib_folder} {fn} --> {target_fn}")
|
|
199
201
|
shutil.copy2(icu_lib_folder / fn, target_fn)
|
|
200
202
|
# remove_rpath(target_fn)
|
|
201
203
|
# set_rpath_origin(target_fn)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.3.0
|
|
@@ -332,10 +332,13 @@ class BuildExt(build_ext):
|
|
|
332
332
|
ct = self.compiler.compiler_type
|
|
333
333
|
opts = self.c_opts.get(ct, [])
|
|
334
334
|
link_opts = self.l_opts.get(ct, [])
|
|
335
|
+
print(f"!!!!!!!!!!! Compiler type: {ct}, opts: {opts}, link_opts: {link_opts}")
|
|
335
336
|
if ct == "unix":
|
|
336
337
|
opts.append(cpp_flag(self.compiler))
|
|
337
338
|
if has_flag(self.compiler, "-fvisibility=hidden"):
|
|
338
339
|
opts.append("-fvisibility=hidden")
|
|
340
|
+
elif ct == "msvc":
|
|
341
|
+
opts.append("/std:c++17")
|
|
339
342
|
|
|
340
343
|
for ext in self.extensions:
|
|
341
344
|
ext.define_macros = [("VERSION_INFO", '"{}"'.format(self.distribution.get_version()))]
|
|
@@ -404,6 +407,7 @@ def extension_modules():
|
|
|
404
407
|
library_dirs = [str(Path(WOWOOL_STAGE, "lib")), get_config_var("LIBDEST")]
|
|
405
408
|
libraries = ["wowool"]
|
|
406
409
|
plugin_libraries = libraries
|
|
410
|
+
extra_compile_args.extend(["/DWIN32"])
|
|
407
411
|
else:
|
|
408
412
|
runtime_library_dirs = [runtime_library_path]
|
|
409
413
|
extra_link_args = ["-Xlinker", "-rpath", "-Xlinker", get_origin_keyword(), "-static-libstdc++"]
|
|
@@ -486,11 +490,11 @@ install_requires = [
|
|
|
486
490
|
version = open("version.txt").read().strip()
|
|
487
491
|
|
|
488
492
|
|
|
489
|
-
|
|
493
|
+
setup(
|
|
490
494
|
name=package_name,
|
|
491
495
|
version=version,
|
|
492
496
|
author="Wowool",
|
|
493
|
-
description="Wowool NLP Toolkit C++ SDK Python Bindings",
|
|
497
|
+
description="Wowool NLP Toolkit C++ SDK Python Bindings, (use nlp-wowool-sdk instead if you want the Python SDK)",
|
|
494
498
|
long_description=long_description,
|
|
495
499
|
long_description_content_type="text/markdown",
|
|
496
500
|
setup_requires=["pybind11"],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.6.3
|
|
@@ -3,16 +3,6 @@
|
|
|
3
3
|
// Otherwise MSVC can not compile the stuff
|
|
4
4
|
/////////////////////////////////////////////////////////////////
|
|
5
5
|
#define WITH_THREAD
|
|
6
|
-
#include <Python.h>
|
|
7
|
-
#include <iostream>
|
|
8
|
-
#include <mutex>
|
|
9
|
-
#include <pybind11/functional.h>
|
|
10
|
-
#include <pybind11/pybind11.h>
|
|
11
|
-
#include <pybind11/stl.h>
|
|
12
|
-
#include <string>
|
|
13
|
-
#include <thread>
|
|
14
|
-
#include <variant>
|
|
15
|
-
#include <vector>
|
|
16
6
|
#include "wowool/analyzer/analyzer.hpp"
|
|
17
7
|
#include "wowool/analyzer/options.hpp"
|
|
18
8
|
#include "wowool/common/exception.hpp"
|
|
@@ -23,11 +13,21 @@
|
|
|
23
13
|
#include "wowool/engine/engine.hpp"
|
|
24
14
|
#include "wowool/filter/filter.hpp"
|
|
25
15
|
#include "wowool/language_identifier/language_identifier.hpp"
|
|
16
|
+
#include <Python.h>
|
|
17
|
+
#include <iostream>
|
|
18
|
+
#include <mutex>
|
|
19
|
+
#include <pybind11/functional.h>
|
|
20
|
+
#include <pybind11/pybind11.h>
|
|
21
|
+
#include <pybind11/stl.h>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <thread>
|
|
24
|
+
#include <variant>
|
|
25
|
+
#include <vector>
|
|
26
26
|
#if !defined(WIN32)
|
|
27
|
-
|
|
27
|
+
#include <signal.h>
|
|
28
28
|
#else
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
#include <thread>
|
|
30
|
+
#include <windows.h>
|
|
31
31
|
#endif
|
|
32
32
|
namespace py = pybind11;
|
|
33
33
|
|
|
@@ -44,7 +44,7 @@ bool get_environment_bool(std::string const &env_id, bool default_value)
|
|
|
44
44
|
if (value_ptr)
|
|
45
45
|
{
|
|
46
46
|
std::string value(value_ptr);
|
|
47
|
-
return value == "true"
|
|
47
|
+
return value == "true" || value == "True";
|
|
48
48
|
}
|
|
49
49
|
return default_value;
|
|
50
50
|
}
|
|
@@ -52,378 +52,360 @@ bool get_environment_bool(std::string const &env_id, bool default_value)
|
|
|
52
52
|
bool lock_gil = get_environment_bool("WOWOOL_LOCK_GIL", false);
|
|
53
53
|
|
|
54
54
|
namespace detail {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
mutable bool initial = true;
|
|
55
|
+
struct DoNotExecFirstTime {
|
|
56
|
+
mutable bool initial = true;
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else
|
|
67
|
-
initial = false;
|
|
68
|
-
}
|
|
58
|
+
template <typename Functor> void operator()(Functor functor) const {
|
|
59
|
+
if (!initial) {
|
|
60
|
+
functor();
|
|
61
|
+
} else
|
|
62
|
+
initial = false;
|
|
63
|
+
}
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
void reset() { initial = true; }
|
|
66
|
+
};
|
|
72
67
|
|
|
73
68
|
} // namespace detail
|
|
74
69
|
|
|
75
|
-
std::ostream &print_string_map(std::ostream &out,
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return out;
|
|
70
|
+
std::ostream &print_string_map(std::ostream &out,
|
|
71
|
+
wowool::common::Options const &options) {
|
|
72
|
+
for (auto const &option : options) {
|
|
73
|
+
out << option.first << ":" << option.second << ",";
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
82
76
|
}
|
|
83
77
|
|
|
84
78
|
namespace tir {
|
|
85
79
|
namespace pywowool {
|
|
86
80
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
void translate(exception_t const &e)
|
|
121
|
-
{
|
|
122
|
-
PyErr_SetString(PyExc_RuntimeError, e.what());
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
wowool::common::Options convert_py_2_api_options(py::dict const &kwargs)
|
|
126
|
-
{
|
|
127
|
-
wowool::common::Options options;
|
|
128
|
-
for (auto const &item : kwargs)
|
|
129
|
-
{
|
|
130
|
-
options.emplace(py::str(item.first), py::str(item.second));
|
|
131
|
-
}
|
|
132
|
-
return options;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
std::string convert_filterset(wowool::filter::Filter const &filterset)
|
|
136
|
-
{
|
|
137
|
-
return filterset.info();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
py::dict convert_options_2_py(wowool::common::Options const &options)
|
|
141
|
-
{
|
|
142
|
-
py::dict kwargs;
|
|
143
|
-
for (auto const &item : options)
|
|
144
|
-
{
|
|
145
|
-
kwargs[py::str(item.first)] = py::str(item.second);
|
|
146
|
-
}
|
|
147
|
-
return kwargs;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// self.options["pytryoshka"] = "true"
|
|
151
|
-
|
|
152
|
-
static wowool::common::Options global_shared_engine_options = {
|
|
153
|
-
{std::string("language"), std::string("auto")},
|
|
154
|
-
// { std::string("verbose") , std::string("trace") },
|
|
155
|
-
{std::string("pytryoshka"), std::string("true")}};
|
|
156
|
-
|
|
157
|
-
static std::shared_ptr<wowool::engine::Engine>
|
|
158
|
-
global_shared_engine; //( global_shared_engine_options );
|
|
159
|
-
|
|
160
|
-
wowool::engine::Engine &get_default_engine(wowool::common::Options &options)
|
|
161
|
-
{
|
|
162
|
-
PYTHON_LOCK
|
|
163
|
-
|
|
164
|
-
if (!global_shared_engine)
|
|
165
|
-
{
|
|
166
|
-
wowool::engine::Engine *global_wowool_engine = new wowool::engine::Engine(options);
|
|
167
|
-
// std::cout << " !!!!!!!!!!!!!! Creating Global Engine" << global_wowool_engine << std::endl;
|
|
168
|
-
global_shared_engine.reset(global_wowool_engine);
|
|
169
|
-
}
|
|
170
|
-
return *global_shared_engine;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
class engine_t : public wowool::engine::Engine
|
|
174
|
-
{
|
|
175
|
-
public:
|
|
176
|
-
// typedef wowool::EngineInterface type;
|
|
177
|
-
|
|
178
|
-
typedef wowool::engine::Engine type;
|
|
179
|
-
|
|
180
|
-
// using wowool::engine::Engine::Engine;
|
|
181
|
-
|
|
182
|
-
// engine_t(wowool::engine::Engine const &&base)
|
|
183
|
-
// : wowool::engine::Engine(std::move(base))
|
|
184
|
-
// {
|
|
185
|
-
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const &&base)" << this << std::endl;
|
|
186
|
-
// }
|
|
187
|
-
|
|
188
|
-
// engine_t(wowool::engine::Engine const &&base, py::dict const &kwarg)
|
|
189
|
-
// : wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg))
|
|
190
|
-
// {
|
|
191
|
-
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const &&base, py::dict const &kwarg)" << this << std::endl;
|
|
192
|
-
// }
|
|
193
|
-
|
|
194
|
-
// we need this one to be able to create multi_process objects.
|
|
195
|
-
engine_t(py::dict const &kwarg)
|
|
196
|
-
: wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg))
|
|
197
|
-
{
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
class lid_t : public wowool::language_identifier::LanguageIdentifier
|
|
202
|
-
{
|
|
203
|
-
public:
|
|
204
|
-
typedef wowool::language_identifier::LanguageIdentifier type;
|
|
205
|
-
|
|
206
|
-
using wowool::language_identifier::LanguageIdentifier::LanguageIdentifier;
|
|
207
|
-
|
|
208
|
-
lid_t(wowool::language_identifier::LanguageIdentifier const &&base)
|
|
209
|
-
: wowool::language_identifier::LanguageIdentifier(std::move(base)) {}
|
|
210
|
-
|
|
211
|
-
lid_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
|
|
212
|
-
: wowool::language_identifier::LanguageIdentifier(engine, tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
213
|
-
|
|
214
|
-
lid_t(py::dict const &kwarg)
|
|
215
|
-
: wowool::language_identifier::LanguageIdentifier(tir::pywowool::get_default_engine(global_shared_engine_options), tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
class domain_t : public wowool::domain::Domain
|
|
219
|
-
{
|
|
220
|
-
public:
|
|
221
|
-
typedef wowool::domain::Domain type;
|
|
222
|
-
|
|
223
|
-
using wowool::domain::Domain::Domain;
|
|
224
|
-
|
|
225
|
-
domain_t(wowool::domain::Domain const &&base)
|
|
226
|
-
: wowool::domain::Domain(std::move(base)) {}
|
|
227
|
-
|
|
228
|
-
domain_t(wowool::analyzer::Engine const &engine, std::string const domain_descriptor, py::dict const &kwarg)
|
|
229
|
-
: wowool::domain::Domain(engine, domain_descriptor, tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
230
|
-
|
|
231
|
-
// we need this one to be able to create multi_process objects.
|
|
232
|
-
domain_t(py::dict const &kwarg)
|
|
233
|
-
: wowool::domain::Domain(
|
|
234
|
-
tir::pywowool::get_default_engine(global_shared_engine_options),
|
|
235
|
-
kwarg["name"].cast<std::string>(),
|
|
236
|
-
tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
237
|
-
|
|
238
|
-
// wowool::analyzer::Results process(wowool::analyzer::Results const document)
|
|
239
|
-
// {
|
|
240
|
-
// char *p = 0;
|
|
241
|
-
// *p = 0;
|
|
242
|
-
// std::cout << "PLUGIN domain_t::process" << std::endl;
|
|
243
|
-
// // py::gil_scoped_release release; // Release the GIL
|
|
244
|
-
// return (*static_cast<wowool::domain::Domain const *>(this))(document);
|
|
245
|
-
// };
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
wowool::filter::FilterCollection string2filterset(std::string const &filter_str)
|
|
249
|
-
{
|
|
250
|
-
auto filter_vector = wowool::common::split(filter_str, ',');
|
|
251
|
-
return wowool::filter::FilterCollection(filter_vector.begin(), filter_vector.end());
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
class filter_t : public wowool::filter::Filter
|
|
255
|
-
{
|
|
256
|
-
public:
|
|
257
|
-
typedef wowool::filter::Filter type;
|
|
258
|
-
|
|
259
|
-
using wowool::filter::Filter::Filter;
|
|
260
|
-
|
|
261
|
-
filter_t(wowool::filter::Filter const &&base)
|
|
262
|
-
: wowool::filter::Filter(std::move(base)) {}
|
|
263
|
-
|
|
264
|
-
filter_t(wowool::filter::FilterCollection const &filterset)
|
|
265
|
-
: wowool::filter::Filter(filterset), _filterset(filterset) {}
|
|
266
|
-
|
|
267
|
-
filter_t(std::string const filterset)
|
|
268
|
-
: wowool::filter::Filter(filterset), _filterset(string2filterset(filterset)) {}
|
|
81
|
+
class exception_t : public std::exception {
|
|
82
|
+
private:
|
|
83
|
+
std::string message;
|
|
84
|
+
std::string extraData;
|
|
85
|
+
|
|
86
|
+
public:
|
|
87
|
+
exception_t(std::string message_, std::string extraData_)
|
|
88
|
+
: message(message_), extraData(extraData_) {}
|
|
89
|
+
// TODO: declare this nothrow
|
|
90
|
+
~exception_t() throw() {}
|
|
91
|
+
const char *what() const throw() { return message.c_str(); }
|
|
92
|
+
std::string getMessage() { return message; }
|
|
93
|
+
std::string getExtraData() { return extraData; }
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
class exception_json_t : public std::exception {
|
|
97
|
+
private:
|
|
98
|
+
std::string json_data;
|
|
99
|
+
|
|
100
|
+
public:
|
|
101
|
+
exception_json_t(std::string json_data_) : json_data(json_data_) {}
|
|
102
|
+
// TODO: declare this nothrow
|
|
103
|
+
~exception_json_t() throw() {}
|
|
104
|
+
const char *what() const throw() { return json_data.c_str(); }
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
void translate(exception_json_t const &e) {
|
|
108
|
+
PyErr_SetString(PyExc_RuntimeError, e.what());
|
|
109
|
+
}
|
|
110
|
+
void translate(exception_t const &e) {
|
|
111
|
+
PyErr_SetString(PyExc_RuntimeError, e.what());
|
|
112
|
+
}
|
|
269
113
|
|
|
270
|
-
|
|
271
|
-
|
|
114
|
+
wowool::common::Options convert_py_2_api_options(py::dict const &kwargs) {
|
|
115
|
+
wowool::common::Options options;
|
|
116
|
+
for (auto const &item : kwargs) {
|
|
117
|
+
options.emplace(py::str(item.first), py::str(item.second));
|
|
118
|
+
}
|
|
119
|
+
return options;
|
|
120
|
+
}
|
|
272
121
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
typedef wowool::analyzer::Results type;
|
|
122
|
+
std::string convert_filterset(wowool::filter::Filter const &filterset) {
|
|
123
|
+
return filterset.info();
|
|
124
|
+
}
|
|
277
125
|
|
|
278
|
-
|
|
126
|
+
py::dict convert_options_2_py(wowool::common::Options const &options) {
|
|
127
|
+
py::dict kwargs;
|
|
128
|
+
for (auto const &item : options) {
|
|
129
|
+
kwargs[py::str(item.first)] = py::str(item.second);
|
|
130
|
+
}
|
|
131
|
+
return kwargs;
|
|
132
|
+
}
|
|
279
133
|
|
|
280
|
-
|
|
281
|
-
: wowool::analyzer::Results(std::move(base)) {}
|
|
282
|
-
};
|
|
134
|
+
// self.options["pytryoshka"] = "true"
|
|
283
135
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
py::dict _kwargs;
|
|
136
|
+
static wowool::common::Options global_shared_engine_options = {
|
|
137
|
+
{std::string("language"), std::string("auto")},
|
|
138
|
+
// { std::string("verbose") , std::string("trace") },
|
|
139
|
+
{std::string("pytryoshka"), std::string("true")}};
|
|
289
140
|
|
|
290
|
-
|
|
291
|
-
|
|
141
|
+
static std::shared_ptr<wowool::engine::Engine>
|
|
142
|
+
global_shared_engine; //( global_shared_engine_options );
|
|
292
143
|
|
|
293
|
-
|
|
294
|
-
|
|
144
|
+
wowool::engine::Engine &get_default_engine(wowool::common::Options &options) {
|
|
145
|
+
PYTHON_LOCK
|
|
295
146
|
|
|
296
|
-
|
|
297
|
-
|
|
147
|
+
if (!global_shared_engine) {
|
|
148
|
+
wowool::engine::Engine *global_wowool_engine =
|
|
149
|
+
new wowool::engine::Engine(options);
|
|
150
|
+
// std::cout << " !!!!!!!!!!!!!! Creating Global Engine" <<
|
|
151
|
+
// global_wowool_engine << std::endl;
|
|
152
|
+
global_shared_engine.reset(global_wowool_engine);
|
|
153
|
+
}
|
|
154
|
+
return *global_shared_engine;
|
|
155
|
+
}
|
|
298
156
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
157
|
+
class engine_t : public wowool::engine::Engine {
|
|
158
|
+
public:
|
|
159
|
+
// typedef wowool::EngineInterface type;
|
|
160
|
+
|
|
161
|
+
typedef wowool::engine::Engine type;
|
|
162
|
+
|
|
163
|
+
// using wowool::engine::Engine::Engine;
|
|
164
|
+
|
|
165
|
+
// engine_t(wowool::engine::Engine const &&base)
|
|
166
|
+
// : wowool::engine::Engine(std::move(base))
|
|
167
|
+
// {
|
|
168
|
+
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const
|
|
169
|
+
// &&base)" << this << std::endl;
|
|
170
|
+
// }
|
|
171
|
+
|
|
172
|
+
// engine_t(wowool::engine::Engine const &&base, py::dict const &kwarg)
|
|
173
|
+
// : wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg))
|
|
174
|
+
// {
|
|
175
|
+
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const
|
|
176
|
+
// &&base, py::dict const &kwarg)" << this << std::endl;
|
|
177
|
+
// }
|
|
178
|
+
|
|
179
|
+
// we need this one to be able to create multi_process objects.
|
|
180
|
+
engine_t(py::dict const &kwarg)
|
|
181
|
+
: wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg)) {
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
class lid_t : public wowool::language_identifier::LanguageIdentifier {
|
|
186
|
+
public:
|
|
187
|
+
typedef wowool::language_identifier::LanguageIdentifier type;
|
|
188
|
+
|
|
189
|
+
using wowool::language_identifier::LanguageIdentifier::LanguageIdentifier;
|
|
190
|
+
|
|
191
|
+
lid_t(wowool::language_identifier::LanguageIdentifier const &&base)
|
|
192
|
+
: wowool::language_identifier::LanguageIdentifier(std::move(base)) {}
|
|
193
|
+
|
|
194
|
+
lid_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
|
|
195
|
+
: wowool::language_identifier::LanguageIdentifier(
|
|
196
|
+
engine, tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
197
|
+
|
|
198
|
+
lid_t(py::dict const &kwarg)
|
|
199
|
+
: wowool::language_identifier::LanguageIdentifier(
|
|
200
|
+
tir::pywowool::get_default_engine(global_shared_engine_options),
|
|
201
|
+
tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
class domain_t : public wowool::domain::Domain {
|
|
205
|
+
public:
|
|
206
|
+
typedef wowool::domain::Domain type;
|
|
207
|
+
|
|
208
|
+
using wowool::domain::Domain::Domain;
|
|
209
|
+
|
|
210
|
+
domain_t(wowool::domain::Domain const &&base)
|
|
211
|
+
: wowool::domain::Domain(std::move(base)) {}
|
|
212
|
+
|
|
213
|
+
domain_t(wowool::analyzer::Engine const &engine,
|
|
214
|
+
std::string const domain_descriptor, py::dict const &kwarg)
|
|
215
|
+
: wowool::domain::Domain(engine, domain_descriptor,
|
|
216
|
+
tir::pywowool::convert_py_2_api_options(kwarg)) {
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// we need this one to be able to create multi_process objects.
|
|
220
|
+
domain_t(py::dict const &kwarg)
|
|
221
|
+
: wowool::domain::Domain(
|
|
222
|
+
tir::pywowool::get_default_engine(global_shared_engine_options),
|
|
223
|
+
kwarg["name"].cast<std::string>(),
|
|
224
|
+
tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
225
|
+
|
|
226
|
+
// wowool::analyzer::Results process(wowool::analyzer::Results const document)
|
|
227
|
+
// {
|
|
228
|
+
// char *p = 0;
|
|
229
|
+
// *p = 0;
|
|
230
|
+
// std::cout << "PLUGIN domain_t::process" << std::endl;
|
|
231
|
+
// // py::gil_scoped_release release; // Release the GIL
|
|
232
|
+
// return (*static_cast<wowool::domain::Domain const *>(this))(document);
|
|
233
|
+
// };
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
wowool::filter::FilterCollection
|
|
237
|
+
string2filterset(std::string const &filter_str) {
|
|
238
|
+
auto filter_vector = wowool::common::split(filter_str, ',');
|
|
239
|
+
return wowool::filter::FilterCollection(filter_vector.begin(),
|
|
240
|
+
filter_vector.end());
|
|
241
|
+
}
|
|
320
242
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
243
|
+
class filter_t : public wowool::filter::Filter {
|
|
244
|
+
public:
|
|
245
|
+
typedef wowool::filter::Filter type;
|
|
246
|
+
|
|
247
|
+
using wowool::filter::Filter::Filter;
|
|
248
|
+
|
|
249
|
+
filter_t(wowool::filter::Filter const &&base)
|
|
250
|
+
: wowool::filter::Filter(std::move(base)) {}
|
|
251
|
+
|
|
252
|
+
filter_t(wowool::filter::FilterCollection const &filterset)
|
|
253
|
+
: wowool::filter::Filter(filterset), _filterset(filterset) {}
|
|
254
|
+
|
|
255
|
+
filter_t(std::string const filterset)
|
|
256
|
+
: wowool::filter::Filter(filterset),
|
|
257
|
+
_filterset(string2filterset(filterset)) {}
|
|
258
|
+
|
|
259
|
+
wowool::filter::FilterCollection const _filterset;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
class results_t : public wowool::analyzer::Results {
|
|
263
|
+
public:
|
|
264
|
+
typedef wowool::analyzer::Results type;
|
|
265
|
+
|
|
266
|
+
using wowool::analyzer::Results::Results;
|
|
267
|
+
|
|
268
|
+
results_t(wowool::analyzer::Results const &&base)
|
|
269
|
+
: wowool::analyzer::Results(std::move(base)) {}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
class analyzer_t : public wowool::analyzer::Analyzer {
|
|
273
|
+
public:
|
|
274
|
+
typedef wowool::analyzer::Analyzer type;
|
|
275
|
+
py::dict _kwargs;
|
|
276
|
+
|
|
277
|
+
using wowool::analyzer::Analyzer::Analyzer;
|
|
278
|
+
using wowool::analyzer::Analyzer::operator();
|
|
279
|
+
|
|
280
|
+
analyzer_t(wowool::analyzer::Analyzer const &&base)
|
|
281
|
+
: wowool::analyzer::Analyzer(std::move(base)) {}
|
|
282
|
+
|
|
283
|
+
analyzer_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
|
|
284
|
+
: wowool::analyzer::Analyzer(
|
|
285
|
+
engine, tir::pywowool::convert_py_2_api_options(kwarg)),
|
|
286
|
+
_kwargs(kwarg) {}
|
|
287
|
+
|
|
288
|
+
std::string
|
|
289
|
+
process_return_string(std::string const &document,
|
|
290
|
+
wowool::common::Options const &json_options) {
|
|
291
|
+
std::string ret_val;
|
|
292
|
+
// std::cout << "options:" ; print_string_map(std::cout , json_options);
|
|
293
|
+
// std::cout << std::endl;
|
|
294
|
+
auto results = (*this)(document, json_options);
|
|
295
|
+
return results.to_json();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
std::string pipeline_expand(std::string const &pipeline,
|
|
300
|
+
std::string const &paths_str, bool file_access,
|
|
301
|
+
bool allow_dev_versions,
|
|
302
|
+
std::string const &pipeline_language) {
|
|
303
|
+
try {
|
|
304
|
+
std::vector<std::string> paths = wowool::common::split(paths_str, ',');
|
|
305
|
+
return wowool::engine::expand_pipeline(
|
|
306
|
+
pipeline, paths, file_access, allow_dev_versions, pipeline_language);
|
|
307
|
+
} catch (wowool::common::JsonException const &ex) {
|
|
308
|
+
throw exception_json_t(ex.what());
|
|
309
|
+
}
|
|
310
|
+
}
|
|
325
311
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
for (auto const &domain_descriptor : domains)
|
|
334
|
-
{
|
|
335
|
-
std::vector<std::string> groups;
|
|
336
|
-
std::string domain = domain_descriptor;
|
|
337
|
-
wowool::domain::get_domain_concepts(domain, groups);
|
|
338
|
-
std::copy(groups.begin(), groups.end(), std::back_inserter(all_groups));
|
|
339
|
-
}
|
|
340
|
-
} catch (std::exception const &ex)
|
|
341
|
-
{
|
|
342
|
-
throw exception_t(ex.what(), "");
|
|
343
|
-
}
|
|
312
|
+
std::string pipeline_parse(std::string const &pipeline) {
|
|
313
|
+
try {
|
|
314
|
+
return wowool::engine::parse_pipeline(pipeline);
|
|
315
|
+
} catch (wowool::common::JsonException const &ex) {
|
|
316
|
+
throw exception_json_t(ex.what());
|
|
317
|
+
}
|
|
318
|
+
}
|
|
344
319
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
detail::DoNotExecFirstTime dneft;
|
|
349
|
-
for (auto const &concept : all_groups)
|
|
350
|
-
{
|
|
351
|
-
if (concept.empty())
|
|
352
|
-
continue;
|
|
320
|
+
bool is_valid_version_format(std::string const &version) {
|
|
321
|
+
return wowool::common::is_valid_version_format(version);
|
|
322
|
+
}
|
|
353
323
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
324
|
+
std::string get_domain_info(std::string const domains_str) {
|
|
325
|
+
std::vector<std::string> all_groups;
|
|
326
|
+
std::vector<std::string> domains = wowool::common::split(domains_str, ',');
|
|
327
|
+
std::stringstream json;
|
|
328
|
+
try {
|
|
329
|
+
for (auto const &domain_descriptor : domains) {
|
|
330
|
+
std::vector<std::string> groups;
|
|
331
|
+
std::string domain = domain_descriptor;
|
|
332
|
+
wowool::domain::get_domain_concepts(domain, groups);
|
|
333
|
+
std::copy(groups.begin(), groups.end(), std::back_inserter(all_groups));
|
|
334
|
+
}
|
|
335
|
+
} catch (std::exception const &ex) {
|
|
336
|
+
throw exception_t(ex.what(), "");
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (!all_groups.empty()) {
|
|
340
|
+
json << "[";
|
|
341
|
+
detail::DoNotExecFirstTime dneft;
|
|
342
|
+
for (auto const &concept : all_groups) {
|
|
343
|
+
if (concept.empty())
|
|
344
|
+
continue;
|
|
345
|
+
|
|
346
|
+
dneft([&json]() { json << ","; });
|
|
347
|
+
json << "\"" << concept << "\"";
|
|
348
|
+
}
|
|
349
|
+
json << "]";
|
|
350
|
+
return json.str();
|
|
351
|
+
} else {
|
|
352
|
+
json << "[]";
|
|
353
|
+
}
|
|
354
|
+
return json.str();
|
|
355
|
+
}
|
|
366
356
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
357
|
+
void print_log_message(unsigned short id, char const *msg) {
|
|
358
|
+
std::cout << msg << std::endl;
|
|
359
|
+
}
|
|
371
360
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
throw exception_t(e.what(), "");
|
|
384
|
-
}
|
|
385
|
-
}
|
|
361
|
+
std::string compile_domain(std::string const domain_descriptor,
|
|
362
|
+
py::dict const &kwargs) {
|
|
363
|
+
try {
|
|
364
|
+
auto options = convert_py_2_api_options(kwargs);
|
|
365
|
+
return wowool::domain::compile_domain(options);
|
|
366
|
+
} catch (wowool::common::Exception &ex) {
|
|
367
|
+
throw exception_t(ex.what(), "");
|
|
368
|
+
} catch (std::exception const &e) {
|
|
369
|
+
throw exception_t(e.what(), "");
|
|
370
|
+
}
|
|
371
|
+
}
|
|
386
372
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
};
|
|
373
|
+
struct options_t {
|
|
374
|
+
static const std::string language;
|
|
375
|
+
};
|
|
391
376
|
|
|
392
|
-
|
|
377
|
+
const std::string options_t::language = wowool::analyzer::option::language;
|
|
393
378
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
379
|
+
auto __exit__callback = []() {
|
|
380
|
+
PYTHON_LOCK
|
|
381
|
+
global_shared_engine.reset();
|
|
382
|
+
};
|
|
398
383
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
std::function<void(unsigned short, const char *)> logit;
|
|
384
|
+
struct PyLog {
|
|
385
|
+
std::function<void(unsigned short, const char *)> logit;
|
|
402
386
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
387
|
+
PyLog(std::function<void(unsigned short, const char *)> logit_)
|
|
388
|
+
: logit(logit_) {}
|
|
389
|
+
};
|
|
406
390
|
|
|
407
|
-
|
|
391
|
+
std::function<void(int, std::string)> pylogit;
|
|
408
392
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
}
|
|
393
|
+
void global_logger_fn(unsigned short id, const char *msg) {
|
|
394
|
+
if (pylogit) {
|
|
395
|
+
pylogit(id, std::string(msg));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
416
398
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
399
|
+
void add_logger(unsigned short id, std::string level,
|
|
400
|
+
const std::function<void(int, std::string)> logit) {
|
|
401
|
+
pylogit = logit;
|
|
402
|
+
wowool::logging::add_logger(id, level, global_logger_fn);
|
|
403
|
+
}
|
|
422
404
|
|
|
423
|
-
|
|
405
|
+
void unset_logger() { pylogit = nullptr; }
|
|
424
406
|
|
|
425
|
-
}
|
|
426
|
-
} // namespace tir
|
|
407
|
+
} // namespace pywowool
|
|
408
|
+
} // namespace tir
|
|
427
409
|
|
|
428
410
|
// clang-format off
|
|
429
411
|
|
|
@@ -444,6 +426,7 @@ PYBIND11_MODULE(_wowool_sdk, m)
|
|
|
444
426
|
m.add_object("_cleanup", py::capsule(tir::pywowool::__exit__callback));
|
|
445
427
|
m.def("get_domain_info", tir::pywowool::get_domain_info);
|
|
446
428
|
m.def("pipeline_expand", tir::pywowool::pipeline_expand);
|
|
429
|
+
m.def("pipeline_parse", tir::pywowool::pipeline_parse);
|
|
447
430
|
m.def("is_valid_version_format", tir::pywowool::is_valid_version_format);
|
|
448
431
|
m.def("compile_domain", tir::pywowool::compile_domain);
|
|
449
432
|
m.def("add_logger", tir::pywowool::add_logger);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import os
|
|
3
3
|
import sys
|
|
4
|
+
from platform import system
|
|
4
5
|
|
|
5
6
|
if "WOWOOL_ROOT" in os.environ:
|
|
6
7
|
WOWOOL_ROOT = os.environ["WOWOOL_ROOT"]
|
|
7
8
|
expanded_wowool_root = Path(WOWOOL_ROOT).expanduser().resolve()
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if platform.system() == "Windows":
|
|
9
|
+
|
|
10
|
+
if system() == "Windows":
|
|
11
11
|
WOWOOL_LIB = expanded_wowool_root / "bin"
|
|
12
12
|
if str(WOWOOL_LIB) not in sys.path:
|
|
13
13
|
sys.path.append(str(WOWOOL_LIB))
|
|
@@ -19,4 +19,7 @@ else:
|
|
|
19
19
|
if str(WOWOOL_LIB) not in sys.path:
|
|
20
20
|
sys.path.append(str(WOWOOL_LIB))
|
|
21
21
|
|
|
22
|
+
if system() == "Windows":
|
|
23
|
+
os.add_dll_directory(str(WOWOOL_LIB))
|
|
24
|
+
|
|
22
25
|
from _wowool_plugin import * # noqa: F401, F403
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import os
|
|
3
3
|
import sys
|
|
4
|
-
|
|
4
|
+
from platform import system
|
|
5
5
|
|
|
6
6
|
if "WOWOOL_ROOT" in os.environ:
|
|
7
7
|
WOWOOL_ROOT = os.environ["WOWOOL_ROOT"]
|
|
8
8
|
expanded_wowool_root = Path(WOWOOL_ROOT).expanduser().resolve()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if platform.system() == "Windows":
|
|
9
|
+
|
|
10
|
+
if system() == "Windows":
|
|
12
11
|
WOWOOL_LIB = expanded_wowool_root / "bin"
|
|
13
12
|
if str(WOWOOL_LIB) not in sys.path:
|
|
14
13
|
sys.path.append(str(WOWOOL_LIB))
|
|
@@ -20,6 +19,8 @@ else:
|
|
|
20
19
|
if str(WOWOOL_LIB) not in sys.path:
|
|
21
20
|
sys.path.append(str(WOWOOL_LIB))
|
|
22
21
|
|
|
22
|
+
if system() == "Windows":
|
|
23
|
+
os.add_dll_directory(str(WOWOOL_LIB))
|
|
23
24
|
|
|
24
25
|
from _wowool_sdk import * # noqa
|
|
25
26
|
from _wowool_sdk import (
|
|
@@ -29,6 +30,7 @@ from _wowool_sdk import (
|
|
|
29
30
|
results,
|
|
30
31
|
TirJsonException,
|
|
31
32
|
pipeline_expand,
|
|
33
|
+
pipeline_parse,
|
|
32
34
|
compile_domain,
|
|
33
35
|
analyzer,
|
|
34
36
|
engine,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wowool-sdk-cpp
|
|
3
|
-
Version: 3.
|
|
4
|
-
Summary: Wowool NLP Toolkit C++ SDK Python Bindings
|
|
3
|
+
Version: 3.6.3
|
|
4
|
+
Summary: Wowool NLP Toolkit C++ SDK Python Bindings, (use nlp-wowool-sdk instead if you want the Python SDK)
|
|
5
5
|
Author: Wowool
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.1.2
|
wowool_sdk_cpp-3.5.6/version.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.5.6
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|