Skip to content

Instantly share code, notes, and snippets.

@n1ckdm
Last active August 5, 2022 08:23
Show Gist options
  • Save n1ckdm/748ff08e4596d75905340521af97e06f to your computer and use it in GitHub Desktop.
Save n1ckdm/748ff08e4596d75905340521af97e06f to your computer and use it in GitHub Desktop.
example of decisiont tables for apostrophe logic
let contraction_table = |w: &str| match
(contraction(w),pronoun(w),with_verb(w)) {
(false ,_ ,_ ) => "No Apostrophe",
(true ,true ,true ) => "Use Apostrophe",
(true ,false ,_ ) => "Use Apostrophe",
(true ,true ,false ) => "No Apostrophe"
};
let possessive_table = |w: &str| match
(possessive(w),is_it_it(w),is_or_has(w),name_ends_in_s(w),plural_name(w),ends_in_s(w)) {
(false ,_ ,_ ,_ ,_ ,_ ) => contraction_table(w),
(true ,true ,true ,_ ,_ ,_ ) => "Apostrophe + s",
(true ,true ,false ,_ ,_ ,_ ) => "No Apostrophe",
(true ,false ,_ ,true ,_ ,_ ) => "Apostrophe at end",
(true ,false ,_ ,false ,true ,_ ) => "Apostrophe at end",
(true ,false ,_ ,false ,false ,true ) => "Apostrophe at end",
(true ,false ,_ ,false ,false ,false ) => "Apostrophe + s",
};
let plural_table = |w: &str| match
(plural(w),single_letter(w),abbreviation(w)) {
(false ,_ ,_ ) => possessive_table(w),
(true ,true ,_ ) => "Apostrophe + s",
(true ,false ,true ) => "Apostrophe + s",
(true ,false ,false ) => "No Apostrophe",
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment