Skip to content

✨ Add support for new filetypes#2429

Open
yzAiden wants to merge 3 commits intoModelEngine-Group:developfrom
yzAiden:support_new_filetypes
Open

✨ Add support for new filetypes#2429
yzAiden wants to merge 3 commits intoModelEngine-Group:developfrom
yzAiden:support_new_filetypes

Conversation

@yzAiden
Copy link

@yzAiden yzAiden commented Feb 5, 2026

一、功能:
1.提升数据清洗能力:支持.epub, .html, .csv, .json, .xml文件类型的清洗和检索。
二、设计:
1.所有新增文件类型均由UnstructuredProcessor进行处理。
2..epub, .html, .csv, .xml类型文件与现有处理逻辑完全一致。
3.对json类型文件的分片进行单独设计,方式为优先将 JSON 解析为文本并在不破坏最外层 key-value 语义的前提下按长度切分,无法安全按 KV 切分时退化为按标点的纯文本切分,解析失败则直接按纯文本策略分片。其余流程与现有处理方式一致。
三、主要改动的位置:
1.sdk/nexent/data_process
四、相关issue引用
#2258

@yzAiden yzAiden closed this Feb 5, 2026
@yzAiden yzAiden reopened this Feb 5, 2026
@yzAiden yzAiden closed this Feb 5, 2026
@yzAiden yzAiden reopened this Feb 5, 2026
@Jasonxia007 Jasonxia007 self-assigned this Feb 25, 2026
'.html': 'text/html',
'.htm': 'text/html',
'.json': 'application/json',
'.epub': 'application/epuub',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

拼写有误,应为 application/epub,请检查

[FILE_EXTENSIONS.MD]: FILE_TYPES.MARKDOWN
[FILE_EXTENSIONS.MD]: FILE_TYPES.MARKDOWN,
[FILE_EXTENSIONS.CSV]: FILE_TYPES.CSV,
[FILE_EXTENSIONS.JSON]: FILE_EXTENSIONS.JSON,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里似乎应该是 FILE_TYPES.JSON,请检查

Returns:
List of text chunks
"""
import orjson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

导入语句建议统一前提至文件头部


try:
data = orjson.loads(file_data)
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议使用orjson的自定异常类,明确区分Decode问题和其他读取问题

Comment on lines +72 to +73
while i > 0 and text[i - 1] not in PUNCTS:
i -= 1
Copy link
Contributor

@Jasonxia007 Jasonxia007 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于标点后带行尾空格的场景,建议先strip,否则下一分段头部会留有空格

Copy link
Contributor

@Jasonxia007 Jasonxia007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有部分代码逻辑需要确认或修改,请关注

Comment on lines +130 to +135
if c == "\\":
esc = True
continue
if c == '"':
in_str = not in_str
continue
Copy link
Contributor

@Jasonxia007 Jasonxia007 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 扫描是从右到左的,但 esc 却在保护 "\" 的下一个(即左侧的)字符,这与期望不一致;
  2. 似乎没有考虑注释行的场景。

建议仔细检查,并使用复杂json体进行自测:

{
    # case1: 值中包含转义引号
    "greeting": "hello \"world\", how are you",
    # case2: 值中包含逗号
    "address": "Beijing, Chaoyang, No.1",
    # case3: 嵌套对象
    "nested": {
        "inner_key": "inner, value",
        "deep": {"a": 1, "b": 2}
    },
    # case4: 数组
    "scores": [10, 20, 30],
    # case5: 值中包含花括号字符
    "template": "use {var} and [idx] here",
    # case6: 连续转义 \\\"
    "escaped_bs": "path is C:\\\\server\\\\share\\\"name\\\"",
    # case7: unicode 转义
    "unicode": "emoji \u00e9\u00e0",
    # case8: 空字符串
    "empty": "",
    # case9: 布尔和null
    "flag": True,
    "nothing": None,
    # case10: 数字
    "count": 42
}

Jasonxia007

This comment was marked as duplicate.

@yzAiden yzAiden force-pushed the support_new_filetypes branch from 679ef3c to 2dfd444 Compare March 2, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants