Skip to content
Open
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
26 changes: 18 additions & 8 deletions harper-core/src/linting/more_adjective.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use itertools::Itertools;

use crate::expr::{Expr, SequenceExpr};
use crate::linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk};
use crate::spell::Dictionary;
use crate::{CharStringExt, Lint, Token, TokenStringExt};

const VOWELS: [char; 5] = ['a', 'e', 'i', 'o', 'u'];
use crate::{
char_ext::CharExt,
expr::{Expr, SequenceExpr},
linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk},
spell::Dictionary,
{CharStringExt, Lint, Token, TokenStringExt},
};

pub struct MoreAdjective<D> {
expr: Box<dyn Expr>,
Expand Down Expand Up @@ -88,8 +89,9 @@ where
return None;
}

// "foreigner" is a noun, not an adjective "more foreign"
// "humaner" = "more humane", not "more human"
if adj_str == "human" {
if adj_str == "foreign" || adj_str == "human" {
return None;
}

Expand Down Expand Up @@ -121,7 +123,7 @@ where
// Double consonant: big -> bigger/biggest
let penult = adj_chars[adj_chars.len() - 2];
let last = adj_chars[adj_chars.len() - 1];
if VOWELS.contains(&penult) && !VOWELS.contains(&last) {
if penult.is_vowel() && !last.is_vowel() {
self.add_valid_candidate(&mut candidates, format!("{}{}{}", adj_str, last, ending));
}

Expand Down Expand Up @@ -299,4 +301,12 @@ mod tests {
MoreAdjective::new(FstDictionary::curated()),
);
}

#[test]
fn dont_flag_more_foreign() {
assert_no_lints(
"There are more foreign visitors this year.",
MoreAdjective::new(FstDictionary::curated()),
);
}
}
Loading