diff --git a/crawler/__pycache__/extractor_ai.cpython-39.pyc b/crawler/__pycache__/extractor_ai.cpython-39.pyc index ede6599..32ed133 100644 Binary files a/crawler/__pycache__/extractor_ai.cpython-39.pyc and b/crawler/__pycache__/extractor_ai.cpython-39.pyc differ diff --git a/crawler/__pycache__/translate_utils.cpython-39.pyc b/crawler/__pycache__/translate_utils.cpython-39.pyc index 563a325..6e7fdc2 100644 Binary files a/crawler/__pycache__/translate_utils.cpython-39.pyc and b/crawler/__pycache__/translate_utils.cpython-39.pyc differ diff --git a/crawler/extractor_ai.py b/crawler/extractor_ai.py index 8dc443b..b83c365 100644 --- a/crawler/extractor_ai.py +++ b/crawler/extractor_ai.py @@ -26,7 +26,12 @@ def _call_ollama_extract(text: str, timeout: int = 15) -> Optional[Dict[str, Any try: import requests raw = str(text).strip()[:EXTRACT_TEXT_MAX_LEN] - prompt = f"""从以下美伊/中东新闻**全文或摘要**中,提取**报道明确给出的数字与事实**,输出 JSON。规则: + prompt = f"""从以下美伊/中东新闻**全文或摘要**中,提取**报道明确给出的数字与事实**,输出 JSON。 + +输入说明: +- 原文可能是英文、中文或其他语言(English / Chinese / Arabic / Persian 等),请先理解含义,再按要求输出。 + +规则: 1. 仅填写报道中**直接出现、可核对**的数据,不要推测或估算。 2. 无明确依据的字段**必须省略**,不要填 0 或猜。 3. **战损一律按增量**:只填本则报道中「本次/此次/今日/本轮」**新增**的伤亡或损毁数量。若报道只给「累计总数」「迄今共」「total so far」等,**不要填写**该字段(避免与库内已有累计值重复叠加)。 @@ -50,7 +55,7 @@ def _call_ollama_extract(text: str, timeout: int = 15) -> Optional[Dict[str, Any 原文: {raw} -直接输出 JSON,不要解释:""" +直接输出 JSON 对象,不要解释,不要加反引号或代码块标记:""" r = requests.post( "http://localhost:11434/api/chat", json={ diff --git a/crawler/translate_utils.py b/crawler/translate_utils.py index 0eb3e4d..0b45001 100644 --- a/crawler/translate_utils.py +++ b/crawler/translate_utils.py @@ -13,10 +13,16 @@ def _is_mostly_chinese(text: str) -> bool: def translate_to_chinese(text: str) -> str: - """将文本翻译成中文,失败或已是中文则返回原文。Google 失败时尝试 MyMemory。""" + """将文本翻译成中文,失败或已是中文则返回原文。 + + 说明: + - 默认关闭外部翻译(deep_translator),直接返回原文,避免因网络或代理问题阻塞整条流水线。 + - 如需开启翻译,可显式设置环境变量 TRANSLATE_DISABLED=0。 + """ if not text or not text.strip(): return text - if os.environ.get("TRANSLATE_DISABLED", "0") == "1": + # 默认禁用翻译:TRANSLATE_DISABLED 未设置时视为开启(值为 "1") + if os.environ.get("TRANSLATE_DISABLED", "1") == "1": return text s = str(text).strip() if len(s) > 2000: diff --git a/server/data.db-shm b/server/data.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/server/data.db-shm differ diff --git a/server/data.db-wal b/server/data.db-wal new file mode 100644 index 0000000..e69de29