MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _infer_section_from_abstract

Function _infer_section_from_abstract

agents/reading-agent/main.py:3759–3803  ·  view source on GitHub ↗

从摘要中推断特定部分的内容 Args: abstract: 论文摘要 section_type: 要推断的部分类型 (background, method, results) Returns: 推断出的部分内容

(abstract: str, section_type: str)

Source from the content-addressed store, hash-verified

3757
3758def _infer_section_from_abstract(abstract: str, section_type: str) -> str:
3759 """
3760 从摘要中推断特定部分的内容
3761
3762 Args:
3763 abstract: 论文摘要
3764 section_type: 要推断的部分类型 (background, method, results)
3765
3766 Returns:
3767 推断出的部分内容
3768 """
3769 if not abstract:
3770 return ""
3771
3772 sentences = _split_sentences(abstract)
3773 if not sentences:
3774 return ""
3775
3776 # 根据部分类型选择不同的线索词
3777 section_cues = {
3778 "background": ("we address", "we tackle", "challenge", "problem", "limitation", "however", "despite", "existing", "prior work"),
3779 "method": ("we propose", "we present", "we introduce", "we develop", "our approach", "our method", "framework", "model", "architecture"),
3780 "results": ("outperform", "improve", "achieve", "demonstrate", "results show", "experimental", "evaluation", "gain", "better than", "superior"),
3781 }
3782
3783 cues = section_cues.get(section_type, ())
3784
3785 # 优先选择包含线索词的句子
3786 matched = []
3787 for sentence in sentences:
3788 lowered = sentence.lower()
3789 if any(cue in lowered for cue in cues):
3790 matched.append(sentence)
3791
3792 if matched:
3793 return " ".join(matched[:2])
3794
3795 # 如果没有匹配的,根据位置返回
3796 if section_type == "background":
3797 return " ".join(sentences[:2]) if len(sentences) >= 2 else sentences[0] if sentences else ""
3798 elif section_type == "results":
3799 return " ".join(sentences[-2:]) if len(sentences) >= 2 else sentences[-1] if sentences else ""
3800 else: # method
3801 mid = len(sentences) // 2
3802 return " ".join(sentences[mid:mid+2]) if len(sentences) > 2 else sentences[mid] if sentences else ""
3803
3804
3805def _extract_heuristic_keywords(
3806 paper: Dict[str, Any],

Callers 1

Calls 2

_split_sentencesFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected