pub enum CountMethod {
WhitespaceSplit,
UnicodeWords,
CjkHybrid,
}Expand description
How words are delimited. Characters are always counted the same way (Unicode scalar
values), independent of this choice — see WordCharCounts.
Variants§
WhitespaceSplit
str::split_whitespace — fast, parity mode (e.g. matching another tool’s count).
Miscounts scripts that are not space-delimited (CJK) and is crude around
punctuation, but it is exactly what many word processors report.
UnicodeWords
UAX #29 word segmentation via unicode_words — the sound general-purpose default:
apostrophes glue ("Elena's" is one word), hyphens split, punctuation-only runs
are excluded. Still undercounts CJK (a run of ideographs may segment as one word).
CjkHybrid
UAX #29 for alphabetic scripts, but every Han / Hiragana / Katakana character counts
as one word — the East-Asian convention, where a “word count” of non-space-delimited
prose approximates a character count. Applied per character (not per detected script
run) so it is correct whether the segmenter split a run per-character (Han) or glued
it (Katakana, UAX #29 rule WB13). Korean (Hangul) is space-delimited and stays on the
UnicodeWords rule.
Trait Implementations§
Source§impl Clone for CountMethod
impl Clone for CountMethod
Source§fn clone(&self) -> CountMethod
fn clone(&self) -> CountMethod
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more