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 (에이커 인치 피트 야드)
|
// 핵토파스칼, 바, 핵타르 AU (에이커 인치 피트 야드)
|
||||||
|
|
||||||
// Process korean letter, choseong shortens
|
// Process korean letter, choseong shortens
|
||||||
export function processKorean(input: string): string {
|
export function processKorean(input: string): string {
|
||||||
input = input.replace(/[아ㅏ어ㅓ]{3,}/g, (content: string) =>
|
|
||||||
content.substring(0, 3),
|
|
||||||
);
|
|
||||||
|
|
||||||
return input.replace(/[ㄱ-ㅎㄲㄸㅃㅆㅉ]+/g, (i) =>
|
return input.replace(/[ㄱ-ㅎㄲㄸㅃㅆㅉ]+/g, (i) =>
|
||||||
i
|
i
|
||||||
.replace(processKorean.DoubleMixedChoseongMapRegex, (content: string) => {
|
.replace(processKorean.DoubleMixedChoseongMapRegex, (content: string) => {
|
||||||
|
|
@ -59,9 +67,14 @@ export function processKorean(input: string): string {
|
||||||
}
|
}
|
||||||
export namespace processKorean {
|
export namespace processKorean {
|
||||||
export const DoubleMixedChoseongMap = {
|
export const DoubleMixedChoseongMap = {
|
||||||
|
ㅈㅇㅅㄹㅎㅅㅇ: "좋은사랑하세요",
|
||||||
|
ㅇㅃㅅㄹㅎㅅㅇ: "이쁜사랑하세요",
|
||||||
|
ㅈㅇㅅㅀㅅㅇ: "좋은사랑하세요",
|
||||||
|
ㅇㅃㅅㅀㅅㅇ: "이쁜사랑하세요",
|
||||||
ㅇㅃㅅㄹ: "이쁜사랑",
|
ㅇㅃㅅㄹ: "이쁜사랑",
|
||||||
ㅇㅈㄹ: "이지랄",
|
ㅇㅈㄹ: "이지랄",
|
||||||
ㅈㄹㄴ: "지랄노",
|
ㅈㄹㄴ: "지랄노",
|
||||||
|
ㅁㅇ: "모야",
|
||||||
ㅎㅇ: "하이",
|
ㅎㅇ: "하이",
|
||||||
ㅅㄹ: "싫어",
|
ㅅㄹ: "싫어",
|
||||||
ㄱㄷ: "기달",
|
ㄱㄷ: "기달",
|
||||||
|
|
@ -500,7 +513,8 @@ export namespace processSymbol {
|
||||||
// Process isolated symbols
|
// Process isolated symbols
|
||||||
export function processIsolatedSymbol(input: string): string {
|
export function processIsolatedSymbol(input: string): string {
|
||||||
return input
|
return input
|
||||||
.replace(/^[?!'"]+ $/, (total) =>
|
.replace(/^ * (\?+) *$/, "어?")
|
||||||
|
.replace(/^ *[?!'"]+ *$/, (total) =>
|
||||||
[...total]
|
[...total]
|
||||||
.map(
|
.map(
|
||||||
(element) =>
|
(element) =>
|
||||||
|
|
@ -541,14 +555,15 @@ export namespace processFullWidth {
|
||||||
|
|
||||||
export function saferKorean(input: string): string {
|
export function saferKorean(input: string): string {
|
||||||
return (input.normalize() + " ")
|
return (input.normalize() + " ")
|
||||||
.let((i) => processUnsounds(i))
|
.let(processUnsounds)
|
||||||
.let((i) => processFullWidth(i))
|
.let(processFullWidth)
|
||||||
.let((i) => processIsolatedSymbol(i))
|
.let(processIsolatedSymbol)
|
||||||
.let((i) => processMarkdown(i))
|
.let(processMarkdown)
|
||||||
.let((i) => processKorean(i))
|
.let(processCensor)
|
||||||
.let((i) => processNumber(i))
|
.let(processKorean)
|
||||||
.let((i) => processSymbol(i))
|
.let(processNumber)
|
||||||
.let((i) => processEmoji(i))
|
.let(processSymbol)
|
||||||
|
.let(processEmoji)
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue