|
import random |
|
|
|
|
|
def main(): |
|
print('Creating 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(1000): |
|
file.write('{"translation":{"le":') |
|
if k <= 1000: |
|
file2.write('{"translation":{"le":') |
|
|
|
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() |