bareun-mal 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/engine.js +26 -11
- package/src/generated/expanded-dict.json +3 -1
package/package.json
CHANGED
package/src/engine.js
CHANGED
|
@@ -21,6 +21,8 @@ const BUILTIN_ENGLISH_CORE = [
|
|
|
21
21
|
'porn', 'hentai', 'rape', 'rapist', 'pedophile', 'nazi', 'cumshot'
|
|
22
22
|
];
|
|
23
23
|
|
|
24
|
+
const MIDDLE_FINGER_PATTERN = /(?:^|[\s"'`.,!?~@#$%^&*()[\]{}<>/\\|_-])ㅗ+(?:$|[\s"'`.,!?~@#$%^&*()[\]{}<>/\\|_-])/;
|
|
25
|
+
|
|
24
26
|
const DIRECT_BYPASS_PATTERNS = [
|
|
25
27
|
{ category: 'profanity', root: '뻐큐(기호)', pattern: /🖕|凸/ },
|
|
26
28
|
{ category: 'hate', root: '나치(심볼)', pattern: /卐|卍/ },
|
|
@@ -32,7 +34,8 @@ const DIRECT_BYPASS_PATTERNS = [
|
|
|
32
34
|
{ category: 'profanity', root: '반초성-지랄', pattern: /(?:^|[^가-힣])지(?:ㄹr|랄)|ㅈ랄/i },
|
|
33
35
|
{ category: 'slang', root: '반초성-닥쳐', pattern: /(?:^|[^가-힣])ㄷ(?:r|ㅏ)쳐/i },
|
|
34
36
|
{ category: 'profanity', root: '느그마(변형)', pattern: /느(?:그|rm|ㄱㅡ)마/i },
|
|
35
|
-
{ category: 'profanity', root: '애미(패드립)', pattern: /(?:^|[^가-힣])애(?:미|ㅁㅣ)(?:$|[^가-힣])/ }
|
|
37
|
+
{ category: 'profanity', root: '애미(패드립)', pattern: /(?:^|[^가-힣])애(?:미|ㅁㅣ)(?:$|[^가-힣])/ },
|
|
38
|
+
{ category: 'profanity', root: '시발점-욕설악용', pattern: /(?:야이|이|저|그|개|씹)\s*시발점|시발점\s*(?:년|놈|새끼|새키|련)/ }
|
|
36
39
|
];
|
|
37
40
|
|
|
38
41
|
const STANDALONE_REVERSED_WORDS = new Map([
|
|
@@ -81,7 +84,10 @@ const EXTRA_SAFE_EXCEPTIONS = [
|
|
|
81
84
|
'병신년',
|
|
82
85
|
'8등신',
|
|
83
86
|
'출발기차',
|
|
84
|
-
'지랄탄'
|
|
87
|
+
'지랄탄',
|
|
88
|
+
'새끼개',
|
|
89
|
+
'다음부터',
|
|
90
|
+
'다음부턴'
|
|
85
91
|
];
|
|
86
92
|
|
|
87
93
|
function createTrie() {
|
|
@@ -202,10 +208,16 @@ function maskExceptions(text, exceptionEntries) {
|
|
|
202
208
|
for (const entry of exceptionEntries) {
|
|
203
209
|
if (!entry.clean) continue;
|
|
204
210
|
if (!compactAlnum.includes(entry.clean) && !compactAlphaHangul.includes(entry.clean)) continue;
|
|
205
|
-
masked = masked.replace(entry.regex, (match) => {
|
|
211
|
+
masked = masked.replace(entry.regex, (match, offset, fullStr) => {
|
|
212
|
+
if (entry.clean === '시발점') {
|
|
213
|
+
const before = fullStr.slice(Math.max(0, offset - 6), offset);
|
|
214
|
+
const after = fullStr.slice(offset + match.length);
|
|
215
|
+
if (/(?:야이|이|저|그|개|씹)\s*$/.test(before) || /^\s*(?:년|놈|새끼|새키|련|아|야)/.test(after)) {
|
|
216
|
+
return match;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
206
219
|
if (/새끼$/.test(entry.clean)) {
|
|
207
|
-
const
|
|
208
|
-
const after = masked.slice(idx + match.length);
|
|
220
|
+
const after = fullStr.slice(offset + match.length);
|
|
209
221
|
if (/^\s*(같은|놈|년|야|아|들)/.test(after)) {
|
|
210
222
|
return match.replace(/새끼$/, ' 새끼');
|
|
211
223
|
}
|
|
@@ -239,6 +251,10 @@ function evaluateText(rawText, index, enabledCategories) {
|
|
|
239
251
|
});
|
|
240
252
|
};
|
|
241
253
|
|
|
254
|
+
if (MIDDLE_FINGER_PATTERN.test(rawStr) || MIDDLE_FINGER_PATTERN.test(safeText)) {
|
|
255
|
+
recordHit('profanity', '뻐큐(기호)', 'bypass', 1.0);
|
|
256
|
+
}
|
|
257
|
+
|
|
242
258
|
const trimmedRaw = rawStr.trim();
|
|
243
259
|
const revHit = STANDALONE_REVERSED_WORDS.get(trimmedRaw);
|
|
244
260
|
if (revHit) {
|
|
@@ -278,10 +294,9 @@ function evaluateText(rawText, index, enabledCategories) {
|
|
|
278
294
|
});
|
|
279
295
|
}
|
|
280
296
|
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
views.enTokens.every((t) => index.englishSet.has(t) || /^[a-z]{2,}$/.test(t));
|
|
297
|
+
const hasHangul = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(safeText);
|
|
298
|
+
const hasEnglishWords = /[a-zA-Z]{2,}/.test(safeText);
|
|
299
|
+
const isLatinOrLogText = !hasHangul && hasEnglishWords;
|
|
285
300
|
|
|
286
301
|
searchTrie(index.koreanJamoTrie, views.jamo, (item) => {
|
|
287
302
|
recordHit(item.category, item.root, 'jamo', 0.95);
|
|
@@ -291,7 +306,7 @@ function evaluateText(rawText, index, enabledCategories) {
|
|
|
291
306
|
recordHit(item.category, item.root, 'jamo', 0.95);
|
|
292
307
|
});
|
|
293
308
|
}
|
|
294
|
-
if (!
|
|
309
|
+
if (!isLatinOrLogText && views.qwertyJamo) {
|
|
295
310
|
searchTrie(index.koreanJamoTrie, views.qwertyJamo, (item) => {
|
|
296
311
|
recordHit(item.category, item.root, 'qwerty', 0.9);
|
|
297
312
|
});
|
|
@@ -302,7 +317,7 @@ function evaluateText(rawText, index, enabledCategories) {
|
|
|
302
317
|
recordHit(item.category, item.root, 'chosung', 0.88);
|
|
303
318
|
});
|
|
304
319
|
}
|
|
305
|
-
if (!
|
|
320
|
+
if (!isLatinOrLogText && views.qwertyConsonants) {
|
|
306
321
|
searchTrie(index.koreanChosungTrie, views.qwertyConsonants, (item) => {
|
|
307
322
|
recordHit(item.category, item.root, 'qwerty-chosung', 0.85);
|
|
308
323
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"sexual": 39658,
|
|
7
7
|
"hate": 37487,
|
|
8
8
|
"english": 2828,
|
|
9
|
-
"exceptions":
|
|
9
|
+
"exceptions": 155
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dictionary": {
|
|
@@ -680795,6 +680795,8 @@
|
|
|
680795
680795
|
"신병교육대",
|
|
680796
680796
|
"발시려",
|
|
680797
680797
|
"나존재",
|
|
680798
|
+
"다음부터",
|
|
680799
|
+
"다음부턴",
|
|
680798
680800
|
"class",
|
|
680799
680801
|
"pass",
|
|
680800
680802
|
"grass",
|