Skip to content

Fix empty cloze words and preserve trailing punctuation#3

Open
derspotter wants to merge 1 commit intobenmanone:masterfrom
derspotter:fix-empty-cloze-and-punctuation
Open

Fix empty cloze words and preserve trailing punctuation#3
derspotter wants to merge 1 commit intobenmanone:masterfrom
derspotter:fix-empty-cloze-and-punctuation

Conversation

@derspotter
Copy link

Summary

  • Fix bug where French sentences with space before punctuation (e.g., C'est vrai ?) could result in empty cloze words
  • Fix bug where trailing punctuation on selected words was lost in display
  • Remove non-existent minicloze-gui from workspace members

Problem

Bug 1: Empty cloze words
French typography puts spaces before ?, !, :, ;. This causes split_inclusive(' ') to create standalone punctuation "words". When randomly selected, remove_punctuation("?") returns "", resulting in:

  • No underscores displayed
  • Empty input matches as "Correct"

Bug 2: Lost punctuation
Words like moment. had their punctuation stripped entirely. The period was part of the selected word but removed for answer matching, and never appeared in second_half.

Solution

  1. Filter out words that become empty after remove_punctuation before random selection
  2. Store raw word (with punctuation) in Prompt, extract trailing punctuation for display, use clean word only for answer comparison

Test plan

  • Tested with minicloze french - sentences now always show proper blanks
  • Trailing punctuation (periods, question marks) preserved in display
  • Answer matching still ignores punctuation

🤖 Generated with Claude Code

@derspotter derspotter force-pushed the fix-empty-cloze-and-punctuation branch from 7a7fe9c to 3423959 Compare January 16, 2026 19:16
Two bugs fixed:

1. Empty cloze words: French typography puts spaces before punctuation
   marks (e.g., "C'est vrai ?"). This causes split_inclusive(' ') to
   create a standalone "?" word. When randomly selected, remove_punctuation
   returns "", resulting in no underscores and empty input matching as
   "Correct". Fixed by filtering out words that become empty after
   punctuation removal.

2. Lost punctuation: Words like "moment." had their punctuation stripped
   entirely since it was part of the selected word but removed for answer
   matching. Now we store the raw word and extract trailing punctuation
   separately for display while still ignoring it for answer comparison.

Also removes non-existent minicloze-gui from workspace members.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@derspotter derspotter force-pushed the fix-empty-cloze-and-punctuation branch from 3423959 to f56a2ca Compare January 22, 2026 08:17
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.

1 participant