Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
feat(scorefn): add offset tfidf bm25 qureycoord
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Sep 12, 2019
1 parent e024594 commit b5e10bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions gnes/indexer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def __init__(self,
:type is_big_score_similar: when set to true, then larger score means more similar
"""
super().__init__(*args, **kwargs)
self.normalize_fn = normalize_fn(context=self) if normalize_fn else ModifierScoreFn(context=self)
self.score_fn = score_fn(context=self) if score_fn else ModifierScoreFn(context=self)
self.normalize_fn = normalize_fn if normalize_fn else ModifierScoreFn(context=self)
self.score_fn = score_fn if score_fn else ModifierScoreFn(context=self)
self.normalize_fn._context = self
self.score_fn._context = self
self.is_big_score_similar = is_big_score_similar
self._num_docs = 0
self._num_chunks = 0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_score_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_combine_score_fn(self):
q_chunk.embedding.CopyFrom(array2blob(np.array([3, 3, 3])))

for _fn in [WeightedChunkOffsetScoreFn, CoordChunkScoreFn, TFIDFChunkScoreFn, BM25ChunkScoreFn]:
indexer = NumpyIndexer(helper_indexer=ListKeyIndexer(), score_fn=_fn)
indexer = NumpyIndexer(helper_indexer=ListKeyIndexer(), score_fn=_fn())
indexer.add(keys=[(0, 1), (1, 2)], vectors=np.array([[1, 1, 1], [2, 2, 2]]), weights=[0.5, 0.8])
queried_result = indexer.query_and_score(q_chunks=[q_chunk], top_k=2)

Expand Down

0 comments on commit b5e10bc

Please sign in to comment.