add maoe unit test

This commit is contained in:
xuanjie.wxb
2023-03-07 15:24:37 +08:00
committed by pangda
parent 798aa93cba
commit ebb50d7887

View File

@@ -1,5 +1,4 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import os
import unittest
from modelscope.pipelines import pipeline
@@ -11,7 +10,11 @@ from modelscope.utils.test_utils import test_level
class NamedEntityRecognitionTest(unittest.TestCase, DemoCompatibilityCheck):
def setUp(self):
os.system('pip install adaseq>=0.5.0')
import subprocess
result = subprocess.run(
['pip', 'install', 'adaseq>=0.6.2', '--no-deps'],
stdout=subprocess.PIPE)
print(result.stdout.decode('utf-8'))
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_run_span_based_ner_pipeline(self):
@@ -23,3 +26,12 @@ class NamedEntityRecognitionTest(unittest.TestCase, DemoCompatibilityCheck):
'1、可测量目标 1周内胸闷缓解。2、下一步诊疗措施1.心内科护理常规,一级护理,低盐低脂饮食,留陪客。'
'2.予“阿司匹林肠溶片”抗血小板聚集,“呋塞米、螺内酯”利尿减轻心前负荷,“瑞舒伐他汀”调脂稳定斑块,“厄贝沙坦片片”降血压抗心机重构'
))
def test_maoe_pipelines(self):
pipeline_ins = pipeline(
Tasks.named_entity_recognition,
'damo/nlp_maoe_named-entity-recognition_chinese-base-general')
print(
pipeline_ins(
'刘培强生理年龄40岁因为在太空中进入休眠状态实际年龄52岁领航员国际空间站中的中国航天员机械工程专家军人军衔中校。'
))