From a51b35f40688ad1be4c370d4338cf87c133f0b40 Mon Sep 17 00:00:00 2001 From: Mart Ratas Date: Mon, 29 Apr 2024 13:00:36 +0100 Subject: [PATCH] CU-8694dpy1c: Return empty generator upon empty stream (#423) * CU-8694dpy1c: Return empty generator upon empty stream * CU-8694dpy1c: Fix empty generator returns * CU-8694dpy1c: Simplify empty generator returns --- medcat/meta_cat.py | 3 ++- medcat/ner/transformers_ner.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/medcat/meta_cat.py b/medcat/meta_cat.py index bf7f09709..655bebfae 100644 --- a/medcat/meta_cat.py +++ b/medcat/meta_cat.py @@ -481,7 +481,8 @@ def pipe(self, stream: Iterable[Union[Doc, FakeDoc]], *args, **kwargs) -> Iterat """ # Just in case if stream is None or not stream: - return stream + # return an empty generator + return config = self.config id2category_value = {v: k for k, v in config.general['category_value2id'].items()} diff --git a/medcat/ner/transformers_ner.py b/medcat/ner/transformers_ner.py index 8f35c3792..1e08db293 100644 --- a/medcat/ner/transformers_ner.py +++ b/medcat/ner/transformers_ner.py @@ -359,7 +359,8 @@ def pipe(self, stream: Iterable[Union[Doc, None]], *args, **kwargs) -> Iterator[ """ # Just in case if stream is None or not stream: - return stream + # return an empty generator + return batch_size_chars = self.config.general['pipe_batch_size_in_chars'] yield from self._process(stream, batch_size_chars) # type: ignore