-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop_word.py
40 lines (27 loc) · 1.1 KB
/
stop_word.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
# -*- coding: utf8 -*-
class StopWord:
def __init__(self, french, english):
self.__stopword = dict()
if not french and not english:
from nltk.corpus import stopwords
self.__stopword["english"] = set(stopwords.words("english"))
self.__stopword["french"] = set(stopwords.words("french"))
else:
self.__stopword["english"] = self.__readfilter(english)
self.__stopword["french"] = self.__readfilter(french)
self.__ponctuation = (",", ";", ".", ":", "(", ")", "\"",
"\'", "<", ">", "=", "«", "»", "#", "[", "]", "+",
"%", "*", "/", "¿", "’", "\x92", "- -", "-")
def __readfilter(self, filename):
"""
"""
word_filter = set()
with open(filename, "r") as filtr_list:
for word in filtr_list:
word_filter.add(word.strip())
return word_filter
def get_stopword(self):
return self.__stopword
def get_ponctuation(self):
return self.__ponctuation