ierhon commited on
Commit
44dee35
1 Parent(s): 2824c91

Update app.py

Browse files

Neuron training. You now need a train.py and a dataset.

Files changed (1) hide show
  1. app.py +24 -8
app.py CHANGED
@@ -27,18 +27,34 @@ class Neuron:
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
 
27
  self.output = output
28
  self.inp = inp
29
  def train(self, inpr):
30
+ lir = len(inpr)
31
+ lirm = lir-1
32
+ linp = len(inp)
33
+ linpm = linp-1
34
+ cid = random.randint(0, lirm)
35
+ if cid < linpm:
36
+ if random.choice([True, True, False]):
37
+ del self.inp[linpm]
38
+ else:
39
+ self.inp[cid] = inpr[cid]
40
+ elif cid == linpm:
41
+ self.inp[cid] = inpr[cid]
42
+ else:
43
+ self.inp.append(inpr[cid])
44
+ # cid = random.randint(0, len(inpr)-1)
45
+ # c2id = random.randint(0, len(inpr[cid])-1)
46
+ # if inpr[cid][c2id] not in self.inp:
47
+ # self.inp.append(inpr[cid][c2id])
48
+ # cid = random.randint(0, len(self.inp)-1)
49
+ # if not check(self.inp[cid], inpr):
50
+ # del self.inp[cid]
51
 
52
  def check(word, list2d):
53
  for i in list2d:
54
  if word in i: return True
55
+
56
+ outs1 = []
57
+
58
  # Work
59
  def get_matches(text):
60
  # prepare text