Browse Source

增加vocab的clear方法

tags/v0.4.10
yh 6 years ago
parent
commit
aabbdb4df5
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      fastNLP/core/vocabulary.py

+ 12
- 1
fastNLP/core/vocabulary.py View File

@@ -322,7 +322,18 @@ class Vocabulary(object):
:return str word: the word
"""
return self.idx2word[idx]

def clear(self):
"""
删除Vocabulary中的词表数据。相当于重新初始化一下。

:return:
"""
self.word_count.clear()
self.word2idx = None
self.idx2word = None
self.rebuild = True

def __getstate__(self):
"""Use to prepare data for pickle.



Loading…
Cancel
Save