Files
沃巴蒂 ff22ed3a8b feat(deepdata): 引入修改密码、文件预览组件与清洗算子增强,deepflow 改名为 deep-flow
本次同步 09-12 至 09-28 的代码变更,主要内容:

新增功能
- 修改密码:后端新增 ChangePasswordRequest DTO 与UserController/UserService
  对应接口,前端新增 ChangePasswordDialog 并在 Header 接入入口
- 文件预览组件重构:file-preview 目录拆分出 VideoPreview(支持 blobUrl 直传)、
  ImagePreview、AudioPreview,index.tsx 统一调度各类型预览器
- 新增 my_ops 算子模块:markitdown_parser、mineru_pdf_parser、text_quality_evaluator
- 新增 tools/minio-file-server MinIO 文件服务

功能增强
- 数据清洗:cleaning_task_service/scheduler/routes 重构,
  data_juicer_executor 与 wrapper 增强,OperatorTable/LogsTable/TaskDetail 同步调整
- 数据标注:annotation sync.py、project.py 接口与schema 更新
- 数据采集、算子市场、首页与菜单路由相关页面调整
- DataJuicer 算子接入(useOperatorOperations、dj_ops_schema)

结构调整
- deepflow/ 更名为 deep-flow/(419 个文件重命名)
- 新增 helm 部署编排、GitHub Actions 之外的自建镜像构建脚本

未纳入本次提交
- scripts-backup/、runtime/python-executor-backup/、components_backup/(备份目录)
- *.backup*、__pycache__ 产物
- zh_core_web_sm-3.8.0-py3-none-any.whl(46MB 构建产物)
- DataX/(内嵌独立仓库,远程亦未收录其源码)
2026-10-03 22:44:56 +08:00

66 lines
3.0 KiB
Python

#!/user/bin/python
# -*- coding: utf-8 -*-
"""
Description: 文档目录去除
Create: 2025/01/13
"""
import re
import time
from typing import Dict, Any
from loguru import logger
from deepdata.core.base_op import Mapper
class ContentCleaner(Mapper):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.no_content_count = 3 # 连续不符合目录结构的行数阈值
# 目录标题
self.content_text_pattern = r"^ *(目 *录|CONTENT(S)?) *$"
# 目录行 前缀格式
self.content_preface_pattern = r"^ *(前言|About This Document|\d+(\.\d+)*|[a-zA-Z]+(\.\d+)*)"
# 目录行 中间格式
self.content_middle_pattern = r"\.{7,}"
# 目录行 结尾格式
self.content_end_pattern = r"(\d|错误!未定义书签。|[IXV]+) *$"
self.content_pattern = self.content_preface_pattern + ".*" + self.content_end_pattern
def execute(self, sample: Dict[str, Any]) -> Dict[str, Any]:
start = time.time()
self.read_file_first(sample)
sample[self.text_key] = self._content_filter(sample[self.text_key])
logger.info(f"fileName: {sample[self.filename_key]}, method: ContentCleaner costs {time.time() - start:.6f} s")
return sample
def _content_filter(self, input_data: str):
count = 0 # 记录不符合目录结构的次数,连续3行不满足要求,则认为已经进入正文
# 目录起始和结束索引
content_start_index, content_end_index = -1, -1
lines = input_data.split("\n")
for i, line in enumerate(lines):
if content_start_index >= 0 and count >= self.no_content_count:
break
# 首先匹配目录或content字眼
if content_start_index < 0 and re.match(self.content_text_pattern, line, re.IGNORECASE):
content_start_index = i
content_end_index = i
# 匹配两种形式的目录行
# 1. 以指定格式开始、指定格式结尾;2.该行包含点数量超过7个
elif content_start_index >= 0 and (re.match(self.content_pattern, line, re.IGNORECASE)
or re.search(self.content_middle_pattern, line)):
content_end_index = i
count = 0
elif content_start_index >= 0 and not (re.match(self.content_pattern, line, re.IGNORECASE)
or re.search(self.content_middle_pattern, line)):
count += 1
if 0 <= content_start_index < content_end_index:
res = "\n".join(lines[:content_start_index] + lines[content_end_index + 1:])
else:
# 只有目录关键字时,关键字不去除;或不符合目录结构,返回原文
res = "\n".join(lines)
return res