use std::ops::RangeInclusive;
pub const KANA: &[char; 92] = &[
'あ', 'い', 'う', 'え', 'お',
'か', 'き', 'く', 'け', 'こ',
'さ', 'し', 'す', 'せ', 'そ',
'た', 'ち', 'つ', 'て', 'と',
'な', 'に', 'ぬ', 'ね', 'の',
'は', 'ひ', 'ふ', 'へ', 'ほ',
'ま', 'み', 'む', 'め', 'も',
'ら', 'り', 'る', 'れ', 'ろ',
'や', 'ゆ', 'よ', 'わ', 'ん',
'を', 'ア', 'イ', 'ウ', 'エ', 'オ',
'カ', 'キ', 'ク', 'ケ', 'コ',
'サ', 'シ', 'ス', 'セ', 'ソ',
'タ', 'チ', 'ツ', 'テ', 'ト',
'ナ', 'ニ', 'ヌ', 'ネ', 'ノ',
'ハ', 'ヒ', 'フ', 'ヘ', 'ホ',
'マ', 'ミ', 'ム', 'メ', 'モ',
'ラ', 'リ', 'ル', 'レ', 'ロ',
'ヤ', 'ユ', 'ヨ', 'ワ', 'ン',
'ヲ', ];
pub const KANA_SWAP: &[Option<char>; 92] = &[
None, None, None, None, None, Some('が'), Some('ぎ'), Some('ぐ'), Some('げ'), Some('ご'), None, None, None, None, None, Some('だ'), Some('ぢ'), Some('づ'), Some('で'), Some('ど'), None, None, None, None, None, Some('ば'), Some('び'), Some('ぶ'), Some('べ'), Some('ぼ'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, Some('ガ'), Some('ギ'), Some('グ'), Some('ゲ'), Some('ゴ'), None, None, None, None, None, Some('ダ'), Some('ヂ'), Some('ヅ'), Some('デ'), Some('ド'), None, None, None, None, None, Some('バ'), Some('ビ'), Some('ブ'), Some('ベ'), Some('ボ'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, ];
pub const KANA_SWAP2: &[Option<char>; 92] = &[
None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, Some('ぱ'), Some('ぴ'), Some('ぽ'), Some('ぺ'), Some('ぽ'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, Some('パ'), Some('ピ'), Some('プ'), Some('ペ'), Some('ポ'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, ];
pub const KANA_SIGN: &[RangeInclusive<usize>; 2] = &[
0..=45,
46..=91,
];
pub const KANA_SUB: &[char; 18] = &[
'ゃ',
'ゅ',
'ょ',
'ャ',
'ュ',
'ョ',
'っ',
'ッ',
'ぁ','ぃ','ぅ','ぇ','ぉ',
'ァ','ィ','ゥ','ェ','ォ',
];
use crate::def::Definition;
pub const KANA_SUB_VALID_FOR: &[Definition; 18] = &[ Definition::single(5..=39),
Definition::single(5..=39),
Definition::single(5..=39),
Definition::single(51..=85),
Definition::single(51..=85),
Definition::single(51..=85),
Definition::single(0..=45),
Definition::single(46..=91),
Definition::single(5..=39),
Definition::single(5..=39),
Definition::single(5..=39),
Definition::single(5..=39),
Definition::single(5..=39),
Definition::single(51..=85),
Definition::single(51..=85),
Definition::single(51..=85),
Definition::single(51..=85),
Definition::single(51..=85),
];
pub fn find_sub(kana: char) -> Option<Vec<char>>
{
for (i,x) in (0..(KANA.len())).zip(KANA.iter()) {
if *x == kana {
let mut output = Vec::with_capacity(KANA_SUB.len());
for (def,sub) in KANA_SUB_VALID_FOR.iter().zip(KANA_SUB.iter())
{
if def.contains(i) {
output.push(sub.clone());
}
}
return Some(output);
}
}
None
}
pub fn sub(i: usize) -> Option<[Option<char>; KANA_SUB.len()]>
{
if i < KANA.len() {
let mut output = [None; KANA_SUB.len()];
for (j, (def,sub)) in (0..).zip(KANA_SUB_VALID_FOR.iter().zip(KANA_SUB.iter()))
{
if def.contains(i) {
output[j] = Some(sub.clone());
}
}
Some(output)
} else {
None
}
}
pub fn sub_all(i: usize) -> Option<Vec<char>>
{
if i < KANA.len() {
let mut output = Vec::with_capacity(KANA_SUB.len());
for (def,sub) in KANA_SUB_VALID_FOR.iter().zip(KANA_SUB.iter())
{
if def.contains(i) {
output.push(sub.clone());
}
}
Some(output)
} else {
None
}
}