You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_domain_classification.py 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import unittest
  3. from modelscope.pipelines import pipeline
  4. from modelscope.utils.constant import Tasks
  5. from modelscope.utils.demo_utils import DemoCompatibilityCheck
  6. from modelscope.utils.test_utils import test_level
  7. class DomainClassificationTest(unittest.TestCase, DemoCompatibilityCheck):
  8. def setUp(self) -> None:
  9. self.task = Tasks.text_classification
  10. self.model_id = 'damo/nlp_domain_classification_chinese'
  11. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  12. def test_run_with_model_name_for_zh_domain(self):
  13. inputs = '通过这种方式产生的离子吸收大地水分之后,可以通过潮解作用,将活性电解离子有效释放到周围土壤中,使接地极成为一个离子发生装置,' \
  14. '从而改善周边土质使之达到接地要求。'
  15. pipeline_ins = pipeline(self.task, model=self.model_id)
  16. print(pipeline_ins(input=inputs))
  17. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  18. def test_run_with_model_name_for_zh_style(self):
  19. model_id = 'damo/nlp_style_classification_chinese'
  20. inputs = '通过这种方式产生的离子吸收大地水分之后,可以通过潮解作用,将活性电解离子有效释放到周围土壤中,使接地极成为一个离子发生装置,' \
  21. '从而改善周边土质使之达到接地要求。'
  22. pipeline_ins = pipeline(self.task, model=model_id)
  23. print(pipeline_ins(input=inputs))
  24. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  25. def test_run_with_model_name_for_en_style(self):
  26. model_id = 'damo/nlp_style_classification_english'
  27. inputs = 'High Power 11.1V 5200mAh Lipo Battery For RC Car Robot Airplanes ' \
  28. 'Helicopter RC Drone Parts 3s Lithium battery 11.1v Battery'
  29. pipeline_ins = pipeline(self.task, model=model_id)
  30. print(pipeline_ins(input=inputs))
  31. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  32. def test_demo_compatibility(self):
  33. self.compatibility_check()
  34. if __name__ == '__main__':
  35. unittest.main()