Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat:Shoot oneself into a leg → oneself in the foot (#1391)
Andrew Dunbarc5e24dc807c9
diff --git a/harper-core/affixes.json b/harper-core/affixes.jsonindex a7c9db4ec..6ebb0896c 100644--- a/harper-core/affixes.json+++ b/harper-core/affixes.json@@ -309,7 +309,7 @@"noun": {}}},- "F": {+ "W": {"#": "'con-' prefix","kind": "prefix","cross_product": true,@@ -755,6 +755,14 @@"person": "First"}}+ },+ "F": {+ "#": "reflexive property",+ "metadata": {+ "pronoun": {+ "is_reflexive": true+ }+ }}}}diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex eebc44004..c9af4b56b 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -16706,7 +16706,7 @@ caviller/NgS!@_cavilling/VNS!@_caving/NVgcavitation/N-cavity/~NFSg+cavity/~NWSgcavort/VdGScaw/NVSgdGcay/~NeSg@@ -16721,7 +16721,7 @@ ceca/Ncecal/Jcecum/Ngcedar/~NgS-cede/~VFrGSd+cede/~VWrGSdceder/NgScedilla/NSgceilidh/NV@@ -16853,14 +16853,14 @@ cervix/Ngcesarean/JNgScesium/Ngcessation/~NgS-cession/NKrFSg+cession/NKrWSgcesspit/NSgcesspool/NgScetacean/JNgSceteriscf/~Vcg/~-ch/~NIiFvT+ch/~NIiWvTchad/~NSchafe/NVGdSchaff/NVGgdS@@ -19926,7 +19926,7 @@ curly/~JN>pTcurmudgeon/NgYScurrant/NgScurrency/~NSg-current/~NJFrY+current/~NJWrYcurrent'scurrents/~Ncurricula/~9@@ -19959,7 +19959,7 @@ cushy/J>Tcusp/~NVgScuspid/NSgcuspidor/NSg-cuss/VNFEGSd+cuss/VNWEGSdcuss'scussed/VJpYcustard/~NgS@@ -20774,7 +20774,7 @@ desalinise/VGdS!_desalinization/Ngdesalinize/VGdSdescant/NVg-descend/~VNFGdS+descend/~VNWGdSdescendant/~JNgSdescendent/JN!@_descender/N@@ -21637,7 +21637,7 @@ doily/NSgdoing/~VNUSgdojo/NgSdoldrums/Ng-dole/~VNFGdS+dole/~VNWGdSdole'sdoleful/JYpdolefulness/Ng@@ -21682,7 +21682,7 @@ don't/~Vdona/~gSdonate/~VdSXGndonation/~Ng-done/~JVNFrU+done/~JVNWrUdong/~NVgdGSdongle/NSgdonkey/~NSg@@ -22086,7 +22086,7 @@ duckling/~NSgduckpins/Ngduckweed/Ngducky/JNT>Sg-duct/~NVeKiFS+duct/~NVeKiWSduct's/Kductile/Jductility/Ng@@ -22241,7 +22241,7 @@ dystopidystopia/Ndystopian/~Jdz/NV-e/~NIFdST+e/~NIWdSTe'en/e'er/e.g./~N@@ -24247,8 +24247,8 @@ federalism/~Ngfederalist/~NJgSfederalization/Ngfederalize/VGdS-federate/JNVFXdSGn-federation/~NJFg+federate/JNVWXdSGn+federation/~NJWgfedora/NSgfee/~NVSgfeeble/~JV>Tp@@ -24265,7 +24265,7 @@ feel/~VNIg>ZGSzfeeler/Ngfeelgood/Jfeeling/~JNVgY-feet/~N+feet/~9feign/VSdGfeigned/JVUfeint/NVJSgdG@@ -24309,7 +24309,7 @@ fenestration/Ngfennel/Ngfentanyl/Ngferal/~JN-ferment/~VNFegS+ferment/~VNWegSfermentation/~Ngfermented/~VJfermenting/V@@ -24346,7 +24346,7 @@ fervent/~JYfervid/JYfervor/Ngfervour/Ng!@_-fess/~VNJFKGSd+fess/~VNJWKGSdfest/~Ng>ZvSfestal/Jfester/NVGgd@@ -24471,9 +24471,9 @@ fightback/Nfighter/~NigSfighting/~JVNigfigment/NgS-figuration/NFg+figuration/NWgfigurative/~JY-figure/~NVFEGSd+figure/~NVWEGSdfigure'sfigurehead/~NSgfigurine/NgS@@ -24543,8 +24543,8 @@ find/~VNzg>ZGSfinder/~Ngfinding/~NVgfindings/~Ng-fine/~JNVerFTGdS-fine's/F+fine/~JNVerWTGdS+fine's/Wfinely/~Rfineness/Ngfinery/Nrg@@ -25235,7 +25235,7 @@ fork/~NVgdGSforkful/NSgforklift/NVgSforlorn/JNVY-form/~NVeriFdGS+form/~NVeriWdGSform'sformal/~JNSgYformaldehyde/Ng@@ -25249,12 +25249,12 @@ formality/~Nigformalization/Ngformalize/VGdSformat/~NVSgv-formation/~NeFrSg+formation/~NeWrSgformatted/~VJrformatter/NgSformatting/~NVgformed/~VU-former/~JNFirg+former/~JNWirgformerly/~Rformfitting/Jformic/J@@ -25322,7 +25322,7 @@ foul/~JVNgd>YTGSpfoulard/Ngfoulmouthed/Jfoulness/Ng-found/~VNFSdG+found/~VNWSdGfoundation/~NSgfoundational/~Jfounded/~VJU@@ -25404,7 +25404,7 @@ fraternal/~JNYfraternisation/Ng!_fraternise/VZGd>S!_fraterniser/Ng!_-fraternity/~NFSg+fraternity/~NWSgfraternization/Ngfraternize/VZGd>Sfraternizer/Ng@@ -25560,7 +25560,7 @@ frolicking/VNfrolicsome/Jfrom/~Pfrond/NSg-front/~NJVFSdG+front/~NJVWSdGfront's/Jfrontage/~NgSfrontal/~JNY@@ -25740,7 +25740,7 @@ furtive/JYpfurtiveness/Ngfury/~NSgfurze/Ng-fuse/~NVeriFGdS+fuse/~NVeriWGdSfuse's/rfusee/NSgfuselage/~NSg@@ -25748,7 +25748,7 @@ fusibility/Ngfusible/JNfusilier/NSgfusillade/NVgS-fusion/~NViFKSg+fusion/~NViWKSgfuss/NVgdSGfussbudget/NgSfussily/R@@ -26079,12 +26079,12 @@ genesis/~Nggenetic/~JSQgeneticist/~NgSgenetics/~Ng-genial/JFY-geniality/NFg+genial/JWY+geniality/NWggeniculate/JVgenie/~NSggenii/N-genital/~JNFY+genital/~JNWYgenitalia/~Nggenitals/~Nggenitive/~JNgS@@ -27909,7 +27909,7 @@ herpetology/Ngherring/~NgSherringbone/NVghers/~I*-herself/~I+herself/~IFhertz/~Nghesitance/Nghesitancy/Ng@@ -28011,7 +28011,7 @@ hilltop/~NgShilly/~Jp>Thilt/~NVgShim/~Io3-himself/~I+himself/~IFhind/~JNg>ZShinder/~VJNGdhindered/~VU@@ -30345,12 +30345,12 @@ iterator/NSitinerant/~JNSgitinerary/~NJSgits/~ID*-itself/~I+itself/~IFiv/~Uivory/~NJSgivy/~NdSgix/~-j/~NF+j/~NWjab/NVSgjabbed/VJjabber/VNSgd>ZG@@ -30563,13 +30563,13 @@ joggle/VNdSgGjohn/~NgSjohnny/~NSgjohnnycake/NgS-join/~VNrFdSG+join/~VNrWdSGjoin's-joiner/NFgS+joiner/NWgSjoinery/Ngjoint/~JNVEGSdjoint's-jointly/~FR+jointly/~WRjoist/NVSgjojoba/~Njoke/~NVgZGd>S@@ -30682,8 +30682,8 @@ jumpsuit/NgSjumpy/JT>pjun/~Njunco/~NSg-junction/~NVFiSg-juncture/NFgS+junction/~NVWiSg+juncture/NWgSjungle/~NJgSjunior/~JNVgSjuniper/~NSg@@ -30725,7 +30725,7 @@ jutting/VNjuvenile/~JNSgjuxtapose/VdSGjuxtaposition/~NVSg-k/~NiFGS+k/~NiWGSkHz/kW/kWh/@@ -32625,7 +32625,7 @@ mammoth/~NJgmammoths/~Nmammy/NSgman/~NJVOUSY # removed `8` pronoun, dialectal & complicates lint heuristics-man's/~NJIVOF+man's/~NJIVOWmanacle/NVdSgGmanage/~VNZGd>SLmanageability/Ng@@ -34707,7 +34707,7 @@ myrmidon/NgSmyrrh/Ngmyrtle/~NSgmys/-myself/~I+myself/~IFmysterious/~JpYmysteriousness/Ngmystery/~NSg@@ -35676,10 +35676,10 @@ notarization/Ngnotarize/VGdSnotary/~NSgnotate/VJGdS-notation/~NFeSg+notation/~NWeSgnotch/~NVGgdSnotchback/NgS-note/~NVFeSdG+note/~NVWeSdGnote'snotebook/~NgSnotelet/NS@@ -36189,7 +36189,7 @@ one/~NIJVSXgnponeness/Ngonerous/JpYonerousness/Ng-oneself/~I+oneself/~IFonetime/Jonfield/Jongoing/~JNV@@ -36477,8 +36477,8 @@ oughtn't/mounce/~NgSour/~Dours/~I-ourself/I-ourselves/~I+ourself/IF # reflexive of the 'Royal We'+ourselves/~IFoust/~VZGd>Souster/~NVgout/~PNVJSzGgd>R@@ -40476,7 +40476,7 @@ querulousness/Ngquery/~NVdSgGBques/Nquesadilla/NgS-quest/~NViFrgS+quest/~NViWrgSquested/Vquesting/NVquestion/~NVSgd>ZGBz@@ -42931,7 +42931,7 @@ schwa/NVgSsci/~Nsciatic/JNsciatica/Ng-science/~NVFgS+science/~NVWgSscientific/~JUQscientism/Ngscientist/~NSg@@ -43048,7 +43048,7 @@ scrimmage/~NVgGdSscrimp/NVJSdGscrimshaw/VNgdGSscrip/NgS-script/~NVFSgdGB+script/~NVWSgdGBscripted/~VJUscriptural/~Jscripture/~NgS@@ -43446,7 +43446,7 @@ sensualist/NSgsensuality/Ngsensuous/JYpsensuousness/Ng-sent/~VNFrU+sent/~VNWrUsentence/~NVgGdSsententious/JYsentience/Nig@@ -43493,7 +43493,7 @@ seq/~Nsequel/~NSgsequence/~NVgZGd>Ssequencing/~VNg-sequential/~JFY+sequential/~JWYsequester/VNSdGsequestrate/VJXGndSsequestration/Ng@@ -43542,8 +43542,8 @@ serration/Ngserried/VJserum/~NgSservant/~NVgS-serve/~NVFreGdS-serve's/rF+serve/~NVWreGdS+serve's/rWserver/~NSgservery/NSservice/~NVEgS@@ -44118,7 +44118,7 @@ sightread/Vsightseeing/~NVgsightseer/NgSsigma/~NgS-sign/~NVrFeGdS+sign/~NVrWeGdSsign's/esignage/~Ngsignal/~NVJgd>YSZG@@ -44144,7 +44144,7 @@ signification/Ngsignify/~VXdSnGsigning's/esignings/~N-signor/NFgS+signor/NWgSsignora/NSgsignore/Nsignori/N@@ -44953,7 +44953,7 @@ solder/NVZGSgd>rsolderer/Ngsoldier/~NVgdYSGsoldiery/Ng-sole/~JNVFSdGg+sole/~JNVWSdGgsolecism/NSgsolely/~Rsolemn/~JpT>Y@@ -45102,7 +45102,7 @@ sorrow/~NVSgdGsorrowful/JYpsorrowfulness/Ngsorry/~JNV>Tp-sort/~NVFrSGdg+sort/~NVWrSGdgsorta/sorted/~VJUsorter/NSg@@ -45401,7 +45401,7 @@ spiraea/NgS!_spiral/~NJVSGgdYspiralled/V!@_spiralling/VN!@_-spire/~NViFrS+spire/~NViWrSspire'sspirea/NSgspirit/~NViSGd@@ -46145,7 +46145,7 @@ straightforward/~JYpSstraightforwardness/Ngstraightness/Ngstraightway/N-strain/~NVFrdSG+strain/~NVWrdSGstrain'sstrainer/NrSgstrait/~JNVgnSX@@ -46511,7 +46511,7 @@ substandard/Jsubstantial/~JNiYsubstantiate/~VGndSXsubstantiated/~VU-substantiation/NFg+substantiation/NWgsubstantive/~JNVSgYsubstation/~NgSsubstituent/N@@ -46671,7 +46671,7 @@ summarize/~VGdSsummarizer/NgSsummary/~JNSgsummat/-summation/~NFgS+summation/~NWgSsummed/~Vsummer/~NVgdSGsummerhouse/NSg@@ -47258,7 +47258,7 @@ tackle/~NVd>SgZGtackler/Ngtacky/JN>Tptaco/~NVgS-tact/~NVFg+tact/~NVWgtactful/JYptactfulness/Ngtactic/~NJSg@@ -47677,7 +47677,7 @@ tempo/~NSgtemporal/~JNYtemporarily/~Rtemporariness/Ng-temporary/~JNFSg+temporary/~JNWSgtemporise/VZGd>S!_temporiser/Ng!_temporize/VZGd>S@@ -47700,7 +47700,7 @@ tenant/~NVSgdGtenanted/VUtenantry/Ngtench/N-tend/~ViEFdGS+tend/~ViEWdGStended/~VUtendency/~NSgtendentious/JYp@@ -47810,8 +47810,8 @@ tertiary/~JNtessellate/JVdSXGntessellation/Ngtest/~NVrKedGS-test's/rFK-testable/JeF+test's/rWK+testable/JeWtestament/~NVgStestamentary/Jtestate/JNS@@ -47842,13 +47842,13 @@ tetracycline/Ngtetrahedral/~Jtetrahedron/~NgStetrameter/NSg-text/~NVFgS+text/~NVWgStextbased/Jtextbook/~NJSgtexted/Vtextile/~NJgStexting/VN-textual/~JFY+textual/~JWYtextural/Jtexture/~NVgGdSthalami/N@@ -47890,7 +47890,7 @@ them/~Io3g # them's as in (one of) them is/hasthematic/~JNQthematically/theme/~NVdSgG-themselves/~I+themselves/~IFthen/~JNCgthence/~thenceforth/@@ -48149,7 +48149,8 @@ thymine/Ngthymus/NgSthyroid/~JNgSthyroidal/J-thyself/I+thyself/IF+fooselfti/~Ng>Ztiara/~NVSgtibia/~Ng@@ -48521,7 +48522,7 @@ torridness/Ngtorsion/~Ngtorsional/Jtorso/~NSg-tort/~NJFErS+tort/~NJWErStort'storte/NSgtortellini/Ng@@ -48576,7 +48577,7 @@ toughie/NSgtoughness/~Ngtoughs/Ntoupee/NgS-tour/~NVeFSGdg+tour/~NVeWSGdgtourism/~Ngtourist/~NVgStouristed/J@@ -48647,13 +48648,13 @@ trackball/NSgtracker/~Ngtrackless/Jtracksuit/NS-tract/~NVeEKFrS+tract/~NVeEKWrStract'stractability/Nigtractable/Jitractably/iR-traction/~NVEFreKg-tractor/~NVFeKgS+traction/~NVEWreKg+tractor/~NVWeKgStrad/~JNtrade/~NVJzd>SgZGtrademark/~NVJSGgd@@ -48971,7 +48972,7 @@ tribulation/NSgtribunal/~NSgtribune/~NgStributary/~NJSg-tribute/~NVFS+tribute/~NVWStribute'strice/VNgtricentennial/NJgS@@ -49050,8 +49051,8 @@ tripwire/NVStrireme/NSgtrisect/VSdGtrisection/Ng-trite/JNFpYT-triteness/NFg+trite/JNWpYT+triteness/NWgtriter/Jtritium/~Ngtriumph/~NVGgd@@ -50459,7 +50460,7 @@ verdant/JYverdict/~NSgverdigris/NVGgdSverdure/NVg-verge/~NVFdSG+verge/~NVWdSGverge'sverger/NgSverifiable/~JU@@ -50488,12 +50489,12 @@ verrucae/9versa/~versatile/~Jversatility/~Ng-verse/~NVrFnGgSdX+verse/~NVrWnGgSdXversed/~JVUversification/Ngversifier/Ngversify/VZGnd>S-version/~NVrFigS+version/~NVrWigSversioned/JVversioning/~Nverso/~NSg@@ -50785,7 +50786,7 @@ vocalise/VNdSG!_vocalist/~NSgvocalization/NgSvocalize/VdSG-vocation/~NFiKrSg+vocation/~NWiKrSgvocational/~JYvocative/JNgSvociferate/VdSGn@@ -52199,8 +52200,8 @@ youngish/Jyoungster/~NgSyour/~Dyours/~I-yourself/~I-yourselves/~I+yourself/~IF+yourselves/~IFyouth/~Ngyouthful/~JYpyouthfulness/Ng@@ -53247,4 +53248,4 @@ z-axis/Ng# And they will be reviewed# Word added using the `just addnoun` command will be added here-handedly+handedly\ No newline at end of filediff --git a/harper-core/src/char_string.rs b/harper-core/src/char_string.rsindex 74d44efb3..88cd6982a 100644--- a/harper-core/src/char_string.rs+++ b/harper-core/src/char_string.rs@@ -8,9 +8,30 @@ pub type CharString = SmallVec<[char; 16]>;/// Extensions to character sequences that make them easier to wrangle.pub trait CharStringExt {+ /// Convert all characters to lowercase, returning a new owned vector if any changes were made.fn to_lower(&self) -> Cow<[char]>;++ /// Normalize the character sequence according to the dictionary's standard character set.fn normalized(&self) -> Cow<[char]>;++ /// Convert the character sequence to a String.fn to_string(&self) -> String;++ /// Case-insensitive comparison with a character slice, assuming the right-hand side is lowercase ASCII.+ /// Only normalizes the left side to lowercase and avoids allocations.+ fn eq_ignore_ascii_case_chars(&self, other: &[char]) -> bool;++ /// Case-insensitive comparison with a string slice, assuming the right-hand side is lowercase ASCII.+ /// Only normalizes the left side to lowercase and avoids allocations.+ fn eq_ignore_ascii_case_str(&self, other: &str) -> bool;++ /// Case-insensitive check if the string ends with the given ASCII suffix.+ /// The suffix is assumed to be lowercase.+ fn ends_with_ignore_ascii_case_chars(&self, suffix: &[char]) -> bool;++ /// Case-insensitive check if the string ends with the given ASCII suffix.+ /// The suffix is assumed to be lowercase.+ fn ends_with_ignore_ascii_case_str(&self, suffix: &str) -> bool;}impl CharStringExt for [char] {@@ -45,6 +66,48 @@ impl CharStringExt for [char] {Cow::Borrowed(self)}}++ fn eq_ignore_ascii_case_str(&self, other: &str) -> bool {+ self.len() == other.len()+ && self+ .iter()+ .zip(other.chars())+ .all(|(a, b)| a.to_ascii_lowercase() == b)+ }++ fn eq_ignore_ascii_case_chars(&self, other: &[char]) -> bool {+ self.len() == other.len()+ && self+ .iter()+ .zip(other.iter())+ .all(|(a, b)| a.to_ascii_lowercase() == *b)+ }++ fn ends_with_ignore_ascii_case_str(&self, suffix: &str) -> bool {+ let suffix_len = suffix.len();+ if self.len() < suffix_len {+ return false;+ }+ self.iter()+ .rev()+ .take(suffix_len)+ .rev()+ .zip(suffix.chars())+ .all(|(a, b)| a.to_ascii_lowercase() == b)+ }++ fn ends_with_ignore_ascii_case_chars(&self, suffix: &[char]) -> bool {+ let suffix_len = suffix.len();+ if self.len() < suffix_len {+ return false;+ }+ self.iter()+ .rev()+ .take(suffix_len)+ .rev()+ .zip(suffix.iter())+ .all(|(a, b)| a.to_ascii_lowercase() == *b)+ }}fn char_to_normalized(c: char) -> char {@@ -65,3 +128,51 @@ macro_rules! char_string {}pub(crate) use char_string;++#[cfg(test)]+mod tests {+ use super::CharStringExt;++ #[test]+ fn eq_ignore_ascii_case_chars_matches_lowercase() {+ assert!(['H', 'e', 'l', 'l', 'o'].eq_ignore_ascii_case_chars(&['h', 'e', 'l', 'l', 'o']));+ }++ #[test]+ fn eq_ignore_ascii_case_chars_does_not_match_different_word() {+ assert!(!['H', 'e', 'l', 'l', 'o'].eq_ignore_ascii_case_chars(&['w', 'o', 'r', 'l', 'd']));+ }++ #[test]+ fn eq_ignore_ascii_case_str_matches_lowercase() {+ assert!(['H', 'e', 'l', 'l', 'o'].eq_ignore_ascii_case_str("hello"));+ }++ #[test]+ fn eq_ignore_ascii_case_str_does_not_match_different_word() {+ assert!(!['H', 'e', 'l', 'l', 'o'].eq_ignore_ascii_case_str("world"));+ }++ #[test]+ fn ends_with_ignore_ascii_case_chars_matches_suffix() {+ assert!(['H', 'e', 'l', 'l', 'o'].ends_with_ignore_ascii_case_chars(&['l', 'o']));+ }++ #[test]+ fn ends_with_ignore_ascii_case_chars_does_not_match_different_suffix() {+ assert!(+ !['H', 'e', 'l', 'l', 'o']+ .ends_with_ignore_ascii_case_chars(&['w', 'o', 'r', 'l', 'd'])+ );+ }++ #[test]+ fn ends_with_ignore_ascii_case_str_matches_suffix() {+ assert!(['H', 'e', 'l', 'l', 'o'].ends_with_ignore_ascii_case_str("lo"));+ }++ #[test]+ fn ends_with_ignore_ascii_case_str_does_not_match_different_suffix() {+ assert!(!['H', 'e', 'l', 'l', 'o'].ends_with_ignore_ascii_case_str("world"));+ }+}diff --git a/harper-core/src/expr/mod.rs b/harper-core/src/expr/mod.rsindex 51da0ee59..1c1e7138a 100644--- a/harper-core/src/expr/mod.rs+++ b/harper-core/src/expr/mod.rs@@ -6,6 +6,7 @@ mod first_match_of;mod fixed_phrase;mod longest_match_of;mod mergeable_words;+mod reflexive_pronoun;mod repeating;mod sequence_expr;mod similar_to_phrase;@@ -26,6 +27,7 @@ pub use expr_map::ExprMap;pub use fixed_phrase::FixedPhrase;pub use longest_match_of::LongestMatchOf;pub use mergeable_words::MergeableWords;+pub use reflexive_pronoun::ReflexivePronoun;pub use repeating::Repeating;pub use sequence_expr::SequenceExpr;pub use similar_to_phrase::SimilarToPhrase;diff --git a/harper-core/src/expr/reflexive_pronoun.rs b/harper-core/src/expr/reflexive_pronoun.rsnew file mode 100644index 000000000..be45b72cf--- /dev/null+++ b/harper-core/src/expr/reflexive_pronoun.rs@@ -0,0 +1,99 @@+use crate::{+ Span, Token,+ expr::{Expr, LongestMatchOf},+ patterns::WordSet,+};++// These are considered ungrammatical, or are at least not in `dictionary.dict` but are commonly used anyway.+// The tests below check if this changes so we can update this `Expr`+const BAD_REFLEXIVE_PRONOUNS: &[&str] = &[+ "hisself",+ "oneselves",+ "theirself",+ "theirselves",+ "themself",+];++#[derive(Default)]+pub struct ReflexivePronoun;++impl Expr for ReflexivePronoun {+ fn run(&self, cursor: usize, tokens: &[Token], source: &[char]) -> Option<Span> {+ let good_pronouns = |token: &Token, _: &[char]| token.kind.is_reflexive_pronoun();+ let bad_pronouns = WordSet::new(BAD_REFLEXIVE_PRONOUNS);+ let expr = LongestMatchOf::new(vec![Box::new(good_pronouns), Box::new(bad_pronouns)]);+ expr.run(cursor, tokens, source)+ }+}++#[cfg(test)]+mod tests {+ use crate::{Document, TokenKind, expr::reflexive_pronoun::BAD_REFLEXIVE_PRONOUNS};++ // These are considered grammatically correct, or are at least in `dictionary.dict`.+ // The tests below check if this changes so we can update this `Expr`+ const GOOD_REFLEXIVE_PRONOUNS: &[&str] = &[+ "herself",+ "himself",+ "itself",+ "myself",+ "oneself",+ "ourself",+ "ourselves",+ "themselves",+ "thyself",+ "yourself",+ "yourselves",+ ];++ fn test_pronoun(word: &str) {+ let doc = Document::new_plain_english_curated(word);+ let token = doc.tokens().next().expect("No tokens in document");++ let is_good_pron = GOOD_REFLEXIVE_PRONOUNS.contains(&word);+ let is_bad_pron = BAD_REFLEXIVE_PRONOUNS.contains(&word);++ match (is_good_pron, is_bad_pron, &token.kind) {+ (true, false, TokenKind::Word(Some(md))) => {+ assert!(md.is_pronoun());+ assert!(md.is_reflexive_pronoun());+ }+ (true, false, TokenKind::Word(None)) => {+ panic!("Widely accepted pronoun '{word}' has gone missing from the dictionary!")+ }+ (false, true, TokenKind::Word(Some(_))) => panic!(+ "Unaccepted pronoun '{word}' that's used in bad English is now in the dictionary!"+ ),+ (false, true, TokenKind::Word(None)) => {}+ (false, false, TokenKind::Word(Some(_))) => panic!(+ "non-pronoun '{word}' is made up just for testing but is now in the dictionary!"+ ),+ (false, false, TokenKind::Word(None)) => {}+ (true, true, _) => panic!("'{word}' is in both good and bad lists"),+ _ => panic!("'{word}' doesn't match any expected case"),+ }+ }++ #[test]+ fn test_good_reflexive_pronouns() {+ for word in GOOD_REFLEXIVE_PRONOUNS {+ test_pronoun(word);+ }+ }++ #[test]+ fn test_bad_reflexive_pronouns() {+ for word in BAD_REFLEXIVE_PRONOUNS {+ test_pronoun(word);+ }+ }++ // It's expected that nobody uses these words even in bad English.+ #[test]+ fn test_non_pronouns() {+ test_pronoun("myselves");+ test_pronoun("weselves");+ test_pronoun("usself");+ test_pronoun("usselves");+ }+}diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rsindex f09e78c9e..c8caba76d 100644--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@ -69,6 +69,7 @@ use super::proper_noun_capitalization_linters;use super::repeated_words::RepeatedWords;use super::save_to_safe::SaveToSafe;use super::sentence_capitalization::SentenceCapitalization;+use super::shoot_oneself_in_the_foot::ShootOneselfInTheFoot;use super::since_duration::SinceDuration;use super::somewhat_something::SomewhatSomething;use super::spaces::Spaces;@@ -399,6 +400,7 @@ impl LintGroup {insert_struct_rule!(RepeatedWords, true);insert_struct_rule!(SaveToSafe, true);insert_pattern_rule!(SinceDuration, true);+ insert_pattern_rule!(ShootOneselfInTheFoot, true);insert_pattern_rule!(SomewhatSomething, true);insert_struct_rule!(Spaces, true);insert_struct_rule!(SpelledNumbers, false);diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex 559c04a4f..4ce545663 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -76,6 +76,7 @@ mod proper_noun_capitalization_linters;mod repeated_words;mod save_to_safe;mod sentence_capitalization;+mod shoot_oneself_in_the_foot;mod since_duration;mod somewhat_something;mod spaces;@@ -158,6 +159,7 @@ pub use pronoun_contraction::PronounContraction;pub use repeated_words::RepeatedWords;pub use save_to_safe::SaveToSafe;pub use sentence_capitalization::SentenceCapitalization;+pub use shoot_oneself_in_the_foot::ShootOneselfInTheFoot;pub use since_duration::SinceDuration;pub use somewhat_something::SomewhatSomething;pub use spaces::Spaces;diff --git a/harper-core/src/linting/shoot_oneself_in_the_foot.rs b/harper-core/src/linting/shoot_oneself_in_the_foot.rsnew file mode 100644index 000000000..31c5feb91--- /dev/null+++ b/harper-core/src/linting/shoot_oneself_in_the_foot.rs@@ -0,0 +1,227 @@+use crate::{+ CharStringExt, Span, Token,+ expr::{Expr, ReflexivePronoun, SequenceExpr},+ linting::Suggestion,+ patterns::WordSet,+};++use super::{ExprLinter, Lint, LintKind};++pub struct ShootOneselfInTheFoot {+ pattern: Box<dyn Expr>,+}++impl Default for ShootOneselfInTheFoot {+ fn default() -> Self {+ let verb_forms = WordSet::new(&["shoot", "shooting", "shoots", "shot", "shooted"]);++ let body_parts = WordSet::new(&["foot", "feet", "leg", "legs"]);++ let pattern = SequenceExpr::default()+ .then(verb_forms)+ .t_ws()+ .then(ReflexivePronoun)+ .t_ws()+ .then_preposition()+ .t_ws()+ .then_determiner()+ .t_ws()+ .then(body_parts);+ Self {+ pattern: Box::new(pattern),+ }+ }+}++impl ExprLinter for ShootOneselfInTheFoot {+ fn expr(&self) -> &dyn Expr {+ self.pattern.as_ref()+ }++ fn match_to_lint(&self, toks: &[Token], src: &[char]) -> Option<Lint> {+ let pron = &toks.get(2)?.span.get_content(src);+ let prep = &toks.get(4)?.span.get_content(src);+ let det = &toks.get(6)?.span.get_content(src);+ let body_part = &toks.get(8)?.span.get_content(src);++ let plural_pron = pron.ends_with_ignore_ascii_case_str("elves");+ let plural_foot = toks.get(8)?.kind.is_plural_noun();++ let is_in = prep.eq_ignore_ascii_case_str("in");+ let is_the = det.eq_ignore_ascii_case_str("the");+ let is_foot = body_part.eq_ignore_ascii_case_str("foot");++ let foot_ok = is_foot || (plural_pron && plural_foot);++ if is_in && is_the && foot_ok {+ return None;+ }++ let in_the_foot = Span::new(toks.get(4)?.span.start, toks.get(8)?.span.end);++ let mut suggestions = vec![Suggestion::replace_with_match_case_str(+ "in the foot",+ in_the_foot.get_content(src),+ )];++ if plural_pron {+ suggestions.push(Suggestion::replace_with_match_case_str(+ "in the feet",+ in_the_foot.get_content(src),+ ));+ }++ Some(Lint {+ span: in_the_foot,+ lint_kind: LintKind::Miscellaneous,+ suggestions,+ message: "The standard idiom is 'shoot oneself in the foot'.".to_string(),+ priority: 50,+ })+ }++ fn description(&self) -> &str {+ "Corrects non-standard variants of 'shoot oneself in the foot'."+ }+}++#[cfg(test)]+mod tests {+ use super::ShootOneselfInTheFoot;+ use crate::linting::tests::{assert_lint_count, assert_suggestion_result};++ #[test]+ fn ignore_correct() {+ assert_lint_count(+ "Don't shoot yourself in the foot.",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }++ #[test]+ fn ignore_title_case() {+ assert_lint_count(+ "Don't Shoot Yourself In The Foot.",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }++ #[test]+ fn ignore_all_caps() {+ assert_lint_count(+ "DON'T SHOOT YOURSELF IN THE FOOT.",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }++ #[test]+ fn fix_shoot_leg() {+ assert_suggestion_result(+ "I managed to shoot myself in the leg when using CF Workers deployment",+ ShootOneselfInTheFoot::default(),+ "I managed to shoot myself in the foot when using CF Workers deployment",+ );+ }++ #[test]+ fn fix_shoot_into_foot() {+ assert_suggestion_result(+ "Or should we keep them to prevent users from shooting themselves into the foot?",+ ShootOneselfInTheFoot::default(),+ "Or should we keep them to prevent users from shooting themselves in the foot?",+ );+ }++ #[test]+ fn fix_shoot_into_feet() {+ assert_suggestion_result(+ "(to prevent you from shooting yourself into the feet)",+ ShootOneselfInTheFoot::default(),+ "(to prevent you from shooting yourself in the foot)",+ );+ }++ #[test]+ fn ignore_themselves_foot() {+ assert_lint_count(+ "Thou shalt not make a rule that prevents C++ programmers from shooting themselves in the foot.",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }++ #[test]+ fn ignore_ourselves_feet() {+ assert_lint_count(+ "It will help avoiding shooting ourselves in the feet.",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }++ #[test]+ fn fix_a_foot() {+ assert_suggestion_result(+ "Shot ourselves in a foot, \"Wrong X-Request-Key\" error #589.",+ ShootOneselfInTheFoot::default(),+ "Shot ourselves in the foot, \"Wrong X-Request-Key\" error #589.",+ );+ }++ #[test]+ fn ignore_shoots_himself() {+ assert_suggestion_result(+ "the administrator shoots himself in the foot and then hops around",+ ShootOneselfInTheFoot::default(),+ "the administrator shoots himself in the foot and then hops around",+ );+ }++ #[test]+ fn ignore_shooting_oneself_in_the_foot() {+ assert_lint_count(+ "A historical document of shooting oneself in the foot, if you will.",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }++ #[test]+ fn fix_oneself_in_a_foot() {+ assert_suggestion_result(+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself in a foot",+ ShootOneselfInTheFoot::default(),+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself in the foot",+ );+ }++ #[test]+ fn fix_oneself_in_the_feet() {+ assert_suggestion_result(+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself in the feet",+ ShootOneselfInTheFoot::default(),+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself in the foot",+ );+ }++ #[test]+ fn fix_oneself_into_the_leg() {+ assert_suggestion_result(+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself into the foot",+ ShootOneselfInTheFoot::default(),+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself in the foot",+ );+ }++ #[test]+ fn ignore_oneself_in_the_toes() {+ assert_lint_count(+ "Forgetting to declare some variable local withing a function definition is a common way to shoot oneself in the toes",+ ShootOneselfInTheFoot::default(),+ 0,+ );+ }+}diff --git a/harper-core/src/token_kind.rs b/harper-core/src/token_kind.rsindex 7dc7a3caa..488e6523e 100644--- a/harper-core/src/token_kind.rs+++ b/harper-core/src/token_kind.rs@@ -432,6 +432,14 @@ impl TokenKind {metadata.is_pronoun()}+ pub fn is_reflexive_pronoun(&self) -> bool {+ let TokenKind::Word(Some(metadata)) = self else {+ return false;+ };++ metadata.is_reflexive_pronoun()+ }+pub fn is_likely_homograph(&self) -> bool {let TokenKind::Word(Some(metadata)) = self else {return false;diff --git a/harper-core/src/word_metadata.rs b/harper-core/src/word_metadata.rsindex 260d019fc..c8dc39bb1 100644--- a/harper-core/src/word_metadata.rs+++ b/harper-core/src/word_metadata.rs@@ -304,7 +304,7 @@ impl WordMetadata {generate_metadata_queries!(noun has proper, plural, possessive.- pronoun has plural, possessive.+ pronoun has plural, possessive, reflexive.verb has linking, auxiliary.conjunction has.adjective has.@@ -351,7 +351,7 @@ impl WordMetadata {)}- /// Checks if the word is definitely nominalpro.+ /// Checks if the word is definitely nominal.pub fn is_nominal(&self) -> bool {self.noun.is_some() || self.pronoun.is_some()}@@ -517,6 +517,7 @@ pub enum Case {pub struct PronounData {pub is_plural: Option<bool>,pub is_possessive: Option<bool>,+ pub is_reflexive: Option<bool>,pub person: Option<Person>,pub case: Option<Case>,}@@ -527,6 +528,7 @@ impl PronounData {Self {is_plural: self.is_plural.or(other.is_plural),is_possessive: self.is_possessive.or(other.is_possessive),+ is_reflexive: self.is_reflexive.or(other.is_reflexive),person: self.person.or(other.person),case: self.case.or(other.case),}diff --git a/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md b/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.mdindex 0e1e5f917..9af552ad7 100644--- a/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md+++ b/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md@@ -45,7 +45,7 @@> but when the Rabbit actually took a watch out of its waistcoat - pocket , and# NSg/C/P NSg/I/C D+ NSg/V+ R V D/P NSg/V NSg/V/J/R/P P ISg/D+ NSg . NSg/V/J . V/C> looked at it , and then hurried on , Alice started to her feet , for it flashed-# V/J NSg/P NPrSg/ISg+ . V/C NSg/J/C V/J J/P . NPr+ V/J P I/J/D+ NSg+ . C/P NPrSg/ISg+ V/J+# V/J NSg/P NPrSg/ISg+ . V/C NSg/J/C V/J J/P . NPr+ V/J P I/J/D+ NPl+ . C/P NPrSg/ISg+ V/J> across her mind that she had never before seen a rabbit with either a# NSg/P I/J/D+ NSg/V+ N/I/C/D+ ISg+ V V C/P NSg/V D/P NSg/V P I/C D/P> waistcoat - pocket , or a watch to take out of it , and burning with curiosity , she@@ -171,7 +171,7 @@>#> Alice was not a bit hurt , and she jumped up on to her feet in a moment : she-# NPr+ V NSg/C D/P NSg/V+ NSg/V/J . V/C ISg+ V/J NSg/V/J/P J/P P I/J/D+ NSg+ NPrSg/J/P D/P+ NSg+ . ISg++# NPr+ V NSg/C D/P NSg/V+ NSg/V/J . V/C ISg+ V/J NSg/V/J/P J/P P I/J/D+ NPl+ NPrSg/J/P D/P+ NSg+ . ISg+> looked up , but it was all dark overhead ; before her was another long passage ,# V/J NSg/V/J/P . NSg/C/P NPrSg/ISg+ V NSg/I/J/C NSg/V/J NSg/J/P . C/P I/J/D+ V I/D NPrSg/V/J NSg/V/J .> and the White Rabbit was still in sight , hurrying down it . There was not a@@ -379,11 +379,11 @@> moment she quite forgot how to speak good English ) ; “ now I’m opening out like# NSg+ ISg+ NSg V NSg/C P NSg/V NPrSg/V/J NPrSg/V/J+ . . . NPrSg/V/J/C W? NSg/V/J NSg/V/J/R/P NSg/V/J/C/P> the largest telescope that ever was ! Good - bye , feet ! ” ( for when she looked down-# D+ + NSg/V+ N/I/C/D+ J V . NPrSg/V/J . NSg/J/P . NSg+ . . . C/P NSg/I/C ISg+ V/J NSg/V/J/P+# D+ + NSg/V+ N/I/C/D+ J V . NPrSg/V/J . NSg/J/P . NPl+ . . . C/P NSg/I/C ISg+ V/J NSg/V/J/P> at her feet , they seemed to be almost out of sight , they were getting so far-# NSg/P I/J/D+ NSg+ . IPl+ V/J P NSg/VX NSg NSg/V/J/R/P P NSg/V+ . IPl+ NSg/V NSg/V NSg/I/J/C NSg/V/J+# NSg/P I/J/D+ NPl+ . IPl+ V/J P NSg/VX NSg NSg/V/J/R/P P NSg/V+ . IPl+ NSg/V NSg/V NSg/I/J/C NSg/V/J> off ) . “ Oh , my poor little feet , I wonder who will put on your shoes and-# NSg/V/J/P+ . . . NPrSg/V . D+ NSg/V/J+ NPrSg/I/J+ NSg+ . ISg+ NSg/V NPrSg/I+ NPrSg/VX NSg/V J/P D+ NPl/V V/C+# NSg/V/J/P+ . . . NPrSg/V . D+ NSg/V/J+ NPrSg/I/J+ NPl+ . ISg+ NSg/V NPrSg/I+ NPrSg/VX NSg/V J/P D+ NPl/V V/C> stockings for you now , dears ? I’m sure I shan’t be able ! I shall be a great deal# NPl/V C/P IPl+ NPrSg/V/J/C . NPl/V+ . W? J ISg+ V NSg/VX NSg/V/J . ISg+ VX NSg/VX D/P NSg/J NSg/V/J+> too far off to trouble myself about you : you must manage the best way you@@ -401,7 +401,7 @@> the carrier , ” she thought ; “ and how funny it’ll seem , sending presents to one’s# D+ NPrSg/J+ . . ISg+ NSg/V . . V/C NSg/C NSg/J W? V . V NPl/V+ P N$> own feet ! And how odd the directions will look !-# NSg/V/J NSg+ . V/C NSg/C NSg/J D+ NSg+ NPrSg/VX NSg/V .+# NSg/V/J NPl+ . V/C NSg/C NSg/J D+ NSg+ NPrSg/VX NSg/V .>#> Alice’s Right Foot , Esq . , Hearthrug , near the Fender , ( with Alice’s love ) .@@ -415,7 +415,7 @@> Just then her head struck against the roof of the hall : in fact she was now more# V/J NSg/J/C I/J/D+ NPrSg/V/J+ V C/P D NSg/V P D+ NPrSg+ . NPrSg/J/P NSg+ ISg+ V NPrSg/V/J/C NPrSg/I/V/J> than nine feet high , and she at once took up the little golden key and hurried-# C/P NSg+ NSg+ NSg/V/J . V/C ISg+ NSg/P NSg/C V NSg/V/J/P D NPrSg/I/J NPrSg/V/J NPrSg/V/J V/C V/J+# C/P NSg+ NPl+ NSg/V/J . V/C ISg+ NSg/P NSg/C V NSg/V/J/P D NPrSg/I/J NPrSg/V/J NPrSg/V/J V/C V/J> off to the garden door .# NSg/V/J/P P D+ NSg/V/J+ NSg/V+ .>@@ -441,7 +441,7 @@>#> After a time she heard a little pattering of feet in the distance , and she-# J/P D/P+ NSg/V/J+ ISg+ V/J D/P NPrSg/I/J V P NSg+ NPrSg/J/P D+ NSg/V+ . V/C ISg++# J/P D/P+ NSg/V/J+ ISg+ V/J D/P NPrSg/I/J V P NPl+ NPrSg/J/P D+ NSg/V+ . V/C ISg+> hastily dried her eyes to see what was coming . It was the White Rabbit# R V/J I/J/D+ NPl/V+ P NSg/V NSg/I+ V+ NSg/V/J . NPrSg/ISg+ V D NPrSg/V/J NSg/V> returning , splendidly dressed , with a pair of white kid gloves in one hand and a@@ -547,7 +547,7 @@> got up and went to the table to measure herself by it , and found that , as nearly# V NSg/V/J/P V/C NSg/V P D+ NSg/V+ P NSg/V I+ NSg/J/P NPrSg/ISg+ . V/C NSg/V N/I/C/D+ . NSg/R R> as she could guess , she was now about two feet high , and was going on shrinking-# NSg/R ISg+ NSg/VX NSg/V . ISg+ V NPrSg/V/J/C J/P NSg+ NSg+ NSg/V/J . V/C V NSg/V/J J/P V+# NSg/R ISg+ NSg/VX NSg/V . ISg+ V NPrSg/V/J/C J/P NSg+ NPl+ NSg/V/J . V/C V NSg/V/J J/P V> rapidly : she soon found out that the cause of this was the fan she was holding ,# R . ISg+ J/R NSg/V NSg/V/J/R/P N/I/C/D D NSg/V/C P I/D+ V D NSg/V ISg+ V NSg/V .> and she dropped it hastily , just in time to avoid shrinking away altogether .@@ -587,7 +587,7 @@> However , she soon made out that she was in the pool of tears which she had wept# C . ISg+ J/R NSg/V NSg/V/J/R/P N/I/C/D ISg+ V NPrSg/J/P D NSg/V P NPl/V+ I/C+ ISg+ V V> when she was nine feet high .-# NSg/I/C ISg+ V NSg+ NSg+ NSg/V/J .+# NSg/I/C ISg+ V NSg+ NPl+ NSg/V/J .>#> “ I wish I hadn’t cried so much ! ” said Alice , as she swam about , trying to find@@ -835,7 +835,7 @@>#> “ In that case , ” said the Dodo solemnly , rising to its feet , “ I move that the-# . NPrSg/J/P N/I/C/D+ NPrSg/V+ . . V/J D NSg R . NSg/V/J/P P ISg/D+ NSg+ . . ISg+ NSg/V N/I/C/D D++# . NPrSg/J/P N/I/C/D+ NPrSg/V+ . . V/J D NSg R . NSg/V/J/P P ISg/D+ NPl+ . . ISg+ NSg/V N/I/C/D D+> meeting adjourn , for the immediate adoption of more energetic remedies — ”# NSg/V+ V . C/P D J NSg P NPrSg/I/V/J NSg/J NPl/V+ . .>@@ -1285,7 +1285,7 @@> “ Mary Ann ! Mary Ann ! ” said the voice . “ Fetch me my gloves this moment ! ” Then# . NPr+ NPrSg/J+ . NPr+ NPrSg/J+ . . V/J D+ NSg/V+ . . NSg/V NPrSg/I+ D+ NPl/V I/D+ NSg+ . . NSg/J/C> came a little pattering of feet on the stairs . Alice knew it was the Rabbit-# NSg/V/P D/P NPrSg/I/J V P NSg+ J/P D+ NPl+ . NPr+ V NPrSg/ISg+ V D NSg/V+# NSg/V/P D/P NPrSg/I/J V P NPl+ J/P D+ NPl+ . NPr+ V NPrSg/ISg+ V D NSg/V> coming to look for her , and she trembled till she shook the house , quite# NSg/V/J P NSg/V C/P I/J/D+ . V/C ISg+ V/J NSg/V/C/P ISg+ NSg/V/J D+ NPrSg/V+ . NSg> forgetting that she was now about a thousand times as large as the Rabbit , and@@ -1521,7 +1521,7 @@> Hardly knowing what she did , she picked up a little bit of stick , and held it# R NSg/V/J/P NSg/I+ ISg+ V . ISg+ V/J NSg/V/J/P D/P NPrSg/I/J NSg/V P NSg/V/J+ . V/C V NPrSg/ISg+> out to the puppy ; whereupon the puppy jumped into the air off all its feet at-# NSg/V/J/R/P P D+ NSg/V+ . C D+ NSg/V+ V/J P D NSg/V NSg/V/J/P NSg/I/J/C ISg/D+ NSg+ NSg/P+# NSg/V/J/R/P P D+ NSg/V+ . C D+ NSg/V+ V/J P D NSg/V NSg/V/J/P NSg/I/J/C ISg/D+ NPl+ NSg/P> once , with a yelp of delight , and rushed at the stick , and made believe to worry# NSg/C . P D/P NSg/V P NSg/V/J+ . V/C V/J NSg/P D+ NSg/V/J+ . V/C NSg/V V P NSg/V> it ; then Alice dodged behind a great thistle , to keep herself from being run@@ -1533,7 +1533,7 @@> Alice , thinking it was very like having a game of play with a cart - horse , and# NPr+ . V NPrSg/ISg+ V J NSg/V/J/C/P V D/P NSg/V/J P NSg/V P D/P NSg/V+ . NSg/V . V/C> expecting every moment to be trampled under its feet , ran round the thistle-# V D+ NSg+ P NSg/VX V/J NSg/J/P ISg/D+ NSg+ . NSg/V NSg/V/J/P D NSg+# V D+ NSg+ P NSg/VX V/J NSg/J/P ISg/D+ NPl+ . NSg/V NSg/V/J/P D NSg> again ; then the puppy began a series of short charges at the stick , running a# P . NSg/J/C D+ NSg/V+ V D/P NSg P NPrSg/V/J/P NPl/V NSg/P D+ NSg/V/J+ . NSg/V/J/P D/P> very little way forwards each time and a long way back , and barking hoarsely all@@ -2105,7 +2105,7 @@> that beautiful garden — how is that to be done , I wonder ? ” As she said this , she# N/I/C/D+ NSg/J NSg/V/J+ . NSg/C VL N/I/C/D+ P NSg/VX NSg/V/J . ISg+ NSg/V . . NSg/R ISg+ V/J I/D+ . ISg+> came suddenly upon an open place , with a little house in it about four feet-# NSg/V/P R P D/P NSg/V/J+ NSg/V+ . P D/P NPrSg/I/J NPrSg/V NPrSg/J/P NPrSg/ISg+ J/P NSg+ NSg++# NSg/V/P R P D/P NSg/V/J+ NSg/V+ . P D/P NPrSg/I/J NPrSg/V NPrSg/J/P NPrSg/ISg+ J/P NSg+ NPl+> high . “ Whoever lives there , ” thought Alice , “ it’ll never do to come upon them# NSg/V/J+ . . I+ V+ W? . . NSg/V NPr+ . . W? V NSg/VX P NSg/V/P P N/I+> this size : why , I should frighten them out of their wits ! ” So she began nibbling@@ -2699,7 +2699,7 @@> did not like to go nearer till she had nibbled some more of the lefthand bit of# V NSg/C NSg/V/J/C/P P NSg/V/J J NSg/V/C/P ISg+ V V/J I/J/R NPrSg/I/V/J P D ? NSg/V P> mushroom , and raised herself to about two feet high : even then she walked up-# NSg/V/J . V/C V/J I+ P J/P NSg+ NSg+ NSg/V/J . NSg/V/J NSg/J/C ISg+ V/J NSg/V/J/P+# NSg/V/J . V/C V/J I+ P J/P NSg+ NPl+ NSg/V/J . NSg/V/J NSg/J/C ISg+ V/J NSg/V/J/P> towards it rather timidly , saying to herself “ Suppose it should be raving mad# P NPrSg/ISg+ NPrSg/V/J R . NSg/V P I+ . V NPrSg/ISg+ VX NSg/VX NSg/V/J N/V/J> after all ! I almost wish I’d gone to see the Hatter instead ! ”@@ -3417,7 +3417,7 @@> First came ten soldiers carrying clubs ; these were all shaped like the three# NSg/V/J+ NSg/V/P NSg NPl/V+ V NPl/V+ . I/D+ NSg/V NSg/I/J/C V/J+ NSg/V/J/C/P D+ NSg+> gardeners , oblong and flat , with their hands and feet at the corners : next the-# W? . NSg/V/J V/C NSg/V/J . P D+ NPl/V V/C NSg+ NSg/P D+ + . NSg/J/P D+# W? . NSg/V/J V/C NSg/V/J . P D+ NPl/V V/C NPl+ NSg/P D+ + . NSg/J/P D> ten courtiers ; these were ornamented all over with diamonds , and walked two and# NSg NPl . I/D+ NSg/V V/J NSg/I/J/C NSg/V/J/P P NPl/V . V/C V/J NSg V/C> two , as the soldiers did . After these came the royal children ; there were ten of@@ -3631,7 +3631,7 @@> furrows ; the balls were live hedgehogs , the mallets live flamingoes , and the# NPl/V . D+ NSg/V+ NSg/V V/J NPl/V . D NPl/V V/J ? . V/C D+> soldiers had to double themselves up and to stand on their hands and feet , to-# NPl/V+ V P NSg/V/J I+ NSg/V/J/P V/C P NSg/V J/P D+ NPl/V V/C NSg+ . P+# NPl/V+ V P NSg/V/J I+ NSg/V/J/P V/C P NSg/V J/P D+ NPl/V V/C NPl+ . P> make the arches .# NSg/V D NPl/V+ .>@@ -5939,7 +5939,7 @@>#> The long grass rustled at her feet as the White Rabbit hurried by — the frightened-# D+ NPrSg/V/J NPrSg/V V/J NSg/P I/J/D+ NSg+ NSg/R D+ NPrSg/V/J+ NSg/V+ V/J NSg/J/P . D+ V/J++# D+ NPrSg/V/J NPrSg/V V/J NSg/P I/J/D+ NPl+ NSg/R D+ NPrSg/V/J+ NSg/V+ V/J NSg/J/P . D+ V/J+> Mouse splashed his way through the neighbouring pool — she could hear the rattle# NSg/V+ V/J ISg/D+ NSg/J+ NSg/J/P D+ V/Ca/Au/Br+ NSg/V+ . ISg+ NSg/VX V D NSg/V> of the teacups as the March Hare and his friends shared their never - ending meal ,diff --git a/harper-core/tests/text/tagged/Difficult sentences.md b/harper-core/tests/text/tagged/Difficult sentences.mdindex 751f95052..4119e8999 100644--- a/harper-core/tests/text/tagged/Difficult sentences.md+++ b/harper-core/tests/text/tagged/Difficult sentences.md@@ -607,7 +607,7 @@> England need a hundred runs , with twenty - five overs remaining . Game on !# NPr+ NSg/VX D/P NSg NPl/V . P NSg . NSg+ NPl/V+ V+ . NSg/V/J J/P .> Your feet will soon warm up once your socks are on .-# D+ NSg+ NPrSg/VX J/R NSg/V/J NSg/V/J/P NSg/C D+ NPl/V+ V+ J/P .+# D+ NPl+ NPrSg/VX J/R NSg/V/J NSg/V/J/P NSg/C D+ NPl/V+ V+ J/P .> I was trying to drink out of the bottle while the top was still on !# ISg+ V NSg/V/J P NSg/V NSg/V/J/R/P P D+ NSg/V+ NSg/V/C/P D+ NSg/V/J+ V NSg/V/J J/P .> Climbing up that steep ridge isn't on . We'll have to find another route .@@ -669,7 +669,7 @@> Should there be an accent on the " e " ?# VX + NSg/VX D/P NSg/V J/P D . NPrSg/I+ . .> He wore old shoes on his feet .-# NPr/ISg+ V NSg/J NPl/V J/P ISg/D+ NSg+ .+# NPr/ISg+ V NSg/J NPl/V J/P ISg/D+ NPl+ .> The lighthouse that you can see is on the mainland .# D+ NSg+ N/I/C/D+ IPl+ NPrSg/VX NSg/V VL J/P D+ NSg+ .> The suspect is thought to still be on the campus .diff --git a/harper-core/tests/text/tagged/The Great Gatsby.md b/harper-core/tests/text/tagged/The Great Gatsby.mdindex 24cd86555..b75cc997e 100644--- a/harper-core/tests/text/tagged/The Great Gatsby.md+++ b/harper-core/tests/text/tagged/The Great Gatsby.md@@ -967,7 +967,7 @@> The horses , needless to say , were not mentioned again . Tom and Miss Baker , with# D+ NPl/V . J P NSg/V . NSg/V NSg/C V/J P . NPrSg/V+ V/C NSg/V NPrSg/J+ . P> several feet of twilight between them , strolled back into the library , as if to-# J/D NSg P NSg/V/J+ NSg/P N/I+ . V/J NSg/V/J P D+ NSg+ . NSg/R NSg/C P+# J/D NPl P NSg/V/J+ NSg/P N/I+ . V/J NSg/V/J P D+ NSg+ . NSg/R NSg/C P> a vigil beside a perfectly tangible body , while , trying to look pleasantly# D/P NSg/V P D/P R NSg/J NSg/V . NSg/V/C/P . NSg/V/J P NSg/V R> interested and a little deaf , I followed Daisy around a chain of connecting@@ -1267,13 +1267,13 @@> across the moonlight , and turning my head to watch it , I saw that I was not# NSg/P D+ NSg/V+ . V/C NSg/V D+ NPrSg/V/J+ P NSg/V NPrSg/ISg+ . ISg+ NSg/V N/I/C/D ISg+ V NSg/C> alone — fifty feet away a figure had emerged from the shadow of my neighbor’s-# J . NSg NSg+ V/J D/P+ NSg/V+ V V/J P D NSg/V/J P D+ N$+# J . NSg NPl+ V/J D/P+ NSg/V+ V V/J P D NSg/V/J P D+ N$> mansion and was standing with his hands in his pockets regarding the silver# NSg+ V/C V NSg/V/J P ISg/D+ NPl/V+ NPrSg/J/P ISg/D+ NPl/V+ V D NSg/V/J+> pepper of the stars . Something in his leisurely movements and the secure# NSg/V P D+ NPl/V+ . NSg/I/V/J NPrSg/J/P ISg/D+ R+ NPl V/C D V/J> position of his feet upon the lawn suggested that it was Mr . Gatsby himself ,-# NSg/V P ISg/D+ NSg+ P D+ NSg/V+ V/J N/I/C/D NPrSg/ISg+ V NSg+ . NPr I+ .+# NSg/V P ISg/D+ NPl+ P D+ NSg/V+ V/J N/I/C/D NPrSg/ISg+ V NSg+ . NPr I+ .> come out to determine what share was his of our local heavens .# NSg/V/P NSg/V/J/R/P P V NSg/I+ NSg/V V ISg/D P D+ NSg/J+ NSg/V+ .>@@ -1365,7 +1365,7 @@> up to New York with Tom on the train one afternoon , and when we stopped by the# NSg/V/J/P P NSg/V/J NPr+ P NPrSg/V+ J/P D+ NSg/V+ NSg/I/V/J NSg+ . V/C NSg/I/C IPl+ V/J NSg/J/P D+> ashheaps he jumped to his feet and , taking hold of my elbow , literally forced me-# ? NPr/ISg+ V/J P ISg/D+ NSg+ V/C . NSg/V/J NSg/V/J P D+ NSg/V+ . R V/J NPrSg/I++# ? NPr/ISg+ V/J P ISg/D+ NPl+ V/C . NSg/V/J NSg/V/J P D+ NSg/V+ . R V/J NPrSg/I+> from the car .# P D+ NSg+ .>@@ -1615,7 +1615,7 @@> The Airedale — undoubtedly there was an Airedale concerned in it somewhere , though# D NPrSg . R + V D/P NPrSg V/J NPrSg/J/P NPrSg/ISg+ NSg . V/C> its feet were startlingly white — changed hands and settled down into Mrs .-# ISg/D+ NSg+ NSg/V R NPrSg/V/J . V/J NPl/V+ V/C V/J NSg/V/J/P P NPl+ .+# ISg/D+ NPl+ NSg/V R NPrSg/V/J . V/J NPl/V+ V/C V/J NSg/V/J/P P NPl+ .> Wilson’s lap , where she fondled the weatherproof coat with rapture .# N$ NSg/V/J+ . NSg/C ISg+ V/J D+ V/J+ NSg/V+ P NSg/V+ .>@@ -1797,7 +1797,7 @@> will cheat you every time . All they think of is money . I had a woman up here# NPrSg/VX NSg/V IPl+ D+ NSg/V/J+ . NSg/I/J/C IPl+ NSg/V P+ VL NSg/J+ . ISg+ V D/P NSg/V NSg/V/J/P NSg/J/R> last week to look at my feet , and when she gave me the bill you’d of thought she-# NSg/V/J+ NSg/J P NSg/V NSg/P D+ NSg+ . V/C NSg/I/C ISg+ V NPrSg/I+ D NPrSg/V+ W? P NSg/V ISg++# NSg/V/J+ NSg/J P NSg/V NSg/P D+ NPl+ . V/C NSg/I/C ISg+ V NPrSg/I+ D NPrSg/V+ W? P NSg/V ISg+> had my appendicitus out . ”# V D+ ? NSg/V/J/R/P . .>@@ -1807,7 +1807,7 @@>#> “ Mrs . Eberhardt . She goes around looking at people’s feet in their own homes . ”-# . NPl . ? . ISg+ NSg/V J/P V NSg/P N$ NSg+ NPrSg/J/P D+ NSg/V/J+ NPl/V+ . .+# . NPl . ? . ISg+ NSg/V J/P V NSg/P N$ NPl+ NPrSg/J/P D+ NSg/V/J+ NPl/V+ . .>#> “ I like your dress , ” remarked Mrs . McKee , “ I think it’s adorable . ”@@ -1855,7 +1855,7 @@> Her husband said “ Sh ! ” and we all looked at the subject again , whereupon Tom# I/J/D+ NSg/V V/J . W? . . V/C IPl+ NSg/I/J/C V/J NSg/P D+ NSg/V/J+ P . C NPrSg/V+> Buchanan yawned audibly and got to his feet .-# NPr+ V/J R V/C V P ISg/D+ NSg+ .+# NPr+ V/J R V/C V P ISg/D+ NPl+ .>#> “ You McKees have something to drink , ” he said . “ Get some more ice and mineral@@ -2231,7 +2231,7 @@> made plans to go somewhere , and then lost each other , searched for each other ,# NSg/V NPl/V+ P NSg/V/J NSg . V/C NSg/J/C V/J D NSg/V/J . V/J C/P D NSg/V/J .> found each other a few feet away . Some time toward midnight Tom Buchanan and-# NSg/V D NSg/V/J D/P N/I+ NSg+ V/J+ . I/J/R NSg/V/J+ J/P NSg/J+ NPrSg/V+ NPr V/C+# NSg/V D NSg/V/J D/P N/I+ NPl+ V/J+ . I/J/R NSg/V/J+ J/P NSg/J+ NPrSg/V+ NPr V/C> Mrs . Wilson stood face to face discussing , in impassioned voices , whether Mrs .# NPl+ . NPr+ V NSg/V+ P NSg/V V . NPrSg/J/P J+ NPl/V+ . I/C NPl+ .> Wilson had any right to mention Daisy’s name .@@ -2353,7 +2353,7 @@> At least once a fortnight a corps of caterers came down with several hundred# NSg/P NSg/J NSg/C D/P NSg/J+ D/P NSg P + NSg/V/P NSg/V/J/P P J/D NSg> feet of canvas and enough colored lights to make a Christmas tree of Gatsby’s-# NSg P NSg/V+ V/C NSg/I NSg/V/J/Am NPl/V+ P NSg/V D/P NPrSg/V/J+ NSg/V P N$+# NPl P NSg/V+ V/C NSg/I NSg/V/J/Am NPl/V+ P NSg/V D/P NPrSg/V/J+ NSg/V P N$> enormous garden . On buffet tables , garnished with glistening hors - d’œuvre ,# J+ NSg/V/J+ . J/P NPrSg/V+ NPl/V+ . V/J P V ? . ? .> spiced baked hams crowded against salads of harlequin designs and pastry pigs@@ -3279,7 +3279,7 @@> But as I walked down the steps I saw that the evening was not quite over . Fifty# NSg/C/P NSg/R ISg+ V/J NSg/V/J/P D+ NPl/V+ ISg+ NSg/V N/I/C/D D+ NSg/V+ V NSg/C NSg NSg/V/J/P . NSg> feet from the door a dozen headlights illuminated a bizarre and tumultuous-# NSg+ P D+ NSg/V+ D/P NSg NPl V/J D/P J V/C J++# NPl+ P D+ NSg/V+ D/P NSg NPl V/J D/P J V/C J+> scene . In the ditch beside the road , right side up , but violently shorn of one# NSg/V+ . NPrSg/J/P D NSg/V P D+ NSg/J+ . NPrSg/V/J NSg/V/J NSg/V/J/P . NSg/C/P R ? P NSg/I/V/J+> wheel , rested a new coupé which had left Gatsby’s drive not two minutes before .@@ -4433,7 +4433,7 @@> When the subject of this instinctive trust returned to the table and sat down# NSg/I/C D NSg/V/J P I/D+ J NSg/V/J V/J P D+ NSg/V+ V/C NSg/V/J NSg/V/J/P> Mr . Wolfshiem drank his coffee with a jerk and got to his feet .-# NSg+ . ? NSg/V ISg/D+ NSg/V/J+ P D/P NSg/V+ V/C V P ISg/D+ NSg+ .+# NSg+ . ? NSg/V ISg/D+ NSg/V/J+ P D/P NSg/V+ V/C V P ISg/D+ NPl+ .>#> “ I have enjoyed my lunch , ” he said , “ and I’m going to run off from you two young@@ -4607,7 +4607,7 @@> curb , and she was sitting in it with a lieutenant I had never seen before . They# NSg/V+ . V/C ISg+ V NSg/V/J NPrSg/J/P NPrSg/ISg P D/P+ NSg/J+ ISg+ V V NSg/V+ C/P . IPl+> were so engrossed in each other that she didn’t see me until I was five feet-# NSg/V NSg/I/J/C V/J NPrSg/J/P D NSg/V/J N/I/C/D ISg+ V NSg/V NPrSg/I+ C/P ISg+ V NSg+ NSg++# NSg/V NSg/I/J/C V/J NPrSg/J/P D NSg/V/J N/I/C/D ISg+ V NSg/V NPrSg/I+ C/P ISg+ V NSg+ NPl+> away .# V/J+ .>@@ -5395,7 +5395,7 @@> The automatic quality of Gatsby’s answer set us all back at least another# D NSg/J NSg/J P N$ NSg/V+ NPrSg/V/J NPr/I+ NSg/I/J/C NSg/V/J NSg/P NSg/J+ I/D+> minute . I had them both on their feet with the desperate suggestion that they-# NSg/V/J+ . ISg+ V N/I+ I/C J/P D+ NSg+ P D+ NSg/J+ NSg+ N/I/C/D+ IPl++# NSg/V/J+ . ISg+ V N/I+ I/C J/P D+ NPl+ P D+ NSg/J+ NSg+ N/I/C/D+ IPl+> help me make tea in the kitchen when the demoniac Finn brought it in on a tray .# NSg/V NPrSg/I+ NSg/V NSg/V+ NPrSg/J/P D+ NSg/V+ NSg/I/C D+ NSg/J+ NPrSg+ V NPrSg/ISg+ NPrSg/J/P J/P D/P+ NSg/V+ .>@@ -5409,7 +5409,7 @@> eyes . However , as calmness wasn’t an end in itself , I made an excuse at the# NPl/V+ . C . NSg/R NSg+ V D/P NSg/V NPrSg/J/P I+ . ISg+ NSg/V D/P NSg/V NSg/P D> first possible moment , and got to my feet .-# NSg/V/J NSg/J+ NSg+ . V/C V P D+ NSg+ .+# NSg/V/J NSg/J+ NSg+ . V/C V P D+ NPl+ .>#> “ Where are you going ? ” demanded Gatsby in immediate alarm .@@ -6375,7 +6375,7 @@>#> This included me . Mr . Sloane got to his feet .-# I/D+ V/J NPrSg/I+ . NSg+ . NPrSg V P ISg/D+ NSg+ .+# I/D+ V/J NPrSg/I+ . NSg+ . NPrSg V P ISg/D+ NPl+ .>#> “ Come along , ” he said — but to her only .@@ -6711,7 +6711,7 @@> I sat on the front steps with them while they waited for their car . It was dark# ISg+ NSg/V/J J/P D+ NSg/V/J+ NPl/V P N/I+ NSg/V/C/P IPl+ V/J C/P D+ NSg+ . NPrSg/ISg+ V NSg/V/J> here in front ; only the bright door sent ten square feet of light volleying out-# NSg/J/R NPrSg/J/P NSg/V/J+ . W? D+ NPrSg/V/J+ NSg/V+ NSg/V NSg NSg/V/J NSg P NSg/V/J+ V NSg/V/J/R/P+# NSg/J/R NPrSg/J/P NSg/V/J+ . W? D+ NPrSg/V/J+ NSg/V+ NSg/V NSg NSg/V/J NPl P NSg/V/J+ V NSg/V/J/R/P> into the soft black morning . Sometimes a shadow moved against a dressing - room# P D+ NSg/J+ NSg/V/J NSg/V+ . R D/P NSg/V/J+ V/J C/P D/P NSg/V+ . NSg/V/J> blind above , gave way to another shadow , an indefinite procession of shadows ,@@ -6739,7 +6739,7 @@>#> He was silent for a moment . The pebbles of the drive crunched under his feet .-# NPr/ISg+ V NSg/J C/P D/P+ NSg+ . D NPl/V P D NSg/V V/J NSg/J/P ISg/D+ NSg+ .+# NPr/ISg+ V NSg/J C/P D/P+ NSg+ . D NPl/V P D NSg/V V/J NSg/J/P ISg/D+ NPl+ .>#> “ Well , he certainly must have strained himself to get this menagerie together . ”@@ -7499,7 +7499,7 @@> His hand , trembling with his effort at self - control , bore to his lips the last# ISg/D+ NSg/V . V P ISg/D+ NSg/V NSg/P NSg/I/V/J . NSg/V . NSg/V P ISg/D+ NPl/V D+ NSg/V/J> of his glass of ale . Daisy’s voice got us to our feet and out on to the blazing-# P ISg/D+ NPrSg/V P NSg+ . N$ NSg/V+ V NPr/I+ P D+ NSg V/C NSg/V/J/R/P J/P P D+ V/J++# P ISg/D+ NPrSg/V P NSg+ . N$ NSg/V+ V NPr/I+ P D+ NPl V/C NSg/V/J/R/P J/P P D+ V/J+> gravel drive .# NSg/V/J+ NSg/V+ .>@@ -7529,7 +7529,7 @@> They went up - stairs to get ready while we three men stood there shuffling the# IPl+ NSg/V NSg/V/J/P . NPl P NSg/V NSg/V/J NSg/V/C/P IPl+ NSg NSg+ V + V D> hot pebbles with our feet . A silver curve of the moon hovered already in the-# NSg/V/J NPl/V P D+ NSg+ . D/P NSg/V/J+ NSg/V/J P D+ NPrSg/V+ V/J W? NPrSg/J/P D++# NSg/V/J NPl/V P D+ NPl+ . D/P NSg/V/J+ NSg/V/J P D+ NPrSg/V+ V/J W? NPrSg/J/P D+> western sky . Gatsby started to speak , changed his mind , but not before Tom# NPrSg/J+ NSg/V+ . NPr V/J P NSg/V . V/J ISg/D+ NSg/V+ . NSg/C/P NSg/C C/P NPrSg/V+> wheeled and faced him expectantly .@@ -7897,7 +7897,7 @@> vigil , but I perceived , after a moment , that other eyes were regarding us with# NSg/V . NSg/C/P ISg+ V/J . J/P D/P+ NSg+ . N/I/C/D NSg/V/J+ NPl/V+ NSg/V V NPr/I+ P> peculiar intensity from less than twenty feet away .-# NSg/J NSg P V/J/C/P C/P NSg+ NSg+ V/J+ .+# NSg/J NSg P V/J/C/P C/P NSg+ NPl+ V/J+ .>#> In one of the windows over the garage the curtains had been moved aside a@@ -8355,7 +8355,7 @@>#> Gatsby sprang to his feet , vivid with excitement .-# NPr V P ISg/D+ NSg+ . NSg/J P NSg+ .+# NPr V P ISg/D+ NPl+ . NSg/J P NSg+ .>#> “ She never loved you , do you hear ? ” he cried . “ She only married you because I@@ -9499,7 +9499,7 @@> through the great rooms for cigarettes . We pushed aside curtains that were like# NSg/J/P D NSg/J NPl/V C/P NPl/V+ . IPl+ V/J NSg/J NPl/V N/I/C/D+ NSg/V NSg/V/J/C/P> pavilions , and felt over innumerable feet of dark wall for electric light-# NPl/V . V/C NSg/V/J NSg/V/J/P J NSg P NSg/V/J NPrSg/V C/P NSg/J NSg/V/J++# NPl/V . V/C NSg/V/J NSg/V/J/P J NPl P NSg/V/J NPrSg/V C/P NSg/J NSg/V/J+> switches — once I tumbled with a sort of splash upon the keys of a ghostly piano .# NPl/V+ . NSg/C ISg+ V/J P D/P NSg/V P NSg/V+ P D NPl/V P D/P+ J/R+ NSg/V/J+ .> There was an inexplicable amount of dust everywhere , and the rooms were musty ,