vortezwohl 0.0.1__tar.gz → 0.0.2__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.
@@ -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
 
@@ -4,9 +4,23 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```
8
- pip install -U git+https://github.com/vortezwohl/vortezwohl-sdk.git
9
- ```
7
+ - With pip
8
+
9
+ ```
10
+ pip install -U vortezwohl
11
+ ```
12
+
13
+ - With uv
14
+
15
+ ```
16
+ uv add -U vortezwohl
17
+ ```
18
+
19
+ - From github
20
+
21
+ ```
22
+ pip install -U git+https://github.com/vortezwohl/vortezwohl-sdk.git
23
+ ```
10
24
 
11
25
  ## Quick Start
12
26
 
@@ -1,10 +1,11 @@
1
- [project]
2
- name = "vortezwohl"
3
- version = "0.0.1"
4
- description = "SDK of vortezwohl."
5
- readme = "README.md"
6
- requires-python = ">=3.10"
7
- dependencies = [
8
- "psutil",
9
- "typing-extensions",
10
- ]
1
+ [project]
2
+ name = "vortezwohl"
3
+ version = "0.0.2"
4
+ description = "SDK of vortezwohl."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "overrides",
9
+ "psutil",
10
+ "typing-extensions",
11
+ ]
@@ -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
 
@@ -9,5 +9,9 @@ vortezwohl.egg-info/requires.txt
9
9
  vortezwohl.egg-info/top_level.txt
10
10
  vortezwohl/concurrent/__init__.py
11
11
  vortezwohl/concurrent/thread_pool.py
12
+ vortezwohl/nlp/__init__.py
13
+ vortezwohl/nlp/base_string_similarity.py
14
+ vortezwohl/nlp/levenshtein_distance.py
15
+ vortezwohl/nlp/longest_common_substring.py
12
16
  vortezwohl/random/__init__.py
13
17
  vortezwohl/random/seed_generator.py
@@ -1,2 +1,3 @@
1
+ overrides
1
2
  psutil
2
3
  typing-extensions
File without changes
File without changes