Fixed a long vowel bug

This commit is contained in:
bernd32 2020-03-13 18:15:32 +05:00
parent b63900b888
commit 728eb7620a
2 changed files with 11 additions and 14 deletions

View File

@ -72,20 +72,12 @@ public class RomajiHenkan {
private String replaceDashMarkerWithLongVowel(String string) {
String resultStr = string;
for (int i = 1; i < string.length(); i++) {
char currentCharacter = string.charAt(i);
char previousCharacter = string.charAt(i - 1);
if (currentCharacter == '-' && isRomanVowel(previousCharacter)) {
switch(previousCharacter) {
case 'a': resultStr = string.replace("a", "ā");
case 'i': resultStr = string.replace("i", "ī");
case 'u': resultStr = string.replace("u", "ū");
case 'e': resultStr = string.replace("e", "ē");
case 'o': resultStr = string.replace("o", "ō");
}
}
}
resultStr = resultStr.replace("-", "");
resultStr = resultStr.replace("a-", "ā");
resultStr = resultStr.replace("i-", "ī");
resultStr = resultStr.replace("u-", "ū");
resultStr = resultStr.replace("e-", "ē");
resultStr = resultStr.replace("o-", "ō");
return resultStr;
}

View File

@ -39,5 +39,10 @@ public class ConvertToKanaTest {
assertEquals("ratte", henkan.convert("ラッテ"));
assertEquals("ko nakatta", henkan.convert("来なかった"));
}
@Test
public void test() {
System.out.println(henkan.convert("思い通りに行かなくて プツリ黙りこくる"));
}
}