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_coreference.py 1.2 kB

123456789101112131415161718192021222324252627282930313233
  1. import unittest
  2. from fastNLP.io.pipe.coreference import CoReferencePipe
  3. class TestCR(unittest.TestCase):
  4. def test_load(self):
  5. class Config():
  6. max_sentences = 50
  7. filter = [3, 4, 5]
  8. char_path = None
  9. config = Config()
  10. file_root_path = "test/data_for_tests/io/coreference/"
  11. train_path = file_root_path + "coreference_train.json"
  12. dev_path = file_root_path + "coreference_dev.json"
  13. test_path = file_root_path + "coreference_test.json"
  14. paths = {"train": train_path, "dev": dev_path, "test": test_path}
  15. bundle1 = CoReferencePipe(config).process_from_file(paths)
  16. bundle2 = CoReferencePipe(config).process_from_file(file_root_path)
  17. print(bundle1)
  18. print(bundle2)
  19. self.assertEqual(bundle1.num_dataset, 3)
  20. self.assertEqual(bundle2.num_dataset, 3)
  21. self.assertEqual(bundle1.num_vocab, 1)
  22. self.assertEqual(bundle2.num_vocab, 1)
  23. self.assertEqual(len(bundle1.get_dataset('train')), 1)
  24. self.assertEqual(len(bundle1.get_dataset('dev')), 1)
  25. self.assertEqual(len(bundle1.get_dataset('test')), 1)
  26. self.assertEqual(len(bundle1.get_vocab('words1')), 84)