hackersgame commited on
Commit
928e26f
·
verified ·
1 Parent(s): 527d48d

Upload fle.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. fle.py +2 -2
fle.py CHANGED
@@ -50,11 +50,11 @@ class FLE:
50
  return [(self.words[i], float(sims[i])) for i in top]
51
 
52
  def analogy(self, a, b, c, n=5):
53
- """a is to b as c is to ? (b - a + c)"""
54
  for w in [a, b, c]:
55
  if w not in self.word2id:
56
  return []
57
- vec = self.normed[self.word2id[b]] - self.normed[self.word2id[a]] + self.normed[self.word2id[c]]
58
  vec = vec / (np.linalg.norm(vec) + 1e-8)
59
  sims = self.normed @ vec
60
  for w in [a, b, c]:
 
50
  return [(self.words[i], float(sims[i])) for i in top]
51
 
52
  def analogy(self, a, b, c, n=5):
53
+ """a is to b as c is to ? (a - b + c)"""
54
  for w in [a, b, c]:
55
  if w not in self.word2id:
56
  return []
57
+ vec = self.normed[self.word2id[a]] - self.normed[self.word2id[b]] + self.normed[self.word2id[c]]
58
  vec = vec / (np.linalg.norm(vec) + 1e-8)
59
  sims = self.normed @ vec
60
  for w in [a, b, c]: