sonatoki 0.3.1__py3-none-any.whl → 0.3.3__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.
- sonatoki/Cleaners.py +4 -1
- sonatoki/Configs.py +52 -31
- sonatoki/Filters.py +96 -33
- sonatoki/Preprocessors.py +12 -6
- sonatoki/Scorers.py +54 -51
- sonatoki/constants.py +21 -29
- sonatoki/linku.json +1 -1
- sonatoki/sandbox.json +1 -1
- sonatoki/utils.py +23 -5
- {sonatoki-0.3.1.dist-info → sonatoki-0.3.3.dist-info}/METADATA +1 -1
- sonatoki-0.3.3.dist-info/RECORD +18 -0
- {sonatoki-0.3.1.dist-info → sonatoki-0.3.3.dist-info}/WHEEL +1 -1
- sonatoki-0.3.1.dist-info/RECORD +0 -18
- {sonatoki-0.3.1.dist-info → sonatoki-0.3.3.dist-info}/licenses/LICENSE +0 -0
sonatoki/utils.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# STL
|
2
2
|
import re
|
3
|
-
|
3
|
+
import itertools
|
4
|
+
from typing import Set, List, TypeVar, Iterable
|
4
5
|
|
5
6
|
# LOCAL
|
6
7
|
from sonatoki.Cleaners import Lowercase, ConsecutiveDuplicates
|
7
8
|
|
8
9
|
TO_ESCAPE = ["\\", "^", "[", "]", "-"]
|
9
10
|
|
11
|
+
T = TypeVar("T")
|
12
|
+
|
10
13
|
|
11
14
|
def prep_dictionary(words: Iterable[str]) -> Set[str]:
|
12
15
|
out: Set[str] = set()
|
@@ -19,7 +22,8 @@ def prep_dictionary(words: Iterable[str]) -> Set[str]:
|
|
19
22
|
|
20
23
|
|
21
24
|
def regex_escape(s: str) -> str:
|
22
|
-
"""Escape all characters which must be escaped when embedded in a character
|
25
|
+
"""Escape all characters which must be escaped when embedded in a character
|
26
|
+
class."""
|
23
27
|
for c in TO_ESCAPE:
|
24
28
|
s = s.replace(c, rf"\{c}") # one backslash
|
25
29
|
return s
|
@@ -69,10 +73,24 @@ def find_unicode_chars(ranges: List[str]) -> str:
|
|
69
73
|
return "".join(result)
|
70
74
|
|
71
75
|
|
76
|
+
def overlapping_pairs(iterable: Iterable[T]) -> Iterable[T]:
|
77
|
+
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
|
78
|
+
return overlapping_ntuples(iterable, n=2)
|
79
|
+
|
80
|
+
|
81
|
+
def overlapping_ntuples(iterable: Iterable[T], n: int) -> Iterable[T]:
|
82
|
+
teed = itertools.tee(iterable, n)
|
83
|
+
for i in range(1, n):
|
84
|
+
for j in range(i):
|
85
|
+
_ = next(teed[i], None)
|
86
|
+
# offset start by position
|
87
|
+
|
88
|
+
# ends when any iter is empty; all groups will be same size
|
89
|
+
return zip(*teed)
|
90
|
+
|
91
|
+
|
72
92
|
if __name__ == "__main__":
|
73
|
-
"""
|
74
|
-
Helper script to fetch UNICODE_PUNCT in constants.py
|
75
|
-
"""
|
93
|
+
"""Helper script to fetch UNICODE_PUNCT in constants.py."""
|
76
94
|
|
77
95
|
PUNCT_CATEGORIES = {
|
78
96
|
"Pc",
|
@@ -0,0 +1,18 @@
|
|
1
|
+
sonatoki-0.3.3.dist-info/METADATA,sha256=b78h2-lsc4aBzkEWrzXTslfvJb-ZVbFjCpgPOF_kYrg,6341
|
2
|
+
sonatoki-0.3.3.dist-info/WHEEL,sha256=SOP-4bEE0jbVaCHQGVvF08uWxk5rcSsfEybvoQVHlD8,90
|
3
|
+
sonatoki-0.3.3.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
4
|
+
sonatoki/Cleaners.py,sha256=x2dT3MpDUfbrHA0EP2D3n1sTiKFFi5jw9ha-1dX973o,1958
|
5
|
+
sonatoki/Configs.py,sha256=ZNKJGeAxgolAxqNSeS7iADvQEcN4X3tY0iaoiAaL95U,4160
|
6
|
+
sonatoki/Filters.py,sha256=mpJBl-YPMF-Yl6mKFXf0D6DwkPR6H424RlvrkSeh4Dc,10714
|
7
|
+
sonatoki/Preprocessors.py,sha256=nvAzxpWP9WwT6gOCKcuiz5F8xYDdKIt9bOVUvy9o-G0,4459
|
8
|
+
sonatoki/Scorers.py,sha256=LRQLgXKTU2VqhkMHFPVxyVt83DXf85_zrpDGk4ThU24,3811
|
9
|
+
sonatoki/Tokenizers.py,sha256=So5_Tu6J98MD3yVcwB_X3lw2uMG0TN6XHcTbQjFCu5Q,4254
|
10
|
+
sonatoki/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
+
sonatoki/__main__.py,sha256=6xc-wIrrFo9wTyn4zRQNAmqwmJBtVvCMwV-CrM-hueA,82
|
12
|
+
sonatoki/constants.py,sha256=wH3iR32-Ic7vSkrMjAZIvmIysTtkJ-KBVU5zv3Oamqs,12656
|
13
|
+
sonatoki/ilo.py,sha256=yyLgNPI0Hmb4f1BzX6IRHr11FPChfL2xDR_9odlr8_8,3849
|
14
|
+
sonatoki/linku.json,sha256=fm4-dks5s9x1bs7q82GNngAedVCWilMPCQ_o-j35QL0,270950
|
15
|
+
sonatoki/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
+
sonatoki/sandbox.json,sha256=zPtZgJ_CpJa-2Den0gTNlk52f-YEwFVcjMarQXeeu5U,77563
|
17
|
+
sonatoki/utils.py,sha256=L984aXxvzfJaZ6GSWRKs7LweOGZYTLK11CdAhpLQr0g,4067
|
18
|
+
sonatoki-0.3.3.dist-info/RECORD,,
|
sonatoki-0.3.1.dist-info/RECORD
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
sonatoki-0.3.1.dist-info/METADATA,sha256=nWomuM-AeE98VwnWen7qffNclw8emxAf-oFtXwba8wI,6341
|
2
|
-
sonatoki-0.3.1.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
|
3
|
-
sonatoki-0.3.1.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
4
|
-
sonatoki/Cleaners.py,sha256=m0j1a1vs9Mdqp724r9Xfh1Y_tyP6GYCkihv8rH8m7lA,1871
|
5
|
-
sonatoki/Configs.py,sha256=NS1_esoDNna8LyH_9bPMkxbo2sMSilYhG1PwYLdq6L8,3402
|
6
|
-
sonatoki/Filters.py,sha256=-j5xSZ8URjqalQVGMBabMvJ5ofZWazfN7YPfXkM_4uQ,9429
|
7
|
-
sonatoki/Preprocessors.py,sha256=aMXXuFBDlJudvzvukvCa7BixuROXXEb62un7I-TGOGs,4441
|
8
|
-
sonatoki/Scorers.py,sha256=W-1uYiqjsDejJzoe592ixs7wHazjJXPhuo-41zuJ26U,3643
|
9
|
-
sonatoki/Tokenizers.py,sha256=So5_Tu6J98MD3yVcwB_X3lw2uMG0TN6XHcTbQjFCu5Q,4254
|
10
|
-
sonatoki/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
sonatoki/__main__.py,sha256=6xc-wIrrFo9wTyn4zRQNAmqwmJBtVvCMwV-CrM-hueA,82
|
12
|
-
sonatoki/constants.py,sha256=XTFmEcnLBXwdYXjTq_EuW9e_TWLtnNLz2vFCf8m-sz0,12844
|
13
|
-
sonatoki/ilo.py,sha256=yyLgNPI0Hmb4f1BzX6IRHr11FPChfL2xDR_9odlr8_8,3849
|
14
|
-
sonatoki/linku.json,sha256=B5KNdhyM5UEfMciROgh1ECHr3i-ASBeMvwrkzNJX47c,271013
|
15
|
-
sonatoki/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
sonatoki/sandbox.json,sha256=hx6LRsfvmmTtqXcXIyCsfSaGK3DZ-GCdbM8xhZQBHoA,77650
|
17
|
-
sonatoki/utils.py,sha256=OMaRyoNvKGKYQCBDjQyaCI58-wMpQ0wrrNjTJKsEZ9Y,3550
|
18
|
-
sonatoki-0.3.1.dist-info/RECORD,,
|
File without changes
|