Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
def test_convert_cooking_time_wakachi_sample():
    wakachi_file = 'weekcook_web/procedure_3/weekcook_sample_proc3.txt'
    wakachi_strings = text_to_strings(wakachi_file)
    convert_strings = convert_cooking_time_wakachi(wakachi_strings)
    expected = ['8分']

    assert convert_strings == expected
Exemple #4
0
def test_convert_cooking_time_strings_00003363():
    sample_file = 'weekcook_web/org/weekcook_00003363.txt'
    strings = text_to_strings(sample_file)
    convert_strings = convert_cooking_time_strings(strings)
    expected = ['5分']

    assert convert_strings == expected
Exemple #5
0
def test_preordering_for_cooking_time_wakachi_00000083():
    wakachi_file = 'weekcook_web/procedure_3/weekcook_00000083_proc3.txt'
    wakachi_string = text_to_strings(wakachi_file)
    convert_strings = convert_cooking_time_strings(wakachi_string)
    preordering_strings = preordering_for_cooking_time_wakachi(wakachi_file, convert_strings)
    expected = ['さんま', 'は', '頭', 'と', '内臓', '(', '腸', ')', 'を', '取除', 'い', 'た', '後', '、', '水', 'で', 'よく', '洗', 'っ', 'て', 'から', 'ペーパー', 'タオル', 'で', '水気', 'を', '拭き取', 'る', '。\n', 'グリル', '(', 'フライパン', 'で', 'も', '可', ')', 'に', 'サラダ', '油', '(', '分量', '外', ')', 'を', '塗', 'る', '。\n', 'さんま', 'に', '塩', 'を', '振', 'っ', 'て', 'から', '、', '温め', 'た', 'グリル', '(', 'フライパン', 'で', 'も', '可', ')', 'に', '並べ', '、', '(', 'フライパン', 'の', '場合', 'は', '火', 'が', '通', 'る', 'まで', ')', '焼', 'く', '。(目安: 約15~20分)\n',  '焼き上が', 'っ', 'た', 'さんま', 'の', '塩焼き', 'を', '、', 'お', '好み', 'で', '笹', 'を', '敷', 'い', 'た', '器', 'に', '盛り付け', '、', 'お', '好み', 'で', 'すだち', 'や', '大根', 'おろし', 'を', '添え', 'たら', '完成', '。\n']

    assert preordering_strings == expected
Exemple #6
0
def test_convert_tool_to_param_sample():
    sample_file = 'weekcook_web/org/weekcook_sample.txt'
    strings = text_to_strings(sample_file)
    tool_param_dict = convert_tool_to_param(strings)
    print(tool_param_dict)
    expected = {
        'tool1': 'オーブントースター',
    }

    assert tool_param_dict == expected
Exemple #7
0
def test_convert_tool_to_param_00003159():
    sample_file = 'weekcook_web/org/weekcook_00003159.txt'
    strings = text_to_strings(sample_file)
    tool_param_dict = convert_tool_to_param(strings)
    print(tool_param_dict)
    expected = {
        'tool1': '電子レンジ',
    }

    assert tool_param_dict == expected
Exemple #8
0
def test_convert_tool_to_param_00001977():
    sample_file = 'weekcook_web/org/weekcook_00001977.txt'
    strings = text_to_strings(sample_file)
    tool_param_dict = convert_tool_to_param(strings)
    print(tool_param_dict)
    expected = {
        'tool1': 'フライパン',
        'tool2': 'グリル',
    }

    assert tool_param_dict == expected
Exemple #9
0
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
Exemple #10
0
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
Exemple #11
0
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