fix(core): stop LetsConfusion flagging quantifiers after let's - #4082
fix(core): stop LetsConfusion flagging quantifiers after let's#4082mauropereiira wants to merge 1 commit into
LetsConfusion flagging quantifiers after let's#4082Conversation
`LetUsRedundancy` matched `let's` followed by any pronoun. The curated dictionary tags `all`, `both`, `everyone` and `everybody` as pronouns, so grammatical sentences like "Let's all go home." were flagged as a redundant subject. Match an object pronoun instead. Every word the rule targets (`us`, `me`, `him`, `her`, `them`, `it`, `you`) has `pronoun.is_object`, and none of the quantifiers do. Filtering on `determiner.is_quantifier` was considered but does not cover `everyone` or `everybody`, which carry no quantifier tag. Fixes Automattic#4037 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TZSh4cTpLoekcsjcKR5nTH
|
Oh at some point I added a "personal pronoun" category. This is a term from linguistics meaning that pronouns that encode 1st/2nd/3rd person and not the everyday sense which would imply they're pronouns which refer to people and not to things. Anyway, pronouns such as "all" are not personal pronouns, so maybe another/better approach might be to switch a |
|
That distinction is useful, thanks, and both predicates do encode it. The metadata for the words involved:
So either predicate fixes the reported bug, since none of the quantifiers is a personal pronoun. The difference is that I think that tips it toward format!("lets {pronoun}")so the matched word becomes the object of "lets we do it" and "lets I do it" are not English, so Happy to switch if you would rather have the wider match and put a guard on the suggestion instead. |
|
Yep my apologies if I send you down any rabbit holes do due commenting after only skimming rather than deeply reading and understanding. |
|
No apology needed, both of those went somewhere useful. The A skim that asks "have you considered X" is worth a lot when the answer turns out to be "no, and here is what happens when I try it". |
Issues
Fixes #4037
Description
LetUsRedundancymatchedlet'sfollowed by any pronoun:The curated dictionary tags
all,both,everyoneandeverybodyas pronouns, so ordinary sentences got flagged as a redundant subject.allandbothare floating quantifiers in apposition to theusalready insidelet's. "Let's all go home." expands to "Let us all go home.", not "Let us us go home."This matches an object pronoun instead. In the curated metadata,
is_objectseparates the two groups exactly:pronoun.is_objectdeterminer.is_quantifierIn the issue thread @hippietrail suggested filtering on
is_quantifier, or a shortlist. I tried theis_quantifierroute first and it does not cover the set:everyoneandeverybodycarry no quantifier tag, so they would keep firing.then_object_pronounalready exists inexpr/sequence_expr.rs, so no new helper is needed.No snapshot files change. The Alice in Wonderland line in
harper-core/tests/text/is writtenlet’s all move one place on.with a typographic apostrophe, andaco("let's")cannot match that, so this false positive never fired on the corpus. It becomes visible only onceWordnormalises apostrophes, which is #3202.#3696 covers
let's you. Sinceyouis an object pronoun, this change leaves that behaviour exactly as it was.Demo
Before:
After:
How Has This Been Tested?
cargo test -p harper-core --libThe existing
LetsConfusiontests still pass unchanged, includingwalking("The crutch let's him walk."),issue_426_us,issue_426_meandissue_548.cargo fmtis clean and no files underharper-core/tests/text/are modified.AI Disclosure
If Your PR Implements or Enhances a Linter
Three of the four test sentences are verbatim from the issue. The fourth, "Let's everybody take a seat.", comes from @hippietrail's question in the issue thread about whether
everybodybehaves the same way. It does, and it is the case theis_quantifierapproach would have missed, so it seemed worth pinning.Checklist