Vedant Vyas commited on
Commit
01c89be
1 Parent(s): c1cfbda

generating valid data

Browse files
Files changed (1) hide show
  1. data/create_data.py +10 -1
data/create_data.py CHANGED
@@ -7,20 +7,29 @@ def main():
7
  # Create JSON data
8
 
9
  WordList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']
 
10
  file = open('data.json', 'w')
 
11
  for _ in range(100):
12
  file.write('{"translation":{"let":')
 
13
  randomNum = random.randint(1, 50)
14
  word = []
 
15
  for i in random.sample(range(1, 100), randomNum):
16
  word.append(WordList[i%17])
 
17
  wordStr = ''.join(word)
18
  wordRev = wordStr[::-1]
 
 
19
  file.write(f'"{wordStr}", "rev" :"{wordRev}"')
20
  file.write('}}\n')
 
 
21
 
22
  file.close()
23
-
24
 
25
 
26
 
 
7
  # Create JSON data
8
 
9
  WordList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']
10
+ ValidWordList = ['r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
11
  file = open('data.json', 'w')
12
+ file2 = open('validData.json', 'w')
13
  for _ in range(100):
14
  file.write('{"translation":{"let":')
15
+ file2.write('{"translation":{"let":')
16
  randomNum = random.randint(1, 50)
17
  word = []
18
+ word2 = []
19
  for i in random.sample(range(1, 100), randomNum):
20
  word.append(WordList[i%17])
21
+ word2.append(ValidWordList[i%9])
22
  wordStr = ''.join(word)
23
  wordRev = wordStr[::-1]
24
+ wordStr2 = ''.join(word2)
25
+ wordRev2 = wordStr2[::-1]
26
  file.write(f'"{wordStr}", "rev" :"{wordRev}"')
27
  file.write('}}\n')
28
+ file2.write(f'"{wordStr2}", "rev" :"{wordRev2}"')
29
+ file2.write('}}\n')
30
 
31
  file.close()
32
+ file2.close()
33
 
34
 
35