Skip to content

Commit adb0e31

Browse files
committed
Consonant and vowel fixes
1 parent 3efc07d commit adb0e31

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

KoreanCVVCPlusPhonemizer/KoreanCVVCPlusPhonemizer.cs

+5-26
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public class KoreanCVVCPlusPhonemizer : Phonemizer {
127127
};
128128

129129

130+
130131
static readonly Dictionary<string, string> vowelLookup;
131132
static readonly Dictionary<string, string> consonantLookup;
132133

@@ -630,28 +631,17 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
630631
var prevLyric = string.Join("", prevUnicode);
631632

632633
// Current note is VV
633-
if (vowelLookup.TryGetValue(prevUnicode.LastOrDefault().ToString() ?? string.Empty, out var vow)) {
634+
if (vowelLookup.TryGetValue(prevLyric.ToString() ?? string.Empty, out var vow)) {
634635
vowel = vow;
635636

636637
var mixVV = $"{vow} {CV}";
637638

638-
if (prevLyric.EndsWith("eo")) {
639-
mixVV = $"eo {CV}";
640-
} else if (prevLyric.EndsWith("eu")) {
641-
mixVV = $"eu {CV}";
642-
} else if (prevLyric.EndsWith("NG")) {
643-
mixVV = $"NG {CV}";
644-
} else if (prevLyric.EndsWith("er")) {
645-
mixVV = $"er {CV}";
646-
}
647-
648639
// try vowlyric then currentlyric
649640
string[] tests = new string[] { mixVV, CV };
650641
if (checkOtoUntilHit(tests, note, out var oto)) {
651642
CV = oto.Alias;
652643
}
653644
}
654-
655645
}
656646

657647
if (nextNeighbour != null) { // 다음에 노트가 있으면
@@ -664,7 +654,7 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
664654

665655
// Get consonant from next note
666656
var consonant = "";
667-
if (consonantLookup.TryGetValue(nextUnicode.FirstOrDefault().ToString() ?? string.Empty, out var con) || (nextLyric.Length >= 3 && consonantLookup.TryGetValue(nextLyric.Substring(0, 3), out con))) {
657+
if (consonantLookup.TryGetValue(nextUnicode.FirstOrDefault().ToString() ?? string.Empty, out var con)) {
668658
consonant = getConsonant(nextNeighbour?.lyric); //Mixed romaja
669659
if ((!isAlphaCon(consonant) || con == "f" || con == "v" || con == "z" || con == "th" || con == "rr")) {
670660
consonant = con;
@@ -983,21 +973,11 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
983973

984974
var prevLyric = string.Join("", prevUnicode);
985975
// Current note is VV
986-
if (vowelLookup.TryGetValue(prevUnicode.LastOrDefault().ToString() ?? string.Empty, out var vow)) {
976+
if (vowelLookup.TryGetValue(prevLyric.ToString() ?? string.Empty, out var vow)) {
987977
vowel = vow;
988978

989979
var vowLyric = $"{vow} {currentLyric}";
990980

991-
if (prevLyric.EndsWith("eo")) {
992-
vowLyric = $"eo {currentLyric}";
993-
} else if (prevLyric.EndsWith("eu")) {
994-
vowLyric = $"eu {currentLyric}";
995-
} else if (prevLyric.EndsWith("NG")) {
996-
vowLyric = $"NG {currentLyric}";
997-
} else if (prevLyric.EndsWith("er")) {
998-
vowLyric = $"er {currentLyric}";
999-
}
1000-
1001981
// try vowlyric then currentlyric
1002982
string[] tests = new string[] { vowLyric, currentLyric };
1003983
if (checkOtoUntilHit(tests, note, out var oto)) {
@@ -1064,7 +1044,7 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
10641044

10651045
// Get consonant from next note
10661046
var consonant = "";
1067-
if (consonantLookup.TryGetValue(nextUnicode.FirstOrDefault().ToString() ?? string.Empty, out var con) || (nextLyric.Length >= 3 && consonantLookup.TryGetValue(nextLyric.Substring(0, 3), out con))) {
1047+
if (consonantLookup.TryGetValue(nextUnicode.FirstOrDefault().ToString() ?? string.Empty, out var con)) {
10681048
consonant = getConsonant(nextNeighbour?.lyric); //Romaja only
10691049
if ((!isAlphaCon(consonant) || con == "f" || con == "v" || con == "z" || con == "th" || con == "rr")) {
10701050
consonant = con;
@@ -1119,7 +1099,6 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
11191099
consonant = "";
11201100
}
11211101

1122-
11231102
if (consonant == "") {
11241103
return new Result {
11251104
phonemes = new Phoneme[] {

0 commit comments

Comments
 (0)