-
Notifications
You must be signed in to change notification settings - Fork 2
/
Mail.py
26 lines (24 loc) · 774 Bytes
/
Mail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
from re import compile
import numpy
import scipy
import nltk
class SingleMail:
def __init__:
stop_words = nltk.corpus.stopwords.words('russian')
regex = re.compile('[%s]' % re.escape(string.punctuation))
def normalized_words(self, article_text):
words = []
oneline = article_text.replace('\n', ' ')
cleaned = nltk.clean_html(oneline.strip())
toks1 = cleaned.split()
for t1 in toks1:
translated = self.regex.sub('', t1)
toks2 = translated.split()
for t2 in toks2:
t2s = t2.strip().lower()
if self.stop_words.has_key(t2s):
pass
else:
words.append(t2s)
return words