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

amr_error

parent 7a478774
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ import pickle
from wesenberg.Konstanten import LIST_SYMBOLS_TO_DELETE, ROOT_PATH, AMRLIB_PATH, \
LIST_MODEL_NAME, LOAD_SPARCY, ROUGE_TYPES, DIVIDER_PATH, BACKUP_SMATCH_ERROR_PATH, SAFE_SMATCH_ERROR, \
AMR_ERROR_PATH, SEARCH_AMR_ERROR
AMR_ERROR_PATH, SAFE_AMR_ERROR
def remove_bugs(sentence):
......@@ -34,21 +34,20 @@ def calc_one_amr(nlp, sentence, file_name):
else:
output = strip_amr_for_smatch(graphs[0])
if SEARCH_AMR_ERROR:
output_list = output.split("\n")
return_list = []
for item in output_list:
output_list = output.split("\n")
search_list = []
if SAFE_AMR_ERROR:
for i, item in enumerate(output_list):
item = item.replace(")", "").replace("(", "").strip()
if item in return_list:
if item not in search_list:
search_list.append(item)
else:
path = os.path.join(AMR_ERROR_PATH)
if not os.path.exists(path):
os.makedirs(path)
with open(path + file_name + ".txt", 'a') as txt:
txt.write(sentence + "\n" + output + "\n\n")
break
else:
return_list.append(item)
break
return output
......
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