@@ -143,7 +143,8 @@ def get_word_vectors(self, words_or_indices: Union[list, tuple], normalized: boo
143143
144144 return self .wv .get_word_vectors (words_or_indices , normalized = normalized , raise_exc = raise_exc ).tolist ()
145145
146- def get_distance (self , word_or_index1 : Union [str , int ], word_or_index2 : Union [str , int ], metric : Union [str , None ]= None , raise_exc : bool = False ) -> float :
146+ def get_distance (self , word_or_index1 : Union [str , int ], word_or_index2 : Union [str , int ], metric : Union [str , None ]= None , \
147+ raise_exc : bool = False ) -> float :
147148 '''
148149 Get cosine distance between two words
149150
@@ -156,7 +157,8 @@ def get_distance(self, word_or_index1: Union[str, int], word_or_index2: Union[st
156157
157158 return self .wv .get_distance (word_or_index1 , word_or_index2 , raise_exc = raise_exc )
158159
159- def get_distances (self , row_words_or_indices : Union [str , int , tuple , list ], col_words_or_indices : Union [list , None ]= None , metric : Union [str , None ]= None , raise_exc : bool = False ) -> list :
160+ def get_distances (self , row_words_or_indices : Union [str , int , tuple , list ], col_words_or_indices : Union [list , None ]= None , \
161+ metric : Union [str , None ]= None , raise_exc : bool = False ) -> list :
160162 '''
161163 Get distances between given words and all words in the vector space
162164
@@ -177,16 +179,16 @@ def get_distances(self, row_words_or_indices: Union[str, int, tuple, list], col_
177179
178180 return self .wv .get_distances (row_words_or_indices , col_words_or_indices = col_words_or_indices , raise_exc = raise_exc ).tolist ()
179181
180- def get_nearest (self , words_or_indices : Union [str , int , list , tuple ], k : int = 512 , metric : Union [str , None ]= None , combination : bool = False , raise_exc : bool = False ) -> list :
182+ def get_nearest (self , words_or_indices : Union [str , int , list , tuple ], k : int = 512 , metric : Union [str , None ]= None , \
183+ combination : bool = False , raise_exc : bool = False ) -> list :
181184 '''
182185 get_nearest_neighbors("india", 20) => [509, 3389, 486, 523, 7125, 16619, 4491, 12191, 6866, 8776, 15232, 14208, 5998, 21916, 5226, 6322, 4343, 6212, 10172, 6186]
183186 get_nearest(["ram", "india"], 5, metric='euclidean') => [[3844, 16727, 15811, 42731, 41516], [509, 3389, 486, 523, 7125]]
184187 get_nearest(['india', 'bosnia'], 10, combination=True) => [523, 509, 486]
185188 '''
186189
187190 if self ._type == 'mem' or 'disk' :
188- neg = self .wv .get_nearest (
189- words_or_indices , k , raise_exc = raise_exc , metric = metric )
191+ neg = self .wv .get_nearest (words_or_indices , k , raise_exc = raise_exc , metric = metric )
190192
191193 if isinstance (words_or_indices , (tuple , list )) and len (words_or_indices ) > 1 :
192194 for neg_key , item in enumerate (neg ):
0 commit comments