Files
MasterarbeitCode/evaluation/add_unused_ingredients.py
2021-04-11 23:28:41 +02:00

29 lines
1000 B
Python

import json
def main():
eval_path = "final_Versions/models/vers2/eval/"
file_name = "substitute_pairs_65.json"
found_substitutes_path = eval_path + file_name
with open(found_substitutes_path, "r") as whole_json_file:
model_substitutes_dict = json.load(whole_json_file)
data_path = "data/"
occurances_path = "mult_ingredients_nice.json"
with open(data_path + occurances_path, "r") as whole_json_file:
occurrences_dict = json.load(whole_json_file)
all_substitutes = {}
for ingredient in occurrences_dict.keys():
if ingredient not in model_substitutes_dict.keys():
all_substitutes[ingredient] = []
# print(ingredient)
else:
all_substitutes[ingredient] = model_substitutes_dict[ingredient]
print(str(len(all_substitutes.keys())))
out_path = eval_path + "complete_" + file_name
with open(out_path, 'w') as f:
json.dump(all_substitutes, f, ensure_ascii=False, indent=4)
main()