def preprocess_reference_text(text):
    """Preprocess a PDF text.

    Parameters
    ----------
    text : str
        The text (possibly from a converted PDF) to preprocess.

    Returns
    -------
    tuple
        A tuple consisting of the following elements:
        - has_reference_section : A boolean which is true when the text contained the string 'reference'
          (not case-sensitive), false otherwise.
        - reference_section : A string containing the reference section.
        - non_reference_section : A string containing the text which was not in the reference section.
    """
    try:
        splitpoint = text.lower().rindex('reference')
    except ValueError:
        splitpoint = False
    while splitpoint and len(text) - splitpoint < 100 and 'reference' in text[:
        splitpoint].lower():
        text = text[:splitpoint]
        splitpoint = text.lower().rindex('reference')
    if not splitpoint:
        has_reference_section = False
        non_reference_section, reference_section = text, ''
    else:
        has_reference_section = True
        non_reference_section, reference_section = text[:splitpoint], text[
            splitpoint:]
    return has_reference_section, reference_section, non_reference_section
