Skip to content

Instantly share code, notes, and snippets.

@gkastrinis
Created March 27, 2021 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkastrinis/818eee88a6d4f00873b997f718abf02a to your computer and use it in GitHub Desktop.
Save gkastrinis/818eee88a6d4f00873b997f718abf02a to your computer and use it in GitHub Desktop.
def hiragana = [
//kana
'a':'あ','i':'い','u':'う','e':'え','o':'お',
'ka':'か','ki':'き','ku':'く','ke':'け','ko':'こ',
'sa':'さ','shi':'し','su':'す','se':'せ','so':'そ',
'ta':'た','chi':'ち','tsu':'つ','te':'て','to':'と',
'na':'な','ni':'に','nu':'ぬ','ne':'ね','no':'の',
'ha':'は','hi':'ひ','fu':'ふ','he':'へ','ho':'ほ',
'ma':'ま','mi':'み','mu':'む','me':'め','mo':'も',
'ya':'や','yu':'ゆ','yo':'よ',
'ra':'ら','ri':'り','ru':'る','re':'れ','ro':'ろ',
'wa':'わ','(w)o':'を',
'n':'ん',
//dakuten
'ga':'が','gi':'ぎ','gu':'ぐ','ge':'げ','go':'ご',
'za':'ざ','ji':'じ','zu':'ず','ze':'ぜ','zo':'ぞ',
'da':'だ','(ji)':'(ぢ)','(zu)':'(づ)','de':'で','do':'ど',
'ba':'ば','bi':'び','bu':'ぶ','be':'べ','bo':'ぼ',
'pa':'ぱ','pi':'ぴ','pu':'ぷ','pe':'ぺ','po':'ぽ',
//combo
'kya':'きゃ','kyu':'きゅ','kyo':'きょ',
'sha':'しゃ','shu':'しゅ','sho':'しょ',
'cha':'ちゃ','chu':'ちゅ','cho':'ちょ',
'nya':'にゃ','nyu':'にゅ','nyo':'にょ',
'hya':'ひゃ','hyu':'ひゅ','hyo':'ひょ',
'mya':'みゃ','myu':'みゅ','myo':'みょ',
'rya':'りゃ','ryu':'りゅ','ryo':'りょ',
'gya':'ぎゃ','gyu':'ぎゅ','gyo':'ぎょ',
'ja':'じゃ','ju':'じゅ','jo':'じょ',
'bya':'びゃ','byu':'びゅ','byo':'びょ',
'pya':'ぴゃ','pyu':'ぴゅ','pyo':'ぴょ'
].entrySet().toList()
def katakana = [
//kana
'a':'ア','i':'イ','u':'ウ','e':'エ','o':'オ',
'ka':'カ','ki':'キ','ku':'ク','ke':'ケ','ko':'コ',
'sa':'サ','shi':'シ','su':'ス','se':'セ','so':'ソ',
'ta':'タ','chi':'チ','tsu':'ツ','te':'テ','to':'ト',
'na':'ナ','ni':'ニ','nu':'ヌ','ne':'ネ','no':'ノ',
'ha':'ハ','hi':'ヒ','fu':'フ','he':'ヘ','ho':'ホ',
'ma':'マ','mi':'ミ','mu':'ム','me':'メ','mo':'モ',
'ya':'ヤ','yu':'ユ','yo':'ヨ',
'ra':'ラ','ri':'リ','ru':'ル','re':'レ','ro':'ロ',
'wa':'ワ','(w)o':'ヲ',
'n':'ン',
//dakuten
'ga':'ガ','gi':'ギ','gu':'グ','ge':'ゲ','go':'ゴ',
'za':'ザ','ji':'ジ','zu':'ズ','ze':'ゼ','zo':'ゾ',
'da':'ダ','(ji)':'(ヂ)','(zu)':'(ヅ)','de':'デ','do':'ド',
'ba':'バ','bi':'ビ','bu':'ブ','be':'ベ','bo':'ボ',
'pa':'パ','pi':'ピ','pu':'プ','pe':'ペ','po':'ポ',
//combo
'kya':'キャ','kyu':'キュ','kyo':'キョ',
'sha':'シャ','shu':'シュ','sho':'ショ',
'cha':'チャ','chu':'チュ','cho':'チョ',
'nya':'ニャ','nyu':'ニュ','nyo':'ニョ',
'hya':'ヒャ','hyu':'ヒュ','hyo':'ヒョ',
'mya':'ミャ','myu':'ミュ','myo':'ミョ',
'rya':'リャ','ryu':'リュ','ryo':'リョ',
'gya':'ギャ','gyu':'ギュ','gyo':'ギョ',
'ja':'ジャ','ju':'ジュ','jo':'ジョ',
'bya':'ビャ','byu':'ビュ','byo':'ビョ',
'pya':'ピャ','pyu':'ピュ','pyo':'ピョ'
].entrySet().toList()
def n = args[0] as Integer
def rnd = new Random()
if ("rev" in args) {
def kana = hiragana + katakana
def N = kana.size()
def res = (1..n).collect { kana[rnd.nextInt(N)] }
Collections.shuffle(res, rnd)
res.eachWithIndex { it, index ->
print "${it.value}, "
if (index % 12 == 11) println ""
}
println "\n\n\n"
res.eachWithIndex { it, index ->
print "${it.key}, "
if (index % 12 == 11) println ""
}
} else {
def N = hiragana.size()
def res = (1..n).collect { rnd.nextInt(N) }
Collections.shuffle(res, rnd)
res.eachWithIndex { it, index ->
print "${hiragana[it].key}, "
if (index % 12 == 11) println ""
}
println "\n\n\n"
res.eachWithIndex { it, index ->
print "${hiragana[it].value} (${katakana[it].value}), "
if (index % 12 == 11) println ""
}
}
println ""
@gkastrinis
Copy link
Author

groovy japrand.groovy 100

groovy japrand.groovy 100 rev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment