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_dataset_loader.py 1.0 kB

123456789101112131415161718192021222324252627282930
  1. import unittest
  2. from fastNLP.io import Conll2003Loader, PeopleDailyCorpusLoader, CSVLoader, SNLILoader, JsonLoader
  3. class TestDatasetLoader(unittest.TestCase):
  4. def test_Conll2003Loader(self):
  5. """
  6. Test the the loader of Conll2003 dataset
  7. """
  8. dataset_path = "../data_for_tests/conll_2003_example.txt"
  9. loader = Conll2003Loader()
  10. dataset_2003 = loader.load(dataset_path)
  11. def test_PeopleDailyCorpusLoader(self):
  12. data_set = PeopleDailyCorpusLoader().load("../data_for_tests/people_daily_raw.txt")
  13. def test_CSVLoader(self):
  14. ds = CSVLoader(sep='\t', headers=['words', 'label']) \
  15. .load('../data_for_tests/tutorial_sample_dataset.csv')
  16. assert len(ds) > 0
  17. def test_SNLILoader(self):
  18. ds = SNLILoader().load('../data_for_tests/sample_snli.jsonl')
  19. assert len(ds) == 3
  20. def test_JsonLoader(self):
  21. ds = JsonLoader().load('../data_for_tests/sample_snli.jsonl')
  22. assert len(ds) == 3