(self, article, abstract, decoded_words, attn_dists, p_gens)
Write some data to json file, which can be read into the in-browser attention visualizer tool:
      https://github.com/abisee/attn_vis

    Args:
      article: The original article string.
      abstract: The human (correct) abstract string.
      attn_dists: List of arrays; the attention distributions.
      decoded_words: List of strings; the words of the generated summary.
      p_gens: List of scalars; the p_gen values. If not running in pointer-generator mode, list of None.
Write some data to json file, which can be read into the in-browser attention visualizer tool:
      https://github.com/abisee/attn_vis
Write some data to json file which can be read into the in - browser attention visualizer tool : https : // github . com / abisee / attn_vis
def write_for_attnvis(self, article, abstract, decoded_words, attn_dists, p_gens):
    """Write some data to json file, which can be read into the in-browser attention visualizer tool:
      https://github.com/abisee/attn_vis

    Args:
      article: The original article string.
      abstract: The human (correct) abstract string.
      attn_dists: List of arrays; the attention distributions.
      decoded_words: List of strings; the words of the generated summary.
      p_gens: List of scalars; the p_gen values. If not running in pointer-generator mode, list of None.
    """
    article_lst = article.split() # list of words
    decoded_lst = decoded_words # list of decoded words
    to_write = {
        'article_lst': [make_html_safe(t) for t in article_lst],
        'decoded_lst': [make_html_safe(t) for t in decoded_lst],
        'abstract_str': make_html_safe(abstract),
        'attn_dists': attn_dists
    }
    if FLAGS.pointer_gen:
      to_write['p_gens'] = p_gens
    output_fname = os.path.join(self._decode_dir, 'attn_vis_data.json')
    with open(output_fname, 'w') as output_file:
      json.dump(to_write, output_file)
    tf.logging.info('Wrote visualization data to %s', output_fname)
def write_for_attnvis ( self , article , abstract , decoded_words , attn_dists , p_gens ) : article_lst = article . split ( ) # list of words decoded_lst = decoded_words # list of decoded words to_write = { 'article_lst' : [ make_html_safe ( t ) for t in article_lst ] , 'decoded_lst' : [ make_html_safe ( t ) for t in decoded_lst ] , 'abstract_str' : make_html_safe ( abstract ) , 'attn_dists' : attn_dists } if FLAGS . pointer_gen : to_write [ 'p_gens' ] = p_gens output_fname = os . path . join ( self . _decode_dir , 'attn_vis_data.json' ) with open ( output_fname , 'w' ) as output_file : json . dump ( to_write , output_file ) tf . logging . info ( 'Wrote visualization data to %s' , output_fname )