import re


def extract_features_for_clustering(text):
    """
    Extracts the presence of specific word phrase features that are used to
    determine the overall structure of the document.
    :param text: original report in str form
    :return: feature vector
    """
    key_phrases = [
        'Electronically signed by',
        'This report was electronically signed|Dictated:',
        'This addendum was electronically signed',
        'This report was electronically dictated and signed',
        'This addendum was electronically dictated and signed',
        'Addendum|ADDENDUM|addendum',
        '--- Addendum ---',
        '\n_____________\n?',
        '\*\*\*\*\*\*\*\* ORIGINAL REPORT \*\*\*\*\*\*\*\*',
        'Report content:',
        '\*\*\*\*\*\*\*\* ADDENDUM( #\d{1})? \*\*\*\*\*\*\*\*'
    ]
    word_features = [1 if re.search(phrase, text) else 0
                     for phrase in key_phrases]
    return word_features