def get_importances(model, batch, enc_states, vocab, sess, hps): if FLAGS.pg_mmr: enc_sentences, enc_tokens = batch.tokenized_sents[ 0], batch.word_ids_sents[0] if FLAGS.importance_fn == 'oracle': human_tokens = get_tokens_for_human_summaries( batch, vocab) # list (of 4 human summaries) of list of token ids metric = 'recall' importances_hat = rouge_l_similarity(enc_tokens, human_tokens, vocab, metric=metric) elif FLAGS.importance_fn == 'svr': if FLAGS.importance_fn == 'svr': with open(os.path.join(FLAGS.actual_log_root, 'svr.pickle'), 'rb') as f: svr_model = cPickle.load(f) enc_sent_indices = importance_features.get_sent_indices( enc_sentences, batch.doc_indices[0]) sent_representations_separate = importance_features.get_separate_enc_states( model, sess, enc_sentences, vocab, hps) importances_hat = get_svr_importances( enc_states[0], enc_sentences, enc_sent_indices, svr_model, sent_representations_separate) elif FLAGS.importance_fn == 'tfidf': importances_hat = get_tfidf_importances(batch.raw_article_sents[0]) importances = util.special_squash(importances_hat) else: importances = None return importances
def get_ROUGE_Ls(art_oovs, all_original_abstracts_sents, vocab, enc_tokens): human_tokens = get_tokens_for_human_summaries( art_oovs, all_original_abstracts_sents, vocab, split_sents=False) # list (of 4 human summaries) of list of token ids metric = 'recall' importances_hat = util.rouge_l_similarity(enc_tokens, human_tokens, vocab, metric=metric) importances = util.special_squash(importances_hat) return importances, importances_hat