middle method
Implementation
String middle(String str) {
String resultMid = "";
String m = "";
for (int i = 1; i < str.length - 1; i++) {
String x = str.substring(i, i + 1);
if (wordMap.containsKey(x)) {
m = wordMap[x][6];
//solving g after a or o
String yy = str.substring(i - 1, i);
if (yy == "a" || yy == "o" || yy == "v") {
if (x == "g") {
m = wordMap[x][2];
}
}
//solving g not after a or o
if (yy != "a" && yy != "o" && yy != "v") {
if (x == "g") {
m = wordMap[x][7];
}
}
//solving g before a or o
if (x == "g") {
String y = str.substring(i + 1, i + 2);
if (y == "a" || y == "o" || y == "v") {
m = wordMap[x][6];
}
}
//2021.3.9
//solving n,d before egshig a,e,i,o,u, U, A, E,
if (x == "n" || x == "d") {
String y = str.substring(i + 1, i + 2);
if (y == "a" ||
y == "e" ||
y == "i" ||
y == "o" ||
y == "v" ||
y == "u" ||
y == "A" ||
y == "E" ||
y == "U") {
m = wordMap[x][7];
}
}
//2021.3.9
//solving N,T before egshig a,e,i,o,u, U, A, E,
if (x == "N" || x == "T" || x == "D") {
m = wordMap[x][7];
}
//2021.3.13
// solving b,p,k,f before o,u
if (x == "b" || x == "p" || x == "k" || x == "f") {
String y = str.substring(i + 1, i + 2);
if (y == "o" || y == "u" || y == "v" || y == "U") {
m = wordMap[x][7];
}
}
//solving h, g before e, i, w
if (x == "h" || x == "g") {
String y = str.substring(i + 1, i + 2);
if (y == "e" || y == "i" || y == "w") {
m = wordMap[x][7];
}
}
//solving h, g before u
if (x == "h" || x == "g") {
String y = str.substring(i + 1, i + 2);
if (y == "u") {
m = wordMap[x][8];
}
}
//solving u for second position, test bumbur bum
if (x == "u" && i == 1) {
m = wordMap[x][7];
}
//solving i after a, e, o
if (x == "i") {
String y = str.substring(i - 1, i);
if (y == "a" || y == "e" || y == "o" || y == "v") {
m = wordMap[x][7];
}
}
//solving g after Positive or Negative i traceback and not before a,e,i, o, u test yabogsan uggugsen jarlig jerlig baigal
if (x == "g") {
String y = str.substring(i - 1, i);
String w = str.substring(i + 1, i + 2);
if (y == "i") {
if (w != "a" &&
w != "e" &&
w != "i" &&
w != "o" &&
y != "v" &&
w != "u") {
for (int j = 1; j <= (i); j++) {
String z = str.substring(i + 1 - j, i + 2 - j);
if (z == "a" || z == "o" || z == "v" || z == "A") {
m = wordMap[x][2];
}
}
}
}
}
//h, g before a , for second last letter
if (x == "h" || x == "g") {
String y = str.substring(i + 1, i + 2);
if (y == "a") {
if (i == str.length - 2) {
m = wordMap[x][10];
}
}
}
//n before a, e, for second last letter test yabona
if (x == "n") {
String y = str.substring(i + 1, i + 2);
if (y == "a" || y == "e") {
if (i == str.length - 2) {
m = wordMap[x][10];
}
}
}
//m, L, y, r before a, e
if (x == "m" || x == "l" || x == "y" || x == "r") {
String y = str.substring(i + 1, i + 2);
if (y == "a" || y == "e") {
if (i == str.length - 2) {
m = wordMap[x][9];
}
}
}
resultMid = resultMid + m;
}
}
return resultMid;
}