Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import os
  2. def load_data(dir):
  3. list = []
  4. for file in os.listdir(dir):
  5. with open(dir + ’/’ + file, ’rb’) as f:
  6. body = f.read().decode(’utf-8’, errors=’ignore’).splitlines() list.append(’ ’.join(body))
  7. return list
  8. BASE_DATA_DIR=’enron1’
  9. ham = [(text, ’ham’) for text in load_data(BASE_DATA_DIR + ’/ham’)] spam = [(text, ’spam’) for text in load_data(BASE_DATA_DIR +
  10. ’/spam’)]
  11. 2
  12. all = ham + spam
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement