nlpertools 1.0.5__py3-none-any.whl → 1.0.6.dev0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- nlpertools/__init__.py +24 -20
- nlpertools/algo/ac.py +18 -0
- nlpertools/algo/bit_ops.py +28 -0
- nlpertools/algo/kmp.py +94 -55
- nlpertools/algo/num_ops.py +12 -0
- nlpertools/algo/template.py +116 -0
- nlpertools/algo/union.py +13 -0
- nlpertools/data_client.py +387 -257
- nlpertools/data_structure/base_structure.py +109 -13
- nlpertools/dataprocess.py +611 -3
- nlpertools/default_db_config.yml +41 -0
- nlpertools/io/__init__.py +3 -3
- nlpertools/io/dir.py +54 -36
- nlpertools/io/file.py +277 -222
- nlpertools/ml.py +483 -460
- nlpertools/monitor/__init__.py +0 -0
- nlpertools/monitor/gpu.py +18 -0
- nlpertools/monitor/memory.py +24 -0
- nlpertools/movie.py +36 -0
- nlpertools/nlpertools_config.yml +1 -0
- nlpertools/{openApi.py → open_api.py} +65 -65
- nlpertools/other.py +364 -249
- nlpertools/pic.py +288 -0
- nlpertools/plugin.py +43 -43
- nlpertools/reminder.py +98 -87
- nlpertools/utils/__init__.py +3 -3
- nlpertools/utils/lazy.py +727 -0
- nlpertools/utils/log_util.py +20 -0
- nlpertools/utils/package.py +89 -76
- nlpertools/utils/package_v1.py +94 -0
- nlpertools/utils/package_v2.py +117 -0
- nlpertools/utils_for_nlpertools.py +93 -93
- nlpertools/vector_index_demo.py +108 -0
- nlpertools/wrapper.py +161 -96
- {nlpertools-1.0.5.dist-info → nlpertools-1.0.6.dev0.dist-info}/LICENSE +200 -200
- nlpertools-1.0.6.dev0.dist-info/METADATA +111 -0
- nlpertools-1.0.6.dev0.dist-info/RECORD +43 -0
- {nlpertools-1.0.5.dist-info → nlpertools-1.0.6.dev0.dist-info}/WHEEL +1 -1
- nlpertools-1.0.6.dev0.dist-info/top_level.txt +2 -0
- nlpertools_helper/__init__.py +10 -0
- nlpertools-1.0.5.dist-info/METADATA +0 -85
- nlpertools-1.0.5.dist-info/RECORD +0 -25
- nlpertools-1.0.5.dist-info/top_level.txt +0 -1
@@ -1,13 +1,109 @@
|
|
1
|
-
#!/usr/bin/python3.8
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
# @Author : youshu.Ji
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
#!/usr/bin/python3.8
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Author : youshu.Ji
|
4
|
+
|
5
|
+
|
6
|
+
class ListNode:
|
7
|
+
def __init__(self, x):
|
8
|
+
self.length = 1
|
9
|
+
if type(x) is int:
|
10
|
+
self.val = x
|
11
|
+
self.next = None
|
12
|
+
else:
|
13
|
+
# 初始化list,感觉用递归会比较好
|
14
|
+
pre = ListNode(x.pop(0))
|
15
|
+
head = pre
|
16
|
+
while x:
|
17
|
+
self.length += 1
|
18
|
+
pre.next = ListNode(x.pop(0))
|
19
|
+
pre = pre.next
|
20
|
+
self.val = head.val
|
21
|
+
self.next = head.next
|
22
|
+
|
23
|
+
def add(self):
|
24
|
+
pass
|
25
|
+
|
26
|
+
def __str__(self):
|
27
|
+
# TODO 循环链表标记出来
|
28
|
+
print_string = [self.val]
|
29
|
+
tmp = self.next
|
30
|
+
# 防止循环链表
|
31
|
+
recurrent_num = 0
|
32
|
+
while tmp and recurrent_num <= self.length + 10:
|
33
|
+
recurrent_num += 1
|
34
|
+
print_string.append(tmp.val)
|
35
|
+
tmp = tmp.next
|
36
|
+
return str(print_string)
|
37
|
+
|
38
|
+
|
39
|
+
class TreeNode:
|
40
|
+
def __init__(self, val=0, left=None, right=None):
|
41
|
+
if type(val) is list:
|
42
|
+
pass
|
43
|
+
else:
|
44
|
+
self.val = val
|
45
|
+
self.left = left
|
46
|
+
self.right = right
|
47
|
+
|
48
|
+
def build_from_list(self):
|
49
|
+
pass
|
50
|
+
|
51
|
+
def __str__(self):
|
52
|
+
pass
|
53
|
+
|
54
|
+
@staticmethod
|
55
|
+
def pre_order(node):
|
56
|
+
stack = []
|
57
|
+
res = []
|
58
|
+
while stack or node:
|
59
|
+
while node:
|
60
|
+
res.append(node)
|
61
|
+
stack.append(node)
|
62
|
+
node = node.left
|
63
|
+
node = stack.pop(-1)
|
64
|
+
node = node.right
|
65
|
+
return res
|
66
|
+
|
67
|
+
def level_order(self, node):
|
68
|
+
# 层序遍历
|
69
|
+
# 直观觉得递归不行,采用迭代
|
70
|
+
# deque表示正在遍历的层
|
71
|
+
deque = [node]
|
72
|
+
nxt_deque = []
|
73
|
+
res = []
|
74
|
+
while deque:
|
75
|
+
while deque:
|
76
|
+
node = deque.pop(0)
|
77
|
+
res.append(node.val)
|
78
|
+
if node.left:
|
79
|
+
nxt_deque.append(node.left)
|
80
|
+
if node.right:
|
81
|
+
nxt_deque.append(node.right)
|
82
|
+
deque, nxt_deque = nxt_deque, []
|
83
|
+
return res
|
84
|
+
|
85
|
+
pass
|
86
|
+
|
87
|
+
def bfs(self):
|
88
|
+
# 具体怎么用迭代写BFS,是根据需求来的。
|
89
|
+
# dp 里面放这个吧(node, depth)
|
90
|
+
pass
|
91
|
+
|
92
|
+
def mid_order(self, node):
|
93
|
+
if node.left:
|
94
|
+
self.mid_order(node.left)
|
95
|
+
print(node.val)
|
96
|
+
if node.right:
|
97
|
+
self.mid_order(node.right)
|
98
|
+
|
99
|
+
def post_order(self, node=None):
|
100
|
+
pass
|
101
|
+
|
102
|
+
def in_order(self, node):
|
103
|
+
# bts的读法
|
104
|
+
pass
|
105
|
+
|
106
|
+
|
107
|
+
if __name__ == '__main__':
|
108
|
+
a = ListNode([1, 2, 3, 4])
|
109
|
+
print(a)
|