termFrequencies function
Term frequencies for a list of tokens (e.g. words).
Implementation
Map<String, int> termFrequencies(List<String> tokens) {
final Map<String, int> tf = <String, int>{};
for (final String t in tokens) {
tf[t] = (tf[t] ?? 0) + 1;
}
return tf;
}