import re


def sentence_tokenizer(simple_split_tokens):
    """
    This function takes in a text tokenized by the split method
    and reconstructs them into sentences
    using regular expressions.

    :param simple_split_tokens
        :type list
            The list of tokens of the sentences/text

     :return sentence_results
        :rtype list
        This is a list of all the sentence contained within the corpus
    """

    # regex expression for recognizing sentences
    # regex 1: single punctuation marks
    # regex 2: typical sentence punctuation
    # regex 3: different period types

    regex = re.compile(rf'''(?P<sentence_basic>[a-zàâçéèêëîïôûùüÿñæœ]+[.!?-])| 
                            (?P<sentence_punctuatuion>)[*!?.]|  
                            (?P<sentence_period>)[.·]  
                            ''', re.VERBOSE)

    new_tokens, sentence = list(), str()
    for tokens in simple_split_tokens:
        match = regex.findall(tokens)
        if match:
            sentence += f"{tokens}<END>"
            new_tokens.append(tokens)
        else:
            sentence += f"{tokens} "
    new_sentence = sentence.split("<END>")

    # Filters out sentences that only consist of white space
    sentence_results = [sen for sen in new_sentence if bool(sen) is True]

    return sentence_results