Limpieza de datos de texto
Ahora que has definido las stopwords y puntuaciones, vamos a usarlas para limpiar aún más los correos de Enron en el dataframe df. Las listas que contienen stopwords y puntuaciones están disponibles como stop y exclude. Aún faltan algunos pasos antes de tener datos limpios, como la "lematización" de palabras y el stemming de los verbos. Los verbos en los correos ya están sometidos a stemming y la lematización ya está hecha por ti en este ejercicio.
Este ejercicio forma parte del curso
Fraud Detection in Python
ejercicio interactivo práctico
Prueba este ejercicio completando este código de ejemplo.
# Import the lemmatizer from nltk
from nltk.stem.wordnet import WordNetLemmatizer
lemma = WordNetLemmatizer()
# Define word cleaning function
def clean(text, stop):
text = text.____()
# Remove stopwords
stop_free = " ".join([word for word in text.lower().split() if ((___ not in ___) and (not word.isdigit()))])
# Remove punctuations
punc_free = ''.join(word for word in stop_free if ___ not in ____)
# Lemmatize all words
normalized = " ".join(____.____(word) for word in punc_free.split())
return normalized