import re from typing import List from unidecode import unidecode def flatten_list(main_list: List[List]) -> List: return [item for sublist in main_list for item in sublist] def count_num_of_characters(text: str) -> int: return len(re.sub(r"[^a-zA-Z]", "", unidecode(text))) def count_num_of_words(text: str) -> int: return len(re.sub(r"[^a-zA-Z ]", "", unidecode(text)).split(" "))