From c889ef636378b8af43427665ee1fbd1505b9c4e1 Mon Sep 17 00:00:00 2001 From: KevinHuSh Date: Mon, 8 Jul 2024 17:40:50 +0800 Subject: [PATCH] examples empty in categorize (#1422) ### What problem does this PR solve? Examples empty in categorize ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- graph/component/categorize.py | 2 +- rag/nlp/term_weight.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graph/component/categorize.py b/graph/component/categorize.py index d18cab6fd..c9ef19164 100644 --- a/graph/component/categorize.py +++ b/graph/component/categorize.py @@ -43,7 +43,7 @@ class CategorizeParam(GenerateParam): def get_prompt(self): cate_lines = [] for c, desc in self.category_description.items(): - for l in desc["examples"].split("\n"): + for l in desc.get("examples", "").split("\n"): if not l: continue cate_lines.append("Question: {}\tCategory: {}".format(l, c)) descriptions = [] diff --git a/rag/nlp/term_weight.py b/rag/nlp/term_weight.py index 720087acc..34765feaf 100644 --- a/rag/nlp/term_weight.py +++ b/rag/nlp/term_weight.py @@ -107,7 +107,7 @@ class Dealer: if re.match(p, t): tk = "#" break - tk = re.sub(r"([\+\\-])", r"\\\1", tk) + #tk = re.sub(r"([\+\\-])", r"\\\1", tk) if tk != "#" and tk: res.append(tk) return res