'Python port of the Moses detokenizer.
:param tokens: A list of strings, i.e. tokenized text.
:type tokens: list(str)
:return: str'

def tokenize(self, tokens, convert_parentheses=False):

    text = '    '.join(tokens)
    for regexp in self.CONTRACTIONS3:
        text = regexp.sub('\\1\\2', text)
    for regexp in self.CONTRACTIONS2:
        text = regexp.sub('\\1\\2', text)
    for (regexp, substitution) in self.ENDING_QUOTES:
        text = regexp.sub(substitution, text)
    text = text.strip()
    (regexp, substitution) = self.DOUBLE_DASHES
    text = regexp.sub(substitution, text)
    if convert_parentheses:
        for (regexp, substitution) in self.CONVERT_PARENTHESES:
            text = regexp.sub(substitution, text)
    for (regexp, substitution) in self.PARENS_BRACKETS:
        text = regexp.sub(substitution, text)
    for (regexp, substitution) in self.PUNCTUATION:
        text = regexp.sub(substitution, text)
    for (regexp, substitution) in self.STARTING_QUOTES:
        text = regexp.sub(substitution, text)
    return text.strip()
