(self, word)
| 164 | self.addWord(word) |
| 165 | |
| 166 | def addWord(self, word): |
| 167 | if word not in self.word2index: |
| 168 | self.word2index[word] = self.n_words |
| 169 | self.word2count[word] = 1 |
| 170 | self.index2word[self.n_words] = word |
| 171 | self.n_words += 1 |
| 172 | else: |
| 173 | self.word2count[word] += 1 |
| 174 | |
| 175 | |
| 176 | ###################################################################### |