Compare commits

...

3 Commits

Author SHA1 Message Date
6786d174a6 Merge pull request 'feat: add mml' (#4) from test into master
Reviewed-on: #4
2026-02-05 13:48:14 +08:00
liuyuanchuang
de6b5d3960 Merge branch 'master' into test 2026-02-05 10:44:39 +08:00
liuyuanchuang
81c2767423 feat: add mml from backend 2026-02-05 10:44:11 +08:00
5 changed files with 19 additions and 18 deletions

View File

@@ -6,16 +6,13 @@ type CreateTaskResponse struct {
}
type GetFormulaTaskResponse struct {
TaskNo string `json:"task_no"`
Status int `json:"status"`
Count int `json:"count"`
Latex string `json:"latex"`
Markdown string `json:"markdown"`
MathML string `json:"mathml"`
MathMLMW string `json:"mathml_mw"`
ImageBlob string `json:"image_blob"`
DocxURL string `json:"docx_url"`
PDFURL string `json:"pdf_url"`
TaskNo string `json:"task_no"`
Status int `json:"status"`
Count int `json:"count"`
Latex string `json:"latex"`
Markdown string `json:"markdown"`
MathML string `json:"mathml"`
MML string `json:"mml"`
}
// FormulaRecognitionResponse 公式识别服务返回的响应
@@ -25,7 +22,8 @@ type FormulaRecognitionResponse struct {
// ImageOCRResponse 图片OCR接口返回的响应
type ImageOCRResponse struct {
Latex string `json:"latex"` // LaTeX 格式内容
Markdown string `json:"markdown"` // Markdown 格式内容
MathML string `json:"mathml"` // MathML 格式(无公式时为空)
Markdown string `json:"markdown"` // Markdown 格式内容
Latex string `json:"latex"` // LaTeX 格式内容 (无公式时为空)
MathML string `json:"mathml"` // MathML 格式(无公式时为空)
MML string `json:"mml"` // MML 格式(无公式时为空)
}

View File

@@ -24,10 +24,7 @@ type TaskListDTO struct {
Latex string `json:"latex"`
Markdown string `json:"markdown"`
MathML string `json:"mathml"`
MathMLMW string `json:"mathml_mw"`
ImageBlob string `json:"image_blob"`
DocxURL string `json:"docx_url"`
PDFURL string `json:"pdf_url"`
MML string `json:"mml"`
}
type TaskListResponse struct {

View File

@@ -180,6 +180,7 @@ func (s *RecognitionService) GetFormualTask(ctx context.Context, taskNo string)
Latex: taskRet.Latex,
Markdown: markdown,
MathML: taskRet.MathML,
MML: taskRet.MML,
Status: int(task.Status),
}, nil
}
@@ -544,6 +545,7 @@ func (s *RecognitionService) processFormulaTask(ctx context.Context, taskID int6
Latex: ocrResp.Latex,
Markdown: ocrResp.Markdown,
MathML: ocrResp.MathML,
MML: ocrResp.MML,
})
if err != nil {
log.Error(ctx, "func", "processFormulaTask", "msg", "保存任务结果失败", "error", err)

View File

@@ -92,11 +92,13 @@ func (svc *TaskService) GetTaskList(ctx context.Context, req *task.TaskListReque
var latex string
var markdown string
var mathML string
var mml string
recognitionResult := recognitionResultMap[item.ID]
if recognitionResult != nil {
latex = recognitionResult.Latex
markdown = recognitionResult.Markdown
mathML = recognitionResult.MathML
mml = recognitionResult.MML
}
originURL, err := oss.GetDownloadURL(ctx, item.FileURL)
if err != nil {
@@ -106,6 +108,7 @@ func (svc *TaskService) GetTaskList(ctx context.Context, req *task.TaskListReque
Latex: latex,
Markdown: markdown,
MathML: mathML,
MML: mml,
TaskID: item.TaskUUID,
FileName: item.FileName,
Status: int(item.Status),

View File

@@ -9,8 +9,9 @@ type RecognitionResult struct {
TaskID int64 `gorm:"column:task_id;bigint;not null;default:0;comment:任务ID" json:"task_id"`
TaskType TaskType `gorm:"column:task_type;varchar(16);not null;comment:任务类型;default:''" json:"task_type"`
Latex string `json:"latex" gorm:"column:latex;type:text;not null;default:''"`
Markdown string `json:"markdown" gorm:"column:markdown;type:text;not null;default:''"` // Mathpix Markdown 格式
Markdown string `json:"markdown" gorm:"column:markdown;type:text;not null;default:''"` // Markdown 格式
MathML string `json:"mathml" gorm:"column:mathml;type:text;not null;default:''"` // MathML 格式
MML string `json:"mml" gorm:"column:mml;type:text;not null;default:''"` // MML 格式
}
type RecognitionResultDao struct {