def test_reader__remove_digits(self): """Check the remove_digits method. All emails should not contains any digit.""" reader = DSReader(dataset_digits) reader.remove_digits() for i, row in reader.dataset.iterrows(): for word in row['email'].split(' '): res = any([digit in str(word) for digit in string.digits]) self.assertEqual(False, res)
# my_dataset = DSReader(my_data_test) # my_dataset.to_lower() # my_dataset.remove_digits() # my_dataset.remove_punctuation_marks() # my_dataset.remove_duplicates() # my_dataset.remove_stopwords() # my_dataset.remove_stopwords() # print(my_dataset.dataset) my_dataset1 = DSReader('C:/Users/Masquerade/Downloads/emails.csv') my_dataset1.to_lower() my_dataset1.remove_digits() my_dataset1.remove_punctuation_marks() my_dataset1.remove_duplicates() my_dataset1.remove_stopwords() my_dataset1.remove_stopwords() # print(my_dataset1.dataset) list_email, list_label = my_dataset1.vectorize() print(list_email.shape) print(list_label.shape) X, y = list_email, list_label # X, y = my_dataset1.dataset.email, my_dataset1.dataset.label X_train, X_test, y_train, y_test = train_test_split(X.values, y.values)