feat: make more test case

This commit is contained in:
qwreey 2026-06-06 15:28:03 +00:00
parent 88de1e82a9
commit abe04dda7c
No known key found for this signature in database

View file

@ -23,14 +23,20 @@ export function processUnsounds(input: string): string {
// 아!아!아!아!아!
// 흐으..흐아아..헤...하아..
// 이런 것들을 단일 단어로 치환합니다. 하지만
// untested
// 혀어어어어어어어엉........ 핫. 혀엉..... 흑... 하앗... 흐윽... 형. 하앙.
// 혀엉.... 하앙... 흐윽... 항. 항. 형... 하앙. 흐으윽... 형... 흡... 혀엉..
// 하아아앗. 혀엉.. 흡... 흐읍... 형.. 하앗. 하아앙... 형... 하앙... 흐윽...
// 혀어어엉.. 하앙. 항. 형... 하앙. 혀엉.... 하앙. 흑... 항. 형... 흡 하앗.
// 혀엉..... 흑. 흣
export function processCensor(input: string): string {
return input
.replace(
/([흐하해헤][아으앙응앗웅응ㅡ!?.,><]+)/g,
/([흐하해헤혀형][아으앙응앗웅응ㅡ!?.,><~'"/]+)/g,
(content: string) => content[0] ?? "",
)
.replace(
/[아ㅏ어ㅓ으ㅡ우ㅜ에오ㅗ야ㅑ앙읏웃앗엣웅응흐해헤헼헥하あアうおーaAoOuU][아ㅏ어ㅓ으ㅡ우ㅜ에오ㅗ야ㅑ앙읏웃앗엣웅응흐해헤헼헥하あアうおーaAoOuU!.,><]{2,}/g,
/[아ㅏ어ㅓ으ㅡ우ㅜ에오ㅗ야ㅑ앙읏웃앗엣웅응흐해헤헼헥하형혀흡흑あアうおーaAoOuU][아ㅏ어ㅓ으ㅡ우ㅜ에오ㅗ야ㅑ앙읏웃앗엣웅응흐해헤헼헥하형혀흡흑あアうおーaAoOuU!.,><~'"/]{2,}/g,
(content: string) => content.substring(0, 3),
);
}
@ -43,12 +49,9 @@ export function processKorean(input: string): string {
i
.replace(processKorean.DoubleMixedChoseongMapRegex, (content: string) => {
// ㅇㅋ => 오키, ㅇㄴ => 아니, ...
const key = content.substring(
0,
2,
) as keyof typeof processKorean.DoubleMixedChoseongMap;
const length = Math.min(Math.floor(content.length / 2), 2);
return processKorean.DoubleMixedChoseongMap[key].repeat(length);
return processKorean.DoubleMixedChoseongMap[
content as keyof typeof processKorean.DoubleMixedChoseongMap
];
})
.replace(processKorean.RepeatedChoseongMapRegex, (content: string) => {
// process ㄴㄴ ㄱㄱ ㅋㅋ ㄷㄷ, ...
@ -111,7 +114,7 @@ export namespace processKorean {
};
export const DoubleMixedChoseongMapRegex = new RegExp(
Object.keys(DoubleMixedChoseongMap)
.map((k) => `(?:${k})+`)
.map((k) => `(?:${k})`)
.join("|"),
"g",
);