WordCountConfig class
Configuration options for word counting behavior.
Controls how punctuation is handled during word counting and allows customization of the punctuation character set.
Example:
// Default behavior (punctuation is removed)
wordsCount("don't"); // Returns 1 (["dont"])
wordsCount("multi-word"); // Returns 1 (["multiword"])
// Split on punctuation instead of removing
const config1 = WordCountConfig(punctuationAsBreaker: true);
wordsCount("don't", config1); // Returns 2 (["don", "t"])
// Add custom punctuation
const config2 = WordCountConfig(punctuation: ['_']);
wordsCount('under_score', config2); // Returns 1 (["underscore"])
// Use only custom punctuation
const config3 = WordCountConfig(
punctuation: ['_'],
disableDefaultPunctuation: true
);
wordsCount("don't_test", config3); // Returns 2 (["don't", "test"])
Constructors
-
WordCountConfig({bool punctuationAsBreaker = false, bool disableDefaultPunctuation = false, List<
String> punctuation = const []}) -
Creates a new word count configuration.
const
Properties
- disableDefaultPunctuation → bool
-
Whether to disable the default punctuation list.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
punctuation
→ List<
String> -
Custom punctuation characters to use in addition to or instead of defaults.
final
- punctuationAsBreaker → bool
-
Whether to treat punctuation as word separators instead of removing them.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited