def test_convert_recipe_parameter_00000083(): org_file = 'weekcook_web/org/weekcook_00000083.txt' org_lines = text_to_strings(org_file) wakachi_file = 'weekcook_web/procedure_3/weekcook_00000083_proc3.txt' wakachi_string = text_to_strings(wakachi_file) json_filepath = 'weekcook_web/ingredient_json/weekcook_00000083.json' with open(json_filepath, 'r', encoding='utf-8') as j: ingredient_dict = json.load(j) num_param_dict = convert_num_to_param(org_lines) tool_param_dict = convert_tool_to_param(org_lines) unit_param_dict = convert_unit_to_param(wakachi_string, num_param_dict) ingredient_param_dict = {'ingredient' + str(idx): v for idx, v in enumerate(ingredient_dict.keys()) if v != '材料'} convert_strings = convert_cooking_time_wakachi(wakachi_file) preordering_wakachi_array = preordering_for_cooking_time_wakachi( wakachi_file, convert_strings, ) converted_strings, _ = convert_recipe_parameter( preordering_wakachi_array, ingredient_param_dict, num_param_dict, unit_param_dict, tool_param_dict, ) expected = '<param4>は頭と内臓(腸)を取除いた後、水でよく洗ってからペーパータオルで水気を拭き取る。\n<param7>(<param6>でも可)にサラダ油(分量外)を塗る。\n<param4>に<param5>を振ってから、温めた<param7>(<param6>でも可)に並べ、(<param6>の場合は火が通るまで)焼く。(目安: 約<param1>~<param2><param3>)\n焼き上がった<param4>の<param5>焼きを、お好みで笹を敷いた器に盛り付け、お好みですだちや大根おろしを添えたら完成。\n' print('converted_strings', converted_strings) assert converted_strings == expected
def test_define_num_param_70percent(): sample_file = 'weekcook_web/org/weekcook_sample.txt' strings = text_to_strings(sample_file) numparam_dict = convert_num_to_param(strings) num_param_70per_dict = define_num_param_70percent(numparam_dict) expected = { 'quantity1': '0', 'quantity2': '0', 'quantity3': '5', } assert num_param_70per_dict == expected
def test_convert_num_to_param_sample(): sample_file = 'weekcook_web/org/weekcook_sample.txt' strings = text_to_strings(sample_file) numparam_dict = convert_num_to_param(strings) print(numparam_dict) expected = { 'quantity1': '1', 'quantity2': '1', 'quantity3': '8', } assert numparam_dict == expected
def test_mapping_70per_to_100per(): sample_file = 'weekcook_web/org/weekcook_sample.txt' strings = text_to_strings(sample_file) numparam_dict = convert_num_to_param(strings) num_param_70per_dict = define_num_param_70percent(numparam_dict) relatetion_70per_100per = mapping_70per_to_100per( numparam_dict, num_param_70per_dict ) expected = [ {'1': '0'}, {'1': '0'}, {'8': '5'}, ] assert relatetion_70per_100per == expected
def test_convert_unit_to_param_00003159(): sample_file = 'weekcook_web/org/weekcook_00003159.txt' strings = text_to_strings(sample_file) numparam_dict = convert_num_to_param(strings) wakachi_file = 'weekcook_web/procedure_3/weekcook_00003159_proc3.txt' wakachi_string = text_to_strings(wakachi_file) unit_param_dict = convert_unit_to_param(wakachi_string, numparam_dict) print(unit_param_dict) expected = { 'unit1': 'w', 'unit2': '分', 'unit3': '等分', } assert unit_param_dict == expected