mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	* Ensure morphological features and lemmas are loaded in from_array, re Issue #152
This commit is contained in:
		
							parent
							
								
									64531d5a3a
								
							
						
					
					
						commit
						5e040855a5
					
				|  | @ -38,3 +38,15 @@ def test_left_right(EN): | |||
|         for child in word.rights: | ||||
|             assert child.head.i == word.i | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.models | ||||
| def test_lemmas(EN): | ||||
|     orig = EN(u'The geese are flying') | ||||
|     result = Doc(orig.vocab).from_bytes(orig.to_bytes()) | ||||
|     the, geese, are, flying = result | ||||
|     assert the.lemma_ == 'the' | ||||
|     assert geese.lemma_ == 'goose' | ||||
|     assert are.lemma_ == 'be' | ||||
|     assert flying.lemma_ == 'fly' | ||||
| 
 | ||||
|   | ||||
|  |  | |||
|  | @ -398,7 +398,7 @@ cdef class Doc: | |||
|                         self.is_parsed = True | ||||
|             elif attr_id == TAG: | ||||
|                 for i in range(length): | ||||
|                     tokens[i].tag = values[i] | ||||
|                     self.vocab.morphology.assign_tag(&tokens[i], values[i]) | ||||
|                     if not self.is_tagged and tokens[i].tag != 0: | ||||
|                         self.is_tagged = True | ||||
|             elif attr_id == POS: | ||||
|  | @ -413,6 +413,8 @@ cdef class Doc: | |||
|             elif attr_id == ENT_TYPE: | ||||
|                 for i in range(length): | ||||
|                     tokens[i].ent_type = values[i] | ||||
|             else: | ||||
|                 raise ValueError("Unknown attribute ID: %d" % attr_id) | ||||
|         set_children_from_heads(self.data, self.length) | ||||
|         return self | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user