mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	fix compile errors
This commit is contained in:
		
							parent
							
								
									27483f9080
								
							
						
					
					
						commit
						f77b99c103
					
				| 
						 | 
					@ -67,8 +67,8 @@ cdef class KnowledgeBase:
 | 
				
			||||||
    # efficient.
 | 
					    # efficient.
 | 
				
			||||||
    cdef object _aliases_table
 | 
					    cdef object _aliases_table
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cdef void c_add_entity(self, hash_t key, float prob, const int32_t* vector_rows,
 | 
					    cdef inline int64_t c_add_entity(self, hash_t key, float prob, const int32_t* vector_rows,
 | 
				
			||||||
                    int feats_row) nogil:
 | 
					                    int feats_row):
 | 
				
			||||||
        """Add an entry to the knowledge base."""
 | 
					        """Add an entry to the knowledge base."""
 | 
				
			||||||
        # This is what we'll map the hash key to. It's where the entry will sit
 | 
					        # This is what we'll map the hash key to. It's where the entry will sit
 | 
				
			||||||
        # in the vector of entries, so we can get it later.
 | 
					        # in the vector of entries, so we can get it later.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										12
									
								
								spacy/kb.pyx
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								spacy/kb.pyx
									
									
									
									
									
								
							| 
						 | 
					@ -11,17 +11,21 @@ cdef class KnowledgeBase:
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cdef hash_t name_hash = hash_string(name)
 | 
					        cdef hash_t name_hash = hash_string(name)
 | 
				
			||||||
        self.c_add_entity(name_hash, prob, self._vectors_table.get_pointer(vectors),
 | 
					        cdef int32_t dummy_value = 342
 | 
				
			||||||
                   self._features_table.get(features))
 | 
					        self.c_add_entity(name_hash, prob, &dummy_value, dummy_value)
 | 
				
			||||||
 | 
					        # TODO self._vectors_table.get_pointer(vectors),
 | 
				
			||||||
 | 
					        #  self._features_table.get(features))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def add_alias(self, alias, entities, probabilities):
 | 
					    def add_alias(self, alias, entities, probabilities):
 | 
				
			||||||
        """For a given alias, add its potential entities and prior probabilies to the KB."""
 | 
					        """For a given alias, add its potential entities and prior probabilies to the KB."""
 | 
				
			||||||
        cdef hash_t alias_hash = hash_string(alias)
 | 
					        cdef hash_t alias_hash = hash_string(alias)
 | 
				
			||||||
 | 
					        cdef hash_t entity_hash = 0
 | 
				
			||||||
 | 
					        cdef int64_t entity_index = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # TODO: check len(entities) == len(probabilities)
 | 
					        # TODO: check len(entities) == len(probabilities)
 | 
				
			||||||
        for entity, prob in zip(entities, probabilities):
 | 
					        for entity, prob in zip(entities, probabilities):
 | 
				
			||||||
            cdef hash_t entity_hash = hash_string(entity)
 | 
					            entity_hash = hash_string(entity)
 | 
				
			||||||
            cdef int64_t entity_index = self._index[entity_hash]
 | 
					            entity_index = self._index[entity_hash]
 | 
				
			||||||
            # TODO: check that entity is already in this KB (entity_index is OK)
 | 
					            # TODO: check that entity is already in this KB (entity_index is OK)
 | 
				
			||||||
            self._aliases_table.add(alias_hash, entity_index, prob)
 | 
					            self._aliases_table.add(alias_hash, entity_index, prob)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user