def process_text(text, pmid=None, python2_path=None):
    if python2_path is None:
        for path in os.environ["PATH"].split(os.pathsep):
            proposed_python2_path = os.path.join(path, 'python2.7')
            if os.path.isfile(proposed_python2_path):
                python2_path = proposed_python2_path
                print('Found python 2 interpreter at', python2_path)
                break
    if python2_path is None:
        raise Exception('Could not find python2 in the directories ' +
                        'listed in the PATH environment variable. ' +
                        'Need python2 to run TEES.')
    a1_text, a2_text, sentence_segmentations = run_on_text(text,
                                                                python2_path)
    tp = TEESProcessor(a1_text, a2_text, sentence_segmentations, pmid)
    return tp