From 43513c896073d763075495441090a6348cc861f7 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 22 May 2026 12:51:10 +0800 Subject: [PATCH] feat: add XThesis standard --- LICENSE | 21 ++++ docs/XThesis.example.xml | 194 +++++++++++++++++++++++++++++ docs/XThesis.md | 71 +++++++++++ docs/XThesis.xsd | 257 +++++++++++++++++++++++++++++++++++++++ src/cli.py | 25 +++- 5 files changed, 564 insertions(+), 4 deletions(-) create mode 100644 LICENSE create mode 100644 docs/XThesis.example.xml create mode 100644 docs/XThesis.md create mode 100644 docs/XThesis.xsd diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1c08082 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2026 yyc12345 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docs/XThesis.example.xml b/docs/XThesis.example.xml new file mode 100644 index 0000000..733f7f5 --- /dev/null +++ b/docs/XThesis.example.xml @@ -0,0 +1,194 @@ + +
+ + + +
+ + 本文提出了一种基于深度学习的图像识别方法。实验结果表明,该方法在 + ImageNet + 数据集上达到了 + 92.3\% + 的准确率。 + + + 关键词: + 深度学习;图像识别;卷积神经网络 + +
+
+ + + + + + 随着深度学习技术的快速发展 + he2016, krizhevsky2012 + ,图像识别领域取得了突破性进展。然而,现有方法在计算效率方面仍存在诸多挑战 + tan2019 + + + + 本文的主要贡献如下: + sec:method,fig:arch + + + + + + 卷积神经网络(CNN)自 + lecun1998 + 提出以来,已成为计算机视觉领域的基础架构。 + + + + + + 本文其余部分组织如下:第 + sec:method + 节介绍所提出的方法,第 + sec:experiment + 节展示实验结果,最后在第 + sec:conclusion + 节进行总结。 + + + + + + + 近年来,多种网络架构被提出。 + simonyan2014, szegedy2015, he2016 + 等代表性工作极大地推动了该领域的发展。 + + + + + + 本节详细描述所提出的方法架构,如 + fig:arch + 所示。整体流程如公式 + eq:loss + 所定义。 + + +
figures/architecture.png
+ + + + 本文采用交叉熵损失函数,其定义如下: + + + \mathcal{L} = -\sum_{i=1}^{N} y_i \log(\hat{y}_i) + + + 其中 + N + 表示类别数量, + y_i + 为真实标签, + \hat{y}_i + 为预测概率。 + + + + + + 模型使用 + Adam + 优化器进行训练,初始学习率设为 + 10^{-3} + + + +
+ + + + 本节在三个标准数据集上评估所提出方法的性能。实验结果汇总于 + tbl:result + + + + + + 实验采用以下数据集: + CIFAR-10 + + CIFAR-100 + + ImageNet + + + + + + + 不同方法的对比结果如下表所示: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法准确率 (%)参数量 (M)
ResNet-1893.011.7
ResNet-5093.525.6
DenseNet-12194.28.0
本文方法95.19.3
+ + + + + 从表中可以看出,本文方法以较少的参数量取得了最优的准确率。 + +
+
+ + + + 本文提出了一种高效的图像识别方法,在多个数据集上验证了其有效性。未来工作将探索该方法在视频分析领域的应用。 + + +
+ + + +
+ + 本研究得到了国家自然科学基金(项目编号:No. 114514)的资助,在此表示感谢。 + +
+ +
+ + 以下是模型核心模块的伪代码实现: + +
+
+ + + references.bib + +
diff --git a/docs/XThesis.md b/docs/XThesis.md new file mode 100644 index 0000000..5c127e2 --- /dev/null +++ b/docs/XThesis.md @@ -0,0 +1,71 @@ +# XThesis 中间格式规范 + +XThesis 是一个基于 XML 的中间格式,用于辅助在 LaTeX 论文与 DOCX 论文之间进行格式转换。 + +## Schema 文件 + +格式的 XML Schema 定义见 [XThesis.xsd](./XThesis.xsd)。所有的元素结构、属性要求、子元素组合规则均在 Schema 中定义。下文仅补充 **XSD 无法在语法层面表达**的语义约束。 + +## XSD 不可表达的约束 + +### 章节嵌套规则 + +`section1` ~ `section9` 的嵌套严格限定为**相邻向下**: + +| 父元素 | 允许的子章节 | +|--------|-------------| +| `section1` | `section2` | +| `section2` | `section3` | +| `section3` | `section4` | +| `section4` | `section5` | +| `section5` | `section6` | +| `section6` | `section7` | +| `section7` | `section8` | +| `section8` | `section9` | +| `section9` | *(无)* | + +禁止: +- **同级别嵌套**:`section1` 内不能再有 `section1` +- **跨级别嵌套**:`section1` 内不能直接出现 `section3`,必须经由 `section2` 逐级过渡 + +### 粗体与斜体互斥 + +`` 与 `` 元素**不能互相嵌套**。文本只能是加粗或斜体之一,不允许 `...` 或 `...` 的形式。需要同时具有两种样式时,应在 `` 或 `` 之外另行处理(例如在转换阶段合并样式)。 + +### 表格列数一致性 + +`` 中 `` 的数量必须与 `` 中每一 `` 内 `` 的数量完全相等。XSD 无法在 Schema 层面约束跨元素的计数值相等,**处理程序须自行校验**并在列数不匹配时报错。 + +### 引用与文献名称的格式 + +`` 与 `` 的文本内容为被引用对象的 **label 名称**,多个名称以逗号分隔: + +```xml +eq:main,fig:arch,tbl:result +``` + +`` 同理,文本内容为被引用文献的标识,多个以逗号分隔: + +```xml +knuth1984,dijkstra1968 +``` + +此外,逗号前后允许空格: + +```xml +eq:main, fig:arch, tbl:result +knuth1984, dijkstra1968 +``` + +### 公式内容的格式 + +`` 与 `` 的文本内容为 **LaTeX 原始代码**,且**不包含**两侧的数学模式标记(`$` / `$$` / `\(` 等)。例如: + +```xml +E = mc^2 +E = mc^2 +``` + +### 文件路径格式 + +`
` 与 `` 的文本内容为文件路径。路径的具体格式(是相对路径还是绝对路径)没有要求。相对路径会在工作目录或资源目录进行查找,非相对路径则直接使用。 diff --git a/docs/XThesis.xsd b/docs/XThesis.xsd new file mode 100644 index 0000000..7596726 --- /dev/null +++ b/docs/XThesis.xsd @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cli.py b/src/cli.py index 9bd6ab1..b59a6bc 100644 --- a/src/cli.py +++ b/src/cli.py @@ -81,6 +81,8 @@ class XThesis2DocxCli: """The path to output Docx file""" config_file: Path """The path to XThesis2Docx configuration file""" + resource_dir: Path + """The path to resource directory for finding images and other resources referred in XThesis file""" def parse_xthesis2docx_cli() -> XThesis2DocxCli: @@ -120,9 +122,21 @@ def parse_xthesis2docx_cli() -> XThesis2DocxCli: help="The path to XThesis2Docx configuration file", metavar="CONFIG.toml", ) + parser.add_argument( + "-r", + "--resource-dir", + dest="resource_dir", + action="store", + type=Path, + required=True, + help="The path to resource directory for finding images and other resources referred in XThesis file", + metavar="RESOURCE_DIR", + ) args = parser.parse_args() - return XThesis2DocxCli(args.input_file, args.output_file, args.config_file) + return XThesis2DocxCli( + args.input_file, args.output_file, args.config_file, args.resource_dir + ) @dataclass(frozen=True) @@ -138,7 +152,7 @@ class LaTeX2DocxCli: backend_config_file: Path """The path to XThesis2Docx configuration file""" resource_dir: Path - """The path to resource directory for finding images and other resources referred in LaTeX file""" + """The path to resource directory for finding images and other resources referred in file""" def break_into( self, intermediate_file: Path @@ -157,7 +171,10 @@ class LaTeX2DocxCli: self.resource_dir, ), XThesis2DocxCli( - intermediate_file, self.output_file, self.backend_config_file + intermediate_file, + self.output_file, + self.backend_config_file, + self.resource_dir, ), ) @@ -215,7 +232,7 @@ def parse_latex2docx_cli() -> LaTeX2DocxCli: action="store", type=Path, required=True, - help="The path to resource directory for finding images and other resources referred in LaTeX file", + help="The path to resource directory for finding images and other resources referred in file", metavar="RESOURCE_DIR", )