Kevin Hu
commited on
Commit
·
3828585
1
Parent(s):
2ccd8d5
Fix potential error. (#4650)
Browse files### What problem does this PR solve?
#4622
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- rag/nlp/search.py +2 -2
rag/nlp/search.py
CHANGED
@@ -465,7 +465,7 @@ class Dealer:
|
|
465 |
if not aggs:
|
466 |
return False
|
467 |
cnt = np.sum([c for _, c in aggs])
|
468 |
-
tag_fea = sorted([(a, round(0.1*(c + 1) / (cnt + S) / (all_tags.get(a, 0.0001)))) for a, c in aggs],
|
469 |
key=lambda x: x[1] * -1)[:topn_tags]
|
470 |
doc[TAG_FLD] = {a: c for a, c in tag_fea if c > 0}
|
471 |
return True
|
@@ -481,6 +481,6 @@ class Dealer:
|
|
481 |
if not aggs:
|
482 |
return {}
|
483 |
cnt = np.sum([c for _, c in aggs])
|
484 |
-
tag_fea = sorted([(a, round(0.1*(c + 1) / (cnt + S) / (all_tags.get(a, 0.0001)))) for a, c in aggs],
|
485 |
key=lambda x: x[1] * -1)[:topn_tags]
|
486 |
return {a: max(1, c) for a, c in tag_fea}
|
|
|
465 |
if not aggs:
|
466 |
return False
|
467 |
cnt = np.sum([c for _, c in aggs])
|
468 |
+
tag_fea = sorted([(a, round(0.1*(c + 1) / (cnt + S) / max(1e-6, all_tags.get(a, 0.0001)))) for a, c in aggs],
|
469 |
key=lambda x: x[1] * -1)[:topn_tags]
|
470 |
doc[TAG_FLD] = {a: c for a, c in tag_fea if c > 0}
|
471 |
return True
|
|
|
481 |
if not aggs:
|
482 |
return {}
|
483 |
cnt = np.sum([c for _, c in aggs])
|
484 |
+
tag_fea = sorted([(a, round(0.1*(c + 1) / (cnt + S) / max(1e-6, all_tags.get(a, 0.0001)))) for a, c in aggs],
|
485 |
key=lambda x: x[1] * -1)[:topn_tags]
|
486 |
return {a: max(1, c) for a, c in tag_fea}
|