3 ms·
Space-separated case: import sys from collections import Counter L = Counter( word for line in sys.stdin for word in
by d0mine 3y ago
Space-separated case:
import sys
from collections import Counter
L = Counter(
word
for line in sys.stdin
for word in line.casefold().split()
)
L is the words' multiset (the desired list of words with counts).
How many words are there in English? 1M?
Huge text [Unicode] files.
Fancier tokenizer:
for word in re.findall(r"\w+", line.casefold())