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_loader.py 822 B

7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324
  1. import unittest
  2. from fastNLP.loader.dataset_loader import POSDatasetLoader
  3. class TestPreprocess(unittest.TestCase):
  4. def test_case_1(self):
  5. data = [[["Tom", "and", "Jerry", "."], ["T", "F", "T", "F"]],
  6. ["Hello", "world", "!"], ["T", "F", "F"]]
  7. pickle_path = "./data_for_tests/"
  8. # POSPreprocess(data, pickle_path)
  9. class TestDatasetLoader(unittest.TestCase):
  10. def test_case_1(self):
  11. data = """Tom\tT\nand\tF\nJerry\tT\n.\tF\n\nHello\tT\nworld\tF\n!\tF"""
  12. lines = data.split("\n")
  13. answer = POSDatasetLoader.parse(lines)
  14. truth = [[["Tom", "and", "Jerry", "."], ["T", "F", "T", "F"]], [["Hello", "world", "!"], ["T", "F", "F"]]]
  15. self.assertListEqual(answer, truth, "POS Dataset Loader")
  16. if __name__ == '__main__':
  17. unittest.main()

一款轻量级的自然语言处理(NLP)工具包,目标是减少用户项目中的工程型代码,例如数据处理循环、训练循环、多卡运行等