mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 07:57:35 +03:00 
			
		
		
		
	Add test for morph analysis
This commit is contained in:
		
							parent
							
								
									3300e3d7ab
								
							
						
					
					
						commit
						3c32590243
					
				
							
								
								
									
										30
									
								
								spacy/tests/doc/test_morphanalysis.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								spacy/tests/doc/test_morphanalysis.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| # coding: utf-8 | ||||
| from __future__ import unicode_literals | ||||
| 
 | ||||
| import pytest | ||||
| import numpy | ||||
| from spacy.attrs import IS_ALPHA, IS_DIGIT, IS_LOWER, IS_PUNCT, IS_TITLE, IS_STOP | ||||
| from spacy.symbols import VERB | ||||
| from spacy.vocab import Vocab | ||||
| from spacy.tokens import Doc | ||||
| 
 | ||||
| @pytest.fixture | ||||
| def i_has(en_tokenizer): | ||||
|     doc = en_tokenizer("I has") | ||||
|     doc[0].tag_ = "PRP" | ||||
|     doc[1].tag_ = "VBZ" | ||||
|     return doc | ||||
| 
 | ||||
| def test_token_morph_id(i_has): | ||||
|     assert i_has[0].morph.id | ||||
|     assert i_has[1].morph.id != 0 | ||||
|     assert i_has[0].morph.id != i_has[1].morph.id | ||||
| 
 | ||||
| def test_morph_props(i_has): | ||||
|     assert i_has[0].morph.pron_type == i_has.vocab.strings["PronType_prs"] | ||||
|     assert i_has[1].morph.pron_type == 0 | ||||
| 
 | ||||
| 
 | ||||
| def test_morph_iter(i_has): | ||||
|     assert list(i_has[0].morph) == ["PronType_prs"] | ||||
|     assert list(i_has[1].morph) == ["Number_sing", "Person_three", "VerbForm_fin"] | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user