Refact: refact on parser structure (#14012)

### What problem does this PR solve?

Refact: refact on parser structure

### Type of change

- [x] Refactoring
This commit is contained in:
Magicbook1108
2026-04-10 10:03:44 +08:00
committed by GitHub
parent cd04467b9b
commit 27329b40ed
6 changed files with 110 additions and 49 deletions

View File

@@ -2251,10 +2251,11 @@ This process aggregates variables from multiple branches into a single variable
spreadsheet: 'Spreadsheet',
image: 'Image',
email: 'Email',
'text&markdown': 'Text & Markup',
code: 'Code',
markdown: 'Markdown',
'text&code': 'Text & Code',
html: 'HTML',
word: 'Word',
doc: 'DOC',
docx: 'DOCX',
slides: 'PPTX',
audio: 'Audio',
video: 'Video',

View File

@@ -1950,10 +1950,11 @@ General实体和关系提取提示来自 GitHub - microsoft/graphrag基于
spreadsheet: '表格',
image: '图片',
email: '邮件',
'text&markdown': '文本与标记',
code: '代码',
markdown: 'Markdown',
'text&code': '文本与代码',
html: 'HTML',
word: 'Word',
doc: 'DOC',
docx: 'DOCX',
slides: 'PPTX',
audio: '音频',
video: '视频',

View File

@@ -9,10 +9,11 @@ export enum FileType {
Spreadsheet = 'spreadsheet',
Image = 'image',
Email = 'email',
TextMarkdown = 'text&markdown',
Code = 'code',
TextMarkdown = 'markdown',
Code = 'text&code',
Html = 'html',
Docx = 'word',
Doc = 'doc',
Docx = 'docx',
PowerPoint = 'slides',
Video = 'video',
Audio = 'audio',
@@ -41,6 +42,11 @@ export enum TextMarkdownOutputFormat {
Text = 'text',
}
export enum TextJsonOutputFormat {
Text = 'text',
Json = 'json',
}
export enum DocxOutputFormat {
Markdown = 'markdown',
Json = 'json',
@@ -64,8 +70,9 @@ export const OutputFormatMap = {
[FileType.Image]: ImageOutputFormat,
[FileType.Email]: EmailOutputFormat,
[FileType.TextMarkdown]: TextMarkdownOutputFormat,
[FileType.Code]: TextMarkdownOutputFormat,
[FileType.Html]: TextMarkdownOutputFormat,
[FileType.Code]: TextJsonOutputFormat,
[FileType.Html]: TextJsonOutputFormat,
[FileType.Doc]: DocxOutputFormat,
[FileType.Docx]: DocxOutputFormat,
[FileType.PowerPoint]: PptOutputFormat,
[FileType.Video]: VideoOutputFormat,
@@ -78,8 +85,9 @@ export const InitialOutputFormatMap = {
[FileType.Image]: ImageOutputFormat.Text,
[FileType.Email]: EmailOutputFormat.Text,
[FileType.TextMarkdown]: TextMarkdownOutputFormat.Text,
[FileType.Code]: TextMarkdownOutputFormat.Text,
[FileType.Html]: TextMarkdownOutputFormat.Text,
[FileType.Code]: TextJsonOutputFormat.Json,
[FileType.Html]: TextJsonOutputFormat.Json,
[FileType.Doc]: DocxOutputFormat.Json,
[FileType.Docx]: DocxOutputFormat.Json,
[FileType.PowerPoint]: PptOutputFormat.Json,
[FileType.Video]: VideoOutputFormat.Text,
@@ -216,12 +224,17 @@ export const initialParserValues = {
},
{
fileFormat: FileType.Code,
output_format: TextMarkdownOutputFormat.Text,
output_format: TextJsonOutputFormat.Json,
preprocess: PreprocessValue.main_content,
},
{
fileFormat: FileType.Html,
output_format: TextMarkdownOutputFormat.Text,
output_format: TextJsonOutputFormat.Json,
preprocess: PreprocessValue.main_content,
},
{
fileFormat: FileType.Doc,
output_format: DocxOutputFormat.Json,
preprocess: PreprocessValue.main_content,
},
{
@@ -340,8 +353,9 @@ export const FileTypeSuffixMap = {
[FileType.Spreadsheet]: ['xls', 'xlsx', 'csv'],
[FileType.Image]: ['jpg', 'jpeg', 'png', 'gif'],
[FileType.Email]: ['eml', 'msg'],
[FileType.TextMarkdown]: ['md', 'markdown', 'mdx', 'txt'],
[FileType.TextMarkdown]: ['md', 'markdown', 'mdx'],
[FileType.Code]: [
'txt',
'py',
'js',
'java',
@@ -357,7 +371,8 @@ export const FileTypeSuffixMap = {
'sql',
],
[FileType.Html]: ['htm', 'html'],
[FileType.Docx]: ['doc', 'docx'],
[FileType.Doc]: ['doc'],
[FileType.Docx]: ['docx'],
[FileType.PowerPoint]: ['pptx', 'ppt'],
[FileType.Video]: ['mp4', 'avi', 'mkv'],
[FileType.Audio]: [

View File

@@ -82,6 +82,10 @@ const PreprocessOptionConfigsMap: Partial<
{ value: MAIN_CONTENT_PREPROCESS_VALUE, required: true },
{ value: PreprocessValue.section_title },
],
[FileType.Doc]: [
{ value: MAIN_CONTENT_PREPROCESS_VALUE, required: true },
{ value: PreprocessValue.section_title },
],
[FileType.Docx]: [
{ value: MAIN_CONTENT_PREPROCESS_VALUE, required: true },
{ value: PreprocessValue.section_title },