From a40f57ae4a63a95891e1137db77a0ba73f74b0d7 Mon Sep 17 00:00:00 2001 From: yh Date: Sat, 6 Jul 2019 10:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DVocabulary=E5=9C=A8=E5=BB=BA?= =?UTF-8?q?=E5=A5=BD=E8=AF=8D=E8=A1=A8=E4=B9=8B=E5=90=8E=E6=96=B0=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=AF=8D=E5=AF=BC=E8=87=B4=E7=9A=84pad=20index?= =?UTF-8?q?=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/core/vocabulary.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fastNLP/core/vocabulary.py b/fastNLP/core/vocabulary.py index 66aabd3d..5e8ae989 100644 --- a/fastNLP/core/vocabulary.py +++ b/fastNLP/core/vocabulary.py @@ -136,10 +136,10 @@ class Vocabulary(object): """ if self.word2idx is None: self.word2idx = {} - if self.padding is not None: - self.word2idx[self.padding] = len(self.word2idx) - if self.unknown is not None: - self.word2idx[self.unknown] = len(self.word2idx) + if self.padding is not None: + self.word2idx[self.padding] = len(self.word2idx) + if self.unknown is not None: + self.word2idx[self.unknown] = len(self.word2idx) max_size = min(self.max_size, len(self.word_count)) if self.max_size else None words = self.word_count.most_common(max_size)