(self, example_generator)
Generates article and abstract text from tf.Example.

    Args:
      example_generator: a generator of tf.Examples from file. See data.example_generator
Generates article and abstract text from tf.Example.
Generates article and abstract text from tf . Example .
def text_generator(self, example_generator):
    """Generates article and abstract text from tf.Example.

    Args:
      example_generator: a generator of tf.Examples from file. See data.example_generator"""
    while True:
      e = example_generator.next() # e is a tf.Example
      try:
        article_text = e.features.feature['article'].bytes_list.value[0] # the article text was saved under the key 'article' in the data files
        abstract_text = e.features.feature['abstract'].bytes_list.value[0] # the abstract text was saved under the key 'abstract' in the data files
      except ValueError:
        tf.logging.error('Failed to get article or abstract from example')
        continue
      if len(article_text)==0: # See https://github.com/abisee/pointer-generator/issues/1
        tf.logging.warning('Found an example with empty article text. Skipping it.')
      else:
        yield (article_text, abstract_text)
def text_generator ( self , example_generator ) : while True : e = example_generator . next ( ) # e is a tf.Example try : article_text = e . features . feature [ 'article' ] . bytes_list . value [ 0 ] # the article text was saved under the key 'article' in the data files abstract_text = e . features . feature [ 'abstract' ] . bytes_list . value [ 0 ] # the abstract text was saved under the key 'abstract' in the data files except ValueError : tf . logging . error ( 'Failed to get article or abstract from example' ) continue if len ( article_text ) == 0 : # See https://github.com/abisee/pointer-generator/issues/1 tf . logging . warning ( 'Found an example with empty article text. Skipping it.' ) else : yield ( article_text , abstract_text )