def normalize_section_names(section_names):
    section_names = [s.lower().strip() for s in section_names]
    frequent_sections = {'preamble': 'preamble', 'impression': 'impression', 'comparison': 'comparison', 'indication': 'indication', 'findings': 'findings', 'examination': 'examination', 'technique': 'technique', 'history': 'history', 'comparisons': 'comparison', 'clinical history': 'history', 'reason for examination': 'indication', 'notification': 'notification', 'reason for exam': 'indication', 'clinical information': 'history', 'exam': 'examination', 'clinical indication': 'indication', 'conclusion': 'impression', 'chest, two views': 'findings', 'recommendation(s)': 'recommendations', 'type of examination': 'examination', 'reference exam': 'comparison', 'patient history': 'history', 'addendum': 'addendum', 'comparison exam': 'comparison', 'date': 'date', 'comment': 'comment', 'findings and impression': 'impression', 'wet read': 'wet read', 'comparison film': 'comparison', 'recommendations': 'recommendations', 'findings/impression': 'impression', 'pfi': 'history', 'recommendation': 'recommendations', 'wetread': 'wet read', 'ndication': 'impression', 'impresson': 'impression', 'imprression': 'impression', 'imoression': 'impression', 'impressoin': 'impression', 'imprssion': 'impression', 'impresion': 'impression', 'imperssion': 'impression', 'mpression': 'impression', 'impession': 'impression', 'findings/ impression': 'impression', 'finding': 'findings', 'findins': 'findings', 'findindgs': 'findings', 'findgings': 'findings', 'findngs': 'findings', 'findnings': 'findings', 'finidngs': 'findings', 'idication': 'indication', 'reference findings': 'findings', 'comparision': 'comparison', 'comparsion': 'comparison', 'comparrison': 'comparison', 'comparisions': 'comparison'}
    p_findings = ['chest', 'portable', 'pa and lateral', 'lateral and pa', 'ap and lateral', 'lateral and ap', 'frontal and', 'two views', 'frontal view', 'pa view', 'ap view', 'one view', 'lateral view', 'bone window', 'frontal upright', 'frontal semi-upright', 'ribs', 'pa and lat']
    p_findings = re.compile('({})'.format('|'.join(p_findings)))
    main_sections = ['impression', 'findings', 'history', 'comparison', 'addendum']
    for (i, s) in enumerate(section_names):
        if (s in frequent_sections):
            section_names[i] = frequent_sections[s]
            continue
        main_flag = False
        for m in main_sections:
            if (m in s):
                section_names[i] = m
                main_flag = True
                break
        if main_flag:
            continue
        m = p_findings.search(s)
        if (m is not None):
            section_names[i] = 'findings'
    return section_names
def normalize_section_names(section_names):
    section_names = [s.lower().strip() for s in section_names]
    frequent_sections = {'preamble': 'preamble', 'impression': 'impression', 'comparison': 'comparison', 'indication': 'indication', 'findings': 'findings', 'examination': 'examination', 'technique': 'technique', 'history': 'history', 'comparisons': 'comparison', 'clinical history': 'history', 'reason for examination': 'indication', 'notification': 'notification', 'reason for exam': 'indication', 'clinical information': 'history', 'exam': 'examination', 'clinical indication': 'indication', 'conclusion': 'impression', 'chest, two views': 'findings', 'recommendation(s)': 'recommendations', 'type of examination': 'examination', 'reference exam': 'comparison', 'patient history': 'history', 'addendum': 'addendum', 'comparison exam': 'comparison', 'date': 'date', 'comment': 'comment', 'findings and impression': 'impression', 'wet read': 'wet read', 'comparison film': 'comparison', 'recommendations': 'recommendations', 'findings/impression': 'impression', 'pfi': 'history', 'recommendation': 'recommendations', 'wetread': 'wet read', 'ndication': 'impression', 'impresson': 'impression', 'imprression': 'impression', 'imoression': 'impression', 'impressoin': 'impression', 'imprssion': 'impression', 'impresion': 'impression', 'imperssion': 'impression', 'mpression': 'impression', 'impession': 'impression', 'findings/ impression': 'impression', 'finding': 'findings', 'findins': 'findings', 'findindgs': 'findings', 'findgings': 'findings', 'findngs': 'findings', 'findnings': 'findings', 'finidngs': 'findings', 'idication': 'indication', 'reference findings': 'findings', 'comparision': 'comparison', 'comparsion': 'comparison', 'comparrison': 'comparison', 'comparisions': 'comparison'}
    p_findings = ['chest', 'portable', 'pa and lateral', 'lateral and pa', 'ap and lateral', 'lateral and ap', 'frontal and', 'two views', 'frontal view', 'pa view', 'ap view', 'one view', 'lateral view', 'bone window', 'frontal upright', 'frontal semi-upright', 'ribs', 'pa and lat']
    p_findings = re.compile('({})'.format('|'.join(p_findings)))
    main_sections = ['impression', 'findings', 'history', 'comparison', 'addendum']
    for (i, s) in enumerate(section_names):
        if (s in frequent_sections):
            section_names[i] = frequent_sections[s]
            continue
        main_flag = False
        for m in main_sections:
            if (m in s):
                section_names[i] = m
                main_flag = True
                break
        if main_flag:
            continue
        m = p_findings.search(s)
        if (m is not None):
            section_names[i] = 'findings'
    return section_names