def process_story(text):
"""Processed a story text into an (article, summary) tuple.
"""
# Split by highlights
elements = text.split("@highlight")
elements = [_.strip() for _ in elements]
story_text = elements[0]
highlights = elements[1:]
# Join all highlights into a single blob
highlights_joined = "; ".join(highlights)
highlights_joined = re.sub(r"\s+", " ", highlights_joined)
highlights_joined = highlights_joined.strip()
# Remove newlines from story
# story_text = story_text.replace("\n", " ")
story_text = re.sub(r"\s+", " ", story_text)
story_text = story_text.strip()
return story_text, highlights_joined
评论列表
文章目录