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.
Files changed (24) hide show
  1. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/PKG-INFO +2 -2
  2. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/pre_setup.py +3 -1
  3. wowool_sdk_cpp-3.6.3/sdk_version.txt +1 -0
  4. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/setup.py +6 -2
  5. wowool_sdk_cpp-3.6.3/version.txt +1 -0
  6. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/native/core/wowool_sdk.cpp +334 -351
  7. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/package/lib/wowool_plugin.py +6 -3
  8. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/package/lib/wowool_sdk.py +6 -4
  9. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/PKG-INFO +2 -2
  10. wowool_sdk_cpp-3.5.6/sdk_version.txt +0 -1
  11. wowool_sdk_cpp-3.5.6/version.txt +0 -1
  12. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/MANIFEST.in +0 -0
  13. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/common_setup.py +0 -0
  14. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/install_requires.txt +0 -0
  15. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/install_requires_wowool.txt +0 -0
  16. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/long_description.md +0 -0
  17. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/pyproject.toml +0 -0
  18. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/setup.cfg +0 -0
  19. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/plugin/wowool_plugin.cpp +0 -0
  20. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool/plugin/wowool_plugin.hpp +0 -0
  21. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/SOURCES.txt +0 -0
  22. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/dependency_links.txt +0 -0
  23. {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.3}/wowool_sdk_cpp.egg-info/not-zip-safe +0 -0
  24. {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.5.6
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 = ["icudt.lib", "icuuc.lib"]
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
- results = setup(
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
- #include <signal.h>
27
+ #include <signal.h>
28
28
  #else
29
- #include <thread>
30
- #include <windows.h>
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" or 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
- struct DoNotExecFirstTime
56
- {
57
- mutable bool initial = true;
55
+ struct DoNotExecFirstTime {
56
+ mutable bool initial = true;
58
57
 
59
- template<typename Functor>
60
- void operator()(Functor functor) const
61
- {
62
- if (!initial)
63
- {
64
- functor();
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
- void reset() { initial = true; }
71
- };
65
+ void reset() { initial = true; }
66
+ };
72
67
 
73
68
  } // namespace detail
74
69
 
75
- std::ostream &print_string_map(std::ostream &out, wowool::common::Options const &options)
76
- {
77
- for (auto const &option : options)
78
- {
79
- out << option.first << ":" << option.second << ",";
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
- class exception_t : public std::exception
88
- {
89
- private:
90
- std::string message;
91
- std::string extraData;
92
-
93
- public:
94
- exception_t(std::string message_, std::string extraData_)
95
- : message(message_), extraData(extraData_) {}
96
- // TODO: declare this nothrow
97
- ~exception_t() throw() {}
98
- const char *what() const throw() { return message.c_str(); }
99
- std::string getMessage() { return message; }
100
- std::string getExtraData() { return extraData; }
101
- };
102
-
103
- class exception_json_t : public std::exception
104
- {
105
- private:
106
- std::string json_data;
107
-
108
- public:
109
- exception_json_t(std::string json_data_)
110
- : json_data(json_data_) {}
111
- // TODO: declare this nothrow
112
- ~exception_json_t() throw() {}
113
- const char *what() const throw() { return json_data.c_str(); }
114
- };
115
-
116
- void translate(exception_json_t const &e)
117
- {
118
- PyErr_SetString(PyExc_RuntimeError, e.what());
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
- wowool::filter::FilterCollection const _filterset;
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
- class results_t : public wowool::analyzer::Results
274
- {
275
- public:
276
- typedef wowool::analyzer::Results type;
122
+ std::string convert_filterset(wowool::filter::Filter const &filterset) {
123
+ return filterset.info();
124
+ }
277
125
 
278
- using wowool::analyzer::Results::Results;
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
- results_t(wowool::analyzer::Results const &&base)
281
- : wowool::analyzer::Results(std::move(base)) {}
282
- };
134
+ // self.options["pytryoshka"] = "true"
283
135
 
284
- class analyzer_t : public wowool::analyzer::Analyzer
285
- {
286
- public:
287
- typedef wowool::analyzer::Analyzer type;
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
- using wowool::analyzer::Analyzer::Analyzer;
291
- using wowool::analyzer::Analyzer::operator();
141
+ static std::shared_ptr<wowool::engine::Engine>
142
+ global_shared_engine; //( global_shared_engine_options );
292
143
 
293
- analyzer_t(wowool::analyzer::Analyzer const &&base)
294
- : wowool::analyzer::Analyzer(std::move(base)) {}
144
+ wowool::engine::Engine &get_default_engine(wowool::common::Options &options) {
145
+ PYTHON_LOCK
295
146
 
296
- analyzer_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
297
- : wowool::analyzer::Analyzer(engine, tir::pywowool::convert_py_2_api_options(kwarg)), _kwargs(kwarg) {}
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
- std::string process_return_string(std::string const &document, wowool::common::Options const &json_options)
300
- {
301
- std::string ret_val;
302
- // std::cout << "options:" ; print_string_map(std::cout , json_options);
303
- // std::cout << std::endl;
304
- auto results = (*this)(document, json_options);
305
- return results.to_json();
306
- }
307
- };
308
-
309
- std::string pipeline_expand(std::string const &pipeline, std::string const &paths_str, bool file_access, bool allow_dev_versions, std::string const &pipeline_language)
310
- {
311
- try
312
- {
313
- std::vector<std::string> paths = wowool::common::split(paths_str, ',');
314
- return wowool::engine::expand_pipeline(pipeline, paths, file_access, allow_dev_versions, pipeline_language);
315
- } catch (wowool::common::JsonException const &ex)
316
- {
317
- throw exception_json_t(ex.what());
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
- bool is_valid_version_format(std::string const &version)
322
- {
323
- return wowool::common::is_valid_version_format(version);
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
- std::string get_domain_info(std::string const domains_str)
327
- {
328
- std::vector<std::string> all_groups;
329
- std::vector<std::string> domains = wowool::common::split(domains_str, ',');
330
- std::stringstream json;
331
- try
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
- if (!all_groups.empty())
346
- {
347
- json << "[";
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
- dneft([&json]() { json << ","; });
355
- json << "\"" << concept << "\"";
356
- }
357
- json << "]";
358
- return json.str();
359
- }
360
- else
361
- {
362
- json << "[]";
363
- }
364
- return json.str();
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
- void print_log_message(unsigned short id, char const *msg)
368
- {
369
- std::cout << msg << std::endl;
370
- }
357
+ void print_log_message(unsigned short id, char const *msg) {
358
+ std::cout << msg << std::endl;
359
+ }
371
360
 
372
- std::string compile_domain(std::string const domain_descriptor, py::dict const &kwargs)
373
- {
374
- try
375
- {
376
- auto options = convert_py_2_api_options(kwargs);
377
- return wowool::domain::compile_domain(options);
378
- } catch (wowool::common::Exception &ex)
379
- {
380
- throw exception_t(ex.what(), "");
381
- } catch (std::exception const &e)
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
- struct options_t
388
- {
389
- static const std::string language;
390
- };
373
+ struct options_t {
374
+ static const std::string language;
375
+ };
391
376
 
392
- const std::string options_t::language = wowool::analyzer::option::language;
377
+ const std::string options_t::language = wowool::analyzer::option::language;
393
378
 
394
- auto __exit__callback = []() {
395
- PYTHON_LOCK
396
- global_shared_engine.reset();
397
- };
379
+ auto __exit__callback = []() {
380
+ PYTHON_LOCK
381
+ global_shared_engine.reset();
382
+ };
398
383
 
399
- struct PyLog
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
- PyLog(std::function<void(unsigned short, const char *)> logit_)
404
- : logit(logit_) {}
405
- };
387
+ PyLog(std::function<void(unsigned short, const char *)> logit_)
388
+ : logit(logit_) {}
389
+ };
406
390
 
407
- std::function<void(int, std::string)> pylogit;
391
+ std::function<void(int, std::string)> pylogit;
408
392
 
409
- void global_logger_fn(unsigned short id, const char *msg)
410
- {
411
- if (pylogit)
412
- {
413
- pylogit(id, std::string(msg));
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
- void add_logger(unsigned short id, std::string level, const std::function<void(int, std::string)> logit)
418
- {
419
- pylogit = logit;
420
- wowool::logging::add_logger(id, level, global_logger_fn);
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
- void unset_logger() { pylogit = nullptr; }
405
+ void unset_logger() { pylogit = nullptr; }
424
406
 
425
- }
426
- } // namespace tir::pywowool
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
- import platform
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
- import platform
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.5.6
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
@@ -1 +0,0 @@
1
- 3.5.6
File without changes