Get abstract (highlights) and article from a story file path.

def _get_art_abs(story_file):
  """Get abstract (highlights) and article from a story file path."""
  # Based on https://github.com/abisee/cnn-dailymail/blob/master/
  #     make_datafiles.py

  lines = _read_text_file(story_file)

  # Lowercase everything
  lines = [line.lower() for line in lines]

  # Put periods on the ends of lines that are missing them
  # (this is a problem in the dataset because many image captions don't end in
  # periods; consequently they end up in the body of the article as run-on
  # sentences)
  def fix_missing_period(line):
    """Adds a period to a line that is missing a period."""
    if '@highlight' in line: return line
    if not line: return line
    if line[-1] in END_TOKENS: return line
    return line + ' .'
  lines = [fix_missing_period(line) for line in lines]

  # Separate out article and abstract sentences
  article_lines = []
  highlights = []
  next_is_highlight = False
  for line in lines:
    if not line:
      continue  # empty line
    elif line.startswith('@highlight'):
      next_is_highlight = True
    elif next_is_highlight:
      highlights.append(line)
    else:
      article_lines.append(line)

  # Make article into a single string
  article = ' '.join(article_lines)

  # Make abstract into a single string, putting <s> and </s> tags around
  # the sentences.
  abstract = ' '.join(['%s %s %s' % (SENTENCE_START, sent,
                                     SENTENCE_END) for sent in highlights])

  return article, abstract