Skip to content
Snippets Groups Projects
Commit 6f55a525 authored by wesenberg's avatar wesenberg
Browse files

amr_error

parent 681c18d9
No related branches found
No related tags found
No related merge requests found
world cup winner lawrence dallaglio won a return to the international scene on wednesday when he was named in england 's six nations training squad .
lawrence dallaglio won the international scene on wednesday
\ No newline at end of file
......@@ -95,8 +95,8 @@ if THIS_OS == "Windows":
BACKUP_AMR_PATH = "wesenberg\\backup_amr\\test\\"
DIVIDER_PATH = "\\"
BACKUP_REWARD_REGION_PATH = "wesenberg\\backup_reward_region\\"
BACKUP_SMATCH_ERROR_PATH = "wesenberg\\smatch_error\\"
AMR_ERROR_PATH = "wesenberg\\amr_error\\"
BACKUP_SMATCH_ERROR_PATH = "wesenberg\\errors\\smatch_error\\"
AMR_ERROR_PATH = "wesenberg\\errors\\amr_error\\"
HUGGINGFACE_PATH = ROOT_PATH + DIVIDER_PATH + "wesenberg\\huggingface_txt"
AMRLIB_PATH = "\\wesenberg\\AmrModel\\"
ALL_RESULTS_PATH = "\\wesenberg\\results\\"
......@@ -118,8 +118,8 @@ else:
DIVIDER_PATH = "/"
HUGGINGFACE_PATH = ROOT_PATH + DIVIDER_PATH + "wesenberg/huggingface_txt"
BACKUP_REWARD_REGION_PATH = "wesenberg/backup_reward_region/"
BACKUP_SMATCH_ERROR_PATH = "wesenberg/smatch_error/"
AMR_ERROR_PATH = "wesenberg/amr_error/"
BACKUP_SMATCH_ERROR_PATH = "wesenberg/errors/smatch_error/"
AMR_ERROR_PATH = "wesenberg/errors/amr_error/"
AMRLIB_PATH = "/wesenberg/AmrModel/"
ALL_RESULTS_PATH = "/wesenberg/results/"
MODEL_PATH = "data/models/"
......
from wesenberg import util, smatch
import smatch
from wesenberg import util
from wesenberg.DataAnalytics import DataAnalytics
from wesenberg.DataResults import DataResults
from wesenberg.util import get_amr_match_new
from wesenberg.util import get_amr_match_new, safe_smatch_error
INT_SMATCH_SOURCE_SUMMARY = "1"
INT_SMATCH_GOLD_SUMMARY = "2"
......@@ -16,7 +18,7 @@ def calc_smatch_to_f(name, source, summary, graph_source, graph_summary):
M is the number of matching triples
T is the total number of triples in the first AMR
G is the total number of triples in the second AMR"""
smatch_pred = smatch.get_amr_match(graph_source, graph_summary)
smatch_pred = calc_one_smatch(graph_source, graph_summary)
smatch_f = util.calc_f_score_smatch(name, source, summary, smatch_pred)
return smatch_f
......@@ -29,6 +31,11 @@ def calc_smatch_to_r(name, source, summary, graph_source, graph_summary):
G is the total number of triples in the second AMR"""
smatch_pred = calc_one_smatch(graph_source=graph_source, graph_summary=graph_summary)
if smatch_pred is (0, 0, 0):
safe_smatch_error(name=name + "_null", one=source, two=summary, recall=0, precision=None, smatch_pred=smatch_pred,
graph_source=graph_source, graph_summary=graph_summary)
smatch_r = util.calc_recall_smatch(name=name, one=source, two=summary, smatch_pred=smatch_pred, graph_source=graph_source, graph_summary=graph_summary)
return smatch_r
......
File moved
......@@ -32,10 +32,13 @@ def calc_one_amr(nlp, sentence, file_name):
sentence = remove_bugs(sentence)
graphs = nlp(sentence)._.to_amr()
if graphs[0] is None:
output = strip_amr_for_smatch(graphs[1])
else:
output = strip_amr_for_smatch(graphs[0])
try:
if graphs[0] is None:
output = strip_amr_for_smatch(graphs[1])
else:
output = strip_amr_for_smatch(graphs[0])
except IndexError:
return ""
if SAFE_AMR_ERROR:
output_list = output.split("\n")
......@@ -430,6 +433,9 @@ def safe_reward_list(path, name, safe_list, step, n=-1):
def get_amr_match_new(cur_amr1, cur_amr2, sent_num=1, justinstance=False, justattribute=False, justrelation=False):
if cur_amr1 is "" or cur_amr2 is "":
return 0, 0, 0
amr_pair = []
for i, cur_amr in (1, cur_amr1), (2, cur_amr2):
try:
......@@ -479,4 +485,3 @@ def get_amr_match_new(cur_amr1, cur_amr2, sent_num=1, justinstance=False, justat
test_triple_num = len(instance1) + len(attributes1) + len(relation1)
gold_triple_num = len(instance2) + len(attributes2) + len(relation2)
return best_match_num, test_triple_num, gold_triple_num
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment