Skip to content

Commit

Permalink
feat(jukebox): convertMonoruby by dictionary when encountering words …
Browse files Browse the repository at this point in the history
…not in dictionary
  • Loading branch information
blueset authored Sep 4, 2024
1 parent a4cb3c3 commit 58670a4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/common/src/utils/transliterate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,19 @@ async function applyFuriganaMapping(
if (cache?.[text]?.[furigana]) {
return cache[text][furigana];
}
const [{ segmentedText, segmentedFurigana }, created] =
let [{ segmentedText, segmentedFurigana }, created] =
await FuriganaMapping.findOrCreate({
where: { text, furigana },
});
if (created) {
const [textGroups, furiganaGroups] = convertMonoruby(text, furigana);
if (textGroups.length > 1 && furiganaGroups.length > 1) {
segmentedText = textGroups.join(",");
segmentedFurigana = furiganaGroups.join(",");
await FuriganaMapping.update({ segmentedText, segmentedFurigana }, { where: { text, furigana } });
created = false;
}
}
if (created || !segmentedText || !segmentedFurigana) {
return [v];
}
Expand Down Expand Up @@ -574,3 +583,7 @@ export async function transliterate(
return text;
}
}
function convertMonoruby(text: string, furigana: string): [any, any] {
throw new Error("Function not implemented.");
}

0 comments on commit 58670a4

Please sign in to comment.