Repository navigation
fix(novelty): keep a question's leading Don't when the source opens with Do not - #1256
antonwolfy wants to merge 4 commits into
Conversation
…ith Do not (intel#1232) `check_wording("reversal", ...)` kept a question's leading negative auxiliary only when the source opened with a contracted one (`_LEADING_NEGATIVE`). A source that opens with the spelled-out `Do not`, `Does not` or `Never` did not match, so the candidate's leading `Don't` was stripped as question phrasing: `Don't run the installer as root?` counted 0 negations against the source's 1 and was accepted as a reversal of `Do not run the installer as root.` A second pattern, `_LEADING_SPELLED_NEGATION` (`do|does|did|can|will|must|should|may not`, `cannot`, `never`), now also makes `_claim_negations` keep the candidate's leading negative auxiliary, so the candidate is rejected as `restates_source`, as it already was for a source opening with `Don't`. `_strip_question_phrasing`, the paraphrase path and the trailing-tag rule are unchanged. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1256 +/- ##
==========================================
+ Coverage 96.14% 96.18% +0.03%
==========================================
Files 498 499 +1
Lines 66004 66470 +466
Branches 11461 11543 +82
==========================================
+ Hits 63460 63933 +473
+ Misses 1573 1564 -9
- Partials 971 973 +2
🚀 New features to boost your workflow:
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: LOCAL (head 0106095)
- Contract: none
- Responsibility: none
- Dependency: none
- Review depth: skim: local change, check diff + tests
- Coverage gaps: none
The mixed-spelling restatement from #1232 is now rejected. All 126 novelty-probe tests passed, but a separate check against the merge base found a regression in a documented leading-question frame. I left the input and both results inline.
…lows it A source that opens with a spelled-out negation kept every leading negative auxiliary of a question candidate, so the documented frame "Isn't it true that I should run the installer as root?" against "Do not run the installer as root." was rejected as polarity_not_flipped. Now only an imperative "Don't <verb>" is kept; "Isn't it true that", "Don't you" and the like stay question phrasing. Tests cover both cases with straight and typographic apostrophes. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@napetrov (#1256 (review)): The review body only points at the inline thread 4712116881, which is answered above (ac219655). |
…he source Settles the review point that `Don't applications store credentials in logs?` against `Do not store credentials in logs.` was rejected as polarity_not_flipped: `applications` is the question's subject, not an imperative verb. A spelled-out source now keeps the candidate's leading Don't only when the word after it is a word of the source. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…ts verb
Settles the review point that `Don't ever run the installer as root?` read `ever` as the verb after `Don't`, found it absent from the source and stripped the leading `Don't`, so the prohibition counted no negation and `check_wording("reversal", ...)` returned `[]` against `Do not run the installer as root.`
The imperative pattern now skips `ever`, `always`, `just`, `still`, `also`, `even`, `really`, `actually`, `simply` and `again` before taking the verb, so the negation is kept and the candidate is rejected as `polarity_not_flipped`. A parametrized test pins the exact diagnostic.
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Summary
On
main,check_wording("reversal", ...)accepts a question that restates a source opening with a spelled-out negation, when the question opens withDon't._claim_negationskeeps a question's leading negative auxiliary only when the source matches_LEADING_NEGATIVE, which lists contracted forms (don't,isn't, ...). A source that opens withDo not,Does notorNeverdoes not match, so the candidate'sDon'tis stripped as question phrasing: it counts 0 negations against the source's 1 and reads as a flipped polarity (#1232).mainDo not run the installer as root.Don't run the installer as root?[]['restates_source']Do not run the installer as root.Don’t run the installer as root?[]['restates_source']Does not run the installer as root.Don't run the installer as root?[]['restates_source']Never run the installer as root.Don't run the installer as root?[]['restates_source']Don't run the installer as root.Don't run the installer as root?['restates_source']['restates_source']Do not run the installer as root.Isn't it true that I should run the installer as root?[][]The issue's fix option is taken: when the source opens with a negation, spelled out or contracted, the candidate's leading negative auxiliary is kept; for a spelled-out source only an imperative
Don't <verb>whose verb is a word of the source is kept, so the documented frameIsn't it true that I should run the installer as root?againstDo not run the installer as root.stays[](a first version of the change returned['polarity_not_flipped']for it, which review caught), and so doesDon't applications store credentials in logs?againstDo not store credentials in logs., whoseapplicationsis a noun subject (also caught in review). An adverb betweenDon'tand the verb is skipped before that comparison, soDon't ever run the installer as root?againstDo not run the installer as root.returns['polarity_not_flipped'](the adverb is new wording, so it is notrestates_source); before,everwas read as the verb, was not a word of the source, and theDon'twas stripped, giving[](review of #1256). It changes the one place that decides it and leaves_strip_question_phrasing, the paraphrase path and the trailing-tag rule alone.Closes #1232
Changes
dokimi/dokimi/novelty/probes.py: new_LEADING_SPELLED_NEGATION(do|does|did|can|will|must|should|may+not,cannot,never, after optional whitespace, case-insensitive) next to_LEADING_NEGATIVE;_claim_negationskeeps the candidate's leading negative auxiliary when_LEADING_NEGATIVEmatches the source, or when_LEADING_SPELLED_NEGATIONmatches it and the candidate opens with an imperativeDon't <verb>(new_LEADING_IMPERATIVE_DONT:Don'tnot followed byit,you,we,the, ... which is a frame, and whose following word must also be a word of the source, so a noun subject such asapplicationsis not taken for a verb). Its docstring names the spelled-out openers. A typographicDon’tsource needs no case of its own:_normalise_negationswrites it as'first.dokimi/tests/test_novelty_probes.py: a test over the openersDo not,Does not,Never,Cannotand the straight and typographicDon'tcandidate, asserting["restates_source"]; a test thatShould the installer be run as root?,Is it fine to run the installer as root?andShould the installer be run as root, shouldn't it?are still accepted as inversions ofDo not run the installer as root.; a test thatIsn't it true that I should run the installer as root?, with a straight and a typographic apostrophe, is accepted againstDo not ...andNever ...sources; a test thatDon't applications store credentials in logs?(both apostrophes) is accepted againstDo not store credentials in logs.._LEADING_IMPERATIVE_DONTalso skipsever,always,just,still,also,even,really,actually,simplyandagainbetweenDon'tand the verb;test_a_dont_question_with_an_adverb_before_the_verb_is_no_inversion_of_a_do_not_sourceasserts['polarity_not_flipped']forever,always,justandreally.Do notsource, and the adverb.Risk
A reversal question that opens with an imperative
Don't <verb>against a source opening withDo not,Does not,Never,Cannotand the like is now counted as keeping that negation, so a restatement is rejected where it was accepted. For a source opening withDon'tthis is what already happened. A candidate that is a real inversion without a leadingDon't <verb>is unchanged ([]), includingIsn't it true that I should run the installer as root?againstDo not run the installer as root.. A source that does not open with a negation (The installer must not run as root.) is unchanged:Isn't it fine to run the installer as root?still returns[]. The paraphrase path is not affected.Testing
On a Linux review host, at
f3422801(onmain4abc47d):make ci-local: 38 passed, 0 failed, 15 skipped (matrix legs from other jobs, micromamba, semgrep, the fuzz job, deploy and report jobs, which need a PR or a tool this run lacks); 29696 tests passed, 23 skipped. An earlier run of the same tree had one failure,tests/test_fuzz_targets.py::test_any_text[verdict](an unraisable-exception warning from aWeakKeyDictionaryfinalizer), which is outside this change and passed alone (136 passed) and in the rerun.Don't ever run the installer as root?againstDo not run the installer as root.returned[]atcc5af5e9and returns['polarity_not_flipped']here; the new test fails onmain's code (4 failed) and on a copy with the adverb group of the pattern replaced by one that never matches (4 failed).main's code the new test file fails:8 failed, 118 passed, first onassert [] == ['restates_source']; with the changetests/test_novelty_probes.pypasses._LEADING_NEGATIVE(themainbehaviour) fails the new restates test withassert [] == ['restates_source']; droppingneverfrom the pattern fails itsNever ...cases; keeping the trailing tag when the leading auxiliary is kept failstest_a_genuine_inversion_of_a_do_not_source_is_still_acceptedwithassert ['polarity_not_flipped'] == []; keeping the leading auxiliary for every candidate of a spelled-out source (dropping the imperative check) failstest_an_isnt_it_true_frame_inverting_a_spelled_out_source_is_not_a_restatementin all four cases, withassert ['polarity_not_flipped'] == []; keeping the leadingDon'twhatever word follows it (dropping the source-word check) failstest_a_dont_question_with_a_noun_subject_inverting_a_do_not_source_is_acceptedin both apostrophe cases (2 failed, 130 passed).Open questions
None.
Revert
A plain revert restores the old behaviour. Nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)