Browse Source

修复vocabulary iterate时不符合常规情况的问题

tags/v0.5.5
yh_cc 5 years ago
parent
commit
4dd16be8ca
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      fastNLP/core/vocabulary.py

+ 3
- 2
fastNLP/core/vocabulary.py View File

@@ -480,8 +480,9 @@ class Vocabulary(object):
@_check_build_vocab
def __iter__(self):
for word, index in self._word2idx.items():
yield word, index
# 依次(word1, 0), (word1, 1)
for index in range(len(self._word2idx)):
yield self.to_word(index), index

def save(self, filepath):
r"""


Loading…
Cancel
Save