Fix translating and update code

This commit is contained in:
Lncvrt committed 2025-07-26 12:19:51 -07:00
1 parent c6eedbeab9
commit b8089f6ad2
3 files changed
+103 -141

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
} }
group = 'xyz.lncvrt.seselulu' group = 'xyz.lncvrt.seselulu'
version = '1.0.0' version = '1.0.1'
jar { jar {
manifest { manifest {
+18 -17
View File
@@ -4,30 +4,31 @@ import java.util.Objects;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
java.util.Scanner myObj = new java.util.Scanner(System.in); // Create a Scanner object java.util.Scanner inputReader = new java.util.Scanner(System.in);
System.out.print("Se Se Lu Lu to english [E] or english to Se Se Lu Lu [S]?: "); System.out.print("Se Se Lu Lu to english [E] or english to Se Se Lu Lu [S]?: ");
// The variable name means English to Se Se Lu Lu or Se Se Lu Lu to English String inputMode = inputReader.nextLine();
// I didn't know what else to name it
String EtoSorStoE = myObj.nextLine(); // Read user input
int Lang = 1;
if (Objects.equals(EtoSorStoE.toLowerCase(), "e")) { int lang = 1;
if (Objects.equals(inputMode.toLowerCase(), "e")) {
System.out.print("Type your Se Se Lu Lu: "); System.out.print("Type your Se Se Lu Lu: ");
} else if (Objects.equals(EtoSorStoE.toLowerCase(), "s")) { } else if (Objects.equals(inputMode.toLowerCase(), "s")) {
System.out.print("Type your English: "); System.out.print("Type your English: ");
Lang = 2; lang = 2;
}
String Sentence = myObj.nextLine();
String ConvertedSentence;
if (Lang == 1) {
ConvertedSentence = Translator.ConvertFrom(Sentence);
} else { } else {
ConvertedSentence = Translator.ConvertTo(Sentence); System.out.print("Invalid mode");
return;
} }
System.out.println("Converted sentence: " + ConvertedSentence); String inputSentence = inputReader.nextLine();
String convertedSentence;
if (lang == 1) {
convertedSentence = Translator.convertFrom(inputSentence);
} else {
convertedSentence = Translator.convertTo(inputSentence);
}
System.out.println("Converted sentence: " + convertedSentence);
} }
} }
+84 -123
View File
@@ -1,132 +1,93 @@
package xyz.lncvrt.seselulu; package xyz.lncvrt.seselulu;
import java.util.HashMap;
import java.util.Map;
public class Translator { public class Translator {
public static String ConvertTo(String input) { private static final Map<String, String> map = new HashMap<>();
StringBuilder sb = new StringBuilder(); private static final Map<String, String> reverseMap = new HashMap<>();
for (char c : input.toCharArray()) {
String mapped = switch (c) { static {
case 'a' -> "selu"; map.put("a", "selu");
case 'b' -> "seselulu"; map.put("b", "seselulu");
case 'c' -> "seseselululu"; map.put("c", "seseselululu");
case 'd' -> "dedecucu"; map.put("d", "dedecucu");
case 'e' -> "lalalulu"; map.put("e", "lalalulu");
case 'f' -> "fafu"; map.put("f", "fafu");
case 'g' -> "googoogaagaa"; map.put("g", "googoogaagaa");
case 'h' -> "hahaha"; map.put("h", "hahaha");
case 'i' -> "eiei"; map.put("i", "eiei");
case 'j' -> "jaja"; map.put("j", "jaja");
case 'k' -> "ok"; map.put("k", "ok");
case 'l' -> "lagu"; map.put("l", "lagu");
case 'm' -> "moo"; map.put("m", "moo");
case 'n' -> "no"; map.put("n", "no");
case 'o' -> "oogabooga"; map.put("o", "oogabooga");
case 'p' -> "pepe"; map.put("p", "pepe");
case 'q' -> "oogalyboogaly"; map.put("q", "oogalyboogaly");
case 'r' -> "rahroo"; map.put("r", "rahroo");
case 's' -> "solay"; map.put("s", "solay");
case 't' -> "tootay"; map.put("t", "tootay");
case 'u' -> "yala"; map.put("u", "yala");
case 'v' -> "vooloo"; map.put("v", "vooloo");
case 'w' -> "waawaa"; map.put("w", "waawaa");
case 'x' -> "tumtum"; map.put("x", "tumtum");
case 'y' -> "yumyum"; map.put("y", "yumyum");
case 'z' -> "zooloola"; map.put("z", "zooloola");
case 'A' -> "SELU"; map.put("A", "SELU");
case 'B' -> "SESELULU"; map.put("B", "SESELULU");
case 'C' -> "SESESELULULU"; map.put("C", "SESESELULULU");
case 'D' -> "DEDECUCU"; map.put("D", "DEDECUCU");
case 'E' -> "LALALULU"; map.put("E", "LALALULU");
case 'F' -> "FAFU"; map.put("F", "FAFU");
case 'G' -> "GOOGOOGAAGAA"; map.put("G", "GOOGOOGAAGAA");
case 'H' -> "HAHAHA"; map.put("H", "HAHAHA");
case 'I' -> "EIEI"; map.put("I", "EIEI");
case 'J' -> "JAJA"; map.put("J", "JAJA");
case 'K' -> "OK"; map.put("K", "OK");
case 'L' -> "LAGU"; map.put("L", "LAGU");
case 'M' -> "MOO"; map.put("M", "MOO");
case 'N' -> "NO"; map.put("N", "NO");
case 'O' -> "OOGABOOGA"; map.put("O", "OOGABOOGA");
case 'P' -> "PEPE"; map.put("P", "PEPE");
case 'Q' -> "OOGALYBOOGALY"; map.put("Q", "OOGALYBOOGALY");
case 'R' -> "RAHROO"; map.put("R", "RAHROO");
case 'S' -> "SOLAY"; map.put("S", "SOLAY");
case 'T' -> "TOOTAY"; map.put("T", "TOOTAY");
case 'U' -> "YALA"; map.put("U", "YALA");
case 'V' -> "VOOLOO"; map.put("V", "VOOLOO");
case 'W' -> "WAAWAA"; map.put("W", "WAAWAA");
case 'X' -> "TUMTUM"; map.put("X", "TUMTUM");
case 'Y' -> "YUMYUM"; map.put("Y", "YUMYUM");
case 'Z' -> "ZOOLOOLA"; map.put("Z", "ZOOLOOLA");
default -> "";
}; for (Map.Entry<String, String> entry : map.entrySet()) {
if (!mapped.isEmpty()) { reverseMap.put(entry.getValue(), entry.getKey());
if (!sb.isEmpty()) sb.append(' ');
sb.append(mapped);
}
} }
return sb.toString();
} }
public static String ConvertFrom(String input) { public static String convertTo(String input) {
StringBuilder sb = new StringBuilder(); StringBuilder result = new StringBuilder();
for (String word : input.split(" ")) { for (char c : input.toCharArray()) {
char mapped = switch (word) { if (c == ' ') {
case "selu" -> 'a'; result.append(" ");
case "seselulu" -> 'b'; } else {
case "seseselululu" -> 'c'; result.append(map.getOrDefault(String.valueOf(c), String.valueOf(c))).append(" ");
case "dedecucu" -> 'd'; }
case "lalalulu" -> 'e';
case "fafu" -> 'f';
case "googoogaagaa" -> 'g';
case "hahaha" -> 'h';
case "eiei" -> 'i';
case "jaja" -> 'j';
case "ok" -> 'k';
case "lagu" -> 'l';
case "moo" -> 'm';
case "no" -> 'n';
case "oogabooga" -> 'o';
case "pepe" -> 'p';
case "oogalyboogaly" -> 'q';
case "rahroo" -> 'r';
case "solay" -> 's';
case "tootay" -> 't';
case "yala" -> 'u';
case "vooloo" -> 'v';
case "waawaa" -> 'w';
case "tumtum" -> 'x';
case "yumyum" -> 'y';
case "zooloola" -> 'z';
case "SELU" -> 'A';
case "SESELULU" -> 'B';
case "SESESELULULU" -> 'C';
case "DEDECUCU" -> 'D';
case "LALALULU" -> 'E';
case "FAFU" -> 'F';
case "GOOGOOGAAGAA" -> 'G';
case "HAHAHA" -> 'H';
case "EIEI" -> 'I';
case "JAJA" -> 'J';
case "OK" -> 'K';
case "LAGU" -> 'L';
case "MOO" -> 'M';
case "NO" -> 'N';
case "OOGABOOGA" -> 'O';
case "PEPE" -> 'P';
case "OOGALYBOOGALY" -> 'Q';
case "RAHROO" -> 'R';
case "SOLAY" -> 'S';
case "TOOTAY" -> 'T';
case "YALA" -> 'U';
case "VOOLOO" -> 'V';
case "WAAWAA" -> 'W';
case "TUMTUM" -> 'X';
case "YUMYUM" -> 'Y';
case "ZOOLOOLA" -> 'Z';
default -> '\0';
};
if (mapped != '\0') sb.append(mapped);
} }
return sb.toString(); return result.toString().trim();
}
public static String convertFrom(String input) {
StringBuilder result = new StringBuilder();
String[] words = input.split(" ");
for (String word : words) {
if (word.isEmpty()) {
result.append(" ");
} else {
result.append(reverseMap.getOrDefault(word, ""));
}
}
return result.toString();
} }
} }