vortezwohl 0.0.1__py3-none-any.whl → 0.0.2__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.
@@ -54,6 +54,10 @@ class ThreadPool(object):
54
54
  except Exception as __e:
55
55
  yield __e, traceback.format_exc()
56
56
 
57
+ def map(self, jobs: Iterable[Callable], arguments: list[Dict] | list[Tuple] | list[NoneType] | None = None) \
58
+ -> tuple[Callable, Any, Any] | Exception:
59
+ return self.gather(jobs=jobs, arguments=arguments)
60
+
57
61
  def shutdown(self, cancel_futures: bool = True):
58
62
  self._thread_pool_executor.shutdown(wait=True, cancel_futures=cancel_futures)
59
63
  return self
File without changes
@@ -0,0 +1,14 @@
1
+ from abc import abstractmethod
2
+
3
+ from typing_extensions import Callable
4
+
5
+
6
+ class BaseStringSimilarity(Callable):
7
+ def __init__(self, ignore_case: bool, *args, **kwargs):
8
+ self._ignore_case = ignore_case
9
+
10
+ @abstractmethod
11
+ def __call__(self, *args, **kwargs): ...
12
+
13
+ @abstractmethod
14
+ def rank(self, s: str, S: list[str]) -> list[str]: ...
@@ -0,0 +1,35 @@
1
+ from overrides import override
2
+
3
+ from vortezwohl.nlp.base_string_similarity import BaseStringSimilarity
4
+
5
+
6
+ class LevenshteinDistance(BaseStringSimilarity):
7
+ def __init__(self, ignore_case: bool = False):
8
+ super().__init__(ignore_case=ignore_case)
9
+
10
+ @override
11
+ def __call__(self, s_1: str, s_2: str) -> int:
12
+ if self._ignore_case:
13
+ s_1, s_2 = s_1.lower(), s_2.lower()
14
+ m, n = len(s_1), len(s_2)
15
+ dp = [[0] * (n + 1) for _ in range(m + 1)]
16
+ for i in range(m + 1):
17
+ dp[i][0] = i
18
+ for j in range(n + 1):
19
+ dp[0][j] = j
20
+ for i in range(1, m + 1):
21
+ for j in range(1, n + 1):
22
+ if s_1[i - 1] == s_2[j - 1]:
23
+ dp[i][j] = dp[i - 1][j - 1]
24
+ else:
25
+ dp[i][j] = min(
26
+ dp[i - 1][j - 1] + 1,
27
+ dp[i - 1][j] + 1,
28
+ dp[i][j - 1] + 1
29
+ )
30
+ return dp[m][n]
31
+
32
+ @override
33
+ def rank(self, s: str, S: list[str]) -> list[str]:
34
+ lcs_list = sorted([(self.__call__(s, x), x) for x in S], key=lambda x: x[0], reverse=False)
35
+ return [x[1] for x in lcs_list]
@@ -0,0 +1,33 @@
1
+ from overrides import override
2
+
3
+ from vortezwohl.nlp.base_string_similarity import BaseStringSimilarity
4
+
5
+
6
+ class LongestCommonSubstring(BaseStringSimilarity):
7
+ def __init__(self, ignore_case: bool = False):
8
+ super().__init__(ignore_case=ignore_case)
9
+
10
+ @override
11
+ def __call__(self, s_1: str, s_2: str) -> str:
12
+ if self._ignore_case:
13
+ s_1, s_2 = s_1.lower(), s_2.lower()
14
+ m, n = len(s_1), len(s_2)
15
+ dp = [[0] * (n + 1) for _ in range(m + 1)]
16
+ max_length = end_index = 0
17
+ for i in range(1, m + 1):
18
+ for j in range(1, n + 1):
19
+ if s_1[i - 1] == s_2[j - 1]:
20
+ dp[i][j] = dp[i - 1][j - 1] + 1
21
+ if dp[i][j] > max_length:
22
+ max_length = dp[i][j]
23
+ end_index = i - 1
24
+ else:
25
+ dp[i][j] = 0
26
+ if max_length == 0:
27
+ return ''
28
+ return s_1[end_index - max_length + 1: end_index + 1]
29
+
30
+ @override
31
+ def rank(self, s: str, S: list[str]) -> list[str]:
32
+ lcs_list = sorted([(len(self.__call__(s, x)), x) for x in S], key=lambda x: x[0], reverse=True)
33
+ return [x[1] for x in lcs_list]
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortezwohl
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: SDK of vortezwohl.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
+ Requires-Dist: overrides
8
9
  Requires-Dist: psutil
9
10
  Requires-Dist: typing-extensions
10
11
  Dynamic: license-file
@@ -15,9 +16,23 @@ Dynamic: license-file
15
16
 
16
17
  ## Installation
17
18
 
18
- ```
19
- pip install -U git+https://github.com/vortezwohl/vortezwohl-sdk.git
20
- ```
19
+ - With pip
20
+
21
+ ```
22
+ pip install -U vortezwohl
23
+ ```
24
+
25
+ - With uv
26
+
27
+ ```
28
+ uv add -U vortezwohl
29
+ ```
30
+
31
+ - From github
32
+
33
+ ```
34
+ pip install -U git+https://github.com/vortezwohl/vortezwohl-sdk.git
35
+ ```
21
36
 
22
37
  ## Quick Start
23
38
 
@@ -0,0 +1,14 @@
1
+ vortezwohl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ vortezwohl/concurrent/__init__.py,sha256=1_W6Ykwb6k2LzkXQaOXEpxBQwvHOOPVMv5DQNMdJqIA,37
3
+ vortezwohl/concurrent/thread_pool.py,sha256=qPrzziraMuE58YM2_1hB8M1Fz9WJsC4aUmTmeO5ts5o,3288
4
+ vortezwohl/nlp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ vortezwohl/nlp/base_string_similarity.py,sha256=8CXuWI3-w4LenR9L8P9RIkohMvG_-j3WNCiDIdpbm1s,371
6
+ vortezwohl/nlp/levenshtein_distance.py,sha256=6cEtw9AfK-ZYyE5NsLWos8QwTIQXyeKib05DF958MeM,1239
7
+ vortezwohl/nlp/longest_common_substring.py,sha256=WR6520AldRH0dw_ONnDrVOsk8fbKN_4CHoqzd4HBheo,1239
8
+ vortezwohl/random/__init__.py,sha256=6_ZYF6L51T3OX61AH3YfweowQ6WbAPUxPrFKGd06fcg,39
9
+ vortezwohl/random/seed_generator.py,sha256=FpAjTQ-3B4GCY1Wab1Rm-vK6Fa6pUUg09zE9vfge3mI,422
10
+ vortezwohl-0.0.2.dist-info/licenses/LICENSE,sha256=fYGoXeTYzghoONDvtIfMSKG2NRaFfS-0XSMwGD8BYcQ,1101
11
+ vortezwohl-0.0.2.dist-info/METADATA,sha256=QBjJ2pLUA84PMNCzgh4DwCWI9G40j7fq8iiTYUqUA2Q,3438
12
+ vortezwohl-0.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ vortezwohl-0.0.2.dist-info/top_level.txt,sha256=pxgR8W5Zjq9NaX1T58sodinodm2PngBMY2YXlCTjhhg,11
14
+ vortezwohl-0.0.2.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- vortezwohl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- vortezwohl/concurrent/__init__.py,sha256=1_W6Ykwb6k2LzkXQaOXEpxBQwvHOOPVMv5DQNMdJqIA,37
3
- vortezwohl/concurrent/thread_pool.py,sha256=623AtQKUEeV8OelXlnwB_YPK8-0jeX0m7Lg3F-hDKo0,3056
4
- vortezwohl/random/__init__.py,sha256=6_ZYF6L51T3OX61AH3YfweowQ6WbAPUxPrFKGd06fcg,39
5
- vortezwohl/random/seed_generator.py,sha256=FpAjTQ-3B4GCY1Wab1Rm-vK6Fa6pUUg09zE9vfge3mI,422
6
- vortezwohl-0.0.1.dist-info/licenses/LICENSE,sha256=fYGoXeTYzghoONDvtIfMSKG2NRaFfS-0XSMwGD8BYcQ,1101
7
- vortezwohl-0.0.1.dist-info/METADATA,sha256=-PxnLBItGYAg2GD0RXpfLU91J4If5FBzXJx5mH3DjyU,3259
8
- vortezwohl-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- vortezwohl-0.0.1.dist-info/top_level.txt,sha256=pxgR8W5Zjq9NaX1T58sodinodm2PngBMY2YXlCTjhhg,11
10
- vortezwohl-0.0.1.dist-info/RECORD,,