import random
import re
import string
-from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
+from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple
import unicodedata
from uuid import uuid4
"""
words = txt.split()
for ngram in ngrams_presplit(words, n):
- return ' '.join(ngram)
+ ret = ''
+ for word in ngram:
+ ret += f'{word} '
+ yield ret.strip()
-def ngrams_presplit(words: Iterable[str], n: int):
+def ngrams_presplit(words: Sequence[str], n: int):
return list_utils.ngrams(words, n)