Skip to content

fix(linting): don't suggest an inflected form for "more <adj> <noun>"#3793

Open
AnayGarodia wants to merge 5 commits into
Automattic:masterfrom
AnayGarodia:fix/more-adjective-quantifier-3688
Open

fix(linting): don't suggest an inflected form for "more <adj> <noun>"#3793
AnayGarodia wants to merge 5 commits into
Automattic:masterfrom
AnayGarodia:fix/more-adjective-quantifier-3688

Conversation

@AnayGarodia

Copy link
Copy Markdown

Disclaimer: This PR was produced with LLM assistance, reviewed and verified by me before submission (per Harper's agent-PR policy).

What

Fixes #3688. MoreAdjective flagged "more short videos" and suggested the inflected form "shorter videos".

Why

When the adjective is immediately followed by a noun it modifies, "more" quantifies the whole noun phrase ("more [short videos]") rather than intensifying the adjective, so rewriting to the comparative changes the meaning. This is the same "look one token past the adjective to spot a false positive" approach the rule already uses for the than <adjective> case (#2925) and the hyphen case (#3568).

How

Add whitespace + noun as a third alternative in the rule's existing optional trailing clause (FirstMatchOf). When it matches, the span is longer than three tokens and the existing toks.len() != 3 guard in match_to_lint already aborts — no new control flow. Existing true positives are unaffected because they aren't followed by a modified noun ("more fast", "more cute", "more good", "more humane than …").

Testing

Added dont_flag_more_short_videos_3688 (1 lint before, 0 after). Full rule suite green, no regressions:

cargo test -p harper-core --lib more_adjective    # 17 passed, 1 ignored
cargo fmt -- --check                              # clean
cargo clippy -- -Dwarnings ...                    # clean

Compatibility

Purely narrows one Style-level false positive; no public API change.

Copilot AI review requested due to automatic review settings July 8, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@AnayGarodia

Copy link
Copy Markdown
Author

Updated the test_most_lints corpus snapshots: the fix removes 6 awkward MoreAdjective suggestions where more/most is followed by an adjective+noun — e.g. "more common plural noun" → "commoner", "a more perfect Union" → "perfecter", "more cheerful carriages" → "cheerfuller". All removals are this one rule; no other lints changed. (The test-chrome-plugin/test-firefox-plugin failures look like unrelated browser-test flakiness — they also fail on my Rust-only sibling PRs.)

@hippietrail hippietrail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More care needs to be taken to deal with words that are both noun and adjective so that we don't block suggestions. Look at the methods starting with .is_kind - there should be one for "is but is not".

.then_positive_adjective(),
) as Box<dyn Expr>,
Box::new(|tok: &Token, _source: &[char]| tok.kind.is_hyphen()),
Box::new(SequenceExpr::whitespace().then_noun()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new branch's prefix overlaps with the branch's one since they both start with whitespace, which isn't necessarily wrong but I always avoid it since things like overlapping POSes are a common source of unexpected false positives and false negatives.

33 | as the more common plural noun. Grammatical context is one way to determine
| ^~~~~~~~~~~ This is not an error, but an inflected form of this adjective also exists
Suggest:
- Replace with: “commoner”

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a problem even though it looks like a bonus. You and I might avoid using "commoner" as an adjective, but it's a legitimate adjective and noun. Hiding the suggestion this way is an unexpected side-effect that should probably be considered by using something other than .then_noun() that takes into account that it might be both a noun and an adjective.

Lint: Style (127 priority)
Message: |
142 | parsing (1997) that merely assigning the most common tag to each known word and
| ^~~~~~~~~~~ This is not an error, but an inflected form of this adjective also exists

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous.

Lint: Style (127 priority)
Message: |
5 | **We the People** of the United States, in Order to form a more perfect Union,
| ^~~~~~~~~~~~ This is not an error, but an inflected form of this adjective also exists

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again. I don't like the adjective "perfecter" but it's still a legit word some users might want.

Message: |
2073 | A dead man passed us in a hearse heaped with blooms, followed by two carriages
2074 | with drawn blinds, and by more cheerful carriages for friends. The friends
| ^~~~~~~~~~~~~ This is not an error, but an inflected form of this adjective also exists

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Message: |
4883 | “Of course she might have loved him just for a minute, when they were first
4884 | married—and loved me more even then, do you see?”
| ^~~~~~~~~ This is not an error, but an inflected form of this adjective also exists

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

5659 | One of my most vivid memories is of coming back West from prep school and later
| ^~~~~~~~~~ This is not an error, but an inflected form of this adjective also exists
Suggest:
- Replace with: “vividest”

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again but unlike the others where the suggested adjectives all seemed ugly, "vividest" is a suggestion I would definitely consider.

There may be even better adjective suggestions this change prevents that we haven't thought of.

@AnayGarodia

Copy link
Copy Markdown
Author

switched to then_kind_is_but_is_not(is_noun, is_adjective) per your pointer (same shape as the one in cant.rs). so a genuine noun head still suppresses — "more short videos" stays quiet — but a trailing word tagged both noun and adjective no longer blocks the suggestion.

heads up on the corpus fallout: three style suggestions come back that then_noun() was silently swallowing — "more common plural" → commoner, "a more perfect Union" → perfecter, "more even then" → evener. that's the direct consequence of not blocking on the ambiguous words. perfecter/evener are debatable, but they're Style hints (dismissable), and filtering them back out would just be the hardcoded-list thing again. lmk if you'd rather draw the line tighter.

@AnayGarodia

Copy link
Copy Markdown
Author

follow-up — the is_noun && !is_adjective version was too blunt. it un-suppressed every noun+adjective word, which pulled back a couple of bad ones on non-gradable adjectives ("a more perfect Union" → perfecter, "more even then" → evener). that's not what you wanted either.

refined it to head-detection: keep then_noun() but require the trailing noun to be the phrase headthen_unless(whitespace + noun). if another noun follows it, the word is functioning adjectivally ("more common plural noun") so the suggestion stays; if it's the head ("more short videos", "more perfect Union,") it suppresses. net: commoner still surfaces (the genuine noun+adjective case), perfecter and evener are gone. only two corpus lines change, both removals.

@hippietrail hippietrail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need more tests to be sure this new logic does what it's intended to do rather than just seeming to work by coincidence. With a very strong preference for real-world examples in the tests rather than contrived ones made up by an AI. Made up by a human would lie somewhere between.

Box::new(
SequenceExpr::whitespace()
.then_noun()
.then_unless(SequenceExpr::whitespace().then_noun()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems confusing but it looks like it now matches "more common noun" but not "more common noun noun"? However, "more common noun" followed by something other than whitespace or "more common noun " followed by something other than a noun will still actually be matched?

When rules start to get confusing with exceptions to exceptions etc. you definitely will want more than a single test case so that you can chase down each one of these loose ends to make sure we're not getting the desired results by fluke.

Unfortunately UnlessStep, .unless() and .then_unless() all lack any tests to clarify what they are and are not intended to do.

@AnayGarodia

Copy link
Copy Markdown
Author

added the tests. all three are real sentences pulled straight from the corpus (harper-core/tests/text/), not made up: "a more perfect Union" from the Constitution, "loved me more even then" from Gatsby, and "the more common plural noun" from the part-of-speech tagging article. grep for them if you want to confirm.

the first two suppress (noun head, and "then" not being a noun), the third still suggests commoner since "plural" is modifying the following "noun" rather than being the head. that contrast is the whole point of the head check, so if it ever regresses one of these three will catch it.

pratyushsinghal7 and others added 5 commits July 17, 2026 12:31
MoreAdjective flagged "more short videos" and suggested "shorter videos".
When the adjective modifies a following noun, "more" quantifies the noun
phrase ("more [short videos]") rather than intensifying the adjective, so
the inflected form changes the meaning. Add a following noun as a third
recognized false-positive shape in the rule's optional trailing clause,
alongside the existing "than <adj>" (Automattic#2925) and hyphen (Automattic#3568) cases.

Closes Automattic#3688.
The MoreAdjective fix removes awkward inflected-form suggestions where
"more/most" is followed by an adjective+noun ("more common plural noun"
-> commoner, "a more perfect Union" -> perfecter, "more cheerful
carriages" -> cheerfuller, etc.). Regenerate the affected corpus
snapshots to reflect the removed false positives.
…oun guard

then_noun() also matched words tagged as both noun and adjective, which
suppressed the inflection suggestion for those (e.g. more common plural).
switch to then_kind_is_but_is_not(is_noun, is_adjective) so a genuine noun
head still suppresses (more short videos) but noun+adjective homographs
don't block the suggestion. refs Automattic#3688.
…se head

is-noun-but-not-adjective was too blunt: it un-suppressed every noun+adjective
word, which re-surfaced bad suggestions on non-gradable adjectives (perfecter,
evener). instead keep then_noun() but require the noun be the head - if another
noun follows it (then_unless), the word is adjectival ("more common plural
noun") and the comparative suggestion stays. "more short videos" still
suppresses; perfecter/evener no longer appear. refs Automattic#3688.
three sentences already in harper-core/tests/text: "a more perfect Union"
(Constitution) and "more even then" (Gatsby) stay suppressed because the
trailing word is the noun head; "the more common plural noun" (a POS article)
still suggests "commoner" because "plural" modifies a following noun. the
suppress-vs-suggest contrast shows the head check isn't coincidental. refs Automattic#3688.
@AnayGarodia
AnayGarodia force-pushed the fix/more-adjective-quantifier-3688 branch from b6f8b29 to 86ec915 Compare July 17, 2026 19:38
@hippietrail

Copy link
Copy Markdown
Collaborator

added the tests. all three are real sentences pulled straight from the corpus (harper-core/tests/text/), not made up: "a more perfect Union" from the Constitution, "loved me more even then" from Gatsby, and "the more common plural noun" from the part-of-speech tagging article. grep for them if you want to confirm.

The problem is that three is still a tiny tiny sample. Ideally we'd be looking outside our tiny internal corpus into GitHub, Stack Overflow, Hacker News, Slashdot, Medium, Reddit where bad English abounds as well as good English. I do this with Google to varying levels of success. I understand AIs can't do this due to robots.txt and Google bot checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive: "more short" flagged to be "shorted" in "more short videos".

4 participants