wowool-common 3.0.2.dev19__py3-none-any.whl
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.
Potentially problematic release.
This version of wowool-common might be problematic. Click here for more details.
- wowool/analysis.py +289 -0
- wowool/analysis_parser.py +102 -0
- wowool/annotation/__init__.py +4 -0
- wowool/annotation/annotation.py +156 -0
- wowool/annotation/concept.py +473 -0
- wowool/annotation/paragraph.py +166 -0
- wowool/annotation/sentence.py +262 -0
- wowool/annotation/token.py +266 -0
- wowool/apps/info.py +97 -0
- wowool/common/pipeline/__init__.py +1 -0
- wowool/common/pipeline/objects.py +45 -0
- wowool/common/utilities.py +13 -0
- wowool/config.py +67 -0
- wowool/diagnostic.py +250 -0
- wowool/document/__init__.py +2 -0
- wowool/document/apps/chunks.py +22 -0
- wowool/document/apps/themes.py +11 -0
- wowool/document/apps/topics.py +11 -0
- wowool/document/document.py +399 -0
- wowool/document/factory.py +176 -0
- wowool/error.py +2 -0
- wowool/io/console/__init__.py +1 -0
- wowool/io/console/argument_parser.py +29 -0
- wowool/io/console/console.py +102 -0
- wowool/io/provider/__init__.py +4 -0
- wowool/io/provider/docx.py +26 -0
- wowool/io/provider/factory.py +173 -0
- wowool/io/provider/file.py +85 -0
- wowool/io/provider/html.py +42 -0
- wowool/io/provider/html_v2.py +420 -0
- wowool/io/provider/input_provider.py +38 -0
- wowool/io/provider/pdf.py +320 -0
- wowool/io/provider/pdf_no_layout.py +48 -0
- wowool/io/provider/rtf.py +14 -0
- wowool/io/provider/str.py +17 -0
- wowool/string/__init__.py +153 -0
- wowool/tool/woc/create.py +42 -0
- wowool/utility/__init__.py +16 -0
- wowool/utility/apps/decorators.py +66 -0
- wowool/utility/apps/yml_include.py +30 -0
- wowool/utility/csv/__init__.py +26 -0
- wowool/utility/default_arguments.py +44 -0
- wowool/utility/diagnostics.py +24 -0
- wowool/utility/iterators/__init__.py +59 -0
- wowool/utility/method_registry.py +20 -0
- wowool/utility/numbers.py +42 -0
- wowool/utility/path/__init__.py +1 -0
- wowool/utility/path/path.py +11 -0
- wowool/utility/text/cleanup.py +82 -0
- wowool/visitor.py +48 -0
- wowool/wow.py +424 -0
- wowool_common-3.0.2.dev19.dist-info/METADATA +10 -0
- wowool_common-3.0.2.dev19.dist-info/RECORD +55 -0
- wowool_common-3.0.2.dev19.dist-info/WHEEL +5 -0
- wowool_common-3.0.2.dev19.dist-info/top_level.txt +1 -0
wowool/wow.py
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from sys import stderr
|
|
3
|
+
import json
|
|
4
|
+
from wowool.utility import is_valid_kwargs, clean_up_empty_keywords
|
|
5
|
+
from wowool.utility.method_registry import register, get_bound_jump_table
|
|
6
|
+
from wowool.analysis import APP_ID as APP_ID_ANALYSIS
|
|
7
|
+
from wowool.document.document import Document
|
|
8
|
+
from operator import itemgetter
|
|
9
|
+
from wowool.utility.default_arguments import make_document_collection
|
|
10
|
+
import logging
|
|
11
|
+
from json import JSONEncoder
|
|
12
|
+
from os import environ
|
|
13
|
+
import gc
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def print_attributes(attributes, begin="@(", end=")"):
|
|
19
|
+
att = []
|
|
20
|
+
for k, vs in attributes.items():
|
|
21
|
+
for v in vs:
|
|
22
|
+
att.append(f"{k}='{v}'")
|
|
23
|
+
if att:
|
|
24
|
+
print(begin, end="")
|
|
25
|
+
print(*att, sep=",", end=end)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def print_attribute_keys(attributes, begin="@(", end=")"):
|
|
29
|
+
att = []
|
|
30
|
+
for k in attributes:
|
|
31
|
+
att.append(f"{k}")
|
|
32
|
+
if att:
|
|
33
|
+
print(begin, end="")
|
|
34
|
+
print(*att, sep=",", end=end)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class WowJSONEncoder(JSONEncoder):
|
|
38
|
+
def default(self, obj):
|
|
39
|
+
if isinstance(obj, set):
|
|
40
|
+
return str(list(obj))
|
|
41
|
+
else:
|
|
42
|
+
return getattr(obj, "to_json")() if hasattr(obj, "to_json") else super().default(obj)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class WowTools:
|
|
46
|
+
def __init__(self, console_):
|
|
47
|
+
# Bind methods to instance
|
|
48
|
+
self.functions = get_bound_jump_table(self)
|
|
49
|
+
self.console = console_
|
|
50
|
+
|
|
51
|
+
@register(command="none")
|
|
52
|
+
def tool_none(self, cli, id: str, doc: Document):
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
@register()
|
|
56
|
+
def raw(self, cli, id: str, doc: Document):
|
|
57
|
+
for app in doc.app_ids():
|
|
58
|
+
if app == APP_ID_ANALYSIS:
|
|
59
|
+
self.console.print(f"{app=}")
|
|
60
|
+
self.console.print(doc.results(app))
|
|
61
|
+
elif app == "eot-print-annotations":
|
|
62
|
+
app_results = doc.results(app)
|
|
63
|
+
if app_results:
|
|
64
|
+
print("-" * 40)
|
|
65
|
+
printed_stream = set()
|
|
66
|
+
for step in app_results:
|
|
67
|
+
print(f"- {step['name']}")
|
|
68
|
+
print(" -" * 20)
|
|
69
|
+
data = step["data"]
|
|
70
|
+
print_stream_header = False
|
|
71
|
+
if "streams" in data:
|
|
72
|
+
for stream in data["streams"]:
|
|
73
|
+
if stream["type"] not in printed_stream:
|
|
74
|
+
print_stream_header = True
|
|
75
|
+
if print_stream_header:
|
|
76
|
+
self.console.print(" <literal>Lexicon input stream:<literal>")
|
|
77
|
+
if "streams" in data:
|
|
78
|
+
for stream in data["streams"]:
|
|
79
|
+
if stream["type"] not in printed_stream:
|
|
80
|
+
printed_stream.add(stream["type"])
|
|
81
|
+
self.console.print(f" <stem>{stream['type']: <18}</stem> : {stream['text']}")
|
|
82
|
+
print(" -" * 20)
|
|
83
|
+
self.console.print(" <literal>Annotations:</literal>")
|
|
84
|
+
for sent in data["sentences"]:
|
|
85
|
+
for annotation in sent[3]:
|
|
86
|
+
annotation_type = annotation[0]
|
|
87
|
+
if annotation_type == 2:
|
|
88
|
+
print_flags_indent = True
|
|
89
|
+
if len(annotation) > 5:
|
|
90
|
+
bits = annotation[5]
|
|
91
|
+
if "deleted" in bits:
|
|
92
|
+
print_flags_indent = False
|
|
93
|
+
|
|
94
|
+
if print_flags_indent:
|
|
95
|
+
self.console.print(
|
|
96
|
+
f" C:({annotation[1]},{annotation[2]}) <uri>{annotation[3]}</uri>",
|
|
97
|
+
end="",
|
|
98
|
+
)
|
|
99
|
+
else:
|
|
100
|
+
self.console.print(
|
|
101
|
+
f" [red]-[/red]C:({annotation[1]},{annotation[2]}) {annotation[3]}",
|
|
102
|
+
end="",
|
|
103
|
+
)
|
|
104
|
+
if len(annotation) > 4:
|
|
105
|
+
print_attributes(annotation[4])
|
|
106
|
+
if len(annotation) > 5:
|
|
107
|
+
print_attribute_keys(annotation[5], begin=" $(")
|
|
108
|
+
print()
|
|
109
|
+
|
|
110
|
+
elif annotation_type == 3:
|
|
111
|
+
self.console.print(
|
|
112
|
+
f"\tT:({annotation[1]},{annotation[2]}) [green bold]{annotation[3]}[/ green bold]",
|
|
113
|
+
end="",
|
|
114
|
+
)
|
|
115
|
+
properties = annotation[4]
|
|
116
|
+
if properties:
|
|
117
|
+
print(" (+", end="")
|
|
118
|
+
print(*properties, sep=",+", end=")")
|
|
119
|
+
|
|
120
|
+
for md in annotation[5]:
|
|
121
|
+
print(f"[{md[0]}:{md[1]}", end="")
|
|
122
|
+
properties = md[2:]
|
|
123
|
+
if properties:
|
|
124
|
+
print(" (+", end="")
|
|
125
|
+
print(*properties, sep=",+", end=")")
|
|
126
|
+
print("]", end="")
|
|
127
|
+
|
|
128
|
+
print()
|
|
129
|
+
|
|
130
|
+
else:
|
|
131
|
+
if doc.results(app):
|
|
132
|
+
self.console.print(f"{app=}")
|
|
133
|
+
self.console.print_json(doc.results(app))
|
|
134
|
+
if doc.metadata:
|
|
135
|
+
self.console.print("metadata:")
|
|
136
|
+
self.console.print_json(json.dumps(doc.metadata, cls=WowJSONEncoder))
|
|
137
|
+
|
|
138
|
+
@register()
|
|
139
|
+
def apps(self, cli, id: str, doc: Document):
|
|
140
|
+
for app in doc.app_ids():
|
|
141
|
+
if app != APP_ID_ANALYSIS:
|
|
142
|
+
self.console.print(f"{app=}")
|
|
143
|
+
self.console.print_json(doc.results(app))
|
|
144
|
+
|
|
145
|
+
@register()
|
|
146
|
+
def json(self, cli, id: str, doc: Document):
|
|
147
|
+
jdoc = doc.to_json()
|
|
148
|
+
print(json.dumps(jdoc, ensure_ascii=False))
|
|
149
|
+
|
|
150
|
+
@register()
|
|
151
|
+
def text(self, cli, id: str, doc: Document):
|
|
152
|
+
if doc.analysis:
|
|
153
|
+
for sentence in doc.analysis:
|
|
154
|
+
print(sentence.text)
|
|
155
|
+
else:
|
|
156
|
+
print(doc.text)
|
|
157
|
+
|
|
158
|
+
@register()
|
|
159
|
+
def canonical(self, cli, id: str, doc: Document):
|
|
160
|
+
from wowool.string import canonicalize
|
|
161
|
+
|
|
162
|
+
assert doc.analysis
|
|
163
|
+
for sentence in doc.analysis:
|
|
164
|
+
print(canonicalize(sentence))
|
|
165
|
+
|
|
166
|
+
@register(command="input_text")
|
|
167
|
+
def input_text(self, cli, id: str, doc: Document):
|
|
168
|
+
print(doc.text)
|
|
169
|
+
|
|
170
|
+
@register()
|
|
171
|
+
def grep(self, cli, id: str, doc: Document):
|
|
172
|
+
from wowool.apps.grep import APP_ID
|
|
173
|
+
from wowool.analysis import APP_ID as ID_ANALYSIS
|
|
174
|
+
|
|
175
|
+
if not doc.has_results(ID_ANALYSIS):
|
|
176
|
+
return
|
|
177
|
+
|
|
178
|
+
grep_results = doc.results(APP_ID)
|
|
179
|
+
if grep_results:
|
|
180
|
+
# self.consolee.print_json(grep_results)
|
|
181
|
+
if cli.grep_results == None:
|
|
182
|
+
cli.grep_results = []
|
|
183
|
+
matches = grep_results["matches"]
|
|
184
|
+
cli.grep_results.extend(matches)
|
|
185
|
+
prev_sentence_idx = -1
|
|
186
|
+
sentences = doc.analysis.sentences
|
|
187
|
+
for match in matches:
|
|
188
|
+
sentence_index = match["sentence_index"]
|
|
189
|
+
if sentence_index != prev_sentence_idx:
|
|
190
|
+
self.console.print(f"[green]Sentence:[/green] {sentences[sentence_index].text}")
|
|
191
|
+
prev_sentence_idx = sentence_index
|
|
192
|
+
self.console.print(f" - [bold]{match['text']}[/bold] ")
|
|
193
|
+
for group in match["groups"]:
|
|
194
|
+
if "literal" in group:
|
|
195
|
+
self.console.print(f" - [blue]{group['name']}[/blue] -> {group['text']} = {group['literal']}")
|
|
196
|
+
else:
|
|
197
|
+
self.console.print(f" - [blue]{group['name']}[/blue] -> {group['text']} ")
|
|
198
|
+
|
|
199
|
+
self.console.print("- " * 20)
|
|
200
|
+
|
|
201
|
+
@register()
|
|
202
|
+
def concepts(self, cli, id: str, doc: Document):
|
|
203
|
+
assert doc.analysis
|
|
204
|
+
for c in doc.analysis.concepts():
|
|
205
|
+
print({**c})
|
|
206
|
+
|
|
207
|
+
@register()
|
|
208
|
+
def stagger(self, cli, id: str, doc: Document):
|
|
209
|
+
from wowool.annotation import Concept
|
|
210
|
+
|
|
211
|
+
assert doc.analysis != None
|
|
212
|
+
for sentence in doc.analysis:
|
|
213
|
+
self.console.print(f"""S({sentence.begin_offset},{sentence.end_offset}): "{sentence.text}" """)
|
|
214
|
+
for concept in Concept.iter(sentence, lambda concept: concept.uri != "Sentence"):
|
|
215
|
+
self.console.print(f""" {concept.uri} -> "{concept.literal}" """, end="")
|
|
216
|
+
if concept.attributes:
|
|
217
|
+
self.console.print("@( ", end="")
|
|
218
|
+
for idx, kv in enumerate(concept.attributes.items()):
|
|
219
|
+
key, value = kv
|
|
220
|
+
if idx != 0:
|
|
221
|
+
self.console.print(",", end="")
|
|
222
|
+
self.console.print(f"{key}=\"{','.join(value)}\"", end="")
|
|
223
|
+
self.console.print(")", end="")
|
|
224
|
+
self.console.print("")
|
|
225
|
+
|
|
226
|
+
@register()
|
|
227
|
+
def stats(self, cli, id: str, doc: Document):
|
|
228
|
+
assert cli.corpus_analyzer, "parent tool has not configured the corpus_analyzer"
|
|
229
|
+
cli.corpus_analyzer(doc)
|
|
230
|
+
|
|
231
|
+
def __getitem__(self, function_name: str):
|
|
232
|
+
assert function_name in self.functions, f"Tool '{function_name}' not implemented."
|
|
233
|
+
return self.functions[function_name]
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def transform_grep_results(results, expression, console):
|
|
237
|
+
from collections import defaultdict
|
|
238
|
+
from tabulate import tabulate
|
|
239
|
+
import os
|
|
240
|
+
|
|
241
|
+
table_format = os.environ["WOWOOL_TABLE_FORMAT"] if "WOWOOL_TABLE_FORMAT" in os.environ else "presto"
|
|
242
|
+
|
|
243
|
+
freq = defaultdict(int)
|
|
244
|
+
collocations = {}
|
|
245
|
+
groups = defaultdict(lambda: defaultdict(int))
|
|
246
|
+
for match in results:
|
|
247
|
+
collocation_hash = ""
|
|
248
|
+
freq[match["text"]] += 1
|
|
249
|
+
for group in match["groups"]:
|
|
250
|
+
collocation_hash += f"""{group["name"]}{group["text"]}"""
|
|
251
|
+
groups[group["name"]][group["text"]] += 1
|
|
252
|
+
|
|
253
|
+
if len(match["groups"]):
|
|
254
|
+
if collocation_hash in collocations:
|
|
255
|
+
collocations[collocation_hash][0] += 1
|
|
256
|
+
else:
|
|
257
|
+
collocations[collocation_hash] = [1, match]
|
|
258
|
+
|
|
259
|
+
freq = sorted(freq.items(), key=lambda k_v: k_v[1], reverse=False)
|
|
260
|
+
collocations = sorted(collocations.items(), key=lambda k_v: k_v[1][0], reverse=False)
|
|
261
|
+
|
|
262
|
+
columns = []
|
|
263
|
+
headers = ["cnt"]
|
|
264
|
+
for key, match in collocations:
|
|
265
|
+
for group in match[1]["groups"]:
|
|
266
|
+
headers.append(group["name"])
|
|
267
|
+
break
|
|
268
|
+
|
|
269
|
+
console.print("\n[bold]Match:[/bold]\n")
|
|
270
|
+
print(tabulate([[v, k] for k, v in freq], tablefmt=table_format))
|
|
271
|
+
|
|
272
|
+
for name, data in groups.items():
|
|
273
|
+
console.print(f"\n[bold]Group: [blue]{name}[/blue][/bold]")
|
|
274
|
+
freq = sorted(data.items(), key=lambda k_v: k_v[1], reverse=False)
|
|
275
|
+
print(tabulate([[v, k] for k, v in freq], tablefmt=table_format))
|
|
276
|
+
|
|
277
|
+
if collocations:
|
|
278
|
+
console.print(f"\n[bold]Collocations: [blue]{expression}[/blue][/bold]\n")
|
|
279
|
+
for key, match in collocations:
|
|
280
|
+
item = [match[0]]
|
|
281
|
+
for group in match[1]["groups"]:
|
|
282
|
+
item.append(group["text"])
|
|
283
|
+
columns.append(item)
|
|
284
|
+
|
|
285
|
+
print(tabulate(columns, headers=headers, tablefmt=table_format))
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def print_grep_results(results, console, **kwargs):
|
|
289
|
+
results = sorted(results.items(), reverse=False, key=itemgetter(1))
|
|
290
|
+
console.print("[", **kwargs)
|
|
291
|
+
total = 0
|
|
292
|
+
# sz = len(results) - 1
|
|
293
|
+
for idx, item in enumerate(results):
|
|
294
|
+
# comma = "," if idx != sz else ""
|
|
295
|
+
total += item[1][0]
|
|
296
|
+
console.print(f"""[{item[1][0]},"{item[0]}", {item[1][1]} ],""", **kwargs)
|
|
297
|
+
console.print(f"""[{total},"TOTAL_COUNT" ]""", **kwargs)
|
|
298
|
+
console.print("]", **kwargs)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class CLI:
|
|
302
|
+
def __init__(self, kwargs, console_=None):
|
|
303
|
+
self.console = console_
|
|
304
|
+
if self.console == None:
|
|
305
|
+
from wowool.io.console import console
|
|
306
|
+
|
|
307
|
+
self.console = console
|
|
308
|
+
|
|
309
|
+
self.kwargs = kwargs.copy()
|
|
310
|
+
clean_up_empty_keywords(self.kwargs)
|
|
311
|
+
if "expression" in self.kwargs:
|
|
312
|
+
self.tool = "grep"
|
|
313
|
+
kwargs["tool"] = "grep"
|
|
314
|
+
expression = self.kwargs["expression"].replace('"', '\\"')
|
|
315
|
+
if "pipeline" in self.kwargs:
|
|
316
|
+
grep_stem = "true" if "grep_stem" in self.kwargs else "false"
|
|
317
|
+
self.kwargs["pipeline"] = f"""{self.kwargs["pipeline"]},grep(expression= " {expression} ", stem={grep_stem}).app"""
|
|
318
|
+
|
|
319
|
+
if "pipeline" not in self.kwargs and "domains" in self.kwargs:
|
|
320
|
+
# We used domains as a alternative for pipelines
|
|
321
|
+
self.kwargs["pipeline"] = self.kwargs["domains"]
|
|
322
|
+
else:
|
|
323
|
+
pipeline_filename = Path(f"""{self.kwargs["pipeline"]}""")
|
|
324
|
+
if str(pipeline_filename).endswith(".pipeline") and pipeline_filename.exists():
|
|
325
|
+
if pipeline_filename.suffix == ".pipeline":
|
|
326
|
+
with open(pipeline_filename) as fh:
|
|
327
|
+
self.kwargs["pipeline"] = fh.readline().strip()
|
|
328
|
+
self.nrof_threads = 1
|
|
329
|
+
if "nrof_threads" in self.kwargs:
|
|
330
|
+
self.nrof_threads = self.kwargs["nrof_threads"]
|
|
331
|
+
|
|
332
|
+
# if "tool" not in kwargs:
|
|
333
|
+
self.tool = kwargs["tool"] if "tool" in kwargs else "raw"
|
|
334
|
+
self.file_count = 0
|
|
335
|
+
stripped = None
|
|
336
|
+
self.tools = WowTools(self.console)
|
|
337
|
+
|
|
338
|
+
self.silent = True if (is_valid_kwargs(kwargs, "silent") and kwargs["silent"] is True) else False
|
|
339
|
+
|
|
340
|
+
if is_valid_kwargs(kwargs, "cleanup"):
|
|
341
|
+
stripped = lambda s: "".join(i for i in s if 31 < ord(i) < 127 or ord(i) == 0xD or ord(i) == 0xA)
|
|
342
|
+
self.doc_collection = make_document_collection(**kwargs)
|
|
343
|
+
|
|
344
|
+
self.corpus_analyzer = None
|
|
345
|
+
self.grep_results = None
|
|
346
|
+
self.ignore_errors = kwargs["ignore_errors"] if "ignore_errors" in kwargs else False
|
|
347
|
+
|
|
348
|
+
def process(self, id, doc):
|
|
349
|
+
from wowool.utility.diagnostics import log_diagnostics
|
|
350
|
+
|
|
351
|
+
print(id, file=stderr)
|
|
352
|
+
log_diagnostics(doc)
|
|
353
|
+
if not doc:
|
|
354
|
+
return
|
|
355
|
+
self.tools[self.tool](self, id, doc)
|
|
356
|
+
self.file_count += 1
|
|
357
|
+
|
|
358
|
+
def run(self):
|
|
359
|
+
try:
|
|
360
|
+
self._run()
|
|
361
|
+
except KeyboardInterrupt:
|
|
362
|
+
if self.grep_results:
|
|
363
|
+
expression = self.kwargs["expression"] if "expression" in self.kwargs else self.kwargs["pipeline"]
|
|
364
|
+
transform_grep_results(self.grep_results, expression, self.console)
|
|
365
|
+
|
|
366
|
+
def _run(self):
|
|
367
|
+
assert hasattr(self, "pipeline") and self.pipeline is not None
|
|
368
|
+
|
|
369
|
+
if self.tool == "info":
|
|
370
|
+
return self.info()
|
|
371
|
+
|
|
372
|
+
if self.nrof_threads >= 1 and "WOWOOL_LOCK_GIL" in environ and environ["WOWOOL_LOCK_GIL"].lower() == "true":
|
|
373
|
+
raise Exception("The environment variable WOWOOL_LOCK_GIL is set to true, this is not supported with multiple threads")
|
|
374
|
+
|
|
375
|
+
if self.nrof_threads == 1:
|
|
376
|
+
for ip in self.doc_collection:
|
|
377
|
+
try:
|
|
378
|
+
self.process(ip.id, self.pipeline(ip))
|
|
379
|
+
except Exception as error:
|
|
380
|
+
if self.ignore_errors:
|
|
381
|
+
self.console.print(f"Error while processing '{ip.id()}': {error}")
|
|
382
|
+
else:
|
|
383
|
+
raise error
|
|
384
|
+
else:
|
|
385
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
386
|
+
|
|
387
|
+
def task(ip):
|
|
388
|
+
try:
|
|
389
|
+
self.process(ip.id, self.pipeline(ip))
|
|
390
|
+
except Exception as error:
|
|
391
|
+
if self.ignore_errors:
|
|
392
|
+
self.console.print(f"Error while processing '{ip.id()}': {error}")
|
|
393
|
+
else:
|
|
394
|
+
raise error
|
|
395
|
+
finally:
|
|
396
|
+
del ip
|
|
397
|
+
gc.collect()
|
|
398
|
+
|
|
399
|
+
with ThreadPoolExecutor(max_workers=self.nrof_threads) as executor:
|
|
400
|
+
executor.map(task, self.doc_collection)
|
|
401
|
+
|
|
402
|
+
if self.grep_results:
|
|
403
|
+
expression = self.kwargs["expression"] if "expression" in self.kwargs else self.kwargs["pipeline"]
|
|
404
|
+
transform_grep_results(self.grep_results, expression, self.console)
|
|
405
|
+
|
|
406
|
+
if "output" in self.kwargs and self.kwargs["output"] is not None:
|
|
407
|
+
fn = Path(self.kwargs["output"])
|
|
408
|
+
suffix = fn.suffix.lower()
|
|
409
|
+
if self.corpus_analyzer:
|
|
410
|
+
# print(str(self.corpus_analyzer))
|
|
411
|
+
if suffix == ".json":
|
|
412
|
+
print(f'Saving to: {self.kwargs["output"]}')
|
|
413
|
+
with open(fn, "w") as wfh:
|
|
414
|
+
json.dump(self.corpus_analyzer.to_json(), wfh)
|
|
415
|
+
return
|
|
416
|
+
elif suffix == ".md":
|
|
417
|
+
print(f'Saving to: {self.kwargs["output"]}')
|
|
418
|
+
with open(fn, "w") as wfh:
|
|
419
|
+
wfh.write(self.corpus_analyzer.to_markdown())
|
|
420
|
+
return
|
|
421
|
+
|
|
422
|
+
else:
|
|
423
|
+
if self.corpus_analyzer:
|
|
424
|
+
print(str(self.corpus_analyzer))
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
wowool/analysis.py,sha256=BurTAfgtKYZObNx2TBKe49bwiqpJvufIazKGenRSpdY,8779
|
|
2
|
+
wowool/analysis_parser.py,sha256=ZTmk3-AXWHdMF8EVYlug8wJYFa7IyPRTrSPl-gZxano,3709
|
|
3
|
+
wowool/config.py,sha256=Jx-uTsdDLw6jza-5W-Ds2_nU8qsB537gllZhpioIMkg,2215
|
|
4
|
+
wowool/diagnostic.py,sha256=cvX4wlE4m0Zk9MiUzgp4KIZ0Ap2Y6B6Do2q7_uZl49c,7497
|
|
5
|
+
wowool/error.py,sha256=UxBxA-vC_gdp0yX1qMkI_MCaW9ZNNUfq82j8ZtgeO2c,33
|
|
6
|
+
wowool/visitor.py,sha256=TVjbFvkhvVhLzg2k7RCJIU-0jEj0ii5HIr6Zo-nyIrE,1651
|
|
7
|
+
wowool/wow.py,sha256=pclP2xwnSpVzZ0OhfMyYu2qOPB0FY021C7rG4ko-63o,17374
|
|
8
|
+
wowool/annotation/__init__.py,sha256=RvjzV1XsyJ-QFSjs6F_f6VufgMfeNKmYykfEMWLwM2Y,213
|
|
9
|
+
wowool/annotation/annotation.py,sha256=kErwub9qewW8z8ewJTC2YnV9DJHOdDBtCyKx4LCFVNA,4824
|
|
10
|
+
wowool/annotation/concept.py,sha256=zMcifpXxC0FBsDdVSuCp-682N8_PMVjE9-_IpsLihnk,15834
|
|
11
|
+
wowool/annotation/paragraph.py,sha256=6u0LteJkjTfqG1RbnOAmZal87Dqv00p2YSOqy73VoZg,5541
|
|
12
|
+
wowool/annotation/sentence.py,sha256=XJm1NweT2rueJHQ7bNt7wvqNYhHZFIH5bPOC0P5q1DY,8928
|
|
13
|
+
wowool/annotation/token.py,sha256=1yQfHS11PZjSKNrI6cvirBTU-xw2Mk7F23h9TWEgWN8,8388
|
|
14
|
+
wowool/apps/info.py,sha256=zIt-Q8zG6nogt-DZQolgKyXP8yF8m4pARvpYXBSsGR8,3243
|
|
15
|
+
wowool/common/utilities.py,sha256=HEONm63nESP5LIxAhWNTT--bMhDk5_C_ziNMuBBdjtA,326
|
|
16
|
+
wowool/common/pipeline/__init__.py,sha256=KIQ-ks9ya6ArbFzo2LoIE2Wq6QxSsDBT9t-oCOCJF-k,89
|
|
17
|
+
wowool/common/pipeline/objects.py,sha256=DrkYQfniCJjDP8fE9U6OcX24hccImOhduJno8sfM14c,1128
|
|
18
|
+
wowool/document/__init__.py,sha256=bqJFHpboxumrEdle41tLtymvCxfPNS1rhqD2fi9Z5XU,112
|
|
19
|
+
wowool/document/document.py,sha256=fT4OH3zZRkGIU6Ro9KPi9OG-RWHY5ebbvF5okx6qv6o,14073
|
|
20
|
+
wowool/document/factory.py,sha256=hi-CZaRRDMr5YGe4RPFu1n3dV0VtGgyUKXXyk6NaTHc,5646
|
|
21
|
+
wowool/document/apps/chunks.py,sha256=gKdJsXnRNhDOA5VDlMmtpbPpl5SX7JgZrk3B0iS_0dU,611
|
|
22
|
+
wowool/document/apps/themes.py,sha256=_vShK1QjfSEJ4zdbSrmyYm0bB-BM7fbPnS1uDXMiOSQ,198
|
|
23
|
+
wowool/document/apps/topics.py,sha256=S4MZADVp5fsX3iaM2MukryFss-gNzrN2bYKXsoHBOqk,198
|
|
24
|
+
wowool/io/console/__init__.py,sha256=MsLIFmcndHH2d61lCKn2JsdXTLqPt2VKsG8FRAmn0n4,41
|
|
25
|
+
wowool/io/console/argument_parser.py,sha256=wqeoeEZNvG0jNlIXGhsvzkozXQ_ppYGyRJnvU21JEZo,940
|
|
26
|
+
wowool/io/console/console.py,sha256=W8Hs3HTe0GIR8AcGLxwYEKs7GnZ1BIsW06X-ChIoGbQ,2792
|
|
27
|
+
wowool/io/provider/__init__.py,sha256=-0Du3rZPT5SDbdO35q2LphQ63UtAr0XWJqvOjkLh0CI,213
|
|
28
|
+
wowool/io/provider/docx.py,sha256=tW3JLKyOsswFM7CYPvVdcZp0MUQG0VEWDi-PjWCDfbQ,769
|
|
29
|
+
wowool/io/provider/factory.py,sha256=8-aEphLAVxFZXY4svKKglABIlBCkYrQrhj_eoUCIcRs,5723
|
|
30
|
+
wowool/io/provider/file.py,sha256=aCEFfFUCh8p5IaaYymMf_GS3nDznWYxvcONCJLVPiWw,2968
|
|
31
|
+
wowool/io/provider/html.py,sha256=h64_cChs3Qs0_dGefHfYE-UGgck7eNw1PfJhO7XXH8Q,1468
|
|
32
|
+
wowool/io/provider/html_v2.py,sha256=c_c_HHiWGMvvHb9iqNYxX08FmlSnE7vL3gsjL5DYdvs,13723
|
|
33
|
+
wowool/io/provider/input_provider.py,sha256=HPVccJ7Mi9ibI2LdyJvH1WWJLrhx33mKSZHXduf6WWg,850
|
|
34
|
+
wowool/io/provider/pdf.py,sha256=ItiSX3T0SLb1ghVScGezgzg4ZOpm9YRhBdbpDPQpeIU,9714
|
|
35
|
+
wowool/io/provider/pdf_no_layout.py,sha256=HYSQKClf-vDVjw3HgXfhqrarSFaIaJtt4RDuig76npg,1317
|
|
36
|
+
wowool/io/provider/rtf.py,sha256=-smhQqGNOFNwNUxC41XyX_BI-OYdi209kn7coPKDWo4,446
|
|
37
|
+
wowool/io/provider/str.py,sha256=nxq288WEUoukFzE-mAi5Bx3ZcFEJT5QvL_sHpF1Fg0I,514
|
|
38
|
+
wowool/string/__init__.py,sha256=g7-k8R2ng1OLoY5iF9MfBKz_JC0x0Z_GamVGK_15VbI,4916
|
|
39
|
+
wowool/tool/woc/create.py,sha256=7qSBqtdh52Q5fu7Eue06oAkWBlH0SM7KCvBDT_1Ncho,1307
|
|
40
|
+
wowool/utility/__init__.py,sha256=uOJsrXHMYnTRJLej2GqHnuQ6jO1SkFJChGLKRKaRIKk,318
|
|
41
|
+
wowool/utility/default_arguments.py,sha256=2I38s68h2KSGQ9sTjBt-4UTmSXHE5SsNrqzSEkq-T5U,1470
|
|
42
|
+
wowool/utility/diagnostics.py,sha256=OqN9a4ZgivwUOoESU2H_HLsoSX5aWJVeWcptP_JApyo,780
|
|
43
|
+
wowool/utility/method_registry.py,sha256=Yt_g-r98j-OI56hBycy2Pm1un0SWWrLb3Fjf__mIpsI,490
|
|
44
|
+
wowool/utility/numbers.py,sha256=dTtMIohRVyldLvX3UHgHr0BFo-lzelcyHDl6TTxfvYM,1003
|
|
45
|
+
wowool/utility/apps/decorators.py,sha256=Wwiqs2WKZQEEUCqcWpkjPI-yyBK4Gph9BZ_ZZVg8DJg,2574
|
|
46
|
+
wowool/utility/apps/yml_include.py,sha256=yGUHuIuG4nrngJNpJj6lTkU7RKXtJOya01qbfntYV64,842
|
|
47
|
+
wowool/utility/csv/__init__.py,sha256=GJiYZSoMywMGuMLk_7YX-dx8revlwm18n3boAiZ3lcU,649
|
|
48
|
+
wowool/utility/iterators/__init__.py,sha256=oOnKogPeE-Yhky1lTsX1cEgYnWORdF-iqSTNmpTuVuo,1278
|
|
49
|
+
wowool/utility/path/__init__.py,sha256=8fzkUt2NwTbeoIjCUVR8tPgvHrCWLXaxXKZlC0oa_xQ,63
|
|
50
|
+
wowool/utility/path/path.py,sha256=6LSPGXUyiYtKP_7LzxDaHUq0UYGIg-Zvgvpc2fdJBA8,285
|
|
51
|
+
wowool/utility/text/cleanup.py,sha256=TlJB_DA-GKKDAffhWa1anWz8lTkceymGymCMu_oWV38,2885
|
|
52
|
+
wowool_common-3.0.2.dev19.dist-info/METADATA,sha256=LWFzQ8KzlIzjp9GTz9caf7KaouN1HE6mr7OweJNl8JI,230
|
|
53
|
+
wowool_common-3.0.2.dev19.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
54
|
+
wowool_common-3.0.2.dev19.dist-info/top_level.txt,sha256=zerqoDN-iHSHwsS1SN2h0q4H6RI1FOVeHW8fNQC9YdU,7
|
|
55
|
+
wowool_common-3.0.2.dev19.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wowool
|