Browse Source

add fitlog and spacy while testing

tags/v0.4.10
Yige Xu 5 years ago
parent
commit
cccc1bfd57
2 changed files with 36 additions and 0 deletions
  1. +2
    -0
      .travis.yml
  2. +34
    -0
      test/io/pipe/test_matching.py

+ 2
- 0
.travis.yml View File

@@ -4,10 +4,12 @@ python:
# command to install dependencies # command to install dependencies
install: install:
- pip install --quiet -r requirements.txt - pip install --quiet -r requirements.txt
- pip install --quiet fitlog
- pip install pytest>=3.6 - pip install pytest>=3.6
- pip install pytest-cov - pip install pytest-cov
# command to run tests # command to run tests
script: script:
- python -m spacy download en
- pytest --cov=fastNLP test/ - pytest --cov=fastNLP test/


after_success: after_success:


+ 34
- 0
test/io/pipe/test_matching.py View File

@@ -72,3 +72,37 @@ class TestRunMatchingPipe(unittest.TestCase):
for x, y in zip(vocab, data_bundle1.iter_vocabs()): for x, y in zip(vocab, data_bundle1.iter_vocabs()):
name, vocabs = y name, vocabs = y
self.assertEqual(x + 1 if name == 'words' else x, len(vocabs)) self.assertEqual(x + 1 if name == 'words' else x, len(vocabs))

def test_spacy(self):
data_set_dict = {
'RTE': ('test/data_for_tests/io/RTE', RTEPipe, RTEBertPipe, (5, 5, 5), (425, 2)),
}
for k, v in data_set_dict.items():
path, pipe1, pipe2, data_set, vocab = v

with self.assertWarns(Warning):
data_bundle1 = pipe1(tokenizer='spacy').process_from_file(path)
data_bundle2 = pipe2(tokenizer='spacy').process_from_file(path)

self.assertTrue(isinstance(data_bundle1, DataBundle))
self.assertEqual(len(data_set), data_bundle1.num_dataset)
print(k)
print(data_bundle1)
print(data_bundle2)
for x, y in zip(data_set, data_bundle1.iter_datasets()):
name, dataset = y
self.assertEqual(x, len(dataset))
self.assertEqual(len(data_set), data_bundle2.num_dataset)
for x, y in zip(data_set, data_bundle2.iter_datasets()):
name, dataset = y
self.assertEqual(x, len(dataset))

self.assertEqual(len(vocab), data_bundle1.num_vocab)
for x, y in zip(vocab, data_bundle1.iter_vocabs()):
name, vocabs = y
self.assertEqual(x, len(vocabs))
self.assertEqual(len(vocab), data_bundle2.num_vocab)
for x, y in zip(vocab, data_bundle1.iter_vocabs()):
name, vocabs = y
self.assertEqual(x + 1 if name == 'words' else x, len(vocabs))


Loading…
Cancel
Save