feat(WIP): processing, 몰수
- 초성에서 Windows 겹받침, Mac 된소리 자음(automata 초성) - 장수 선택에에서 검은색 테마 - 양 선택기에 숫자 추가
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
const convListLevel1: Record<string, Record<string, string>> = {
|
||||
'ㄱ': {
|
||||
'ㅅ': 'ㄳ',
|
||||
},
|
||||
'ㄴ': {
|
||||
'ㅈ': 'ㄵ',
|
||||
'ㅎ': 'ㄶ',
|
||||
},
|
||||
'ㄹ': {
|
||||
'ㅂ': 'ㄼ',
|
||||
'ㄱ': 'ㄺ',
|
||||
'ㅅ': 'ㄽ',
|
||||
'ㅁ': 'ㄻ',
|
||||
'ㅎ': 'ㅀ',
|
||||
'ㅌ': 'ㄾ',
|
||||
'ㅍ': 'ㄿ',
|
||||
},
|
||||
'ㅂ': {
|
||||
'ㅅ': 'ㅄ',
|
||||
},
|
||||
}
|
||||
|
||||
const convListLevel2: Record<string, Record<string, string>> = {
|
||||
'ㄱ': {
|
||||
'ㄱ': 'ㄲ',
|
||||
'ㅅ': 'ㄳ',
|
||||
},
|
||||
'ㄴ': {
|
||||
'ㅈ': 'ㄵ',
|
||||
'ㅎ': 'ㄶ',
|
||||
},
|
||||
'ㄷ': {
|
||||
'ㄷ': 'ㄸ',
|
||||
},
|
||||
'ㄹ': {
|
||||
'ㅂ': 'ㄼ',
|
||||
'ㄱ': 'ㄺ',
|
||||
'ㅅ': 'ㄽ',
|
||||
'ㅁ': 'ㄻ',
|
||||
'ㅎ': 'ㅀ',
|
||||
'ㅌ': 'ㄾ',
|
||||
'ㅍ': 'ㄿ',
|
||||
},
|
||||
'ㅂ': {
|
||||
'ㅂ': 'ㅃ',
|
||||
'ㅅ': 'ㅄ',
|
||||
},
|
||||
'ㅅ': {
|
||||
'ㅅ': 'ㅆ',
|
||||
},
|
||||
'ㅈ': {
|
||||
'ㅈ': 'ㅉ',
|
||||
}
|
||||
}
|
||||
|
||||
function automata초성(text: string, convList: Record<string, Record<string, string>>): string{
|
||||
const result: string[] = [];
|
||||
let head: undefined | string = undefined;
|
||||
for (const ch of text) {
|
||||
if (head === undefined) {
|
||||
if(!(ch in convList)){
|
||||
result.push(ch);
|
||||
continue;
|
||||
}
|
||||
head = ch;
|
||||
continue;
|
||||
}
|
||||
|
||||
const nextConv = convList[head];
|
||||
if(ch in nextConv){
|
||||
result.push(nextConv[ch]);
|
||||
head = undefined;
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(head);
|
||||
if(!(ch in convList)){
|
||||
result.push(ch);
|
||||
continue;
|
||||
}
|
||||
head = ch;
|
||||
}
|
||||
if(head !== undefined){
|
||||
result.push(head);
|
||||
}
|
||||
return result.join('');
|
||||
}
|
||||
|
||||
export function automata초성All(text: string): [string, string]{
|
||||
return [automata초성(text, convListLevel1), automata초성(text, convListLevel2)];
|
||||
}
|
||||
|
||||
export function automata초성Level1(text: string): string{
|
||||
return automata초성(text, convListLevel1);
|
||||
}
|
||||
|
||||
export function automata초성Level2(text: string): string {
|
||||
return automata초성(text, convListLevel2);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
const charList = [
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'y', 'z',
|
||||
];
|
||||
|
||||
export function randStr(len: number): string {
|
||||
const result = [];
|
||||
const charListLen = charList.length;
|
||||
let isStart = true;
|
||||
|
||||
while(len > 0){
|
||||
const randChrIdx = Math.floor(Math.random() * charListLen);
|
||||
if(isStart){
|
||||
if(randChrIdx == 0){
|
||||
continue;
|
||||
}
|
||||
isStart = false;
|
||||
}
|
||||
result.push(charList[randChrIdx]);
|
||||
len -= 1;
|
||||
}
|
||||
return result.join('');
|
||||
}
|
||||
Reference in New Issue
Block a user