Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"publisher": "SiddharthaPrasad",
"icon": "images/icon.png",
"license": "MIT",
"version": "0.5.4",
"version": "0.5.5",
"repository": {
"type": "git",
"url": "https://github.com/sidprasad/pick-regex"
Expand Down
13 changes: 5 additions & 8 deletions src/pickController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,15 +682,12 @@ export class PickController {
for (const record of this.wordHistory) {
if (record.classification === WordClassification.ACCEPT) {
for (const candidate of this.candidates) {
if (candidate.eliminated) {
continue;
}
if (this.analyzer.verifyMatch(record.word, candidate.pattern)) {
candidate.positiveVotes++;
} else {
// Candidate fails to match an accepted word - negative vote
candidate.negativeVotes++;
if (candidate.negativeVotes >= candidate.eliminationThreshold) {
if (!candidate.eliminated && candidate.negativeVotes >= candidate.eliminationThreshold) {
candidate.eliminated = true;
logger.info(
`[Replay] Eliminated candidate "${candidate.pattern}" after ${candidate.negativeVotes} negative votes (threshold ${candidate.eliminationThreshold}) - failed to match accepted word "${record.word}".`
Expand All @@ -700,17 +697,17 @@ export class PickController {
}
} else if (record.classification === WordClassification.REJECT) {
for (const candidate of this.candidates) {
if (candidate.eliminated) {
continue;
}
if (this.analyzer.verifyMatch(record.word, candidate.pattern)) {
candidate.negativeVotes++;
if (candidate.negativeVotes >= candidate.eliminationThreshold) {
if (!candidate.eliminated && candidate.negativeVotes >= candidate.eliminationThreshold) {
candidate.eliminated = true;
logger.info(
`[Replay] Eliminated candidate "${candidate.pattern}" after ${candidate.negativeVotes} negative votes (threshold ${candidate.eliminationThreshold}) - incorrectly matched rejected word "${record.word}".`
);
}
} else {
// Candidate correctly does NOT match a rejected word - positive vote
candidate.positiveVotes++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid adding positive votes for reject replays

In recalculateVotes, a rejected word that does not match now increments positiveVotes, but the normal classification path treats this case as neutral (no positive vote). As a result, any time vote history is replayed (e.g., refineCandidates or updateClassification), candidates can gain extra positives solely for rejecting words, changing selectBestCandidate and termination outcomes compared to the original session. This makes results depend on whether a recalculation occurred rather than the actual voting logic.

Useful? React with 👍 / 👎.

}
}
}
Expand Down