From 5a2c542ce22829c356e46b0b922d53db4ba34c5e Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Tue, 3 Sep 2024 14:30:07 +0800 Subject: [PATCH] make term similarity robust (#2212) ### What problem does this PR solve? ### Type of change - [x] Performance Improvement --- rag/nlp/query.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rag/nlp/query.py b/rag/nlp/query.py index a8d2d0b59..81a4bc304 100644 --- a/rag/nlp/query.py +++ b/rag/nlp/query.py @@ -106,10 +106,9 @@ class EsQueryer: m) for m in sm] sm = [EsQueryer.subSpecialChar(m) for m in sm if len(m) > 1] sm = [m for m in sm if len(m) > 1] - if len(sm) < 2: - sm = [] keywords.append(re.sub(r"[ \\\"']+", "", tk)) + keywords.extend(sm) if len(keywords) >= 12: break tk_syns = self.syn.lookup(tk)