Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #===================================================
  2. # Learning to rank - Train
  3. #===================================================
  4.  
  5. print "\nStarting Training Phase:\n"
  6.  
  7. arrays = []
  8. ys = []
  9. namess = []
  10.  
  11. for subdir, dirs, files in os.walk("train"):
  12. for i, file in enumerate(files):
  13. if file.lower().endswith('.txt'):
  14. # get the file names iteratively
  15. (prefix, sep, suffix) = file.rpartition('.')
  16. the_file = os.path.join(os.getcwd(), subdir + os.path.sep + prefix + '.txt')
  17. the_key_file = os.path.join(os.getcwd(), subdir + os.path.sep + prefix + '.key')
  18.  
  19. try:
  20. print the_file
  21. print the_key_file
  22. # get the features
  23. feature_array, y, names = get_features_from_file_name(the_file, the_key_file)
  24. ##print "dimensions", feature_array.shape
  25. # save the features into lists of arrays
  26. arrays.append(feature_array)
  27. ys.append(y)
  28. namess += names
  29. print "done", i
  30. except UnicodeDecodeError:
  31. "Unicode decode error, skipping"
  32.  
  33.  
  34. print "Finished"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement