Skip to content
Permalink
Browse files

fix(scorer): fix np float conversion

  • Loading branch information...
hanxiao committed Sep 2, 2019
1 parent 2d6c70f commit a46582508727c0247cf855fd6d88a1279e6ed05f
Showing with 12 additions and 12 deletions.
  1. +11 −11 gnes/indexer/base.py
  2. +1 −1 gnes/router/base.py
@@ -115,16 +115,16 @@ def eq1(q_chunk: 'gnes_pb2.Chunk', d_chunk: 'gnes_pb2.Chunk',
score.explained = json.dumps({
'name': 'chunk-eq1',
'operand': [{'name': 'd_chunk_weight',
'value': d_chunk.weight,
'value': float(d_chunk.weight),
'doc_id': d_chunk.doc_id,
'offset': d_chunk.offset},
{'name': 'q_chunk_weight',
'value': q_chunk.weight,
'value': float(q_chunk.weight),
'offset': q_chunk.offset},
{'name': 'relevance',
'value': relevance}],
'value': float(relevance)}],
'op': 'prod',
'value': score.value
'value': float(score.value)
})
return score

@@ -152,18 +152,18 @@ def _cal_divergence(q_chunk: 'gnes_pb2.Chunk', d_chunk: 'gnes_pb2.Chunk'):
score.explained = json.dumps({
'name': 'chunk-eq2',
'operand': [{'name': 'd_chunk_weight',
'value': d_chunk.weight,
'value': float(d_chunk.weight),
'doc_id': d_chunk.doc_id,
'offset': d_chunk.offset},
{'name': 'q_chunk_weight',
'value': q_chunk.weight,
'value': float(q_chunk.weight),
'offset': q_chunk.offset},
{'name': 'relevance',
'value': relevance},
'value': float(relevance)},
{'name': 'offset_divergence',
'value': divergence}],
'value': float(divergence)}],
'op': 'prod',
'value': score.value
'value': float(score.value)
})
return score

@@ -184,10 +184,10 @@ def eq1(d: 'gnes_pb2.Document',
'name': 'doc-eq1',
'operand': [json.loads(s.explained),
{'name': 'doc_weight',
'value': d.weight,
'value': float(d.weight),
'doc_id': d.doc_id}],
'op': 'prod',
'value': s.value
'value': float(s.value)
})
return s

@@ -107,7 +107,7 @@ def apply(self, msg: 'gnes_pb2.Message', accum_msgs: List['gnes_pb2.Message'], *
'name': 'topk-reduce',
'op': self._reduce_op,
'operand': [json.loads(vv) for vv in v['explains']],
'value': r.score.value
'value': float(r.score.value)
})
self.set_key(r, k)

0 comments on commit a465825

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