fix(linting): don't flag sentence-initial "Backup" before a modal - #3794
fix(linting): don't flag sentence-initial "Backup" before a modal#3794AnayGarodia wants to merge 3 commits into
Conversation
hippietrail
left a comment
There was a problem hiding this comment.
Thanks for this but there are subtle things that the coding AIs are not yet good at in relation to grammar checking.
|
|
||
| // If the next word is a present or simple past verb form compatible with a 3rd person singular noun | ||
| // If the next word is a present or simple past verb form compatible with a 3rd person singular noun, | ||
| // or an auxiliary/modal verb ("Backup will run", "Backup can be restored"), the word is the subject noun. |
There was a problem hiding this comment.
There is an assumption that a modal verb can't also be used after a phrasal verb. These kinds of assumptions need to be verified. AIs are terrible at this. I use Google manually and I think they are not able to even if they hadn't already "made up their minds". Here's what I found:
- The data you back up should be determined by how important it is to you
- The number of files you back up can affect both the time required to run the backup and the size of the resulting backup.
- But if your estate is going to attract inheritance tax, any gift you leave to Back Up will be deducted from your estate before any tax liability is calculated.
- The photos you back up might capture quiet moments at home
- Swimming to the bottom, touching your elbows to a fresh fuel canister, and immediately swimming back up would probably be enough to kill you.
- The data you can back up may vary depending on your operating system or phone version.
These all read very naturally and give the impression that legit use of "back up" followed by a modal is common
There was a problem hiding this comment.
|
fair caution. the subtle bug you're pointing at: I put the modal check in the general tightened it: the auxiliary/modal signal now only applies with nothing before the word ( if there's a specific construction you had in mind that's still off, point me at it — happy to add it as a test. |
Yep if you've already got something like
I'm on the road right now so might not have the brain space to dedicate to think it through fully but I'll definitely let you know if one does pop into my head. |
hippietrail
left a comment
There was a problem hiding this comment.
More tests would help a lot.
| ); | ||
| } | ||
|
|
||
| #[test] |
There was a problem hiding this comment.
I believe it was in this thread where I posted half a dozen counterexamples earlier? Those were real-word sentences found by Googling so I would add at least one of them and in this case possibly all of them as additional tests.
There was a problem hiding this comment.
Done in aad85f1: all six are in dont_flag_back_up_verb_before_modal_3661, alongside still-flagged guards pinning the assumption ("Backup your files daily." -> "Back up your files daily.", "You should backup before upgrading." -> "back up").
|
added the tests. pulled in all six of your back-up-before-modal sentences as real-world cases — they stay unflagged, as they should. also widened the sentence-initial check past "will" to "can"/"should", and added the bit that actually pins down the assumption: a bare "backup" with no modal after it still gets flagged ("Backup your files daily" → "Back up your files daily", "You should backup before upgrading" → "back up"). so the exception only fires sentence-initial with a modal right after, and real errors still come through. one honest note: your six are already two words, so the rule never considers them candidates in the first place — they pass trivially. i kept them because they document that "back up" + modal is legit, but the sentence-initial and still-flagged cases are the ones that actually exercise the change. happy to drop the trivial ones if you'd rather. |
PhrasalVerbAsCompoundNoun rewrote "Backup" to "back up" in sentences
like "Backup will run automatically." The rule already treats a
following present/past verb form as a signal that the word is the
subject noun, but modal/auxiliary verbs ("will", "can", "should") were
not covered, so a compound noun followed by a modal was still flagged.
Add is_auxiliary_verb() to that check.
Closes Automattic#3661.
…-initial an auxiliary/modal after the word (e.g. "Backup will run") signals a preceding subject noun, but only with nothing before it. mid-sentence will/can/might are just as often nouns, so gate the modal case on maybe_prev_tok.is_none() to match what the test actually claims. refs Automattic#3661.
…ption verify the Automattic#3661 modal exception with real data rather than a single case: - sentence-initial "Backup" before will/can/should stays unflagged (the fix) - six real "back up" + modal sentences (from @hippietrail's review) stay unflagged, documenting that a following modal isn't itself noun evidence - a genuine "backup" verb error with no modal after it is still flagged, so the exception stays narrow. refs Automattic#3661.
3bce11a to
aad85f1
Compare
|
@hippietrail Following up after the earlier revision: the modal guard remains limited to sentence-initial |
What
Fixes #3661.
PhrasalVerbAsCompoundNounflagged sentence-initial "Backup" and suggested "back up" in sentences like "Backup will run automatically."Why
The rule already treats a following present/simple-past/past verb form as evidence that the compound noun is the subject (
ItsFollowedByVerb), e.g. "Backup is scheduled" and "Backup has finished" are correctly left alone. But modal/auxiliary verbs weren't covered, so "Backup will run", "Backup can be restored", and "Backup should complete" were still flagged.How
Add
next_tok.kind.is_auxiliary_verb()to the existing "followed by a verb" check. Modals (will/can/should/…) are tagged as auxiliary verbs, so this closes the gap without new control flow. True positives are unaffected — they are followed by a preposition or end of clause ("I backup", "you checkout"), not by an auxiliary.Testing
Added
dont_flag_backup_before_modal_3661. Full rule suite green, no regressions:Compatibility
Narrows one false positive; no public API or other-input behavior change.