I often have a need to count tokens in a corpus. In Python, there are many ways to do this, but currently I most often use defaultdicts: 123d = defaultdict(int) for x in sequence: d[x] += 1 I would like to get rid of the for-loop and construct such a dictionary at once. I [...]
Pages
Categories
Archives