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

123456789101112131415161718192021222324252627282930
  1. import unittest
  2. import os
  3. from fastNLP.io.pipe.classification import SSTPipe, SST2Pipe, IMDBPipe, YelpFullPipe, YelpPolarityPipe
  4. from fastNLP.io.pipe.classification import ChnSentiCorpPipe
  5. @unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
  6. class TestClassificationPipe(unittest.TestCase):
  7. def test_process_from_file(self):
  8. for pipe in [YelpPolarityPipe, SST2Pipe, IMDBPipe, YelpFullPipe, SSTPipe]:
  9. with self.subTest(pipe=pipe):
  10. print(pipe)
  11. data_bundle = pipe(tokenizer='raw').process_from_file()
  12. print(data_bundle)
  13. class TestRunPipe(unittest.TestCase):
  14. def test_load(self):
  15. for pipe in [IMDBPipe]:
  16. data_bundle = pipe(tokenizer='raw').process_from_file('test/data_for_tests/io/imdb')
  17. print(data_bundle)
  18. @unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
  19. class TestCNClassificationPipe(unittest.TestCase):
  20. def test_process_from_file(self):
  21. for pipe in [ChnSentiCorpPipe]:
  22. with self.subTest(pipe=pipe):
  23. data_bundle = pipe(bigrams=True, trigrams=True).process_from_file()
  24. print(data_bundle)