From b1a46d5adcf855e4b60ef8014e68e0e97e2dfc97 Mon Sep 17 00:00:00 2001 From: donblack01 Date: Mon, 10 Mar 2025 10:13:11 +0800 Subject: [PATCH] =?UTF-8?q?Fix:when=20start=20with=20=20source=20code=20no?= =?UTF-8?q?t=20in=20docker=20env=20report=20'UnicodeDec=E2=80=A6=20(#5802)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? fix:when start with  source code not in docker env report "UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 5: illegal multibyte sequence" in windows ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: tangyu <1@1.com> --- api/db/init_data.py | 2 +- deepdoc/parser/resume/entities/corporations.py | 6 +++--- deepdoc/parser/resume/entities/schools.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/db/init_data.py b/api/db/init_data.py index 365256bdf..506377c47 100644 --- a/api/db/init_data.py +++ b/api/db/init_data.py @@ -160,7 +160,7 @@ def add_graph_templates(): dir = os.path.join(get_project_base_directory(), "agent", "templates") for fnm in os.listdir(dir): try: - cnvs = json.load(open(os.path.join(dir, fnm), "r")) + cnvs = json.load(open(os.path.join(dir, fnm), "r",encoding="utf-8")) try: CanvasTemplateService.save(**cnvs) except Exception: diff --git a/deepdoc/parser/resume/entities/corporations.py b/deepdoc/parser/resume/entities/corporations.py index a52bfa14a..43793668d 100644 --- a/deepdoc/parser/resume/entities/corporations.py +++ b/deepdoc/parser/resume/entities/corporations.py @@ -30,10 +30,10 @@ GOODS = pd.read_csv( GOODS["cid"] = GOODS["cid"].astype(str) GOODS = GOODS.set_index(["cid"]) CORP_TKS = json.load( - open(os.path.join(current_file_path, "res/corp.tks.freq.json"), "r") + open(os.path.join(current_file_path, "res/corp.tks.freq.json"), "r",encoding="utf-8") ) -GOOD_CORP = json.load(open(os.path.join(current_file_path, "res/good_corp.json"), "r")) -CORP_TAG = json.load(open(os.path.join(current_file_path, "res/corp_tag.json"), "r")) +GOOD_CORP = json.load(open(os.path.join(current_file_path, "res/good_corp.json"), "r",encoding="utf-8")) +CORP_TAG = json.load(open(os.path.join(current_file_path, "res/corp_tag.json"), "r",encoding="utf-8")) def baike(cid, default_v=0): diff --git a/deepdoc/parser/resume/entities/schools.py b/deepdoc/parser/resume/entities/schools.py index 2bc40e836..4425236be 100644 --- a/deepdoc/parser/resume/entities/schools.py +++ b/deepdoc/parser/resume/entities/schools.py @@ -25,7 +25,7 @@ TBL = pd.read_csv( os.path.join(current_file_path, "res/schools.csv"), sep="\t", header=0 ).fillna("") TBL["name_en"] = TBL["name_en"].map(lambda x: x.lower().strip()) -GOOD_SCH = json.load(open(os.path.join(current_file_path, "res/good_sch.json"), "r")) +GOOD_SCH = json.load(open(os.path.join(current_file_path, "res/good_sch.json"), "r",encoding="utf-8")) GOOD_SCH = set([re.sub(r"[,. &()()]+", "", c) for c in GOOD_SCH])