text_html_output_1.png
from nltk.corpus import stopwords

from nltk.stem import WordNetLemmatizer

import pandas as pd

import re

df_train = pd.read_csv('/kaggle/input/nlp-getting-started/train.csv')
df_test = pd.read_csv('/kaggle/input/nlp-getting-started/test.csv')
df_sub = pd.read_csv('/kaggle/input/nlp-getting-started/sample_submission.csv')

def preprocessing(df):
    derlem = []
    for i in range(len(df.text)):
        text = re.sub('https?://\\S+', '', df.text[i])
        text = re.sub('http?://\\S+', '', text)
        text = re.sub('[^a-zA-Z]', ' ', text)
        text = re.sub('\\n', ' ', text)
        text = re.sub('\\s+', ' ', text).strip()
        text = text.lower()
        text = text.split()
        text = [WordNetLemmatizer().lemmatize(kelime) for kelime in text if not kelime in set(stopwords.words('english'))]
        text = ' '.join(text)
        derlem.append(text)
    df['clean_text'] = derlem
    return df

df_test = preprocessing(df_test)
df_train = preprocessing(df_train)
print(df_train.text[417])
print(df_train.clean_text[417])