i += 1 nps = reconcile.getNPs(f) gold_chains = reconcile.getGoldChains(f) try: all_pairs = reconcile.getFauxPairs(f, PREDICTIONS) except: continue response_pairs = [] for pair in all_pairs: if pair[0] is None or pair[1] is None: continue response_pairs.append(pair) labeled_annots = reconcile.labelCorrectPairs(gold_chains, response_pairs) for pair in labeled_annots: if ACE: if pair[2]: processACE(f, pair[1], correct_qps) else: processACE(f, pair[1], incorrect_qps) sys.stderr.write("\r \r\n") print(len(list(correct_qps.keys()))) print(len(list(incorrect_qps.keys()))) columns = {} with open("/home/ngilbert/public_html/ace.qp.html", 'w') as htmlFile: htmlFile.write("<html>\n") htmlFile.write("\t<head><title>ACE QP Results</title></head>\n")
continue #get the sentences sentences = reconcile.getSentences(f) #remove the pairs we don't care about tracked_pairs = [] for pair in faux_pronoun_pairs: ana_head = specificity_utils.getHead(pair[1].getText()).lower() if ana_head in FAUX_PRONOUNS: if ana_head not in list(tracked_nouns.keys()): tracked_nouns[ana_head] = Noun(ana_head) tracked_pairs.append(pair) #label the correct or incorrect pairs labeled_faux_pairs = reconcile.labelCorrectPairs(gold_chains, tracked_pairs) for lpair in labeled_faux_pairs: ana_head = specificity_utils.getHead(lpair[1].getText()).lower() key = "{0}:{1}:{2}".format(f, lpair[1].getStart(), lpair[1].getEnd()) tracked_nouns[ana_head].instances[key] = utils.textClean(lpair[1].getText()) tracked_nouns[ana_head].antecedents[key] = utils.textClean(lpair[0].getText()) tracked_nouns[ana_head].labels[key] = lpair[2] #this is an incorrect antecedent if not lpair[2]: closest_true_antecedent = closest_antecedent(gold_chains, lpair[1])
# pairs.append(pair) elif "-baseline" in sys.argv: RESPONSE_TYPE = "Baseline" baseline_pairs = reconcile.getFauxPairs( f, "features.goldnps/predictions.Baseline.byte_dist") for pair in baseline_pairs: tags = pos.getSubset(pair[1].getStart(), pair[1].getEnd()) text = utils.textClean(pair[1].getText()).lower() ana_head = qp_utils.getHead2(text, tags) if ana_head in QPs: pairs.append(pair) else: print("Please select response type.") sys.exit(1) labeled_annots = reconcile.labelCorrectPairs(gold_chains, pairs) for pair in labeled_annots: total_scores["vps_guessed"] += 1 if pair[2]: print(pair[0].ppprint() + " <- " + pair[1].ppprint()) total_scores["vps_correct"] += 1 else: print(pair[0].ppprint() + " <- " + pair[1].ppprint() + "*") print("=" * 72) print("{0} accuracy".format(RESPONSE_TYPE)) try: result = total_scores["vps_correct"] / float( total_scores["vps_guessed"]) print("Total: {0} / {1} = {2:0.2f}".format(total_scores["vps_correct"], total_scores["vps_guessed"],
files.extend([ x for x in [x.strip() for x in fileList.readlines()] if not x.startswith("#") ]) total_new_correct_resolutions = 0 total_new_incorrect_resolutions = 0 for f in files: print("File: {0}".format(f)) response1 = reconcile.getAllResponsePairs( f, "/features." + base + "/" + predictions1) response2 = reconcile.getAllResponsePairs( f, "/features." + second + "/" + predictions2) gold_chains = reconcile.getGoldChains(f) gold_response1 = reconcile.labelCorrectPairs(gold_chains, response1) gold_system1_pairs = {} for pair in gold_response1: key = "%s:%s" % (pair[0].getID(), pair[1].getID()) gold_system1_pairs[key] = pair gold_system2_pairs = {} gold_response2 = reconcile.labelCorrectPairs(gold_chains, response2) for pair in gold_response2: key = "%s:%s" % (pair[0].getID(), pair[1].getID()) gold_system2_pairs[key] = pair system1_pairs = {} system2_pairs = {} for pair in response1: if pair[2] > 0: