test.py 900 B

123456789101112131415161718192021222324252627282930313233343536
  1. import argparse
  2. import math
  3. import numpy as np
  4. parser = argparse.ArgumentParser()
  5. parser.add_argument('--start', type=int, default=1)
  6. parser.add_argument('--end', type=int, default=12)
  7. parser.add_argument('--step', type=int, default=1)
  8. args = parser.parse_args()
  9. words_8763 = ''
  10. with open('dict_eng_8763.txt', 'r', encoding='utf-8') as fp:
  11. words_8763 = fp.readlines()
  12. fp.close()
  13. eng_list = []
  14. for word in words_8763:
  15. eng_list.append(word.rstrip('\n'))
  16. wp = open('eng_text.txt', 'w')
  17. for i in range(args.start, args.end+1, args.step):
  18. for j in range(0, 360):
  19. arr1 = np.random.rand(i)*len(eng_list)
  20. text = ''
  21. k = 1
  22. for num in arr1:
  23. if k == len(arr1):
  24. text += eng_list[math.floor(num)] + '\n'
  25. else:
  26. text += eng_list[math.floor(num)] + ' '
  27. k += 1
  28. wp.write(text)
  29. wp.close()