code: def analogy(self, pos, neg, n=10, metric="cosine"):
          
          exclude = pos + neg
          pos = [(word, 1.0) for word in pos]
          neg = [(word, -1.0) for word in neg]
  
          mean = []
          for word, direction in pos + neg:
              mean.append(direction * self[word])
          mean = np.array(mean).mean(axis=0)
  
          metrics = distance(self.vectors, mean, metric=metric)
          best = metrics.argsort()[::-1][:n + len(exclude)]
  
          exclude_idx = [np.where(best == self.ix(word)) for word in exclude if self.ix(word) in best]
          new_best = np.delete(best, exclude_idx)
          best_metrics = metrics[new_best]
          return new_best[:n], best_metrics[:n]
docs: Analogy similarity.
  
          Parameters
          ----------
          pos : list
          neg : list
  
          Returns
          -------
          Tuple of 2 numpy.array:
              1. position in self.vocab
              2. cosine similarity
  
          Example
          -------
              `king - man + woman = queen` will be: `pos=['king', 'woman'], neg=['man']`