mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	Draft tests for new Example class
This commit is contained in:
		
							parent
							
								
									c833ebe1ad
								
							
						
					
					
						commit
						f1189dc205
					
				|  | @ -4,12 +4,8 @@ from spacy.tokens import Doc | |||
| from spacy.vocab import Vocab | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture | ||||
| def vocab(): | ||||
|     return Vocab() | ||||
| 
 | ||||
| 
 | ||||
| def test_Example_init_requires_doc_objects(vocab): | ||||
| def test_Example_init_requires_doc_objects(): | ||||
|     vocab = Vocab() | ||||
|     with pytest.raises(TypeError): | ||||
|         eg = Example(None, None) | ||||
|     with pytest.raises(TypeError): | ||||
|  | @ -19,12 +15,50 @@ def test_Example_init_requires_doc_objects(vocab): | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| def test_Example_from_dict(vocab): | ||||
| def test_Example_from_dict_basic(): | ||||
|     eg = Example.from_dict( | ||||
|         Doc(vocab, words=["hello", "world"]), | ||||
|         Doc(Vocab(), words=["hello", "world"]), | ||||
|         { | ||||
|             "words": ["hello", "world"] | ||||
|         } | ||||
|     ) | ||||
|     assert isinstance(eg.x, Doc) | ||||
|     assert isinstance(eg.y, Doc) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize("annots", [ | ||||
|     {"words": ["ice", "cream"], "tags": ["NN", "NN"]}, | ||||
| ]) | ||||
| def test_Example_from_dict_with_tags(annots): | ||||
|     vocab = Vocab() | ||||
|     predicted = Doc(vocab, words=annots["words"]) | ||||
|     eg = Example.from_dict(predicted, annots) | ||||
|     for i, token in enumerate(eg.reference): | ||||
|         assert token.tag_ == annots["tags"][i] | ||||
| 
 | ||||
| 
 | ||||
| """ | ||||
| def test_Example_from_dict_with_entities(vocab): | ||||
|     # TODO | ||||
|     pass | ||||
| 
 | ||||
| def test_Example_from_dict_with_parse(vocab): | ||||
|     # TODO | ||||
|     pass | ||||
| 
 | ||||
| def test_Example_from_dict_with_morphology(vocab): | ||||
|     # TODO | ||||
|     pass | ||||
| 
 | ||||
| def test_Example_from_dict_with_sent_start(vocab): | ||||
|     # TODO | ||||
|     pass | ||||
| 
 | ||||
| def test_Example_from_dict_with_cats(vocab): | ||||
|     # TODO | ||||
|     pass | ||||
| 
 | ||||
| def test_Example_from_dict_with_links(vocab): | ||||
|     # TODO | ||||
|     pass | ||||
| """ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user