text_plain_output_1.png
from nltk.corpus import stopwords

from nltk.stem import WordNetLemmatizer

from sklearn.feature_extraction.text import TfidfVectorizer

from sklearn.naive_bayes import MultinomialNB

import pandas as pd

import pandas as pd

import re

import re

email = 'We are goind USA to meet on saturday or sunday on 09:30 PM or 10:00 am ok on january good ? in Cairo or Giza ?'

email = email.lower()

re.findall('saturday|sunday|monday|wednesday', email)

re.findall('january|february', email)

re.findall('\\d{1,2}:\\d{1,2} a?p?m', email)

df = pd.DataFrame(columns=['text', 'label'])

old_dataset = pd.read_csv('./events.csv')

import re
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from wordcloud import WordCloud
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
from sklearn.feature_extraction.text import CountVectorizer
wnl = WordNetLemmatizer()
engstopwords = stopwords.words('english')

def lemmatize_all_types(word):
    word = wnl.lemmatize(word, 'a')
    word = wnl.lemmatize(word, 'v')
    word = wnl.lemmatize(word, 'n')
    return word
def clean(text):
    text = re.sub('https?://\\w+\\.\\w+\\.\\w+', '', text).lower()
    text = re.sub('[^a-zA-Z ]', '', text)
    text = list(map(lemmatize_all_types, text.split()))
    text = [word for word in text if word not in engstopwords]
    text = ' '.join(text)
    return text

df = pd.read_csv('../input/emails-events/emails_events.csv')

tfidf = TfidfVectorizer(max_features=10000)
dtm = tfidf.fit_transform(X).toarray()
words = tfidf.get_feature_names()
X_dtm = pd.DataFrame(columns=words, data=dtm)

model = MultinomialNB()

model.fit(X_train, y_train)

model.score(X_test, y_test)

text = 'can we have meeting on the next week please on morning'
text = clean(text)
enc = tfidf.transform([text])
model.predict(enc)

text = 'what a beautiful garden that we saw in the cinema'
text = clean(text)
enc = tfidf.transform([text])
model.predict(enc)