getStopWords function
- Locale locale
Returns the Stopwords set for the given locale.
Looks up the stop-word set by Locale.languageCode. 58 languages are supported; see Stopwords for the full list.
Throws ArgumentError if no stop-word set exists for the given language code.
final stopWords = getStopWords(Locale.parse('en'));
final tokens = ['the', 'quick', 'brown', 'fox'];
final content = tokens.where((t) => !stopWords.listing.contains(t)).toList();
Implementation
Stopwords getStopWords(Locale locale) {
try {
return Stopwords.values.byName(locale.languageCode);
} on ArgumentError {
throw ArgumentError.value(
locale.languageCode,
'locale.languageCode',
'No stop-word set available for language',
);
}
}