termFrequencies function
Term frequencies for a list of tokens (e.g. words). Audited: 2026-06-12 11:26 EDT
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;
}