Skip to content

Commit

Permalink
Update transcribe.js changed order of rules
Browse files Browse the repository at this point in the history
  • Loading branch information
stefangrotz authored Nov 24, 2023
1 parent d3f5239 commit cfb42dc
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions transcribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,6 @@ function transcribeEsperantoToPolish(text) {
text = text.replace(new RegExp(override.eo, "g"), override.pl);
}

// Apply fragment replacements
for (let fragment of rules.fragments) {
text = text.replace(new RegExp(fragment.match, "g"), fragment.replace);
}

// Apply number replacements with more complex logic
text = text.replace(/\b(\d+)(?:\.(\d+))?\b/g, (match, whole, fraction) => {
whole = parseInt(whole, 10);
fraction = fraction ? parseInt(fraction, 10) : 0;
return transcribeNumber(whole, fraction, rules);
});

// Transcribe letter by letter
let transcribedText = "";
for (let char of text) {
Expand All @@ -120,6 +108,19 @@ function transcribeEsperantoToPolish(text) {
transcribedText += char; // Keep the character as is if no rule applies
}
}

// Apply fragment replacements
for (let fragment of rules.fragments) {
text = text.replace(new RegExp(fragment.match, "g"), fragment.replace);
}

// Apply number replacements with more complex logic
text = text.replace(/\b(\d+)(?:\.(\d+))?\b/g, (match, whole, fraction) => {
whole = parseInt(whole, 10);
fraction = fraction ? parseInt(fraction, 10) : 0;
return transcribeNumber(whole, fraction, rules);
});


return transcribedText;
}
Expand Down

0 comments on commit cfb42dc

Please sign in to comment.