Skip to content

Commit 15bb02f

Browse files
committed
Fix edge cases of empty inputs for MTL
(cherry picked from commit f123d36) (cherry picked from commit 1fa9cac)
1 parent ea11f96 commit 15bb02f

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

hanlp/components/mtl/multi_task_learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def predict(self,
475475
A :class:`~hanlp_common.document.Document`.
476476
"""
477477
doc = Document()
478-
if not data:
478+
if not data or not any(data):
479479
return doc
480480

481481
target_tasks = resolved_tasks or self.resolve_tasks(tasks, skip_tasks)

hanlp/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Author: hankcs
33
# Date: 2019-12-28 19:26
44

5-
__version__ = '2.1.0-beta.22'
5+
__version__ = '2.1.0-beta.23'
66
"""HanLP version"""
77

88

tests/test_mtl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def test_mtl_empty_str(self):
2929
mtl([' '])
3030
mtl(['', ' '])
3131
mtl(['', ' ', 'good'])
32+
mtl([[]], skip_tasks='tok*')
3233

3334
def test_skip_tok(self):
3435
pre_tokenized_sents = [

0 commit comments

Comments
 (0)