LCOV - code coverage report
Current view: top level - src - stopwords.dart (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 5 5
Test Date: 2026-07-06 21:45:09 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2026 The Authors
       2              : //
       3              : // Licensed under the Apache License, Version 2.0 (the "License");
       4              : // you may not use this file except in compliance with the License.
       5              : // You may obtain a copy of the License at
       6              : //
       7              : //      https://www.apache.org/licenses/LICENSE-2.0
       8              : //
       9              : // Unless required by applicable law or agreed to in writing, software
      10              : // distributed under the License is distributed on an "AS IS" BASIS,
      11              : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12              : // See the License for the specific language governing permissions and
      13              : // limitations under the License.
      14              : 
      15              : import 'package:intl/locale.dart' show Locale;
      16              : 
      17              : import 'stopwords.g.dart';
      18              : 
      19              : export 'stopwords.g.dart' show Stopwords;
      20              : 
      21              : /// Returns the [Stopwords] set for the given [locale].
      22              : ///
      23              : /// Looks up the stop-word set by [Locale.languageCode]. 58 languages are
      24              : /// supported; see [Stopwords] for the full list.
      25              : ///
      26              : /// Throws [ArgumentError] if no stop-word set exists for the given language
      27              : /// code.
      28              : ///
      29              : /// ```dart
      30              : /// final stopWords = getStopWords(Locale.parse('en'));
      31              : /// final tokens = ['the', 'quick', 'brown', 'fox'];
      32              : /// final content = tokens.where((t) => !stopWords.listing.contains(t)).toList();
      33              : /// ```
      34            1 : Stopwords getStopWords(Locale locale) {
      35              :   try {
      36            2 :     return Stopwords.values.byName(locale.languageCode);
      37            1 :   } on ArgumentError {
      38            1 :     throw ArgumentError.value(
      39            1 :       locale.languageCode,
      40              :       'locale.languageCode',
      41              :       'No stop-word set available for language',
      42              :     );
      43              :   }
      44              : }
        

Generated by: LCOV version 2.0-1