mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 07:57:35 +03:00 
			
		
		
		
	Morphology: Use StringStore.items() to enumerate features when pickling
				
					
				
			This commit is contained in:
		
							parent
							
								
									d6237880b0
								
							
						
					
					
						commit
						1af9510ceb
					
				|  | @ -7,6 +7,7 @@ from libcpp.memory cimport shared_ptr | ||||||
| 
 | 
 | ||||||
| from .errors import Warnings | from .errors import Warnings | ||||||
| from . import symbols | from . import symbols | ||||||
|  | from .strings import get_string_id | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| cdef class Morphology: | cdef class Morphology: | ||||||
|  | @ -27,7 +28,7 @@ cdef class Morphology: | ||||||
|         self.strings = strings |         self.strings = strings | ||||||
| 
 | 
 | ||||||
|     def __reduce__(self): |     def __reduce__(self): | ||||||
|         tags = set([self.get(self.strings[s]) for s in self.strings]) |         tags = set([self.get(key) for key, _ in self.strings.items()]) | ||||||
|         tags -= set([""]) |         tags -= set([""]) | ||||||
|         return (unpickle_morphology, (self.strings, sorted(tags)), None, None) |         return (unpickle_morphology, (self.strings, sorted(tags)), None, None) | ||||||
| 
 | 
 | ||||||
|  | @ -99,7 +100,7 @@ cdef class Morphology: | ||||||
|             if features == "": |             if features == "": | ||||||
|                 features = self.EMPTY_MORPH |                 features = self.EMPTY_MORPH | ||||||
| 
 | 
 | ||||||
|             tag_hash = self.strings[features] |             tag_hash = get_string_id(features) | ||||||
|             tag = self._lookup_tag(tag_hash) |             tag = self._lookup_tag(tag_hash) | ||||||
|             if tag: |             if tag: | ||||||
|                 return deref(tag).key |                 return deref(tag).key | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user