Skip to content
Permalink
Browse files

feat(chunk scorer): add offset divergence

  • Loading branch information...
jemmyshin committed Aug 30, 2019
1 parent 64cea23 commit 8cdcb7e8a079aa0c8234f24baecce552a75b4a26
Showing with 24 additions and 24 deletions.
  1. +24 −24 gnes/indexer/base.py
@@ -128,30 +128,6 @@ def eq1(q_chunk: 'gnes_pb2.Chunk', d_chunk: 'gnes_pb2.Chunk',
})
return score


class DocScorer:

@staticmethod
def eq1(d: 'gnes_pb2.Document',
s: 'gnes_pb2.Response.QueryResponse.ScoredResult.Score') -> 'gnes_pb2.Response.QueryResponse.ScoredResult.Score':
"""
score *= d.weight
:param d:
:param s:
:return:
"""
s.value *= d.weight
s.explained = json.dumps({
'name': 'doc-eq1',
'operand': [json.loads(s.explained),
{'name': 'doc_weight',
'value': d.weight,
'doc_id': d.doc_id}],
'op': 'prod',
'value': s.value
})
return s

@staticmethod
def eq2(q_chunk: 'gnes_pb2.Chunk', d_chunk: 'gnes_pb2.Chunk',
relevance):
@@ -192,6 +168,30 @@ def _cal_divergence(q_chunk: 'gnes_pb2.Chunk', d_chunk: 'gnes_pb2.Chunk'):
return score


class DocScorer:

@staticmethod
def eq1(d: 'gnes_pb2.Document',
s: 'gnes_pb2.Response.QueryResponse.ScoredResult.Score') -> 'gnes_pb2.Response.QueryResponse.ScoredResult.Score':
"""
score *= d.weight
:param d:
:param s:
:return:
"""
s.value *= d.weight
s.explained = json.dumps({
'name': 'doc-eq1',
'operand': [json.loads(s.explained),
{'name': 'doc_weight',
'value': d.weight,
'doc_id': d.doc_id}],
'op': 'prod',
'value': s.value
})
return s


class JointIndexer(CompositionalTrainableBase):

@property

0 comments on commit 8cdcb7e

Please sign in to comment.
You can’t perform that action at this time.