Add more censorship to prevent making strange sounds
This commit is contained in:
parent
dae830ba6a
commit
aa8aa9ada2
1 changed files with 28 additions and 13 deletions
|
|
@ -16,14 +16,22 @@ export function processUnsounds(input: string): string {
|
|||
);
|
||||
}
|
||||
|
||||
export function processCensor(input: string): string {
|
||||
return input
|
||||
.replace(
|
||||
/(흐[아으앙응앗웅응ㅡ]+[!?.,><]*)|(하[아으앙응앗웅응ㅡ]+[!?.,><]*)/g,
|
||||
(content: string) => content[0] ?? "",
|
||||
)
|
||||
.replace(
|
||||
/[아ㅏ어ㅓ으ㅡ우ㅜ에오ㅗ야ㅑ앙읏웃앗엣웅응흐헤헼헥하あアうおーaAoOuU][아ㅏ어ㅓ으ㅡ우ㅜ에오ㅗ야ㅑ앙읏웃앗엣웅응흐헤헼헥하あアうおーaAoOuU!.,><]{2,}/g,
|
||||
(content: string) => content.substring(0, 3),
|
||||
);
|
||||
}
|
||||
|
||||
// 핵토파스칼, 바, 핵타르 AU (에이커 인치 피트 야드)
|
||||
|
||||
// Process korean letter, choseong shortens
|
||||
export function processKorean(input: string): string {
|
||||
input = input.replace(/[아ㅏ어ㅓ]{3,}/g, (content: string) =>
|
||||
content.substring(0, 3),
|
||||
);
|
||||
|
||||
return input.replace(/[ㄱ-ㅎㄲㄸㅃㅆㅉ]+/g, (i) =>
|
||||
i
|
||||
.replace(processKorean.DoubleMixedChoseongMapRegex, (content: string) => {
|
||||
|
|
@ -59,9 +67,14 @@ export function processKorean(input: string): string {
|
|||
}
|
||||
export namespace processKorean {
|
||||
export const DoubleMixedChoseongMap = {
|
||||
ㅈㅇㅅㄹㅎㅅㅇ: "좋은사랑하세요",
|
||||
ㅇㅃㅅㄹㅎㅅㅇ: "이쁜사랑하세요",
|
||||
ㅈㅇㅅㅀㅅㅇ: "좋은사랑하세요",
|
||||
ㅇㅃㅅㅀㅅㅇ: "이쁜사랑하세요",
|
||||
ㅇㅃㅅㄹ: "이쁜사랑",
|
||||
ㅇㅈㄹ: "이지랄",
|
||||
ㅈㄹㄴ: "지랄노",
|
||||
ㅁㅇ: "모야",
|
||||
ㅎㅇ: "하이",
|
||||
ㅅㄹ: "싫어",
|
||||
ㄱㄷ: "기달",
|
||||
|
|
@ -500,7 +513,8 @@ export namespace processSymbol {
|
|||
// Process isolated symbols
|
||||
export function processIsolatedSymbol(input: string): string {
|
||||
return input
|
||||
.replace(/^[?!'"]+ $/, (total) =>
|
||||
.replace(/^ * (\?+) *$/, "어?")
|
||||
.replace(/^ *[?!'"]+ *$/, (total) =>
|
||||
[...total]
|
||||
.map(
|
||||
(element) =>
|
||||
|
|
@ -541,14 +555,15 @@ export namespace processFullWidth {
|
|||
|
||||
export function saferKorean(input: string): string {
|
||||
return (input.normalize() + " ")
|
||||
.let((i) => processUnsounds(i))
|
||||
.let((i) => processFullWidth(i))
|
||||
.let((i) => processIsolatedSymbol(i))
|
||||
.let((i) => processMarkdown(i))
|
||||
.let((i) => processKorean(i))
|
||||
.let((i) => processNumber(i))
|
||||
.let((i) => processSymbol(i))
|
||||
.let((i) => processEmoji(i))
|
||||
.let(processUnsounds)
|
||||
.let(processFullWidth)
|
||||
.let(processIsolatedSymbol)
|
||||
.let(processMarkdown)
|
||||
.let(processCensor)
|
||||
.let(processKorean)
|
||||
.let(processNumber)
|
||||
.let(processSymbol)
|
||||
.let(processEmoji)
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue