Chat-Transform/src/client/java/io/gitlab/jfronny/chattransform/Cfg.java

154 lines
5.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package io.gitlab.jfronny.chattransform;
import io.gitlab.jfronny.commons.serialize.gson.api.v1.Ignore;
import io.gitlab.jfronny.libjf.config.api.v1.*;
import java.util.LinkedHashMap;
import java.util.Map;
@JfConfig
public class Cfg {
@Entry public static Map<String, String> substitutions = Map.of();
@Entry public static Mode mode = Mode.Live;
@Entry public static boolean visualize = true;
public enum Mode {
Live, OnSend
}
@Preset
public static void owo() {
substitutions = new LinkedHashMap<>();
substitutions.put("r", "w");
substitutions.put("l", "w");
substitutions.put("R", "W");
substitutions.put("L", "W");
substitutions.put("no", "nu");
substitutions.put("has", "haz");
substitutions.put("have", "haz");
substitutions.put("you", "uu");
substitutions.put("the ", "da ");
substitutions.put("The ", "Da ");
}
@Preset
public static void demonstrationPurposesOnly() {
substitutions = new LinkedHashMap<>();
substitutions.put("chat-transform", "Chat-Transform (this mod)");
substitutions.put(":tm:", "");
substitutions.put("(c)", "©");
}
@Ignore private static final String katakanaTable = """
a i u e o n
ア イ ウ エ オ ン
x ァ ィ ゥ ェ ォ
k カ キ ク ケ コ
ky キャ キュ キョ
s サ ス セ ソ
sh シャ シ シュ シェ ショ
t タ ティ ツ テ ト
ts ツ
ch チャ チ チュ チェ チョ
n ナ ニ ヌ ネ
ny ニャ ニュ ニョ
h ハ ヒ フ ヘ ホ
hy ヒャ ヒュ ヒョ
f ファ フィ フ フェ フォ
m マ ミ ム メ モ
my ミャ ミュ ミョ
y ヤ ユ ヨ
r ラ リ ル レ ロ
ry リャ リィ リュ リェ リョ
w ワ ウィ ウェ ヲ
g ガ ギ グ ゲ ゴ
gy ギャ ギュ ギョ
z ザ ズ ゼ ゾ/ヂョ
j ジャ/ヂャ ジ/ヂ ジュ/ヂュ ジェ ジョ
d ダ ヅ デ ド
b バ ビ ブ ベ ボ
by ビャ ビュ ビョ
p パ ピ プ ペ ポ
py ピャ ピュ ピョ
v ゔ""";
@Ignore private static final String hiraganaTable = """
a i u e o n
あ い う え お ん
x ぁ ぃ ぅ ぇ ぉ
k か き く け こ
ky きゃ きゅ きょ
s さ す せ そ
sh しゃ し しゅ しょ
t た つ て と
ts つ
ch ちゃ ち ちゅ ちぇ ちょ
n な に ぬ ね の
ny にゃ にゅ にょ
h は ひ ふ へ ほ
hy ひゃ ひゅ ひょ
f ふ
m ま み む め も
my みゃ みゅ みょ
y や ゆ よ
r ら り る れ ろ
ry りゃ りぃ りゅ りぇ りょ
w わ ゐ ゑ を
g が ぎ ぐ げ ご
gy ぎゃ ぎゅ ぎょ
z ざ ず ぜ ぞ/ぢょ
j じゃ/ぢゃ じ/ぢ じゅ/ぢゅ じょ
d だ づ で ど
b ば び ぶ べ ぼ
by びゃ びゅ びょ
p ぱ ぴ ぷ ぺ ぽ
py ぴゃ ぴゅ ぴょ
v ゔ""";
@Ignore private static final char[] consonants = "bcdfghjklmprstwz".toCharArray();
private static void fromTable(String table) {
String[] rows = table.split("\n");
String[] colNames = rows[0].split("\t");
for (int i = 1; i < rows.length; i++) {
String row = rows[i];
String[] cols = row.split("\t");
String rowName = cols[0];
for (int j = 1; j < cols.length; j++) {
String kana = cols[j];
String value = rowName + colNames[j];
String[] kanas = kana.split("/");
for (String singleKana : kanas) {
if (!singleKana.isEmpty()) {
substitutions.put(value, singleKana);
}
}
}
}
}
@Preset
public static void katakana() {
substitutions = new LinkedHashMap<>();
substitutions.put("-", "");
for (char c : consonants) {
substitutions.put("" + c + c, "" + c);
}
substitutions.put("nn", "");
fromTable(katakanaTable);
System.out.println("katakana " + substitutions);
}
@Preset
public static void hiragana() {
substitutions = new LinkedHashMap<>();
substitutions.put("-", "");
for (char c : consonants) {
substitutions.put("" + c + c, "" + c);
}
substitutions.put("nn", "");
fromTable(hiraganaTable);
System.out.println("hiragana " + substitutions);
}
}