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:
36
java-svc/Dockerfile
Normal file
36
java-svc/Dockerfile
Normal file
@@ -0,0 +1,36 @@
|
||||
# WordFileParse Java Service — Docker build with pre-built JAR
|
||||
# First build JAR locally: mvn package -DskipTests
|
||||
# Then: docker build -t wordparse-java -f java-svc/Dockerfile .
|
||||
FROM eclipse-temurin:17-jdk
|
||||
|
||||
# Install Ruby + Python + build deps
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 python3-pip python3-venv \
|
||||
ruby ruby-dev build-essential libxml2-dev libxslt-dev pkg-config \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install pre-built Ruby gems (except nokogiri — compiled for current Ruby)
|
||||
COPY scripts/mathtype2mathml/install/gems/one/*.gem \
|
||||
scripts/mathtype2mathml/install/gems/two/bindata-*.gem \
|
||||
scripts/mathtype2mathml/install/gems/two/concurrent-ruby-*.gem \
|
||||
scripts/mathtype2mathml/install/gems/two/mini_portile2-*.gem \
|
||||
scripts/mathtype2mathml/install/gems/two/pry-*.gem \
|
||||
scripts/mathtype2mathml/install/gems/two/ruby-ole-*.gem \
|
||||
scripts/mathtype2mathml/install/gems/third/parallel-*.gem \
|
||||
/tmp/gems/
|
||||
RUN gem install /tmp/gems/*.gem --no-doc && rm -rf /tmp/gems
|
||||
RUN gem install nokogiri --no-doc
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy transform scripts
|
||||
COPY scripts/ /opt/transform/
|
||||
|
||||
# Python deps for omml_mathml2latex
|
||||
RUN pip3 install --break-system-packages -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple lxml
|
||||
|
||||
# Copy pre-built JAR
|
||||
COPY java-svc/target/word-file-parse-1.0.0.jar /app/app.jar
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["java", "-jar", "/app/app.jar"]
|
||||
Reference in New Issue
Block a user