Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Spam Classifier - Load all Emails

Now we will load the emails.


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.

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...