术语表更新以旧值为准

This commit is contained in:
xunbu
2025-08-29 00:01:34 +08:00
parent 277182ed69
commit e949f2440c
4 changed files with 7 additions and 7 deletions

View File

@@ -79,7 +79,7 @@ You are a professional machine translation engine.
chunk: list[dict[str, str]]
try:
glossary_dict = {d["src"]: d["dst"] for d in chunk}
result = result | glossary_dict
result = glossary_dict | result
except JSONDecodeError as e:
self.logger.info(f"json解析错误解析文本:{chunk},错误:{e.__repr__()}")
except Exception as e:

View File

@@ -73,4 +73,4 @@ $$1+1=2$$
if self.glossary_dict is None:
self.glossary_dict = {}
if update_dict is not None:
self.glossary_dict = self.glossary_dict | update_dict
self.glossary_dict = update_dict | self.glossary_dict

View File

@@ -152,4 +152,4 @@ Warning: Never wrap the entire JSON object in quotes to make it a single string.
if self.glossary_dict is None:
self.glossary_dict = {}
if update_dict is not None:
self.glossary_dict = self.glossary_dict | update_dict
self.glossary_dict = update_dict | self.glossary_dict

View File

@@ -53,4 +53,4 @@ The translated txt text as plain text.
if self.glossary_dict is None:
self.glossary_dict = {}
if update_dict is not None:
self.glossary_dict = self.glossary_dict | update_dict
self.glossary_dict = update_dict | self.glossary_dict