def METHOD_NAME(text, lang):
    if lang in WHITESPACE_LANGS:
        tokens = whitespace_tokenize(text)
    elif lang in MIXED_SEGMENTATION_LANGS:
        tokens = mixed_segmentation(text)
    else:
        raise Exception('Unknown Language {}'.format(lang))
    return ' '.join([t for t in tokens if t.strip() != ''])