From 8614b89a19719e3cb3fc9f0f9196a1dbe65a8e02 Mon Sep 17 00:00:00 2001 From: yh Date: Sun, 15 Sep 2019 22:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0conll=E7=9A=84pipe=E5=AF=B9bi?= =?UTF-8?q?oes=E7=9A=84=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/io/pipe/conll.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fastNLP/io/pipe/conll.py b/fastNLP/io/pipe/conll.py index 24ba2ba0..70af5acb 100644 --- a/fastNLP/io/pipe/conll.py +++ b/fastNLP/io/pipe/conll.py @@ -38,8 +38,10 @@ class _NERPipe(Pipe): """ if encoding_type == 'bio': self.convert_tag = iob2 - else: + elif encoding_type == 'bioes': self.convert_tag = lambda words: iob2bioes(iob2(words)) + else: + raise ValueError("encoding_type only supports `bio` and `bioes`.") self.lower = lower def process(self, data_bundle: DataBundle) -> DataBundle: @@ -132,12 +134,16 @@ class Conll2003Pipe(Pipe): """ if chunk_encoding_type == 'bio': self.chunk_convert_tag = iob2 - else: + elif chunk_encoding_type == 'bioes': self.chunk_convert_tag = lambda tags: iob2bioes(iob2(tags)) + else: + raise ValueError("chunk_encoding_type only supports `bio` and `bioes`.") if ner_encoding_type == 'bio': self.ner_convert_tag = iob2 - else: + elif ner_encoding_type == 'bioes': self.ner_convert_tag = lambda tags: iob2bioes(iob2(tags)) + else: + raise ValueError("ner_encoding_type only supports `bio` and `bioes`.") self.lower = lower def process(self, data_bundle) -> DataBundle: @@ -236,8 +242,10 @@ class _CNNERPipe(Pipe): """ if encoding_type == 'bio': self.convert_tag = iob2 - else: + elif encoding_type == 'bioes': self.convert_tag = lambda words: iob2bioes(iob2(words)) + else: + raise ValueError("encoding_type only supports `bio` and `bioes`.") self.bigrams = bigrams self.trigrams = trigrams