-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.au3
114 lines (103 loc) · 5.84 KB
/
helpers.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include-once
#include <Math.au3>
Func __au3Console_array($v1 = Null, $v2 = Null, $v3 = Null, $v4 = Null, $v5 = Null, $v6 = Null, $v7 = Null, $v8 = Null, $v9 = Null, $v10 = Null, $v11 = Null, $v12 = Null, $v13 = Null, $v14 = Null, $v15 = Null, $v16 = Null, $v17 = Null, $v18 = Null, $v19 = Null, $v20 = Null, $v21 = Null, $v22 = Null, $v23 = Null, $v24 = Null, $v25 = Null, $v26 = Null, $v27 = Null, $v28 = Null, $v29 = Null, $v30 = Null, $v31 = Null, $v32 = Null, $v33 = Null, $v34 = Null, $v35 = Null, $v36 = Null, $v37 = Null, $v38 = Null, $v39 = Null, $v40 = Null, $v41 = Null, $v42 = Null, $v43 = Null, $v44 = Null, $v45 = Null, $v46 = Null, $v47 = Null, $v48 = Null, $v49 = Null, $v50 = Null, $v51 = Null, $v52 = Null, $v53 = Null, $v54 = Null, $v55 = Null, $v56 = Null, $v57 = Null, $v58 = Null, $v59 = Null, $v60 = Null, $v61 = Null, $v62 = Null, $v63 = Null, $v64 = Null, $v65 = Null, $v66 = Null, $v67 = Null, $v68 = Null, $v69 = Null, $v70 = Null, $v71 = Null, $v72 = Null, $v73 = Null, $v74 = Null, $v75 = Null, $v76 = Null, $v77 = Null, $v78 = Null, $v79 = Null, $v80 = Null, $v81 = Null, $v82 = Null, $v83 = Null, $v84 = Null, $v85 = Null, $v86 = Null, $v87 = Null, $v88 = Null, $v89 = Null, $v90 = Null, $v91 = Null, $v92 = Null, $v93 = Null, $v94 = Null, $v95 = Null, $v96 = Null, $v97 = Null, $v98 = Null, $v99 = Null, $v100 = Null, $v101 = Null, $v102 = Null, $v103 = Null, $v104 = Null, $v105 = Null, $v106 = Null, $v107 = Null, $v108 = Null, $v109 = Null, $v110 = Null, $v111 = Null, $v112 = Null, $v113 = Null, $v114 = Null, $v115 = Null, $v116 = Null, $v117 = Null, $v118 = Null, $v119 = Null, $v120 = Null, $v121 = Null, $v122 = Null, $v123 = Null, $v124 = Null, $v125 = Null, $v126 = Null, $v127 = Null, $v128 = Null, $v129 = Null, $v130 = Null, $v131 = Null, $v132 = Null, $v133 = Null, $v134 = Null, $v135 = Null, $v136 = Null, $v137 = Null, $v138 = Null, $v139 = Null, $v140 = Null, $v141 = Null, $v142 = Null, $v143 = Null, $v144 = Null, $v145 = Null, $v146 = Null, $v147 = Null, $v148 = Null, $v149 = Null, $v150 = Null, $v151 = Null, $v152 = Null, $v153 = Null, $v154 = Null, $v155 = Null, $v156 = Null, $v157 = Null, $v158 = Null, $v159 = Null, $v160 = Null, $v161 = Null, $v162 = Null, $v163 = Null, $v164 = Null, $v165 = Null, $v166 = Null, $v167 = Null, $v168 = Null, $v169 = Null, $v170 = Null, $v171 = Null, $v172 = Null, $v173 = Null, $v174 = Null, $v175 = Null, $v176 = Null, $v177 = Null, $v178 = Null, $v179 = Null, $v180 = Null, $v181 = Null, $v182 = Null, $v183 = Null, $v184 = Null, $v185 = Null, $v186 = Null, $v187 = Null, $v188 = Null, $v189 = Null, $v190 = Null, $v191 = Null, $v192 = Null, $v193 = Null, $v194 = Null, $v195 = Null, $v196 = Null, $v197 = Null, $v198 = Null, $v199 = Null, $v200 = Null, $v201 = Null, $v202 = Null, $v203 = Null, $v204 = Null, $v205 = Null, $v206 = Null, $v207 = Null, $v208 = Null, $v209 = Null, $v210 = Null, $v211 = Null, $v212 = Null, $v213 = Null, $v214 = Null, $v215 = Null, $v216 = Null, $v217 = Null, $v218 = Null, $v219 = Null, $v220 = Null, $v221 = Null, $v222 = Null, $v223 = Null, $v224 = Null, $v225 = Null, $v226 = Null, $v227 = Null, $v228 = Null, $v229 = Null, $v230 = Null, $v231 = Null, $v232 = Null, $v233 = Null, $v234 = Null, $v235 = Null, $v236 = Null, $v237 = Null, $v238 = Null, $v239 = Null, $v240 = Null, $v241 = Null, $v242 = Null, $v243 = Null, $v244 = Null, $v245 = Null, $v246 = Null, $v247 = Null, $v248 = Null, $v249 = Null, $v250 = Null)
Local $a[@NumParams]
Local $i
For $i = 1 To @NumParams Step +1
$a[$i - 1] = Eval('v'&$i)
Next
Return $a
EndFunc
Func __au3Console_assoc_array()
Local $a[0][2]
Return $a
EndFunc
Func __au3Console_array_assoc_get($array, $key)
Local $i
For $i = 0 To UBound($array, 1) - 1 Step +1
If $array[$i][0] == $key Then Return $array[$i][1]
Next
Return Null
EndFunc
Func __au3Console_array_assoc_isset($array, $key)
Return Not (__au3Console_array_assoc_get($array, $key) = Null)
EndFunc
Func __au3Console_array_assoc_key_exists($array, $key)
Local $i
For $i = 0 To UBound($array, 1) - 1 Step +1
If $array[$i][0] == $key Then Return True
Next
Return False
EndFunc
Func __au3Console_array_assoc_set(ByRef $array, $key, $value)
Local $i
For $i = 0 To UBound($array, 1) - 1 Step +1
If $array[$i][0] == $key Then
$array[$i][1] = $value
Return $value
EndIf
Next
Redim $array[UBound($array, 1) + 1][2]
$array[UBound($array, 1) - 1][0] = $key
$array[UBound($array, 1) - 1][1] = $value
Return $value
EndFunc
Func __au3Console_array_assoc_values($array)
Local $a[UBound($array, 1)]
Local $i
For $i = 0 To UBound($array, 1) - 1 Step +1
$a[$i] = $array[$i][1]
Next
Return $a
EndFunc
Func __au3Console_array_assoc_in_array($value, $array)
For $i = 0 To UBound($array, 1) - 1 Step +1
If $array[$i][1] = $value Then Return True
Next
Return False
EndFunc
Func __au3Console_array_assoc_keys($array)
Local $a[UBound($array, 1)]
Local $i
For $i = 0 To UBound($array, 1) - 1 Step +1
$a[$i] = $array[$i][0]
Next
Return $a
EndFunc
; Source: https://autoit.de/thread/83972-levenshtein-distanz/
Func __au3Console_levenshtein($s, $t)
Local $m, $n, $iMaxM, $iMaxN
$n = StringLen($s)
$m = StringLen($t)
$ss = StringSplit($s, "")
$tt = StringSplit($t, "")
$iMaxN = $n + 1
$iMaxM = $m + 1
Dim $d[$iMaxN + 1][$iMaxM + 1]
$d[0][0] = 0
If $n = 0 Then
Return $m
ElseIf $m = 0 Then
Return $n
EndIf
For $i = 1 To $n
$d[$i][0] = $d[$i - 1][0] + 1
Next
For $j = 1 To $m
$d[0][$j] = $d[0][$j - 1] + 1
Next
For $i = 1 To $n
For $j = 1 To $m
$jj = $j - 1
$ii = $i - 1
Local $cost
If (StringMid($s, $i, 1) = StringMid($t, $j, 1)) Then
$cost = 0
Else
$cost = 1
EndIf
$d[$i][$j] = _Min(_Min($d[$ii][$j] + 1, $d[$i][$jj] + 1), $d[$ii][$jj] + $cost)
Next
Next
Return $d[$n][$m]
EndFunc