(self, string)
| 65 | return string.strip().lower() |
| 66 | |
| 67 | def remove_stopword(self, string): |
| 68 | if self.stop_words is None: |
| 69 | from nltk.corpus import stopwords |
| 70 | self.stop_words = set(stopwords.words('english')) |
| 71 | |
| 72 | if type(string) is str: |
| 73 | string = string.split() |
| 74 | |
| 75 | new_string = list() |
| 76 | for word in string: |
| 77 | if word in self.stop_words: |
| 78 | continue |
| 79 | new_string.append(word) |
| 80 | |
| 81 | return " ".join(new_string) |
| 82 | |
| 83 | def replace_num(self, string): |
| 84 | result = re.sub(self.num, '<num>', string) |