Expand description
contractions
is a library to handle contractions
So far only data sets to expand contractions are implemented.
Expands “I’m” to “I am” etc. The default data set has a replacement for all-lowercase, all-uppercase and first letter uppercase.
§Example
let contractions = contractions::Contractions::default();
assert_eq!("I am sure you would have been fine.", contractions.apply("I’m sure you’d’ve been fine."));
assert_eq!("Are you sure?", contractions.apply("R u sure?"));
let mut contractions = Contractions::new();
contractions.add_from_json(contractions::SINGLE_CONTRACTIONS_JSON);
assert_eq!("I am sad you couldn’t’ve come.", contractions.apply("I’m sad you couldn’t’ve come."));
Structs§
- Contractions
- Main actor in the
contractions
crate
Constants§
- CONTRACTIONS_
JSON_ ORDER - The list of all json strings.
- EXPAND_
DOUBLE_ CONTRACTIONS_ JSON - Contains contractions with two apostroph in json form (eg: Who’ll’ve, Wouldn’t’ve, Mustn’t’ve)
- EXPAND_
DOUBLE_ NO_ APOSTROPHE_ CONTRACTIONS_ JSON - Contains most of
CONTRACTIONS_DOUBLE_JSON
contractions but without apostroph - EXPAND_
PARTIAL_ CONTRACTIONS_ JSON - Contains partial contractions in json form. (eg: ’m, ’ve, n’t, ’re)
- EXPAND_
SINGLE_ CONTRACTIONS_ JSON - Contains contractions with one apostroph in json form (eg: I’m, I’ve, ’twas)
- EXPAND_
SINGLE_ NO_ APOSTROPHE_ CONTRACTIONS_ JSON - Contains most of
CONTRACTIONS_SINGLE_JSON
contractions but without apostroph - EXPAND_
SLANG_ JSON - Contains slang terms which will be expanded/changed to their full form
- EXPAND_
TRIPPLE_ CONTRACTIONS_ JSON - Contains contractions with three apostroph in json form (Y’all’d’ve, ’twou’dn’t)