Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
bug fix and multilingual testcase [master]
Browse files Browse the repository at this point in the history
  • Loading branch information
uroybd committed Sep 29, 2018
1 parent e48aa74 commit 6b1bfaf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Expand Up @@ -23,7 +23,25 @@ public class BengaliLanguageUtils extends LanguageUtils {
put("্ব", "w");
}
};

// Vowels Only
private final static HashMap<String, String> vowels = new HashMap<String, String>() {
{
put("আ", "aa");
put("অ", "a");
put("ই", "i");
put("ঈ", "ii");
put("উ", "u");
put("ঊ", "uu");
put("ঋ", "ri");
put("এ", "e");
put("ঐ", "oi");
put("ও", "o");
put("ঔ", "ou");
}
};

// Vowels and Hasants
private final static HashMap<String, String> vowelsAndHasants = new HashMap<String, String>() {
{
put("আ", "aa");
Expand Down Expand Up @@ -243,7 +261,7 @@ public static String transliterate(String txt) {
}
}
String whitespace = m.group(12);
if (nextNeedsO && kaar == null && whitespace == null) {
if (nextNeedsO && kaar == null && whitespace == null && !vowels.containsKey(m.group(0))) {
appendableString = appendableString + "o";
lastHadO++;
thisNeedsO = false;
Expand All @@ -255,7 +273,7 @@ public static String transliterate(String txt) {
lastHadO = 0;
}
nextNeedsO = false;
if (thisNeedsO && kaar == null && whitespace == null) {
if (thisNeedsO && kaar == null && whitespace == null && !vowels.containsKey(m.group(0))) {
appendableString = appendableString + "o";
lastHadO++;
}
Expand Down
Expand Up @@ -60,9 +60,11 @@ public void testStringTransliterateArabic() {
@Test
public void testStringTransliterateBengali() throws Exception {
// input with cyrillic and diacritic letters
String[] inputs = { "অনিরুদ্ধ", "বিজ্ঞানযাত্রা চলছে চলবে।", "আমি সব দেখেশুনে ক্ষেপে গিয়ে করি বাঙলায় চিৎকার!" };
String[] inputs = { "অনিরুদ্ধ", "বিজ্ঞানযাত্রা চলছে চলবে।", "আমি সব দেখেশুনে ক্ষেপে গিয়ে করি বাঙলায় চিৎকার!",
"আমার জাভা কোড is so bad! কী আর বলবো!" };
String[] outputs = { "oniruddho", "biggaanJaatraa cholchhe cholbe.",
"aami sob dekheshune kkhepe giye kori baanglaay chitkaar!" };
"aami sob dekheshune kkhepe giye kori baanglaay chitkaar!",
"aamaar jaabhaa koD is so bad! kii aar bolbo!"};

String result;

Expand Down

0 comments on commit 6b1bfaf

Please sign in to comment.