Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions harper-core/dictionary.dict
Original file line number Diff line number Diff line change
Expand Up @@ -37129,24 +37129,24 @@ overproduction/Nmg
overpromise/VSGd
overprotect/VSdGv
overqualified/J
overran/~V
overran/~Vt
overrange/VGdSN
overrate/VGdSN
overreach/VGdSN
overreact/VSdG
overreaction/NwSg
overread/JVSdG
overread/JVbtTSG
overrefined/VJ
overregulate/VdSGn
overreliance/Nmg
overrepresent/VGdS
overrepresentation/Nmg
overridden/V
override/~VGSNg
overridden/VT
override/~VbGSNg
overripe/Jg
overrode/V
overrode/Vt
overrule/VGdS
overrun/~VSNg
overrun/~VSNgbT
overrunning/V6
oversampling/VNmg
oversaturate/VdSGn
Expand Down Expand Up @@ -40209,7 +40209,7 @@ pronouncement/NSg
pronto/
pronunciation/~NgS
proof/~NwSgJVdGr
proofread/V>GSNZ
proofread/VbtT>GSNZ
proofreader/Ng
prop/~NgSV
propaganda/~Nmg
Expand Down Expand Up @@ -41084,7 +41084,7 @@ ramrod/NSgV
ramrodded/VtT
ramrodding/V6
ramshackle/JV
ran/~VtNr
ran/~Vtr # removed nautical noun sense
ranch/~NgSVd>GZ
rancher/~Ng
ranching/~VNg
Expand Down Expand Up @@ -44504,7 +44504,7 @@ sight/~NwgSVGdz
sighting/~NgV6
sightless/J
sightly/J^>U
sightread/Vb
sightread/VbtT
sightseeing/~NgV6
sightseer/NgS
sigma/~NgS
Expand Down
24 changes: 18 additions & 6 deletions harper-core/src/expr/sequence_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ impl SequenceExpr {
self.then(WordSet::new(words))
}

/// Matches any token whose `Kind` exactly matches.
pub fn then_strict(self, kind: TokenKind) -> Self {
self.then(move |tok: &Token, _source: &[char]| tok.kind == kind)
}

/// Match against one or more whitespace tokens.
pub fn then_whitespace(self) -> Self {
self.then(WhitespacePattern)
Expand Down Expand Up @@ -229,7 +224,7 @@ impl SequenceExpr {

/// Matches any word.
pub fn then_any_word(self) -> Self {
self.then(|tok: &Token, _source: &[char]| tok.kind.is_word())
self.then_kind_where(|kind| kind.is_word())
}

/// Match examples of `word` that have any capitalization.
Expand Down Expand Up @@ -266,6 +261,23 @@ impl SequenceExpr {

// One kind

/// Matches any token whose `Kind` exactly matches.
pub fn then_kind(self, kind: TokenKind) -> Self {
self.then(move |tok: &Token, _source: &[char]| tok.kind == kind)
}

/// Matches a token where the provided closure returns true for the token's kind.
pub fn then_kind_where<F>(mut self, predicate: F) -> Self
where
F: Fn(&TokenKind) -> bool + Send + Sync + 'static,
{
self.exprs
.push(Box::new(move |tok: &Token, _source: &[char]| {
predicate(&tok.kind)
}));
self
}

/// Match a token of a given kind which is not in the list of words.
pub fn then_kind_except<F>(self, pred_is: F, ex: &'static [&'static str]) -> Self
where
Expand Down
12 changes: 8 additions & 4 deletions harper-core/src/linting/lint_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ use super::way_too_adjective::WayTooAdjective;
use super::well_educated::WellEducated;
use super::whereas::Whereas;
use super::widely_accepted::WidelyAccepted;
use super::will_non_lemma::WillNonLemma;
use super::win_prize::WinPrize;
use super::wordpress_dotcom::WordPressDotcom;
use super::would_never_have::WouldNeverHave;

use super::{ExprLinter, Lint};
use super::{HtmlDescriptionLinter, Linter};
use crate::linting::dashes::Dashes;
Expand Down Expand Up @@ -467,12 +469,12 @@ impl LintGroup {
));
out.merge_from(&mut closed_compounds::lint_group());
out.merge_from(&mut initialisms::lint_group());
// out.merge_from(&mut update_place_names::lint_group());

// Add all the more complex rules to the group.
// Please maintain alphabetical order.
// On *nix you can maintain sort order with `sort -t'(' -k2`
insert_expr_rule!(APart, true);
insert_expr_rule!(AWhile, true);
insert_expr_rule!(Addicting, true);
insert_expr_rule!(AdjectiveDoubleDegree, true);
insert_struct_rule!(AdjectiveOfA, true);
Expand All @@ -498,9 +500,6 @@ impl LintGroup {
insert_expr_rule!(CautionaryTale, true);
insert_expr_rule!(ChangeTack, true);
insert_expr_rule!(ChockFull, true);
insert_expr_rule!(AWhile, true);
insert_struct_rule!(SubjectPronoun, true);
insert_struct_rule!(FindFine, true);
insert_struct_rule!(CommaFixes, true);
insert_struct_rule!(CompoundNouns, true);
insert_expr_rule!(CompoundSubjectI, true);
Expand All @@ -524,6 +523,7 @@ impl LintGroup {
insert_expr_rule!(FeelFell, true);
insert_expr_rule!(FewUnitsOfTimeAgo, true);
insert_expr_rule!(FillerWords, true);
insert_struct_rule!(FindFine, true);
insert_expr_rule!(FirstAidKit, true);
insert_expr_rule!(ForNoun, true);
insert_expr_rule!(FreePredicate, true);
Expand Down Expand Up @@ -611,6 +611,7 @@ impl LintGroup {
insert_struct_rule!(Spaces, true);
insert_struct_rule!(SpelledNumbers, false);
insert_expr_rule!(SplitWords, true);
insert_struct_rule!(SubjectPronoun, true);
insert_expr_rule!(ThatThan, true);
insert_expr_rule!(ThatWhich, true);
insert_expr_rule!(TheHowWhy, true);
Expand Down Expand Up @@ -670,6 +671,9 @@ impl LintGroup {
out.add("MassPlurals", MassPlurals::new(dictionary.clone()));
out.config.set_rule_enabled("MassPlurals", true);

out.add("WillNonLemma", WillNonLemma::new(dictionary.clone()));
out.config.set_rule_enabled("WillNonLemma", true);

out
}

Expand Down
3 changes: 1 addition & 2 deletions harper-core/src/linting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ mod way_too_adjective;
mod well_educated;
mod whereas;
mod widely_accepted;
mod will_non_lemma;
mod win_prize;
mod wordpress_dotcom;
mod would_never_have;
Expand Down Expand Up @@ -426,15 +427,13 @@ pub mod tests {
if !found_bad.is_empty() || !unseen_good.is_empty() {
eprintln!("\n=== Test Summary ===");

// In the summary section, change these loops:
if !found_bad.is_empty() {
eprintln!("\n❌ Found {} bad suggestions:", found_bad.len());
for (i, j, text) in &found_bad {
eprintln!(" - lint[{i}].suggestions[{j}]: \"{text}\"");
}
}

// And for the good suggestions:
if !unseen_good.is_empty() {
eprintln!(
"\n❌ Missing {} expected good suggestions:",
Expand Down
5 changes: 5 additions & 0 deletions harper-core/src/linting/simple_past_to_past_participle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ const IRREGULAR_VERBS: &[(&str, &str)] = &[
("led", "led"),
("mistook", "mistaken"),
("output", "output"),
("overthrew", "overthrown"),
("overtook", "overtaken"),
("overwrote", "overwritten"),
("paid", "paid"),
("partook", "partaken"),
// proved, proved/proven
("put", "put"),
("ran", "run"),
("rang", "rung"),
("read", "read"),
("redid", "redone"),
("reset", "reset"),
("rode", "ridden"),
("rose", "risen"),
Expand All @@ -66,9 +69,11 @@ const IRREGULAR_VERBS: &[(&str, &str)] = &[
("stood", "stood"),
("swam", "swum"),
("swore", "sworn"),
("taught", "taught"),
("thought", "thought"),
("trod", "trodden"),
("took", "taken"),
("undid", "undone"),
// was, been
// were, been
("went", "gone"),
Expand Down
Loading
Loading