File size: 1,209 Bytes
c1cfbda e0623e0 c1cfbda 01c89be 4ac1a8c e0623e0 4ac1a8c e0623e0 c1cfbda 01c89be c1cfbda e0623e0 c1cfbda 4ac1a8c e0623e0 4ac1a8c e0623e0 4ac1a8c e0623e0 c1cfbda 4ac1a8c c1cfbda 01c89be c1cfbda |
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 |
import random
def main():
print('Creating data...')
# Create JSON data
# Create JSON data
WordList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']
ValidWordList = ['l','m', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
file = open('data.json', 'w')
file2 = open('validData.json', 'w')
for k in range(10000):
file.write('{"translation":{"le":')
if k <= 1000:
file2.write('{"translation":{"le":')
#randomNum = random.randint(1, 10)
randomNum = 10
word = []
word2 = []
for i in random.sample(range(1, 100), randomNum):
word.append(WordList[i%9])
if k <= 1000:
word2.append(ValidWordList[i%11])
wordStr = ' '.join(word)
wordRev = wordStr[::-1]
if k <= 1000:
wordStr2 = ' '.join(word2)
wordRev2 = wordStr2[::-1]
file2.write(f'"{wordStr2}.", "rev" :"{wordRev2}."')
file2.write('}}\n')
file.write(f'"{wordStr}.", "rev" :"{wordRev}."')
file.write('}}\n')
file.close()
file2.close()
if __name__ == '__main__':
main() |