wowool-common 3.5.3.dev22__py3-none-any.whl → 3.5.4.dev13__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/annotation/__init__.py +1 -1
- wowool/annotation/annotation.py +1 -4
- wowool/annotation/annotation_list.py +7 -0
- wowool/annotation/entity.py +15 -18
- wowool/annotation/paragraph.py +2 -2
- wowool/annotation/sentence.py +4 -3
- wowool/annotation/token.py +14 -16
- wowool/document/analysis/document.py +3 -3
- wowool/io/provider/factory.py +35 -6
- wowool/io/provider/html_v2.py +8 -7
- wowool/string/__init__.py +14 -1
- wowool/utility/default_arguments.py +12 -1
- wowool/utility/mime_type/mime_type.py +1 -0
- {wowool_common-3.5.3.dev22.dist-info → wowool_common-3.5.4.dev13.dist-info}/METADATA +1 -1
- {wowool_common-3.5.3.dev22.dist-info → wowool_common-3.5.4.dev13.dist-info}/RECORD +17 -16
- {wowool_common-3.5.3.dev22.dist-info → wowool_common-3.5.4.dev13.dist-info}/WHEEL +0 -0
- {wowool_common-3.5.3.dev22.dist-info → wowool_common-3.5.4.dev13.dist-info}/top_level.txt +0 -0
wowool/annotation/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# flake8: noqa
|
|
2
|
-
from wowool.annotation.annotation import Annotation
|
|
2
|
+
from wowool.annotation.annotation import Annotation
|
|
3
3
|
from wowool.annotation.token import Token
|
|
4
4
|
from wowool.annotation.entity import Entity
|
|
5
5
|
from wowool.annotation.sentence import Sentence
|
wowool/annotation/annotation.py
CHANGED
|
@@ -86,6 +86,7 @@ class Annotation(BasicAnnotation):
|
|
|
86
86
|
@staticmethod
|
|
87
87
|
def _document_iter(doc) -> Iterator["Annotation"]:
|
|
88
88
|
for sentence in doc:
|
|
89
|
+
yield sentence
|
|
89
90
|
for annotation in sentence:
|
|
90
91
|
yield annotation
|
|
91
92
|
|
|
@@ -126,7 +127,3 @@ class Annotation(BasicAnnotation):
|
|
|
126
127
|
yield from Annotation._sentence_iter(object)
|
|
127
128
|
else:
|
|
128
129
|
raise TypeError(f"Expected Document, TextAnalysis, Sentence, but got '{type(object)}'")
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
class ErrorAnnotationNotFound(ValueError):
|
|
132
|
-
pass
|
wowool/annotation/entity.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from wowool.annotation.annotation import Annotation
|
|
2
|
+
from wowool.annotation.annotation import Annotation
|
|
3
3
|
from wowool.annotation.token import Token
|
|
4
|
-
from typing import Callable, Union, List, cast, Generator, Iterator, Self
|
|
4
|
+
from typing import Callable, Union, List, cast, Generator, Iterator, Self, Protocol
|
|
5
|
+
from wowool.annotation.annotation_list import AnnotationList
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def _align(idx, collection) -> int:
|
|
@@ -130,7 +131,7 @@ class Entity(Annotation):
|
|
|
130
131
|
return self._attributes
|
|
131
132
|
|
|
132
133
|
@property
|
|
133
|
-
def stems(self) ->
|
|
134
|
+
def stems(self) -> list[str]:
|
|
134
135
|
"""The stems of the concept.
|
|
135
136
|
|
|
136
137
|
Returns:
|
|
@@ -165,7 +166,7 @@ class Entity(Annotation):
|
|
|
165
166
|
return self._text
|
|
166
167
|
|
|
167
168
|
@property
|
|
168
|
-
def tokens(self) ->
|
|
169
|
+
def tokens(self) -> list[Token]:
|
|
169
170
|
"""The tokens of the concept.
|
|
170
171
|
|
|
171
172
|
Returns:
|
|
@@ -181,7 +182,7 @@ class Entity(Annotation):
|
|
|
181
182
|
return self._tokens
|
|
182
183
|
|
|
183
184
|
@property
|
|
184
|
-
def annotations(self) ->
|
|
185
|
+
def annotations(self) -> list[Annotation]:
|
|
185
186
|
"""The annotations of the concept.
|
|
186
187
|
|
|
187
188
|
Returns:
|
|
@@ -473,21 +474,19 @@ class Entity(Annotation):
|
|
|
473
474
|
elif isinstance(object, Entity):
|
|
474
475
|
yield from Entity._concept_iter(object, filter, align)
|
|
475
476
|
else:
|
|
476
|
-
raise TypeError(f"Expected Document, TextAnalysis, Sentence, or Entity but got '{type(object)}'")
|
|
477
|
+
raise TypeError(f"Expected Document, AnalysisDocument, TextAnalysis, Sentence, or Entity but got '{type(object)}'")
|
|
477
478
|
|
|
478
479
|
@staticmethod
|
|
479
|
-
def next(sentence:
|
|
480
|
+
def next(sentence: AnnotationList | list[Annotation], object: Annotation) -> Entity | None:
|
|
480
481
|
"""Get the next Entity in the sentence.
|
|
481
482
|
|
|
482
483
|
Args:
|
|
483
484
|
sentence (List[Annotation]): The list of annotations in the sentence.
|
|
484
|
-
object (
|
|
485
|
+
object (Annotation): The current object.
|
|
485
486
|
|
|
486
487
|
Returns:
|
|
487
|
-
Entity: The next Entity.
|
|
488
|
+
Entity|None: The next Entity or None if no next entity is found.
|
|
488
489
|
|
|
489
|
-
Raises:
|
|
490
|
-
ErrorAnnotationNotFound: If no next entity is found.
|
|
491
490
|
"""
|
|
492
491
|
index = object.index + 1
|
|
493
492
|
sentence_length = len(sentence)
|
|
@@ -496,21 +495,19 @@ class Entity(Annotation):
|
|
|
496
495
|
return cast(Entity, sentence[index])
|
|
497
496
|
else:
|
|
498
497
|
index += 1
|
|
499
|
-
|
|
498
|
+
return None
|
|
500
499
|
|
|
501
500
|
@staticmethod
|
|
502
|
-
def prev(sentence:
|
|
501
|
+
def prev(sentence: AnnotationList | list[Annotation], object: Annotation) -> Entity | None:
|
|
503
502
|
"""Get the previous Entity in the sentence.
|
|
504
503
|
|
|
505
504
|
Args:
|
|
506
505
|
sentence (List[Annotation]): The list of annotations in the sentence.
|
|
507
|
-
object (
|
|
506
|
+
object (Annotation): The current object.
|
|
508
507
|
|
|
509
508
|
Returns:
|
|
510
|
-
Entity: The previous Entity.
|
|
509
|
+
Entity: The previous Entity or None if no previous entity is found.
|
|
511
510
|
|
|
512
|
-
Raises:
|
|
513
|
-
ErrorAnnotationNotFound: If no previous entity is found.
|
|
514
511
|
"""
|
|
515
512
|
index = object.index - 1
|
|
516
513
|
while index >= 0:
|
|
@@ -518,7 +515,7 @@ class Entity(Annotation):
|
|
|
518
515
|
return cast(Entity, sentence[index])
|
|
519
516
|
else:
|
|
520
517
|
index -= 1
|
|
521
|
-
|
|
518
|
+
return None
|
|
522
519
|
|
|
523
520
|
def _set_sentence_annotations_index(self, sentence_annotations: list[Annotation], annotation_idx: int):
|
|
524
521
|
"""Set the sentence annotations and annotation index.
|
wowool/annotation/paragraph.py
CHANGED
|
@@ -95,7 +95,7 @@ class Paragraph(Annotation):
|
|
|
95
95
|
def same_paragraph(original_text: str, prev: Sentence, next: Sentence) -> bool:
|
|
96
96
|
annotation = prev.annotations[-1]
|
|
97
97
|
|
|
98
|
-
if prev.is_header:
|
|
98
|
+
if prev.is_header and not next.is_header:
|
|
99
99
|
return True
|
|
100
100
|
|
|
101
101
|
prev_last_token = cast(Token, annotation) if annotation.is_token else None
|
|
@@ -136,7 +136,7 @@ class Paragraph(Annotation):
|
|
|
136
136
|
yield paragraph
|
|
137
137
|
|
|
138
138
|
@staticmethod
|
|
139
|
-
def iter(object, original_text
|
|
139
|
+
def iter(object, original_text: str) -> Iterator["Paragraph"]:
|
|
140
140
|
"""Iterate over the paragraphs in a document or analysis.
|
|
141
141
|
|
|
142
142
|
Example:
|
wowool/annotation/sentence.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from io import StringIO
|
|
2
2
|
from wowool.annotation.annotation import BasicAnnotation
|
|
3
|
-
from wowool.annotation.
|
|
3
|
+
from wowool.annotation.annotation_list import AnnotationList
|
|
4
|
+
from wowool.annotation.token import Token, Annotation
|
|
4
5
|
from wowool.annotation.entity import Entity
|
|
5
6
|
from typing import Callable, Iterator, Self
|
|
6
7
|
|
|
@@ -13,7 +14,7 @@ def _filter_pass_thru(sentence) -> bool:
|
|
|
13
14
|
return True
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
class Sentence(BasicAnnotation):
|
|
17
|
+
class Sentence(BasicAnnotation, AnnotationList):
|
|
17
18
|
"""Class that contains the tokens and entities of a sentence."""
|
|
18
19
|
|
|
19
20
|
FilterType = Callable[[Self], bool]
|
|
@@ -151,7 +152,7 @@ class Sentence(BasicAnnotation):
|
|
|
151
152
|
concept._annotation_idx = 0
|
|
152
153
|
return concept.find(uri)
|
|
153
154
|
|
|
154
|
-
def __getitem__(self, value):
|
|
155
|
+
def __getitem__(self, value) -> Annotation | None:
|
|
155
156
|
return self.annotations[value] if value < len(self.annotations) else None
|
|
156
157
|
|
|
157
158
|
@property
|
wowool/annotation/token.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from wowool.annotation.annotation import Annotation
|
|
2
|
+
from wowool.annotation.annotation import Annotation
|
|
3
|
+
from wowool.annotation.annotation_list import AnnotationList
|
|
3
4
|
from typing import List, MutableSet, cast, Generator
|
|
4
5
|
import warnings
|
|
5
6
|
from typing import NewType
|
|
@@ -27,11 +28,11 @@ class Token(Annotation):
|
|
|
27
28
|
"""
|
|
28
29
|
super(Token, self).__init__(begin_offset, end_offset)
|
|
29
30
|
self.literal: str = literal
|
|
30
|
-
self._morphology:
|
|
31
|
+
self._morphology: list["MorphData"] = []
|
|
31
32
|
self._properties: MutableSet[str] = set()
|
|
32
33
|
|
|
33
34
|
@property
|
|
34
|
-
def morphology(self) ->
|
|
35
|
+
def morphology(self) -> list["MorphData"]:
|
|
35
36
|
"""Get the morphological data of the token.
|
|
36
37
|
|
|
37
38
|
Returns:
|
|
@@ -48,11 +49,11 @@ class Token(Annotation):
|
|
|
48
49
|
"""
|
|
49
50
|
return self._properties
|
|
50
51
|
|
|
51
|
-
def _set_morphology(self, morphology:
|
|
52
|
+
def _set_morphology(self, morphology: list[MorphData]):
|
|
52
53
|
"""Set the morphological data of the token.
|
|
53
54
|
|
|
54
55
|
Args:
|
|
55
|
-
morphology (
|
|
56
|
+
morphology (list[MorphData]): A list of MorphData objects to set.
|
|
56
57
|
"""
|
|
57
58
|
self._morphology = morphology
|
|
58
59
|
|
|
@@ -239,7 +240,7 @@ class Token(Annotation):
|
|
|
239
240
|
raise TypeError(f"Expected Document, TextAnalysis, Sentence, or Entity but got '{type(object)}'")
|
|
240
241
|
|
|
241
242
|
@staticmethod
|
|
242
|
-
def next(sentence, object: Token) -> Token:
|
|
243
|
+
def next(sentence: AnnotationList | list[Annotation], object: Token) -> "Token|None":
|
|
243
244
|
"""Return the next Token.
|
|
244
245
|
|
|
245
246
|
Args:
|
|
@@ -247,10 +248,8 @@ class Token(Annotation):
|
|
|
247
248
|
object (Token): The current object to find the next token from.
|
|
248
249
|
|
|
249
250
|
Returns:
|
|
250
|
-
Token: The next token in the sentence.
|
|
251
|
+
Token|None: The next token in the sentence or None if not found.
|
|
251
252
|
|
|
252
|
-
Raises:
|
|
253
|
-
ErrorAnnotationNotFound: If no next token is found.
|
|
254
253
|
"""
|
|
255
254
|
index = object.index + 1
|
|
256
255
|
sentence_length = len(sentence)
|
|
@@ -259,21 +258,20 @@ class Token(Annotation):
|
|
|
259
258
|
return cast(Token, sentence[index])
|
|
260
259
|
else:
|
|
261
260
|
index += 1
|
|
262
|
-
|
|
261
|
+
|
|
262
|
+
return None
|
|
263
263
|
|
|
264
264
|
@staticmethod
|
|
265
|
-
def prev(sentence, object: Entity | Token) -> Token:
|
|
265
|
+
def prev(sentence: AnnotationList | list[Annotation], object: Entity | Token) -> Token | None:
|
|
266
266
|
"""Return the previous Token.
|
|
267
267
|
|
|
268
268
|
Args:
|
|
269
|
-
sentence (Sentence): The sentence containing the tokens.
|
|
269
|
+
sentence (Sentence|list[Annotation]): The sentence containing the tokens.
|
|
270
270
|
object (Entity|Token): The current object to find the previous token from.
|
|
271
271
|
|
|
272
272
|
Returns:
|
|
273
|
-
Token: The previous token in the sentence.
|
|
273
|
+
Token|None: The previous token in the sentence or None if not found.
|
|
274
274
|
|
|
275
|
-
Raises:
|
|
276
|
-
ErrorAnnotationNotFound: If no previous token is found.
|
|
277
275
|
"""
|
|
278
276
|
index = object.index - 1
|
|
279
277
|
while index >= 0:
|
|
@@ -281,7 +279,7 @@ class Token(Annotation):
|
|
|
281
279
|
return cast(Token, sentence[index])
|
|
282
280
|
else:
|
|
283
281
|
index -= 1
|
|
284
|
-
|
|
282
|
+
return None
|
|
285
283
|
|
|
286
284
|
|
|
287
285
|
class MorphData:
|
|
@@ -143,7 +143,7 @@ class AnalysisDocument(DocumentInterface):
|
|
|
143
143
|
return self._metadata
|
|
144
144
|
|
|
145
145
|
@property
|
|
146
|
-
def analysis(self):
|
|
146
|
+
def analysis(self) -> TextAnalysis:
|
|
147
147
|
"""Get the Analysis of the document.
|
|
148
148
|
|
|
149
149
|
Contains the Sentences, Tokens and Concepts, or None if the document
|
|
@@ -397,7 +397,7 @@ class AnalysisDocument(DocumentInterface):
|
|
|
397
397
|
text = '"' + self.text[:50].strip().replace("\n", " ") + '"' if self.text else None
|
|
398
398
|
return f"<AnalysisDocument id={self.id} mime_type={self.mime_type} size={sz} text={text} >"
|
|
399
399
|
else:
|
|
400
|
-
return "<AnalysisDocument id={self.id} mime_type={self.mime_type} >"
|
|
400
|
+
return f"<AnalysisDocument id={self.id} mime_type={self.mime_type} >"
|
|
401
401
|
|
|
402
402
|
def __str__(self):
|
|
403
403
|
with StringIO() as output:
|
|
@@ -491,7 +491,7 @@ class AnalysisDocument(DocumentInterface):
|
|
|
491
491
|
Raises:
|
|
492
492
|
ValueError: If the document has not been processed by a Language.
|
|
493
493
|
"""
|
|
494
|
-
if self.analysis is not None:
|
|
494
|
+
if self.analysis is not None and self.text is not None:
|
|
495
495
|
yield from Paragraph.iter(self.analysis, self.text)
|
|
496
496
|
else:
|
|
497
497
|
raise ValueError(STR_MISSING_ANALYSIS)
|
wowool/io/provider/factory.py
CHANGED
|
@@ -3,6 +3,11 @@ from typing import Union, Optional
|
|
|
3
3
|
from wowool.document.document_interface import DocumentInterface
|
|
4
4
|
from wowool.utility.path import expand_path
|
|
5
5
|
from wowool.io.provider.encoding import get_data_encoding
|
|
6
|
+
from wowool.document.document_interface import MT_STRING
|
|
7
|
+
from wowool.document.analysis.text_analysis import AnalysisInputProvider
|
|
8
|
+
|
|
9
|
+
DEFAULT_TEXT_MIME_TYPE = "plain/text"
|
|
10
|
+
DEFAULT_ANALYSIS_DATA_TYPE = AnalysisInputProvider.MIME_TYPE
|
|
6
11
|
|
|
7
12
|
|
|
8
13
|
def data2str(data: Union[str, bytes, None], encoding="utf-8") -> str:
|
|
@@ -62,6 +67,15 @@ def _make_docx(uid, data, **kwargs) -> DocumentInterface:
|
|
|
62
67
|
raise ModuleNotFoundError(f"install the python-docx library, 'pip install python-docx' {ex}")
|
|
63
68
|
|
|
64
69
|
|
|
70
|
+
def _make_file(uid, data, encoding: str | None = None, metadata: dict | None = None, **kwargs) -> DocumentInterface:
|
|
71
|
+
from wowool.io.provider.file import FileInputProvider
|
|
72
|
+
|
|
73
|
+
options = {}
|
|
74
|
+
if "cleanup" in kwargs:
|
|
75
|
+
options["cleanup"] = kwargs["cleanup"]
|
|
76
|
+
return FileInputProvider(fid=uid, encoding=encoding, metadata=metadata, **options)
|
|
77
|
+
|
|
78
|
+
|
|
65
79
|
def _make_pdf(uid, data, **kwargs) -> DocumentInterface:
|
|
66
80
|
assert data is None, "The pdf reader does not support data, only files"
|
|
67
81
|
try:
|
|
@@ -78,13 +92,26 @@ def _invalid_type(uid, data, **kwargs):
|
|
|
78
92
|
|
|
79
93
|
|
|
80
94
|
creators = {
|
|
81
|
-
|
|
82
|
-
"
|
|
95
|
+
DEFAULT_TEXT_MIME_TYPE: _make_str,
|
|
96
|
+
"txt": _make_file,
|
|
97
|
+
MT_STRING: _make_str,
|
|
98
|
+
"utf8": _make_str,
|
|
83
99
|
"text": _make_str,
|
|
84
|
-
"
|
|
85
|
-
"
|
|
100
|
+
"file": _make_file,
|
|
101
|
+
"text/plain": _make_file,
|
|
102
|
+
"text/html": _make_html,
|
|
86
103
|
"pdf": _make_pdf,
|
|
87
104
|
"docx": _make_docx,
|
|
105
|
+
"text/rtf": _make_rtf,
|
|
106
|
+
"text/csv": _make_file,
|
|
107
|
+
"application/pdf": _make_pdf,
|
|
108
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": _make_docx,
|
|
109
|
+
"file/utf8": _make_file,
|
|
110
|
+
"md": _make_file,
|
|
111
|
+
"md/utf8": _make_file,
|
|
112
|
+
"html/utf8": _make_html,
|
|
113
|
+
"pdf/utf8": _make_pdf,
|
|
114
|
+
"docx/utf8": _make_docx,
|
|
88
115
|
"_invalid_type": _invalid_type,
|
|
89
116
|
}
|
|
90
117
|
|
|
@@ -113,7 +140,6 @@ class Factory:
|
|
|
113
140
|
html_data = fh.read()
|
|
114
141
|
doc = Factory.create(id = fn, data = html_data, provider_type = "html")
|
|
115
142
|
"""
|
|
116
|
-
|
|
117
143
|
_data = data
|
|
118
144
|
if id is not None and _data is None:
|
|
119
145
|
try:
|
|
@@ -143,7 +169,10 @@ class Factory:
|
|
|
143
169
|
|
|
144
170
|
if not provider_type:
|
|
145
171
|
provider_type = "txt" if _data is None else "text"
|
|
146
|
-
|
|
172
|
+
if provider := creators.get(provider_type):
|
|
173
|
+
return provider(id, _data, encoding=encoding, **kwargs)
|
|
174
|
+
else:
|
|
175
|
+
raise RuntimeError(f"Unknown provider type: {provider_type}")
|
|
147
176
|
|
|
148
177
|
@staticmethod
|
|
149
178
|
def split_path_on_wildcards(path_description: Path, pattern: str = "*.txt"):
|
wowool/io/provider/html_v2.py
CHANGED
|
@@ -42,13 +42,13 @@ default_config = {
|
|
|
42
42
|
"ul": end_sentence_tag,
|
|
43
43
|
"p": """\n\n""",
|
|
44
44
|
"li": begin_list_tag,
|
|
45
|
-
"title": "#",
|
|
46
|
-
"h1": "\n#",
|
|
47
|
-
"h2": "\n\n##",
|
|
48
|
-
"h3": "\n\n###",
|
|
49
|
-
"h4": "\n\n####",
|
|
50
|
-
"h5": "\n\n#####",
|
|
51
|
-
"h6": "\n\n######",
|
|
45
|
+
"title": "# ",
|
|
46
|
+
"h1": "\n# ",
|
|
47
|
+
"h2": "\n\n## ",
|
|
48
|
+
"h3": "\n\n### ",
|
|
49
|
+
"h4": "\n\n#### ",
|
|
50
|
+
"h5": "\n\n##### ",
|
|
51
|
+
"h6": "\n\n###### ",
|
|
52
52
|
},
|
|
53
53
|
"tags_end": {
|
|
54
54
|
"ul": default_remove,
|
|
@@ -350,6 +350,7 @@ class HTMLFileInputProvider(DocumentInterface):
|
|
|
350
350
|
use_readability: bool = True,
|
|
351
351
|
metadata: dict | None = None,
|
|
352
352
|
css_selector: str | None = None,
|
|
353
|
+
**kwargs,
|
|
353
354
|
):
|
|
354
355
|
self._id = str(fid)
|
|
355
356
|
if config:
|
wowool/string/__init__.py
CHANGED
|
@@ -139,10 +139,12 @@ def canonicalize(obj, lemmas: bool = False, dates=True, spelling=True) -> str:
|
|
|
139
139
|
skip_until_offset = 0
|
|
140
140
|
annotation_count = len(annotations_range)
|
|
141
141
|
prev_token = None
|
|
142
|
-
|
|
142
|
+
annotation_idx = 0
|
|
143
|
+
while annotation_idx < annotation_count:
|
|
143
144
|
annotation = annotations_range[annotation_idx]
|
|
144
145
|
if annotation.begin_offset < skip_until_offset:
|
|
145
146
|
prev_token = annotation
|
|
147
|
+
annotation_idx += 1
|
|
146
148
|
continue
|
|
147
149
|
else:
|
|
148
150
|
skip_until_offset = 0
|
|
@@ -156,8 +158,18 @@ def canonicalize(obj, lemmas: bool = False, dates=True, spelling=True) -> str:
|
|
|
156
158
|
output.write(" ")
|
|
157
159
|
if lemmas:
|
|
158
160
|
output.write(token.lemma)
|
|
161
|
+
if "rewrite" in token.properties:
|
|
162
|
+
next_token = Token.next(annotations_range, token)
|
|
163
|
+
if next_token and next_token.literal == "-":
|
|
164
|
+
annotation_idx += 1
|
|
159
165
|
elif spelling and bool(GUESSER_PROPERTIES.intersection(token.properties)):
|
|
160
166
|
output.write(token.lemma)
|
|
167
|
+
elif "rewrite" in token.properties:
|
|
168
|
+
output.write(token.lemma)
|
|
169
|
+
next_token = Token.next(annotations_range, token)
|
|
170
|
+
if next_token and next_token.literal == "-":
|
|
171
|
+
annotation_idx += 1
|
|
172
|
+
|
|
161
173
|
else:
|
|
162
174
|
output.write(token.literal)
|
|
163
175
|
|
|
@@ -177,6 +189,7 @@ def canonicalize(obj, lemmas: bool = False, dates=True, spelling=True) -> str:
|
|
|
177
189
|
output.write(" ")
|
|
178
190
|
output.write((concept.attributes["abs_date"][0]))
|
|
179
191
|
skip_until_offset = concept.end_offset
|
|
192
|
+
annotation_idx += 1
|
|
180
193
|
|
|
181
194
|
return output.getvalue()
|
|
182
195
|
|
|
@@ -16,6 +16,15 @@ def default_cleanup(text: str) -> str:
|
|
|
16
16
|
return "".join(i for i in text if 31 < ord(i) < 127 or ord(i) == 0xD or ord(i) == 0xA)
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def return_generator(docs): # -> Generator[Any, Any, None]:
|
|
20
|
+
"""Return a generator for the given documents."""
|
|
21
|
+
if isinstance(docs, list):
|
|
22
|
+
for doc in docs:
|
|
23
|
+
yield doc
|
|
24
|
+
else:
|
|
25
|
+
yield docs
|
|
26
|
+
|
|
27
|
+
|
|
19
28
|
def make_document_collection(
|
|
20
29
|
text: Optional[Union[list, str]] = None,
|
|
21
30
|
file: Optional[Union[Path, str]] = None,
|
|
@@ -57,4 +66,6 @@ def make_document_collection(
|
|
|
57
66
|
for text_ in text:
|
|
58
67
|
doc_collection.append(Document.create(text_))
|
|
59
68
|
|
|
60
|
-
return doc_collection
|
|
69
|
+
return return_generator(doc_collection)
|
|
70
|
+
raise RuntimeError("You must provide either text or file input to create a document collection.")
|
|
71
|
+
# return Document.glob(folder, pattern, stripped=stripped, **kwargs)
|
|
@@ -2,13 +2,14 @@ wowool/config.py,sha256=Jx-uTsdDLw6jza-5W-Ds2_nU8qsB537gllZhpioIMkg,2215
|
|
|
2
2
|
wowool/diagnostic.py,sha256=C7xE0J9Ln6qjlhmL6mX0iiKzPrni1g7VJQJ8J603f18,9895
|
|
3
3
|
wowool/error.py,sha256=UxBxA-vC_gdp0yX1qMkI_MCaW9ZNNUfq82j8ZtgeO2c,33
|
|
4
4
|
wowool/wow.py,sha256=T-_LV-hHVpm9On64eKMvKjVhD230baks1_KZ4OPA9Fg,17736
|
|
5
|
-
wowool/annotation/__init__.py,sha256=
|
|
6
|
-
wowool/annotation/annotation.py,sha256=
|
|
5
|
+
wowool/annotation/__init__.py,sha256=Qwv0vjJH2zs8yqT_Koyl3kgE7rHZRyERackkrFwRDA8,297
|
|
6
|
+
wowool/annotation/annotation.py,sha256=66_SpVundaGKUyiKe6cNaTLURsRaGcuEHOc2QKH72QQ,4094
|
|
7
|
+
wowool/annotation/annotation_list.py,sha256=LUbZI8e8PuwcqHQY_VWPDjoMj6mlpmk88FxnskMUEcg,205
|
|
7
8
|
wowool/annotation/concept.py,sha256=j7oXlIyy1nUOXEh6nhrUVyEVrFOFuZRZIh5nuVKp1vQ,70
|
|
8
|
-
wowool/annotation/entity.py,sha256=
|
|
9
|
-
wowool/annotation/paragraph.py,sha256=
|
|
10
|
-
wowool/annotation/sentence.py,sha256=
|
|
11
|
-
wowool/annotation/token.py,sha256=
|
|
9
|
+
wowool/annotation/entity.py,sha256=3d7ZZjL7SPelE0-GvnHE3vL3SXtxXfMwTq5q92APDws,18451
|
|
10
|
+
wowool/annotation/paragraph.py,sha256=K-s_njTF6VyvulW1l0TZTRhfrbdeJEj8IXNf4RPES-Y,5972
|
|
11
|
+
wowool/annotation/sentence.py,sha256=Zeh2fBB-TNnPMUh9eIbb_4cOjyJrJsF1yRxSoPz0wys,8093
|
|
12
|
+
wowool/annotation/token.py,sha256=ZOBbjPi749jDR338xpqzhLgXQZRoI8PD0Ox7YO5kKt4,11881
|
|
12
13
|
wowool/apps/info.py,sha256=4lGDPR_XsNINi5yEAueT21EfX6kESpbpwBTqpwwvYCk,3218
|
|
13
14
|
wowool/common/utilities.py,sha256=bGjoD4U08-XQ9jrDa9eFGzQuzpRKSWNjqhP0UcKZRR4,640
|
|
14
15
|
wowool/common/pipeline/__init__.py,sha256=KIQ-ks9ya6ArbFzo2LoIE2Wq6QxSsDBT9t-oCOCJF-k,89
|
|
@@ -20,7 +21,7 @@ wowool/document/document_interface.py,sha256=SVG4gL2TtFQLhGKcaKIZht6rLmEYqxQpBUy
|
|
|
20
21
|
wowool/document/factory.py,sha256=_osK-UAlDoNdIq0nnJV8GhmSQuMQc316L0GEO9qUOPE,10831
|
|
21
22
|
wowool/document/serialize.py,sha256=AD2G6vlVSgLcuvWRxv-xD5SbziC9rI3HIujyAwG7qn4,2631
|
|
22
23
|
wowool/document/analysis/analysis_parser.py,sha256=_d6b5_aDvgg6XtCCVnNoXGL58bT0irIgbXUAAoaUtys,4036
|
|
23
|
-
wowool/document/analysis/document.py,sha256=
|
|
24
|
+
wowool/document/analysis/document.py,sha256=feaLR7pjO8xWXXUeSMPW8XeVZRUzx0AGE5pIkoReObg,20846
|
|
24
25
|
wowool/document/analysis/document_format_exception.py,sha256=5AJxZFgyCD3u13QZioQRiuqKo-OD9Le_B_kzHrC5HrE,307
|
|
25
26
|
wowool/document/analysis/text_analysis.py,sha256=6sMZxcNAdjsVZyKiOm9TvfJzL41soVkG75vIQWcupoI,9389
|
|
26
27
|
wowool/document/analysis/utilities.py,sha256=t59v-Z_tpQsSHr8Ys5miMcZMgIKEuC21xGWXyZGUbJU,170
|
|
@@ -38,16 +39,16 @@ wowool/io/provider/__init__.py,sha256=hTUFPiirYqaEYFS51SrhJqk0aFXxBJFaZ0H8E5E73w
|
|
|
38
39
|
wowool/io/provider/binary.py,sha256=aUSY-u2o_k7fIkrVZtbEZCuBQaabqnuQycX3Rqs4YfY,1168
|
|
39
40
|
wowool/io/provider/docx.py,sha256=15ZY3ytwHWOHdc8qp90BP1bDT6F_TSDQrrGMGx61YEs,1316
|
|
40
41
|
wowool/io/provider/encoding.py,sha256=GRft7DyTgTCckKe2C9KupDRwEOb_dPFiTX7garXxd-0,701
|
|
41
|
-
wowool/io/provider/factory.py,sha256=
|
|
42
|
+
wowool/io/provider/factory.py,sha256=SX87hNavHQ80feWxQBAWvDDqlfmLuHSgVIWO0a9Ug5c,6969
|
|
42
43
|
wowool/io/provider/file.py,sha256=cBf7dfmfMIxyu6hVKHIfhbOkcKdP6IDC6DuamuxZvkQ,3250
|
|
43
|
-
wowool/io/provider/html_v2.py,sha256=
|
|
44
|
+
wowool/io/provider/html_v2.py,sha256=ldzfQKtALZZD1AVCrvzstE2Msqcdlaw4kwfyC3y9-LY,15587
|
|
44
45
|
wowool/io/provider/pdf_no_layout.py,sha256=BdUDB8et22m8-HlWprUqlIT8voSy3Cj0zUHfcwilnPY,1168
|
|
45
46
|
wowool/io/provider/rtf.py,sha256=i_5aDx-7EybCKyD4mRHCCoXvBhqmofUEwgnWspryDdk,966
|
|
46
47
|
wowool/io/provider/str.py,sha256=EcLLOv-h3MsDDPvi9aFxmt89tXH6QbOgQhyKoQBTciE,946
|
|
47
|
-
wowool/string/__init__.py,sha256=
|
|
48
|
+
wowool/string/__init__.py,sha256=kGRfw-DpZOklKlsODj-EsZj0xcN4B7X8bCWX7zzhB-w,7337
|
|
48
49
|
wowool/tool/woc/create.py,sha256=7qSBqtdh52Q5fu7Eue06oAkWBlH0SM7KCvBDT_1Ncho,1307
|
|
49
50
|
wowool/utility/__init__.py,sha256=uOJsrXHMYnTRJLej2GqHnuQ6jO1SkFJChGLKRKaRIKk,318
|
|
50
|
-
wowool/utility/default_arguments.py,sha256=
|
|
51
|
+
wowool/utility/default_arguments.py,sha256=kiBG0ZjBQ4_nKn8gb3dlIaRziqt4-hM6G6HsMmrUrN8,2109
|
|
51
52
|
wowool/utility/diagnostics.py,sha256=RFx_i_80or1S0wnh1WjHQEUYAFZuPMb8UIuWwO0BMjc,820
|
|
52
53
|
wowool/utility/method_registry.py,sha256=_WpOnAWXycRhcuvOolY_OPJxs05XNTC4RC7GdVFHe3U,867
|
|
53
54
|
wowool/utility/numbers.py,sha256=dTtMIohRVyldLvX3UHgHr0BFo-lzelcyHDl6TTxfvYM,1003
|
|
@@ -55,11 +56,11 @@ wowool/utility/apps/decorators.py,sha256=8bWXvaOVB1mwPU4eEDh5PGD9O3SuPoK3HcDxNsO
|
|
|
55
56
|
wowool/utility/apps/yml_include.py,sha256=yGUHuIuG4nrngJNpJj6lTkU7RKXtJOya01qbfntYV64,842
|
|
56
57
|
wowool/utility/csv/__init__.py,sha256=GJiYZSoMywMGuMLk_7YX-dx8revlwm18n3boAiZ3lcU,649
|
|
57
58
|
wowool/utility/iterators/__init__.py,sha256=hX5Qd7FIcqZbS5gdHvRuvsSc5Erhqdlcab5WrB9D6Ps,1817
|
|
58
|
-
wowool/utility/mime_type/mime_type.py,sha256=
|
|
59
|
+
wowool/utility/mime_type/mime_type.py,sha256=amgUZas_1YevuysvkssSIaGpUc2IohHkw3fWbDZFog8,2404
|
|
59
60
|
wowool/utility/path/__init__.py,sha256=8fzkUt2NwTbeoIjCUVR8tPgvHrCWLXaxXKZlC0oa_xQ,63
|
|
60
61
|
wowool/utility/path/path.py,sha256=6LSPGXUyiYtKP_7LzxDaHUq0UYGIg-Zvgvpc2fdJBA8,285
|
|
61
62
|
wowool/utility/text/cleanup.py,sha256=vN6I9n5PJN2EEhTaxyD2_jSVJ_BGI3EGaMr06LvgRT0,2886
|
|
62
|
-
wowool_common-3.5.
|
|
63
|
-
wowool_common-3.5.
|
|
64
|
-
wowool_common-3.5.
|
|
65
|
-
wowool_common-3.5.
|
|
63
|
+
wowool_common-3.5.4.dev13.dist-info/METADATA,sha256=n9YUEV6p_gKfUU0n4NX1jv1dwPILhqoW5nGMA2rdt-c,421
|
|
64
|
+
wowool_common-3.5.4.dev13.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
65
|
+
wowool_common-3.5.4.dev13.dist-info/top_level.txt,sha256=zerqoDN-iHSHwsS1SN2h0q4H6RI1FOVeHW8fNQC9YdU,7
|
|
66
|
+
wowool_common-3.5.4.dev13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|