From baf009fe5c14acc24272e34c1a979835fd5dbb73 Mon Sep 17 00:00:00 2001 From: Gosicfly Date: Tue, 17 Dec 2019 17:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=9D=9E=E6=B3=95=E6=A0=BC?= =?UTF-8?q?=E5=BC=8Fcatch=E4=BD=8F=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E5=B0=86sample=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 出现非法格式catch住的时候,应该将sample清空,不然会一直报warning,sample也会一直累积新的内容得不到正确的更新。 --- fastNLP/io/file_reader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fastNLP/io/file_reader.py b/fastNLP/io/file_reader.py index f1c90284..a5f9a472 100644 --- a/fastNLP/io/file_reader.py +++ b/fastNLP/io/file_reader.py @@ -117,6 +117,7 @@ def _read_conll(path, encoding='utf-8', indexes=None, dropna=True): except Exception as e: if dropna: logger.warning('Invalid instance which ends at line: {} has been dropped.'.format(line_idx)) + sample = [] continue raise ValueError('Invalid instance which ends at line: {}'.format(line_idx)) elif line.startswith('#'):