Project - Building Spam Classifier

You are currently auditing this course.
5 / 27

Spam Classifier - Load all Emails

Now we will load the emails.

INSTRUCTIONS

We have downloaded all the emails, both spam and ham. Now we will load all of them:

HAM_DIR = os.path.join(SPAM_PATH, "easy_ham")
SPAM_DIR = os.path.join(SPAM_PATH, "spam")
ham_filenames = [name for name in sorted(os.listdir(HAM_DIR)) if len(name) > 20]
spam_filenames = [name for name in sorted(os.listdir(SPAM_DIR)) if len(name) > 20]

The sorted function sorts the elements of a given iterable in a specific order (either ascending or descending) and returns the sorted iterable as a list. Here, we are storing those lists in ham_filenames and spam_filenames variables.

Get Hint See Answer

Loading comments...