From ae5caf584ad92bae77c438e96ebfdf4c9ff320d9 Mon Sep 17 00:00:00 2001 From: pangda Date: Wed, 11 Jan 2023 22:13:03 +0800 Subject: [PATCH] [to #42322933] add UT for adaseq span-based ner pipeline Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11398124 --- tests/pipelines/adaseq_pipelines/__init__.py | 0 .../test_named_entity_recognition.py | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/pipelines/adaseq_pipelines/__init__.py create mode 100644 tests/pipelines/adaseq_pipelines/test_named_entity_recognition.py diff --git a/tests/pipelines/adaseq_pipelines/__init__.py b/tests/pipelines/adaseq_pipelines/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/pipelines/adaseq_pipelines/test_named_entity_recognition.py b/tests/pipelines/adaseq_pipelines/test_named_entity_recognition.py new file mode 100644 index 00000000..4a0af955 --- /dev/null +++ b/tests/pipelines/adaseq_pipelines/test_named_entity_recognition.py @@ -0,0 +1,25 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +import os +import unittest + +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks +from modelscope.utils.demo_utils import DemoCompatibilityCheck +from modelscope.utils.test_utils import test_level + + +class NamedEntityRecognitionTest(unittest.TestCase, DemoCompatibilityCheck): + + def setUp(self): + os.system('pip install adaseq>=0.5.0') + + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') + def test_run_span_based_ner_pipeline(self): + pipeline_ins = pipeline( + Tasks.named_entity_recognition, + 'damo/nlp_nested-ner_named-entity-recognition_chinese-base-med') + print( + pipeline_ins( + '1、可测量目标: 1周内胸闷缓解。2、下一步诊疗措施:1.心内科护理常规,一级护理,低盐低脂饮食,留陪客。' + '2.予“阿司匹林肠溶片”抗血小板聚集,“呋塞米、螺内酯”利尿减轻心前负荷,“瑞舒伐他汀”调脂稳定斑块,“厄贝沙坦片片”降血压抗心机重构' + ))