Spaces:
Runtime error
Runtime error
profnecrya
commited on
Commit
·
f3bf74c
1
Parent(s):
a8a6954
Update app.py
Browse files
app.py
CHANGED
@@ -21,25 +21,38 @@ def check3(inp, inp2):
|
|
21 |
if shortest[i] == longest[i]:
|
22 |
out += 2
|
23 |
return out - ((out-ls)*0.5) - (ll-ls) * 0.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Work
|
26 |
def get_matches(text):
|
27 |
# prepare text
|
28 |
textR=str(text)
|
29 |
-
textR=textR.split() #
|
30 |
# Variables
|
31 |
-
countl=0
|
32 |
queue=len(textR)
|
33 |
-
output=
|
34 |
# try to correct it
|
35 |
try:
|
36 |
##return(difflib.get_close_matches(text, dictionary)) #[0].replace("\n", "")
|
37 |
for x in range(queue):
|
38 |
-
output
|
39 |
-
|
40 |
-
countl+=1
|
41 |
-
if countl>=queue:
|
42 |
-
return(output)
|
43 |
except Exception as ex: # Print error if error
|
44 |
return(ex)
|
45 |
|
|
|
21 |
if shortest[i] == longest[i]:
|
22 |
out += 2
|
23 |
return out - ((out-ls)*0.5) - (ll-ls) * 0.5
|
24 |
+
|
25 |
+
class Neuron:
|
26 |
+
def __init__(self, inp, output: str):
|
27 |
+
self.output = output
|
28 |
+
self.inp = inp
|
29 |
+
def train(self, inpr):
|
30 |
+
cid = random.randint(0, len(inpr)-1)
|
31 |
+
c2id = random.randint(0, len(inpr[cid])-1)
|
32 |
+
if inpr[cid][c2id] not in self.inp:
|
33 |
+
self.inp.append(inpr[cid][c2id])
|
34 |
+
cid = random.randint(0, len(self.inp)-1)
|
35 |
+
if not check(self.inp[cid], inpr):
|
36 |
+
del self.inp[cid]
|
37 |
+
|
38 |
+
def check(word, list2d):
|
39 |
+
for i in list2d:
|
40 |
+
if word in i: return True
|
41 |
|
42 |
# Work
|
43 |
def get_matches(text):
|
44 |
# prepare text
|
45 |
textR=str(text)
|
46 |
+
textR=textR.split() # Split inputed text to list
|
47 |
# Variables
|
|
|
48 |
queue=len(textR)
|
49 |
+
output=[]
|
50 |
# try to correct it
|
51 |
try:
|
52 |
##return(difflib.get_close_matches(text, dictionary)) #[0].replace("\n", "")
|
53 |
for x in range(queue):
|
54 |
+
output.append(difflib.get_close_matches(textR, dictionary))
|
55 |
+
return(output)
|
|
|
|
|
|
|
56 |
except Exception as ex: # Print error if error
|
57 |
return(ex)
|
58 |
|