@dan-uni/dan-any-plugin-detaolu 1.4.0 → 2.0.0
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/README.md +33 -14
- package/dist/index.d.mts +66 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -23
- package/.babelrc.json +0 -12
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -2738
- package/dist/index.js.LICENSE.txt +0 -9
- package/dist/index.test.d.ts +0 -1
- package/dist/index.umd.min.js +0 -41392
- package/dist/index.umd.min.js.LICENSE.txt +0 -46
- package/dist/pakku.js/index.d.ts +0 -70
- package/dist/pakku.js/similarity_stub.d.ts +0 -9
- package/dist/pakku.js/types.d.ts +0 -76
- package/rslib.config.ts +0 -27
- package/src/index.test.ts +0 -39
- package/src/index.ts +0 -72
- package/src/pakku.js/index.ts +0 -615
- package/src/pakku.js/similarity-gen.js +0 -344
- package/src/pakku.js/similarity-gen.wasm +0 -0
- package/src/pakku.js/similarity_stub.ts +0 -113
- package/src/pakku.js/types.ts +0 -203
- package/tsconfig.json +0 -106
- package/tsconfig.tsbuildinfo +0 -1
- /package/dist/{static/wasm/21072e5de5.module.wasm → 73f7e7f2dd1a4caa.wasm} +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* The buffer module from node.js, for the browser.
|
|
3
|
-
*
|
|
4
|
-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
5
|
-
* @license MIT
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/*!
|
|
9
|
-
* The buffer module from node.js, for the browser.
|
|
10
|
-
*
|
|
11
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
12
|
-
* @license MIT
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/*! *****************************************************************************
|
|
16
|
-
Copyright (C) Microsoft. All rights reserved.
|
|
17
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
18
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
19
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
|
|
21
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
22
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
23
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
24
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
25
|
-
|
|
26
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
27
|
-
and limitations under the License.
|
|
28
|
-
***************************************************************************** */
|
|
29
|
-
|
|
30
|
-
/*! LICENSE: index.min.js.LICENSE.txt */
|
|
31
|
-
|
|
32
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
33
|
-
|
|
34
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
35
|
-
|
|
36
|
-
/*! zero-fill. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @author: xmcp(代码主要逻辑来源)
|
|
40
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/core/combine_worker.ts
|
|
41
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/background/config.ts
|
|
42
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/page/options.html
|
|
43
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/page/options.ts
|
|
44
|
-
* @license: GPL-3.0
|
|
45
|
-
* 本文件内代码来源见上,经部分修改,并整合config注释
|
|
46
|
-
*/
|
package/dist/pakku.js/index.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author: xmcp(代码主要逻辑来源)
|
|
3
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/core/combine_worker.ts
|
|
4
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/background/config.ts
|
|
5
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/page/options.html
|
|
6
|
-
* @see: https://github.com/xmcp/pakku.js/blob/master/pakkujs/page/options.ts
|
|
7
|
-
* @license: GPL-3.0
|
|
8
|
-
* 本文件内代码来源见上,经部分修改,并整合config注释
|
|
9
|
-
*/
|
|
10
|
-
import type { DanmuChunk, DanmuClusterOutput, DanmuObject } from './types';
|
|
11
|
-
export declare const DEFAULT_CONFIG: {
|
|
12
|
-
/**
|
|
13
|
-
* 时间阈值:合并时间差在n秒之内的重复弹幕
|
|
14
|
-
* 超长(大概 60 秒以上?)的阈值可能会导致程序运行缓慢
|
|
15
|
-
*/
|
|
16
|
-
THRESHOLD: number;
|
|
17
|
-
/**
|
|
18
|
-
* 编辑距离合并阈值:
|
|
19
|
-
* 根据编辑距离判断不完全一致但内容相近(例如有错别字)的弹幕
|
|
20
|
-
* 能有效击杀 "你指尖跃动的电光" 和 "你之间跃动的电光" 等
|
|
21
|
-
* @example 禁用(0), 轻微(≤3), 中等(≤5), 强力(≤8)
|
|
22
|
-
*/
|
|
23
|
-
MAX_DIST: number;
|
|
24
|
-
/**
|
|
25
|
-
* 词频向量合并阈值:
|
|
26
|
-
* 根据 2-Gram 频率向量的夹角判断不完全一致但内容类似的弹幕
|
|
27
|
-
* 能有效击杀 "yeah!~" 和 "yeah!~yeah!~yeah!~yeah!~" 等
|
|
28
|
-
* @example 禁用(1000), 轻微(60%), 中等(45%), 强力(30%)
|
|
29
|
-
*/
|
|
30
|
-
MAX_COSINE: number;
|
|
31
|
-
/**
|
|
32
|
-
* 识别谐音弹幕:
|
|
33
|
-
* 将常用汉字转换为拼音再进行比较
|
|
34
|
-
* 能有效击杀 "布拉迪巴特福来" 和 "布拉迪·八德福莱" 等
|
|
35
|
-
*/
|
|
36
|
-
TRIM_PINYIN: boolean;
|
|
37
|
-
TRIM_ENDING: boolean;
|
|
38
|
-
TRIM_SPACE: boolean;
|
|
39
|
-
TRIM_WIDTH: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* 内容替换:符合这些规则的弹幕,判断是否合并前会先对内容进行替换
|
|
42
|
-
*/
|
|
43
|
-
FORCELIST: string[][];
|
|
44
|
-
/**
|
|
45
|
-
* 内容替换规则命中时:继续尝试匹配后续规则
|
|
46
|
-
*/
|
|
47
|
-
FORCELIST_CONTINUE_ON_MATCH: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* 内容替换规则命中时:即使未触发合并也使用替换后的文本
|
|
50
|
-
*/
|
|
51
|
-
FORCELIST_APPLY_SINGULAR: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* 强制忽略:符合这些规则的弹幕不会被合并,优先级高于内容替换规则
|
|
54
|
-
*/
|
|
55
|
-
WHITELIST: [string, string][];
|
|
56
|
-
/**
|
|
57
|
-
* 强制删除:符合这些规则的弹幕会直接被删除(未实现)
|
|
58
|
-
*/
|
|
59
|
-
BLACKLIST: [string, string][];
|
|
60
|
-
/**
|
|
61
|
-
* 合并不同类型的弹幕(取消勾选后,底部弹幕不会跟滚动弹幕合并到一起)
|
|
62
|
-
*/
|
|
63
|
-
CROSS_MODE: boolean;
|
|
64
|
-
PROC_TYPE7: boolean;
|
|
65
|
-
PROC_TYPE4: boolean;
|
|
66
|
-
PROC_POOL1: boolean;
|
|
67
|
-
};
|
|
68
|
-
export type Config = Partial<typeof DEFAULT_CONFIG>;
|
|
69
|
-
declare function merge(chunk: DanmuChunk<DanmuObject>, config?: Config): Promise<DanmuClusterOutput>;
|
|
70
|
-
export default merge;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Config } from '.';
|
|
2
|
-
import type { int, Stats } from './types';
|
|
3
|
-
export declare function init(wasm_module: ArrayBuffer): Promise<void>;
|
|
4
|
-
export declare function begin_chunk(config: Config): void;
|
|
5
|
-
export declare function begin_index_lock(): void;
|
|
6
|
-
export declare function detect_similarity(str: string, mode: number, index_l: int, S: Stats): null | {
|
|
7
|
-
reason: string;
|
|
8
|
-
idx_diff: int;
|
|
9
|
-
};
|
package/dist/pakku.js/types.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { UniDM } from '@dan-uni/dan-any';
|
|
2
|
-
export type int = number;
|
|
3
|
-
export type float = number;
|
|
4
|
-
export type AnyObject = {
|
|
5
|
-
[k: string]: any;
|
|
6
|
-
};
|
|
7
|
-
export interface DanmuObject {
|
|
8
|
-
time_ms: int;
|
|
9
|
-
mode: int;
|
|
10
|
-
content: string;
|
|
11
|
-
pool: int;
|
|
12
|
-
danuni_dan: UniDM;
|
|
13
|
-
}
|
|
14
|
-
export interface DanmuObjectPeer extends DanmuObject {
|
|
15
|
-
pakku: {
|
|
16
|
-
sim_reason: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export interface DanmuObjectRepresentative extends DanmuObject {
|
|
20
|
-
pakku: {
|
|
21
|
-
peers: DanmuObjectPeer[];
|
|
22
|
-
desc: string[];
|
|
23
|
-
disp_str: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface DanmuObjectDeleted extends DanmuObject {
|
|
27
|
-
pakku: {
|
|
28
|
-
deleted_reason: string;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export interface DanmuChunk<ObjectType extends DanmuObject> {
|
|
32
|
-
objs: ObjectType[];
|
|
33
|
-
}
|
|
34
|
-
export interface DanmuCluster {
|
|
35
|
-
peers: DanmuObjectPeer[];
|
|
36
|
-
desc: string[];
|
|
37
|
-
chosen_str: string;
|
|
38
|
-
}
|
|
39
|
-
export interface DanmuClusterPtr {
|
|
40
|
-
peers_ptr: [int, string][];
|
|
41
|
-
desc: string[];
|
|
42
|
-
chosen_str: string;
|
|
43
|
-
danuni_count: int;
|
|
44
|
-
danuni_dans: DanmuObject[];
|
|
45
|
-
}
|
|
46
|
-
export interface DanmuClusterOutput {
|
|
47
|
-
clusters: DanmuClusterPtr[];
|
|
48
|
-
stats: Stats;
|
|
49
|
-
deleted_chunk: DanmuObjectDeleted[];
|
|
50
|
-
}
|
|
51
|
-
export declare class Stats {
|
|
52
|
-
combined_identical: number;
|
|
53
|
-
combined_edit_distance: number;
|
|
54
|
-
combined_pinyin_distance: number;
|
|
55
|
-
combined_cosine_distance: number;
|
|
56
|
-
deleted_blacklist: number;
|
|
57
|
-
deleted_blacklist_each: {
|
|
58
|
-
[k: string]: int;
|
|
59
|
-
};
|
|
60
|
-
ignored_whitelist: number;
|
|
61
|
-
ignored_type: number;
|
|
62
|
-
num_taolu_matched: number;
|
|
63
|
-
}
|
|
64
|
-
export declare class Queue<T> {
|
|
65
|
-
storage: {
|
|
66
|
-
[k: int]: T;
|
|
67
|
-
};
|
|
68
|
-
index_l: int;
|
|
69
|
-
index_r: int;
|
|
70
|
-
constructor(init?: T[]);
|
|
71
|
-
push(item: T): void;
|
|
72
|
-
pop(): void;
|
|
73
|
-
peek(): T | null;
|
|
74
|
-
size(): number;
|
|
75
|
-
[Symbol.iterator](): IterableIterator<T>;
|
|
76
|
-
}
|
package/rslib.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill'
|
|
2
|
-
import { defineConfig } from '@rslib/core'
|
|
3
|
-
|
|
4
|
-
import pkg from './package.json'
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
lib: [
|
|
8
|
-
{
|
|
9
|
-
format: 'esm',
|
|
10
|
-
output: {
|
|
11
|
-
filename: { js: '[name].js' },
|
|
12
|
-
target: 'node',
|
|
13
|
-
},
|
|
14
|
-
dts: true,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
format: 'umd',
|
|
18
|
-
output: {
|
|
19
|
-
filename: { js: '[name].umd.min.js' },
|
|
20
|
-
target: 'web',
|
|
21
|
-
},
|
|
22
|
-
dts: true,
|
|
23
|
-
umdName: pkg.name,
|
|
24
|
-
plugins: [pluginNodePolyfill()],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
})
|
package/src/index.test.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
//基于以下注释,根据vitest生成测试用例
|
|
2
|
-
import { describe, it } from 'vitest'
|
|
3
|
-
|
|
4
|
-
import { UniPool } from '@dan-uni/dan-any'
|
|
5
|
-
|
|
6
|
-
import detaolu from '.'
|
|
7
|
-
|
|
8
|
-
const xml = `<i>
|
|
9
|
-
<chatserver>chat.bilibili.com</chatserver>
|
|
10
|
-
<chatid>1156756312</chatid>
|
|
11
|
-
<mission>0</mission>
|
|
12
|
-
<maxlimit>2947</maxlimit>
|
|
13
|
-
<state>0</state>
|
|
14
|
-
<real_name>0</real_name>
|
|
15
|
-
<source>k-v</source>
|
|
16
|
-
<d p="13.213,1,25,16777215,1686314041,3,ff41173d,1335658005672492032">喜欢</d>
|
|
17
|
-
<d p="13.213,1,25,16777215,1686590010,0,296b35b5,1337972999512832512">来了 哈哈~~</d>
|
|
18
|
-
<d p="13.246,1,25,16777215,1686276875,0,5664cfc4,1335346233459549696">就是</d>
|
|
19
|
-
<d p="13.266,1,25,16777215,1686283375,0,c7e6646f,1335400761013670912">什么鬼?</d>
|
|
20
|
-
<d p="13.284,1,25,16777215,1686291338,0,38662881,1335467554877267456">哇哦</d>
|
|
21
|
-
<d p="13.306,1,25,16777215,1686268410,0,4c01de10,1335275224983600896">试试</d>
|
|
22
|
-
<d p="13.331,1,25,16777215,1686948453,3,56a3c5d5,1340979831550069760">不喜欢</d>
|
|
23
|
-
<d p="13.374,1,25,16777215,1686300770,3,647fe355,1335546672880933888">不喜欢</d>
|
|
24
|
-
<d p="13.376,1,25,16777215,1686297921,0,469d94b8,1335522778300134400">哦豁</d>
|
|
25
|
-
<d p="13.419,1,25,8700107,1686268005,0,be402447,1335271828100244224">太酷啦</d>
|
|
26
|
-
<d p="13.419,1,25,16777215,1686316828,3,7ffb6619,1335681385016736768">喜欢</d>
|
|
27
|
-
<d p="13.459,1,25,16777215,1686299729,0,45834405,1335537942797634048">一般,不好看</d>
|
|
28
|
-
<d p="13.462,1,25,16777215,1686302133,0,3cab672c,1335558106620590080">哈哈哈</d>
|
|
29
|
-
<d p="13.481,1,25,16777215,1686297342,0,ce67fafd,1335517923728804864">?</d>
|
|
30
|
-
<d p="13.499,1,25,16777215,1686301548,3,2848bf1c,1335553202649003264">不喜欢</d>
|
|
31
|
-
</i>`
|
|
32
|
-
|
|
33
|
-
describe('其它', () => {
|
|
34
|
-
const pool = UniPool.fromBiliXML(xml)
|
|
35
|
-
it('反套路(基于pakku.js实现的弹幕去重)', async () => {
|
|
36
|
-
const d = (await pool.pipe(detaolu({ MAX_COSINE: 1000 }))).minify()
|
|
37
|
-
console.info(d)
|
|
38
|
-
})
|
|
39
|
-
})
|
package/src/index.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Config as DeTaoLuConfig } from './pakku.js'
|
|
2
|
-
|
|
3
|
-
import { UniDM, UniDMTools, UniPool } from '@dan-uni/dan-any'
|
|
4
|
-
|
|
5
|
-
import pakkujs from './pakku.js'
|
|
6
|
-
|
|
7
|
-
async function detaolu(that: UniPool, config?: DeTaoLuConfig) {
|
|
8
|
-
const p = await pakkujs(
|
|
9
|
-
{
|
|
10
|
-
objs: that.dans.map((d) => ({
|
|
11
|
-
time_ms: d.progress * 1000,
|
|
12
|
-
mode: d.mode, //TODO
|
|
13
|
-
content: d.content,
|
|
14
|
-
pool: d.pool,
|
|
15
|
-
// danuni_sender: d.senderID,
|
|
16
|
-
danuni_dan: d,
|
|
17
|
-
})),
|
|
18
|
-
},
|
|
19
|
-
config,
|
|
20
|
-
)
|
|
21
|
-
const selected = p.clusters.map((p) => {
|
|
22
|
-
if (p.danuni_dans.length === 1) {
|
|
23
|
-
return p.danuni_dans[0].danuni_dan
|
|
24
|
-
} else {
|
|
25
|
-
const dans = p.danuni_dans
|
|
26
|
-
const pool = new UniPool(dans.map((d) => d.danuni_dan))
|
|
27
|
-
function isAllBottomMode(p: UniPool) {
|
|
28
|
-
return p.dans.every((d) => d.mode === UniDMTools.Modes.Bottom)
|
|
29
|
-
}
|
|
30
|
-
const progess = pool.dans.map((d) => d.progress)
|
|
31
|
-
return UniDM.create({
|
|
32
|
-
SOID: pool.shared.SOID ?? pool.dans[0].SOID,
|
|
33
|
-
progress: dans[0].danuni_dan.progress,
|
|
34
|
-
mode:
|
|
35
|
-
pool.shared.mode ??
|
|
36
|
-
(isAllBottomMode(pool)
|
|
37
|
-
? UniDMTools.Modes.Bottom
|
|
38
|
-
: UniDMTools.Modes.Top),
|
|
39
|
-
fontsize: dans.length > 0 ? 36 : 25,
|
|
40
|
-
color: pool.shared.color ?? pool.most.color,
|
|
41
|
-
senderID: 'detaolu[bot]@dan-any',
|
|
42
|
-
content: p.chosen_str,
|
|
43
|
-
weight: 10,
|
|
44
|
-
pool: pool.shared.pool ?? pool.most.pool,
|
|
45
|
-
attr: [UniDMTools.DMAttr.Protect],
|
|
46
|
-
platform: pool.shared.platform ?? pool.most.platform,
|
|
47
|
-
extra: {
|
|
48
|
-
danuni: {
|
|
49
|
-
merge: {
|
|
50
|
-
count: p.danuni_count,
|
|
51
|
-
duration: Number.parseFloat(
|
|
52
|
-
(Math.max(...progess) - Math.min(...progess)).toFixed(3),
|
|
53
|
-
),
|
|
54
|
-
senders: pool.dans
|
|
55
|
-
.filter((d) => d.content === p.chosen_str)
|
|
56
|
-
.map((d) => d.senderID),
|
|
57
|
-
taolu_count: pool.dans.length,
|
|
58
|
-
taolu_senders: pool.dans.map((d) => d.senderID),
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
return new UniPool(selected)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function detaolu_constructor(config?: DeTaoLuConfig) {
|
|
69
|
-
return (that: UniPool) => detaolu(that, config)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default detaolu_constructor
|