@aim-packages/subtitle 0.0.19 → 0.1.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/dist/index.es.js CHANGED
@@ -1057,36 +1057,56 @@ function G0(n) {
1057
1057
  return u1(n, J6 | K6);
1058
1058
  }
1059
1059
  class I0 {
1060
+ /**
1061
+ * 构造函数
1062
+ * @param options 重复检测选项
1063
+ */
1060
1064
  constructor(e) {
1065
+ /** 重复检测阈值,默认为2次 */
1061
1066
  Y(this, "threshold", 2);
1067
+ /** 当前重复次数 */
1062
1068
  Y(this, "hit", 0);
1069
+ /** 前一个字幕片段 */
1063
1070
  Y(this, "prevSegment");
1071
+ /** 当前重复的字幕片段 */
1064
1072
  Y(this, "hitSegment");
1073
+ /** 重复片段列表 */
1065
1074
  Y(this, "hitSegmentList", []);
1075
+ /** 配置选项 */
1066
1076
  Y(this, "options");
1067
1077
  this.options = e || {};
1068
1078
  }
1079
+ /**
1080
+ * 添加字幕片段进行重复检测
1081
+ * @param segment 要检测的字幕片段
1082
+ */
1069
1083
  push(e) {
1070
1084
  var a, t;
1071
1085
  this.hitSegment && this.hitSegment.text !== e.text && (this.hitSegmentList.push(this.hitSegment), this.reset()), this.prevSegment && e.text === this.prevSegment.text ? (this.hit++, this.hit === 1 && (this.hitSegment = G0(this.prevSegment), this.hitSegment.et = e.et, this.hitSegment.hit = 1), this.threshold <= this.hit && this.hitSegment && (this.hitSegment.et = e.et, this.hitSegment.hit = this.hit, (t = (a = this.options).onHit) == null || t.call(a, this.hitSegmentList))) : this.hit = 0, this.prevSegment = e;
1072
1086
  }
1087
+ /**
1088
+ * 结束检测,处理最后的重复片段
1089
+ */
1073
1090
  end() {
1074
1091
  var e, a;
1075
1092
  this.hitSegment && (this.hitSegmentList.push(this.hitSegment), (a = (e = this.options).onHit) == null || a.call(e, this.hitSegmentList)), this.reset();
1076
1093
  }
1094
+ /**
1095
+ * 重置检测器状态
1096
+ */
1077
1097
  reset() {
1078
1098
  this.hit = 0, this.prevSegment = void 0, this.hitSegment = void 0;
1079
1099
  }
1080
1100
  }
1081
1101
  const I = {
1102
+ /** 检测是否存在句子分割符号(逗号、句号、问号、感叹号等) */
1082
1103
  punc: /[.,?!\],。!?…]{1}/,
1083
- // 是否存在句子分割符号
1104
+ /** 检测是否存在行尾分割符号(句号、问号、感叹号等) */
1084
1105
  em: /[.?!\]。!?…]{1}/,
1085
- // 是否存在行尾分割符号
1106
+ /** 检测是否存在连续空白字符(行首行尾空白、多个连续空格) */
1086
1107
  space: /^\s+|\s+$|\s{2,}/g,
1087
- // 是否存在连续空白
1108
+ /** 检测是否存在行尾标点和可能存在的空格字符 */
1088
1109
  ep: /[.,?!,。!?…]{1}\s*$/
1089
- // 是否存在行尾标点和可能存在的空格字符
1090
1110
  };
1091
1111
  function w6(n, e) {
1092
1112
  var m;
@@ -1240,6 +1260,7 @@ function _0(n) {
1240
1260
  language: e,
1241
1261
  languageName: R1(e),
1242
1262
  probability: 1
1263
+ // 单语言检测时概率设为 1
1243
1264
  };
1244
1265
  }
1245
1266
  function A7(n) {
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@aim-packages/subtitle",
3
- "version": "0.0.19",
3
+ "version": "0.1.0",
4
4
  "main": "dist/index.cjs.js",
5
5
  "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist/",
8
+ "README.md"
9
+ ],
6
10
  "scripts": {
7
11
  "dev": "vite",
8
12
  "build": "tsc && vite build",