From aabbdb4df5464cde1cc37e98772260c8a25997cc Mon Sep 17 00:00:00 2001 From: yh Date: Fri, 17 May 2019 14:01:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0vocab=E7=9A=84clear=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/core/vocabulary.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fastNLP/core/vocabulary.py b/fastNLP/core/vocabulary.py index 03759194..3d9598a3 100644 --- a/fastNLP/core/vocabulary.py +++ b/fastNLP/core/vocabulary.py @@ -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.