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

Commit

Permalink
fix(scorer): fix np float conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 2, 2019
1 parent 2d6c70f commit a465825
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions gnes/indexer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion gnes/router/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a465825

Please sign in to comment.