(
paper: Dict[str, Any],
user_profile: Dict[str, Any],
report_payload: Optional[Dict[str, Any]] = None,
response_language: str = "zh",
)
| 4355 | |
| 4356 | |
| 4357 | def generate_reading_report( |
| 4358 | paper: Dict[str, Any], |
| 4359 | user_profile: Dict[str, Any], |
| 4360 | report_payload: Optional[Dict[str, Any]] = None, |
| 4361 | response_language: str = "zh", |
| 4362 | ) -> str: |
| 4363 | payload = report_payload or build_heuristic_report_payload( |
| 4364 | paper, |
| 4365 | user_profile, |
| 4366 | response_language=response_language, |
| 4367 | ) |
| 4368 | language = _normalize_response_language(payload.get("response_language") or response_language) |
| 4369 | is_en = language == "en" |
| 4370 | labels = { |
| 4371 | "untitled": "Untitled Paper" if is_en else "Untitled Paper", |
| 4372 | "source_no_abstract_link": "The source did not return a usable abstract. View the original paper here:" if is_en else "源站暂未返回可用摘要。请直接查看原文链接:", |
| 4373 | "source_no_abstract": "The source did not return a usable abstract. Check the original PDF or paper page directly." if is_en else "源站暂未返回可用摘要,建议直接查看原文 PDF 或论文主页。", |
| 4374 | "analysis_pdf": "PDF full text" if is_en else "PDF 全文", |
| 4375 | "analysis_source_page": "source page + metadata" if is_en else "源站正文 + 元数据", |
| 4376 | "analysis_metadata": "abstract + metadata" if is_en else "摘要 + 元数据", |
| 4377 | "model": "model" if is_en else "模型", |
| 4378 | "keywords": "Keywords" if is_en else "关键词", |
| 4379 | "one_sentence": "One-Sentence Summary" if is_en else "一句话总结", |
| 4380 | "one_sentence_empty": "There is not enough information to generate a one-sentence summary yet." if is_en else "当前没有足够信息生成一句话总结。", |
| 4381 | "abstract": "Abstract" if is_en else "摘要", |
| 4382 | "problem_empty": "Start from the abstract and introduction to verify the research problem." if is_en else "建议先回到原文摘要和引言确认研究问题。", |
| 4383 | "related_empty": "The automatic parser did not extract a stable Related Work thread. Check the introduction, related-work section, and citations to identify the main compared methods." if is_en else "当前自动解析没有稳定提取出 Related Work 的完整脉络。可先从论文引言、相关工作章节和引用线索核对它主要对比了哪些方法。", |
| 4384 | "related_prefix": "Based on current evidence, the paper is positioned around: " if is_en else "从当前证据可见,论文的定位至少包括:", |
| 4385 | "solution_empty": "Method details were not extracted reliably; focus on the Method / Approach section." if is_en else "当前未成功提炼方法细节,请重点阅读 Method / Approach 部分。", |
| 4386 | "experiments_empty": "No clear experimental setup was extracted; check Experiments / Results, tables, figures, and key metrics." if is_en else "当前没有提炼出明确实验设置,请重点核对 Experiments / Results、表格、图示和主要指标。", |
| 4387 | "future_empty": "Current information is insufficient; revisit limitations, failure cases, ablation gaps, and cross-domain generalization in the paper." if is_en else "当前信息不足,建议从局限性、失败案例、消融缺口和跨领域泛化四个角度回原文继续挖掘。", |
| 4388 | "contributions_prefix": "Main contributions include: " if is_en else "主要贡献包括:", |
| 4389 | "limitations_prefix": "Important boundaries include: " if is_en else "需要注意的边界包括:", |
| 4390 | "relevance_prefix": "Relationship to the user profile: " if is_en else "与用户画像的关系:", |
| 4391 | "summary_empty": "Current information is insufficient; connect the abstract, introduction, method, and conclusion in the original paper." if is_en else "当前信息不足,建议回到原文摘要、引言、方法和结论串联主线。", |
| 4392 | "recommendation": "Recommendation" if is_en else "推荐指数", |
| 4393 | "reason": "Reason" if is_en else "推荐理由", |
| 4394 | "details": "Paper Details" if is_en else "基本信息", |
| 4395 | "authors": "Authors" if is_en else "作者", |
| 4396 | "affiliation": "Affiliation" if is_en else "机构", |
| 4397 | "source": "Source" if is_en else "来源", |
| 4398 | "subjects": "Subjects/Categories" if is_en else "主题/分类", |
| 4399 | "date": "Date" if is_en else "日期", |
| 4400 | "recommendation_level": "Recommendation" if is_en else "推荐级别", |
| 4401 | "analysis_source": "Analysis source" if is_en else "解析来源", |
| 4402 | "generation_model": "Generation model" if is_en else "生成模型", |
| 4403 | "not_provided": "Not provided" if is_en else "未提供", |
| 4404 | "unknown": "Unknown" if is_en else "未知", |
| 4405 | "analysis_note": "Analysis note" if is_en else "解析说明", |
| 4406 | } |
| 4407 | field_sep = ": " if is_en else ":" |
| 4408 | list_joiner = "; " if is_en else ";" |
| 4409 | sentence_end = "." if is_en else "。" |
| 4410 | report_style = _normalize_report_style(payload.get("report_style")) |
| 4411 | title = _clean_text(paper.get("title")) or labels["untitled"] |
| 4412 | abstract = _clean_abstract_text(payload.get("abstract") or paper.get("abstract")) |
| 4413 | clean_abstract_summary = _clean_text(payload.get("clean_abstract_summary")) |
| 4414 | if clean_abstract_summary and (not _clean_text(abstract) or _looks_like_extraction_noise(abstract)): |
no test coverage detected