Filter phonetic glosses from Complete the Sentence quiz

Examples shorter than 4 words (like pronunciation guides
"discutir(dees-koo-teer)") are now rejected by both
isBlankResolvable and buildQuestion. The engine only picks real
multi-word sentences for the quiz prompt.

Every card already has at least one real sentence alongside its
phonetic entries, so no data regeneration is needed — the filter
alone fixes the issue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-04-11 22:22:28 -05:00
parent a51d2abd47
commit 5fa1cc3921
2 changed files with 39 additions and 13 deletions

View File

@@ -60,6 +60,7 @@ public struct SentenceQuizEngine {
public static func buildQuestion(for card: VocabCard, exampleIndex: Int) -> Question? {
guard exampleIndex >= 0, exampleIndex < card.examplesES.count else { return nil }
let sentence = card.examplesES[exampleIndex]
guard sentence.split(separator: " ").count >= minimumWordCount else { return nil }
let sentenceEN = exampleIndex < card.examplesEN.count ? card.examplesEN[exampleIndex] : ""
let storedBlank = exampleIndex < card.examplesBlanks.count ? card.examplesBlanks[exampleIndex] : ""
@@ -79,8 +80,13 @@ public struct SentenceQuizEngine {
// MARK: - Private
/// Minimum number of whitespace-separated tokens for an example to count as
/// a real sentence (filters out phonetic glosses like "discutir(dees-koo-teer)").
public static let minimumWordCount = 4
private static func isBlankResolvable(card: VocabCard, exampleIndex: Int) -> Bool {
let sentence = card.examplesES[exampleIndex]
guard sentence.split(separator: " ").count >= minimumWordCount else { return false }
let storedBlank = exampleIndex < card.examplesBlanks.count ? card.examplesBlanks[exampleIndex] : ""
if !storedBlank.isEmpty, sentence.range(of: storedBlank, options: .caseInsensitive) != nil {
return true