mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	* Add supersense data to Lexeme objects. Add simple has_sense method to check the flag.
This commit is contained in:
		
							parent
							
								
									64fafa98be
								
							
						
					
					
						commit
						e23d1582a2
					
				| 
						 | 
					@ -6,7 +6,7 @@ from murmurhash.mrmr cimport hash64
 | 
				
			||||||
from libc.string cimport memset
 | 
					from libc.string cimport memset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .orth cimport word_shape
 | 
					from .orth cimport word_shape
 | 
				
			||||||
from .typedefs cimport attr_t
 | 
					from .typedefs cimport attr_t, flags_t
 | 
				
			||||||
import numpy
 | 
					import numpy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,9 @@ cdef int set_lex_struct_props(LexemeC* lex, dict props, StringStore string_store
 | 
				
			||||||
    lex.sentiment = props['sentiment']
 | 
					    lex.sentiment = props['sentiment']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    lex.flags = props['flags']
 | 
					    lex.flags = props['flags']
 | 
				
			||||||
 | 
					    cdef flags_t sense_id
 | 
				
			||||||
 | 
					    for sense_id in props.get('senses', []):
 | 
				
			||||||
 | 
					        lex.senses |= 1 << sense_id
 | 
				
			||||||
    lex.repvec = empty_vec
 | 
					    lex.repvec = empty_vec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,3 +49,6 @@ cdef class Lexeme:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cpdef bint check(self, attr_id_t flag_id) except -1:
 | 
					    cpdef bint check(self, attr_id_t flag_id) except -1:
 | 
				
			||||||
        return self.flags & (1 << flag_id)
 | 
					        return self.flags & (1 << flag_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cpdef bint has_sense(self, flags_t flag_id) except -1:
 | 
				
			||||||
 | 
					        return self.senses & (1 << flag_id)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ cdef struct LexemeC:
 | 
				
			||||||
    const float* repvec
 | 
					    const float* repvec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    flags_t flags
 | 
					    flags_t flags
 | 
				
			||||||
 | 
					    flags_t senses
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    attr_t id
 | 
					    attr_t id
 | 
				
			||||||
    attr_t length
 | 
					    attr_t length
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user