process_story.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:seq2seq 作者: google 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号