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

Function _build_scholar_fallback_excerpt

agents/coldstart-agent/main.py:789–799  ·  view source on GitHub ↗

Extract a small text excerpt when the structured page cannot be parsed.

(html_text: str)

Source from the content-addressed store, hash-verified

787
788
789def _build_scholar_fallback_excerpt(html_text: str) -> str:
790 """Extract a small text excerpt when the structured page cannot be parsed."""
791 title = _strip_html(_extract_first_group(r"<title[^>]*>(.*?)</title>", html_text))
792 description = _strip_html(
793 _extract_first_group(
794 r'<meta[^>]+name=["\']description["\'][^>]+content=["\'](.*?)["\']&#x27;,
795 html_text,
796 )
797 )
798 body_excerpt = _collapse_whitespace(_strip_html(html_text))[:600]
799 return " ".join(part for part in (title, description, body_excerpt) if part).strip()
800
801
802def _extract_external_homepage_url(html_text: str, base_url: str = "") -> str:

Callers 1

Calls 3

_extract_first_groupFunction · 0.85
_collapse_whitespaceFunction · 0.85
_strip_htmlFunction · 0.70

Tested by

no test coverage detected