init: WordFileParse docx→HTML 解析服务(含 Word EQ 域公式修复)
服务:Spring Boot 3.2 + docx4j 8.3.9,POST /api/v3/server_office_file/file/parse
接受 .docx,返回 HTML(公式 → LaTeX,图片 → RustFS 外链)
公式支持三类来源:
- OMML(Word 2007+ 公式) → Python omml_mathml2latex
- MathType OLE 对象 → Ruby mathtype2mathml → MathML → LaTeX
- Word EQ 域(老教辅主力) → EqToLatexUtil(本次新增)
本次改动:
1. 新增 java-svc/.../core/EqToLatexUtil.java:
移植自 jby backend-services office-core,EQ 语法 → LaTeX
(\f→\dfrac、\r→\sqrt、\i→\int/\sum/\prod、\s→^{}/_{}、\b→\left\right、
\a→array、\x→\boxed/\overline、\o\al 堆叠、圈码、化学符号、极限、连等式)
品牌标记 JBYU* → WPU*,与采集端一致
2. CtoMathFinder:接上 EQ 分支(原为 not-ported 桩),域代码经
EqToLatexUtil.convert 转 LaTeX 写入 eqLatexMap(WPEQNUM 占位符)
3. WordParseUtil.dealPlaceholder:EQ 的 LaTeX 同样加 \( \) 包裹
(原先因 WPEQNUM 例外不加包裹,前端/MathJax 不渲染)
修前症状:教辅 Word 里分式/方程组/上下标整段丢失(如 {−1/3, 1} 变成 {-,1})
修后实测:46 份教辅 2908 处 EQ 域全部还原,公式总数 2954 处、零未包裹残留
安全:application.yml(含 RustFS 密钥)不入库,提供 application.yml.example;
OssService 的 @Value 默认密钥已清空
This commit is contained in:
132
java-src/domain/param/ParseParam.java
Normal file
132
java-src/domain/param/ParseParam.java
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* com.alibaba.fastjson.annotation.JSONField
|
||||
* org.springframework.web.multipart.MultipartFile
|
||||
*/
|
||||
package com.jby.officecore.domain.param;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public class ParseParam
|
||||
implements Serializable {
|
||||
private static final long serialVersionUID = 4113866861283462539L;
|
||||
private String sourceUrl;
|
||||
@JSONField(serialize=false)
|
||||
private MultipartFile sourceFile;
|
||||
private List<JSONObject> latexReplaceList;
|
||||
private Boolean newParseVersion;
|
||||
private Long fileId;
|
||||
|
||||
public String getSourceUrl() {
|
||||
return this.sourceUrl;
|
||||
}
|
||||
|
||||
public MultipartFile getSourceFile() {
|
||||
return this.sourceFile;
|
||||
}
|
||||
|
||||
public List<JSONObject> getLatexReplaceList() {
|
||||
return this.latexReplaceList;
|
||||
}
|
||||
|
||||
public Boolean getNewParseVersion() {
|
||||
return this.newParseVersion;
|
||||
}
|
||||
|
||||
public Long getFileId() {
|
||||
return this.fileId;
|
||||
}
|
||||
|
||||
public ParseParam setSourceUrl(String sourceUrl) {
|
||||
this.sourceUrl = sourceUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParseParam setSourceFile(MultipartFile sourceFile) {
|
||||
this.sourceFile = sourceFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParseParam setLatexReplaceList(List<JSONObject> latexReplaceList) {
|
||||
this.latexReplaceList = latexReplaceList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParseParam setNewParseVersion(Boolean newParseVersion) {
|
||||
this.newParseVersion = newParseVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParseParam setFileId(Long fileId) {
|
||||
this.fileId = fileId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ParseParam)) {
|
||||
return false;
|
||||
}
|
||||
ParseParam other = (ParseParam)o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
String this$sourceUrl = this.getSourceUrl();
|
||||
String other$sourceUrl = other.getSourceUrl();
|
||||
if (this$sourceUrl == null ? other$sourceUrl != null : !this$sourceUrl.equals(other$sourceUrl)) {
|
||||
return false;
|
||||
}
|
||||
MultipartFile this$sourceFile = this.getSourceFile();
|
||||
MultipartFile other$sourceFile = other.getSourceFile();
|
||||
if (this$sourceFile == null ? other$sourceFile != null : !this$sourceFile.equals(other$sourceFile)) {
|
||||
return false;
|
||||
}
|
||||
List<JSONObject> this$latexReplaceList = this.getLatexReplaceList();
|
||||
List<JSONObject> other$latexReplaceList = other.getLatexReplaceList();
|
||||
if (this$latexReplaceList == null ? other$latexReplaceList != null : !((Object)this$latexReplaceList).equals(other$latexReplaceList)) {
|
||||
return false;
|
||||
}
|
||||
Boolean this$newParseVersion = this.getNewParseVersion();
|
||||
Boolean other$newParseVersion = other.getNewParseVersion();
|
||||
if (this$newParseVersion == null ? other$newParseVersion != null : !((Object)this$newParseVersion).equals(other$newParseVersion)) {
|
||||
return false;
|
||||
}
|
||||
Long this$fileId = this.getFileId();
|
||||
Long other$fileId = other.getFileId();
|
||||
return !(this$fileId == null ? other$fileId != null : !((Object)this$fileId).equals(other$fileId));
|
||||
}
|
||||
|
||||
protected boolean canEqual(Object other) {
|
||||
return other instanceof ParseParam;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int PRIME = 59;
|
||||
int result = 1;
|
||||
String $sourceUrl = this.getSourceUrl();
|
||||
result = result * 59 + ($sourceUrl == null ? 43 : $sourceUrl.hashCode());
|
||||
MultipartFile $sourceFile = this.getSourceFile();
|
||||
result = result * 59 + ($sourceFile == null ? 43 : $sourceFile.hashCode());
|
||||
List<JSONObject> $latexReplaceList = this.getLatexReplaceList();
|
||||
result = result * 59 + ($latexReplaceList == null ? 43 : ((Object)$latexReplaceList).hashCode());
|
||||
Boolean $newParseVersion = this.getNewParseVersion();
|
||||
result = result * 59 + ($newParseVersion == null ? 43 : ((Object)$newParseVersion).hashCode());
|
||||
Long $fileId = this.getFileId();
|
||||
result = result * 59 + ($fileId == null ? 43 : ((Object)$fileId).hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ParseParam(sourceUrl=" + this.getSourceUrl() + ", sourceFile=" + this.getSourceFile() + ", latexReplaceList=" + this.getLatexReplaceList() + ", newParseVersion=" + this.getNewParseVersion() + ", fileId=" + this.getFileId() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user