-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathindex.ts
More file actions
370 lines (333 loc) · 11.1 KB
/
index.ts
File metadata and controls
370 lines (333 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// 使用 i18n-ally 扩展查看对应的中文翻译
// 有些情况下无法判断具体的性别命名空间,只能使用 `(x|f):` 的格式来限定范围
// 概率标签的标准:有A标签的本子中,只有 10% 的本子没有 B 标签
// 「`A标签 -B标签` 的搜索结果数」<「`A标签` 的搜索结果数」的 10%
// `A标签 -B标签` 的搜索结果里也一堆漏标B标签的除外
// 有没有必要加上复杂规则呢?
// - 组合标签
// - 单扶她 + 单女主 = 大概率「扶上女」
// - 根据条件将「大概率」限定为「必须」
// - 单萝莉 + 贫乳 + (单女主) = 肯定无法共存
// - 把画廊类型也加进标签,方便过滤 CG 集等图库
// (虽说现在的 possibleConflict 已经这么过滤了
const rules = {
// 存在第二个标签时,必须同时存在第一个标签
// 主要是各种前置标签
prerequisite: {
// 乱伦
'(x|f):incest': [
'f:cousin',
'f:aunt',
'f:daughter',
'f:mother',
'f:granddaughter',
'f:sister',
'f:grandmother',
'f:niece',
],
'(x|m):incest': ['m:cousin'],
'f:incest': ['f:inseki', 'f:low_incest'],
'm:incest': ['m:inseki', 'm:low_incest'],
'x:incest': ['x:inseki', 'x:low_incest'],
// 女性乱交
'f:group': [
'f:fff_threesome',
'f:ttt_threesome',
'f:fft_threesome',
'f:ttf_threesome',
],
// 男性乱交
'm:group': ['m:mmm_threesome'],
// 混合性别的乱交
'x:group': [
'x:mmf_threesome',
'x:mmt_threesome',
'x:ttm_threesome',
'x:ffm_threesome',
'x:mtf_threesome',
'x:oyakodon',
'x:shimaidon',
'x:gang_rape',
],
// 无法限定性别的乱交
'(x|f):group': [
'f:oyakodon',
'f:shimaidon',
'f:multiple_straddling',
'f:gang_rape',
'f:layer_cake',
'f:harem',
],
'(x|m):group': [
'm:oyakodon',
'm:shimaidon',
'm:multiple_straddling',
'm:gang_rape',
'm:layer_cake',
'm:harem',
],
'f:yuri': ['f:fff_threesome'],
'm:yaoi': ['m:group', 'm:mmm_threesome'],
'f:futanari': [
'f:ttt_threesome',
'f:fft_threesome',
'f:ttf_threesome',
'f:full-packaged_futanari',
'f:futanarization',
],
'f:shemale': ['f:ball-less_shemale'],
'f:lolicon': [
'f:kodomo_doushi',
'x:kodomo_doushi',
'f:oppai_loli',
'f:mesugaki',
'f:low_lolicon',
],
'm:shotacon': ['m:kodomo_doushi', 'x:kodomo_doushi'],
'f:blowjob': [
'f:multimouth_blowjob',
'f:blowjob_face',
'f:deepthroat',
'f:focus_blowjob',
],
'm:blowjob': [
'm:multimouth_blowjob',
'm:blowjob_face',
'm:deepthroat',
'm:focus_blowjob',
],
'f:handjob': ['f:multiple_handjob'],
'm:handjob': ['m:multiple_handjob'],
'f:assjob': ['f:multiple_assjob'],
'm:assjob': ['m:multiple_assjob'],
'f:footjob': ['f:multiple_footjob'],
'm:footjob': ['m:multiple_footjob'],
'f:paizuri': ['f:focus_paizuri'],
'm:paizuri': ['m:focus_paizuri'],
'f:rimjob': ['f:focus_rimjob'],
'm:rimjob': ['m:focus_rimjob'],
'f:cunnilingus': ['f:focus_cunnilingus'], // 不知道为啥没有 m:focus_cunnilingus 标签
'f:anal': [
'f:focus_anal',
'f:anal_intercourse',
'f:tail_plug',
'f:butt_plug',
],
'm:anal': [
'm:focus_anal',
'm:anal_intercourse',
'm:tail_plug',
'm:butt_plug',
],
'f:rape': ['f:gang_rape'],
'm:rape': ['m:gang_rape'],
'(f|m):corpse': ['f:necrophilia', 'm:necrophilia'],
'(f|m):masturbation': ['f:phone_sex', 'm:phone_sex'],
'f:bondage': ['f:fanny_packing', 'f:shibari', 'f:straitjacket'],
'm:bondage': ['m:fanny_packing', 'm:shibari', 'm:straitjacket'],
'f:inflation': ['f:cumflation'],
'm:inflation': ['m:cumflation'],
'f:lactation': ['f:milking'],
'm:lactation': ['m:milking'],
'f:piercing': ['f:nipple_piercing', 'f:genital_piercing'],
'm:piercing': ['m:nipple_piercing', 'm:genital_piercing'],
'f:big_breasts': ['f:huge_breasts', 'f:gigantic_breasts'],
'f:huge_breasts': ['f:gigantic_breasts'],
'f:sex_toys': ['f:tail_plug', 'f:butt_plug', 'f:unusual_insertions'],
'm:sex_toys': ['m:tail_plug', 'm:butt_plug', 'm:unusual_insertions'],
'f:swimsuit': ['f:bikini'],
'm:swimsuit': ['m:bikini'],
'f:crossdressing': ['f:schoolboy_uniform'],
'f:bandages': ['f:sarashi'],
'f:monster_girl': ['f:zombie', 'f:skeleton'],
'f:tail': ['f:multiple_tails'],
'(f|m):robot': ['f:dismantling', 'm:dismantling'],
},
// 存在第一个标签时,就不应该存在其他标签
conflict: {
// 纯女性
'f:females_only': [
'f:futanari',
'f:bisexual',
'f:ttt_threesome',
'f:fft_threesome',
'f:ttf_threesome',
'x:mmf_threesome',
'x:mmt_threesome',
'x:ttm_threesome',
'x:mtf_threesome',
'x:group',
'm:*',
'x:*',
],
// 单女主
'f:sole_female': [
'f:ttt_threesome',
'f:fft_threesome',
'x:mmt_threesome',
'x:ttm_threesome',
'm:mmm_threesome',
],
// 单扶她
'f:sole_dickgirl': [
'f:fff_threesome',
'f:ttt_threesome',
'f:ttf_threesome',
'x:mmf_threesome',
'x:ttm_threesome',
'm:mmm_threesome',
],
},
// 存在第一个标签时,「大概率」不可能存在第二个标签
// 主要是各种容易搞混的,以为应该共存实际上是二选一的标签
// 只不过因为可能同时存在多个角色,所以只能是「大概率」
possibleConflict: {
'f:dark_skin': ['f:tanlines'],
'm:dark_skin': ['m:tanlines'],
'f:lolicon': ['f:small_breasts'],
'f:breast_feeding': ['f:nipple_stimulation'],
},
// 存在第一个标签时,「大概率」可能存在第二个标签
// 如果第二个标签含有前置标签,则应该省略,以便减少标签数增加可读性
combo: {
'f:horse_girl': ['f:kemonomimi', 'f:tail'],
'f:dog_girl': ['f:kemonomimi'],
'f:mouse_girl': ['f:kemonomimi'],
'f:bunny_girl': ['f:kemonomimi', 'f:leotard'],
'f:catgirl': ['f:kemonomimi'],
'f:cowgirl': ['f:kemonomimi'],
'f:oni': ['f:horns'],
// 作品
'p:uma_musume_pretty_derby': ['f:horse_girl'],
'p:blue_archive': ['f:halo'],
'p:zombie_land_saga': ['f:zombie'],
// 角色
// LL
'c:ayumu_uehara': ['f:hair_buns'],
'c:yu_takasaki': ['f:twintails'],
'c:rurino_osawa': ['f:twintails'],
'c:sayaka_murano': ['f:twintails'],
'c:hime_anyoji': ['f:ponytail'],
'c:nico_yazawa': ['f:twintails'],
'c:eli_ayase': ['f:ponytail'],
'c:nozomi_tojo': ['f:twintails'],
'c:honoka_kosaka': ['f:ponytail'],
'c:ruby_kurosawa': ['f:twintails'],
'c:yoshiko_tsushima': ['f:hair_buns'],
'c:kanan_matsuura': ['f:ponytail'],
'c:ria_kazuno': ['f:twintails'],
'c:seira_kazuno': ['f:ponytail'],
'c:chisato_arashi': ['f:hair_buns'],
'c:ren_hazuki': ['f:ponytail'],
// bang dream
'c:arisa_ichigaya': ['f:twintails'],
'c:saaya_yamabuki': ['f:ponytail'],
'c:himari_uehara': ['f:twintails'],
'c:ako_udagawa': ['f:twintails'],
'c:reona_nyubara': ['f:twintails'],
'c:tsukushi_futaba': ['f:twintails'],
// 孤独摇滚
'c:hitori_gotou': ['f:very_long_hair'],
'c:nijika_ijichi': ['f:ponytail', 'f:very_long_hair'],
// 方舟
'c:amiya': ['f:kemonomimi'],
'c:rosmontis': ['f:kemonomimi'],
'c:suzuran': ['f:lolicon', 'f:kemonomimi', 'f:tail', 'f:multiple_tails'],
'c:shamare': ['f:lolicon', 'f:kemonomimi'],
'c:schwarz': ['f:kemonomimi', 'f:ponytail', 'f:tail'],
'c:ceylon': ['f:hair_buns'],
// other
'c:remilia_scarlet': ['f:wings', 'f:vampire'],
'c:flandre_scarlet': ['f:wings', 'f:vampire'],
'c:koakuma': ['f:wings', 'f:demon_girl'],
'c:yuko_yoshida': ['f:horns', 'f:tail', 'f:demon_girl'],
'c:suletta_mercury': ['f:thick_eyebrows'],
'c:junna_hoshimi': ['f:glasses'],
'c:euphyllia_magenta': ['f:very_long_hair'],
'c:misuzu_hataya': ['f:beauty_mark'],
'c:kotone_fujita': ['f:twintails'],
'c:mizuki_akiyama': ['m:crossdressing'],
'c:nagisa_kirifuji': ['f:angel', 'f:halo', 'f:very_long_hair', 'f:wings'],
'c:mika_misono': ['f:angel', 'f:halo', 'f:very_long_hair', 'f:wings'],
'c:kanade_yoisaki': ['f:very_long_hair'],
'c:mafuyu_asahina': ['f:ponytail'],
},
};
export const getTagLintRules = () => {
const shortNamespace = new Map<RegExp, string>(
(
[
['p', 'parody'],
['c', 'character'],
['g', 'group'],
['a', 'artist'],
['m', 'male'],
['f', 'female'],
['x', 'mixed'],
['o', 'other'],
] as [string, string][]
).map(([short, full]) => [new RegExp(`\\b${short}\\b(?=.*:)`), full]),
);
// 将缩写的命名空间转回全拼
const getTagName = (tag: string) => {
let fullTag = tag;
for (const re of shortNamespace.keys())
if (re.test(fullTag)) {
fullTag = fullTag.replace(re, shortNamespace.get(re)!);
}
return fullTag;
};
const createRuleMap = (map: Record<string, string[]>, reverse = false) => {
const ruleMap = new Map<string, Set<string>>();
if (reverse)
for (let [targetTag, tags] of Object.entries(map)) {
targetTag = getTagName(targetTag);
for (let tag of tags) {
tag = getTagName(tag);
if (ruleMap.has(tag)) ruleMap.get(tag)!.add(targetTag);
else ruleMap.set(tag, new Set([targetTag]));
}
}
else
for (const [tag, targetTag] of Object.entries(map))
ruleMap.set(getTagName(tag), new Set(targetTag.map(getTagName)));
return ruleMap;
};
return {
prerequisite: createRuleMap(rules.prerequisite, true),
conflict: createRuleMap(rules.conflict),
possibleConflict: createRuleMap(rules.possibleConflict),
// 写的时候为了可以根据不同作品分类而没有反转
// 但为了减少代码,在打包时反转了下,所以在用时得再反转回去
combo: createRuleMap(rules.combo, true),
};
};
/** 拆分多个命名空间的标签 */
export const splitTagNamespace = (tag: string) => {
if (!tag.startsWith('(')) return [tag];
const [, namespaces, tagName] = /\((.+?)\)(.+)/.exec(tag)!;
return namespaces.split('|').map((namespace) => `${namespace}${tagName}`);
};
/** 判断是否缺少指定命名空间下的标签 */
export const isMissingNamespace = (
tagList: Set<string>,
...namespaces: string[]
) => {
for (const namespace of namespaces)
for (const tag of tagList) if (tag.startsWith(namespace)) return false;
return true;
};
/** 检查标签是否存在 */
export const hasTag = (tagList: Set<string>, tagName: string) => {
if (tagName.startsWith('('))
for (const tag of splitTagNamespace(tagName))
if (tagList.has(tag)) return true;
if (tagName.endsWith(':*'))
return !isMissingNamespace(tagList, tagName.split(':*')[0]);
return tagList.has(tagName);
};
/** 判断是否缺少指定标签 */
export const isMissingTags = (tagList: Set<string>, ...tags: string[]) => {
for (const tag of tags) if (tagList.has(tag)) return false;
return true;
};