initial commit of project
This commit is contained in:
29
evaluation/add_unused_ingredients.py
Normal file
29
evaluation/add_unused_ingredients.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user