Quellcode durchsuchen

Fix potential error. (#4650)

### What problem does this PR solve?
#4622

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.16.0
Kevin Hu vor 9 Monaten
Ursprung
Commit
4011c8f68c
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen
  1. 2
    2
      rag/nlp/search.py

+ 2
- 2
rag/nlp/search.py Datei anzeigen

@@ -465,7 +465,7 @@ class Dealer:
if not aggs:
return False
cnt = np.sum([c for _, c in aggs])
tag_fea = sorted([(a, round(0.1*(c + 1) / (cnt + S) / (all_tags.get(a, 0.0001)))) for a, c in aggs],
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],
key=lambda x: x[1] * -1)[:topn_tags]
doc[TAG_FLD] = {a: c for a, c in tag_fea if c > 0}
return True
@@ -481,6 +481,6 @@ class Dealer:
if not aggs:
return {}
cnt = np.sum([c for _, c in aggs])
tag_fea = sorted([(a, round(0.1*(c + 1) / (cnt + S) / (all_tags.get(a, 0.0001)))) for a, c in aggs],
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],
key=lambda x: x[1] * -1)[:topn_tags]
return {a: max(1, c) for a, c in tag_fea}

Laden…
Abbrechen
Speichern