Apply multiple fixers to LLM translation output in sequence
Apply all requested fixers by type, processing them in order and accumulating fixes. Each fixer receives the output of the previous fixer, allowing multiple corrections to be applied in a single pass.
Speaker labels to recognize when fixing collapsed speaker lines.If not provided, labels will be inferred automatically from the text.Example: ["Questioner", "The Shaykh", "Mu'adhdhin"]
Punctuation tokens that may appear before a collapsed speaker label.Used to detect patterns like "... The Shaykh:" and preserve punctuation when inserting newlines.Default: ['.', '?', '!', '…', '،', '؛', ':', ':', '-', '–', '—']
import { fixAll } from 'wobble-bibble';const malformedText = `P1 - Questioner: What is the ruling? The Shaykh: The ruling is permissible.P2 - The text continues here. Questioner: Another question?`;const result = fixAll(malformedText, { types: ['collapsed_speakers'], config: { speakerLabels: ['Questioner', 'The Shaykh'] }});console.log(result.text);// P1 - Questioner: What is the ruling?// The Shaykh: The ruling is permissible.// P2 - The text continues here.// Questioner: Another question?console.log(result.applied);// ['collapsed_speakers']console.log(result.counts);// { fixCollapsedSpeakerLines: 2 }
Fixers are applied in the order specified in options.types. Each fixer receives the output of the previous fixer:
const result = fixAll(text, { types: ['collapsed_speakers', 'other_future_fixer']});// 1. collapsed_speakers fixer runs on original text// 2. other_future_fixer runs on output from step 1// 3. Final result contains accumulated fixes
The counts object tracks how many fixes each fixer applied, using the function name as the key:
const result = fixAll(text, { types: ['collapsed_speakers'] });// If fixCollapsedSpeakerLines found and fixed 5 instances:console.log(result.counts);// { fixCollapsedSpeakerLines: 5 }