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
+104 -142

No files matched your search

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