fastcdm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastcdm-0.1.0/LICENSE +185 -0
- fastcdm-0.1.0/PKG-INFO +312 -0
- fastcdm-0.1.0/README.md +101 -0
- fastcdm-0.1.0/fastcdm/__init__.py +5 -0
- fastcdm-0.1.0/fastcdm/box.py +23 -0
- fastcdm-0.1.0/fastcdm/clean.py +48 -0
- fastcdm-0.1.0/fastcdm/colorize.py +53 -0
- fastcdm-0.1.0/fastcdm/core.py +306 -0
- fastcdm-0.1.0/fastcdm/latex_processor.py +814 -0
- fastcdm-0.1.0/fastcdm/matcher.py +222 -0
- fastcdm-0.1.0/fastcdm/render/render_worker.py +179 -0
- fastcdm-0.1.0/fastcdm/render/templates/formula.html +67 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/auto-render.min.js +1 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex.min.css +1 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex.min.js +1 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_AMS-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_AMS-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_AMS-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Fraktur-Bold.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Fraktur-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Bold.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Bold.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Bold.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-BoldItalic.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Italic.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Italic.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Italic.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Main-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Math-BoldItalic.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Math-Italic.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Math-Italic.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Math-Italic.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Bold.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Italic.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Script-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Script-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Script-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size1-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size1-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size1-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size2-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size2-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size2-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size3-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size3-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size3-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size4-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size4-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Size4-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Typewriter-Regular.woff +0 -0
- fastcdm-0.1.0/fastcdm/render/templates/lib/katex_fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- fastcdm-0.1.0/fastcdm/tokenize.py +277 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/preprocess_formula.js +387 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/preprocess_tabular.js +395 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/cli.js +32 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/katex.js +74 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/Lexer.js +162 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/Options.js +189 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/ParseError.js +40 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/Parser.js +798 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/Settings.js +28 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/Style.js +126 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/buildCommon.js +450 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/buildHTML.js +1402 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/buildMathML.js +533 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/buildTree.js +40 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/delimiter.js +542 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/domTree.js +269 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/environments.js +295 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/fontMetrics.js +147 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/fontMetricsData.js +1752 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/functions.js +585 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/mathMLTree.js +102 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/parseData.js +13 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/parseTree.js +17 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/symbols.js +687 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/katex/src/utils.js +106 -0
- fastcdm-0.1.0/fastcdm/tokenize_latex/third_party/match-at/lib/matchAt.js +42 -0
- fastcdm-0.1.0/fastcdm.egg-info/PKG-INFO +312 -0
- fastcdm-0.1.0/fastcdm.egg-info/SOURCES.txt +109 -0
- fastcdm-0.1.0/fastcdm.egg-info/dependency_links.txt +1 -0
- fastcdm-0.1.0/fastcdm.egg-info/requires.txt +13 -0
- fastcdm-0.1.0/fastcdm.egg-info/top_level.txt +1 -0
- fastcdm-0.1.0/pyproject.toml +60 -0
- fastcdm-0.1.0/setup.cfg +4 -0
- fastcdm-0.1.0/setup.py +3 -0
- fastcdm-0.1.0/tests/test_grammer.py +8 -0
fastcdm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
9
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
11
|
+
the copyright owner that is granting the License.
|
|
12
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
13
|
+
entities that control, are controlled by, or are under common control
|
|
14
|
+
with that entity. For the purposes of this definition, "control" means
|
|
15
|
+
(i) the power, direct or indirect, to cause the direction or management
|
|
16
|
+
of such entity, whether by contract or otherwise, or (ii) ownership of
|
|
17
|
+
fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
|
|
18
|
+
ownership of such entity.
|
|
19
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
20
|
+
permissions granted by this License.
|
|
21
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
22
|
+
including but not limited to software source code, documentation source,
|
|
23
|
+
and configuration files.
|
|
24
|
+
"Object" form shall mean any form resulting from mechanical transformation
|
|
25
|
+
or translation of a Source form, including but not limited to compiled
|
|
26
|
+
object code, generated documentation, and conversions to other media types.
|
|
27
|
+
"Work" shall mean the work of authorship, whether in Source or Object
|
|
28
|
+
form, made available under the License, as indicated by a copyright
|
|
29
|
+
notice that is included in or attached to the work (an example is
|
|
30
|
+
provided in the Appendix below).
|
|
31
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
32
|
+
form, that is based on (or derived from) the Work and for which the
|
|
33
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
34
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
35
|
+
of this License, Derivative Works shall not include works that remain
|
|
36
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
37
|
+
the Work and Derivative Works thereof.
|
|
38
|
+
"Contribution" shall mean any work of authorship, including
|
|
39
|
+
the original version of the Work and any modifications or additions
|
|
40
|
+
to that Work or Derivative Works thereof, that is intentionally submitted
|
|
41
|
+
to Licensor for inclusion in the Work by the copyright owner or by an
|
|
42
|
+
individual or Legal Entity authorized to submit on behalf of the copyright
|
|
43
|
+
owner. For the purposes of this definition, "submitted" means any form of
|
|
44
|
+
electronic, verbal, or written communication sent to the Licensor or its
|
|
45
|
+
representatives, including but not limited to communication on electronic
|
|
46
|
+
mailing lists, source code control systems, and issue tracking systems
|
|
47
|
+
that are managed by, or on behalf of, the Licensor for the purpose of
|
|
48
|
+
discussing and improving the Work, but excluding communication that is
|
|
49
|
+
conspicuously marked or otherwise designated in writing by the copyright
|
|
50
|
+
owner as "Not a Contribution."
|
|
51
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
52
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
53
|
+
subsequently incorporated within the Work.
|
|
54
|
+
|
|
55
|
+
2. Grant of Copyright License.
|
|
56
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
57
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
58
|
+
royalty-free, irrevocable copyright license to reproduce, prepare
|
|
59
|
+
Derivative Works of, publicly display, publicly perform, sublicense,
|
|
60
|
+
and distribute the Work and such Derivative Works in Source or Object form.
|
|
61
|
+
|
|
62
|
+
3. Grant of Patent License.
|
|
63
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
64
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
65
|
+
royalty-free, irrevocable (except as stated in this section) patent license
|
|
66
|
+
to make, have made, use, offer to sell, sell, import, and otherwise
|
|
67
|
+
transfer the Work, where such license applies only to those patent claims
|
|
68
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
69
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work
|
|
70
|
+
to which such Contribution(s) was submitted. If You institute patent litigation
|
|
71
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
72
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
73
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
74
|
+
licenses granted to You under this License for that Work shall terminate
|
|
75
|
+
as of the date such litigation is filed.
|
|
76
|
+
|
|
77
|
+
4. Redistribution.
|
|
78
|
+
You may reproduce and distribute copies of the Work or Derivative Works
|
|
79
|
+
thereof in any medium, with or without modifications, and in Source or
|
|
80
|
+
Object form, provided that You meet the following conditions:
|
|
81
|
+
|
|
82
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
83
|
+
a copy of this License; and
|
|
84
|
+
|
|
85
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
86
|
+
that You changed the files; and
|
|
87
|
+
|
|
88
|
+
(c) You must retain, in the Source form of any Derivative Works that
|
|
89
|
+
You distribute, all copyright, patent, trademark, and attribution
|
|
90
|
+
notices from the Source form of the Work, excluding those notices that
|
|
91
|
+
do not pertain to any part of the Derivative Works; and
|
|
92
|
+
|
|
93
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
94
|
+
then any Derivative Works that You distribute must include a readable
|
|
95
|
+
copy of the attribution notices contained within such NOTICE file,
|
|
96
|
+
excluding those notices that do not pertain to any part of the
|
|
97
|
+
Derivative Works, in at least one of the following places: within a
|
|
98
|
+
NOTICE text file distributed as part of the Derivative Works; within the
|
|
99
|
+
Source form or documentation, if provided along with the Derivative Works;
|
|
100
|
+
or, within a display generated by the Derivative Works, if and wherever
|
|
101
|
+
such third-party notices normally appear. The contents of the NOTICE file
|
|
102
|
+
are for informational purposes only and do not modify the License.
|
|
103
|
+
You may add Your own attribution notices within Derivative Works that
|
|
104
|
+
You distribute, alongside or as an addendum to the NOTICE text from the
|
|
105
|
+
Work, provided that such additional attribution notices cannot be construed
|
|
106
|
+
as modifying the License.
|
|
107
|
+
|
|
108
|
+
You may add Your own copyright statement to Your modifications and may
|
|
109
|
+
provide additional or different license terms and conditions for use,
|
|
110
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
111
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
112
|
+
distribution of the Work otherwise complies with the conditions stated
|
|
113
|
+
in this License.
|
|
114
|
+
|
|
115
|
+
5. Submission of Contributions.
|
|
116
|
+
Unless You explicitly state otherwise, any Contribution intentionally
|
|
117
|
+
submitted for inclusion in the Work by You to the Licensor shall be under
|
|
118
|
+
the terms and conditions of this License, without any additional
|
|
119
|
+
terms or conditions. Notwithstanding the above, nothing herein shall supersede
|
|
120
|
+
or modify the terms of any separate license agreement you may have executed
|
|
121
|
+
with Licensor regarding such Contributions.
|
|
122
|
+
|
|
123
|
+
6. Trademarks.
|
|
124
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
125
|
+
service marks, or product names of the Licensor, except as required for
|
|
126
|
+
reasonable and customary use in describing the origin of the Work and
|
|
127
|
+
reproducing the content of the NOTICE file.
|
|
128
|
+
|
|
129
|
+
7. Disclaimer of Warranty.
|
|
130
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work
|
|
131
|
+
(and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
132
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
133
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
134
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
135
|
+
You are solely responsible for determining the appropriateness of using or
|
|
136
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
137
|
+
permissions under this License.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability.
|
|
140
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
141
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
142
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
143
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
144
|
+
or consequential damages of any character arising as a result of this License or
|
|
145
|
+
out of the use or inability to use the Work (including but not limited to damages
|
|
146
|
+
for loss of goodwill, work stoppage, computer failure or malfunction, or any and
|
|
147
|
+
all other commercial damages or losses), even if such Contributor has been
|
|
148
|
+
advised of the possibility of such damages.
|
|
149
|
+
|
|
150
|
+
9. Accepting Warranty or Additional Liability.
|
|
151
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer,
|
|
152
|
+
and charge a fee for, acceptance of support, warranty, indemnity, or other
|
|
153
|
+
liability obligations and/or rights consistent with this License. However, in
|
|
154
|
+
accepting such obligations, You may act only on Your own behalf and on Your sole
|
|
155
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
156
|
+
indemnify, defend, and hold each Contributor harmless for any liability
|
|
157
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
158
|
+
accepting any such warranty or additional liability.
|
|
159
|
+
|
|
160
|
+
END OF TERMS AND CONDITIONS
|
|
161
|
+
|
|
162
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
163
|
+
|
|
164
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
165
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
166
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
167
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
168
|
+
recommend that a file or class name and description of purpose be included on
|
|
169
|
+
the same "printed page" as the copyright notice for easier identification within
|
|
170
|
+
third-party archives.
|
|
171
|
+
|
|
172
|
+
Copyright (c) 2025 KevinQiu
|
|
173
|
+
|
|
174
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
175
|
+
you may not use this file except in compliance with the License.
|
|
176
|
+
You may obtain a copy of the License at
|
|
177
|
+
|
|
178
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
179
|
+
|
|
180
|
+
Unless required by applicable law or agreed to in writing, software
|
|
181
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
182
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
183
|
+
See the License for the specific language governing permissions and
|
|
184
|
+
limitations under the License.
|
|
185
|
+
|
fastcdm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fastcdm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast CDM utilities for LaTeX tokenization, rendering, and matching
|
|
5
|
+
Author: KevinQiu
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
14
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
16
|
+
the copyright owner that is granting the License.
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
18
|
+
entities that control, are controlled by, or are under common control
|
|
19
|
+
with that entity. For the purposes of this definition, "control" means
|
|
20
|
+
(i) the power, direct or indirect, to cause the direction or management
|
|
21
|
+
of such entity, whether by contract or otherwise, or (ii) ownership of
|
|
22
|
+
fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
|
|
23
|
+
ownership of such entity.
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
25
|
+
permissions granted by this License.
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation source,
|
|
28
|
+
and configuration files.
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation
|
|
30
|
+
or translation of a Source form, including but not limited to compiled
|
|
31
|
+
object code, generated documentation, and conversions to other media types.
|
|
32
|
+
"Work" shall mean the work of authorship, whether in Source or Object
|
|
33
|
+
form, made available under the License, as indicated by a copyright
|
|
34
|
+
notice that is included in or attached to the work (an example is
|
|
35
|
+
provided in the Appendix below).
|
|
36
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
37
|
+
form, that is based on (or derived from) the Work and for which the
|
|
38
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
39
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
40
|
+
of this License, Derivative Works shall not include works that remain
|
|
41
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
42
|
+
the Work and Derivative Works thereof.
|
|
43
|
+
"Contribution" shall mean any work of authorship, including
|
|
44
|
+
the original version of the Work and any modifications or additions
|
|
45
|
+
to that Work or Derivative Works thereof, that is intentionally submitted
|
|
46
|
+
to Licensor for inclusion in the Work by the copyright owner or by an
|
|
47
|
+
individual or Legal Entity authorized to submit on behalf of the copyright
|
|
48
|
+
owner. For the purposes of this definition, "submitted" means any form of
|
|
49
|
+
electronic, verbal, or written communication sent to the Licensor or its
|
|
50
|
+
representatives, including but not limited to communication on electronic
|
|
51
|
+
mailing lists, source code control systems, and issue tracking systems
|
|
52
|
+
that are managed by, or on behalf of, the Licensor for the purpose of
|
|
53
|
+
discussing and improving the Work, but excluding communication that is
|
|
54
|
+
conspicuously marked or otherwise designated in writing by the copyright
|
|
55
|
+
owner as "Not a Contribution."
|
|
56
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
57
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
58
|
+
subsequently incorporated within the Work.
|
|
59
|
+
|
|
60
|
+
2. Grant of Copyright License.
|
|
61
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
62
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
63
|
+
royalty-free, irrevocable copyright license to reproduce, prepare
|
|
64
|
+
Derivative Works of, publicly display, publicly perform, sublicense,
|
|
65
|
+
and distribute the Work and such Derivative Works in Source or Object form.
|
|
66
|
+
|
|
67
|
+
3. Grant of Patent License.
|
|
68
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
69
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
70
|
+
royalty-free, irrevocable (except as stated in this section) patent license
|
|
71
|
+
to make, have made, use, offer to sell, sell, import, and otherwise
|
|
72
|
+
transfer the Work, where such license applies only to those patent claims
|
|
73
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
74
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work
|
|
75
|
+
to which such Contribution(s) was submitted. If You institute patent litigation
|
|
76
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
77
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
78
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
79
|
+
licenses granted to You under this License for that Work shall terminate
|
|
80
|
+
as of the date such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution.
|
|
83
|
+
You may reproduce and distribute copies of the Work or Derivative Works
|
|
84
|
+
thereof in any medium, with or without modifications, and in Source or
|
|
85
|
+
Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
88
|
+
a copy of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
91
|
+
that You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that
|
|
94
|
+
You distribute, all copyright, patent, trademark, and attribution
|
|
95
|
+
notices from the Source form of the Work, excluding those notices that
|
|
96
|
+
do not pertain to any part of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
99
|
+
then any Derivative Works that You distribute must include a readable
|
|
100
|
+
copy of the attribution notices contained within such NOTICE file,
|
|
101
|
+
excluding those notices that do not pertain to any part of the
|
|
102
|
+
Derivative Works, in at least one of the following places: within a
|
|
103
|
+
NOTICE text file distributed as part of the Derivative Works; within the
|
|
104
|
+
Source form or documentation, if provided along with the Derivative Works;
|
|
105
|
+
or, within a display generated by the Derivative Works, if and wherever
|
|
106
|
+
such third-party notices normally appear. The contents of the NOTICE file
|
|
107
|
+
are for informational purposes only and do not modify the License.
|
|
108
|
+
You may add Your own attribution notices within Derivative Works that
|
|
109
|
+
You distribute, alongside or as an addendum to the NOTICE text from the
|
|
110
|
+
Work, provided that such additional attribution notices cannot be construed
|
|
111
|
+
as modifying the License.
|
|
112
|
+
|
|
113
|
+
You may add Your own copyright statement to Your modifications and may
|
|
114
|
+
provide additional or different license terms and conditions for use,
|
|
115
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
116
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
117
|
+
distribution of the Work otherwise complies with the conditions stated
|
|
118
|
+
in this License.
|
|
119
|
+
|
|
120
|
+
5. Submission of Contributions.
|
|
121
|
+
Unless You explicitly state otherwise, any Contribution intentionally
|
|
122
|
+
submitted for inclusion in the Work by You to the Licensor shall be under
|
|
123
|
+
the terms and conditions of this License, without any additional
|
|
124
|
+
terms or conditions. Notwithstanding the above, nothing herein shall supersede
|
|
125
|
+
or modify the terms of any separate license agreement you may have executed
|
|
126
|
+
with Licensor regarding such Contributions.
|
|
127
|
+
|
|
128
|
+
6. Trademarks.
|
|
129
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
130
|
+
service marks, or product names of the Licensor, except as required for
|
|
131
|
+
reasonable and customary use in describing the origin of the Work and
|
|
132
|
+
reproducing the content of the NOTICE file.
|
|
133
|
+
|
|
134
|
+
7. Disclaimer of Warranty.
|
|
135
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work
|
|
136
|
+
(and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
138
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
139
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
140
|
+
You are solely responsible for determining the appropriateness of using or
|
|
141
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
142
|
+
permissions under this License.
|
|
143
|
+
|
|
144
|
+
8. Limitation of Liability.
|
|
145
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
146
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
147
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
148
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
149
|
+
or consequential damages of any character arising as a result of this License or
|
|
150
|
+
out of the use or inability to use the Work (including but not limited to damages
|
|
151
|
+
for loss of goodwill, work stoppage, computer failure or malfunction, or any and
|
|
152
|
+
all other commercial damages or losses), even if such Contributor has been
|
|
153
|
+
advised of the possibility of such damages.
|
|
154
|
+
|
|
155
|
+
9. Accepting Warranty or Additional Liability.
|
|
156
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer,
|
|
157
|
+
and charge a fee for, acceptance of support, warranty, indemnity, or other
|
|
158
|
+
liability obligations and/or rights consistent with this License. However, in
|
|
159
|
+
accepting such obligations, You may act only on Your own behalf and on Your sole
|
|
160
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
161
|
+
indemnify, defend, and hold each Contributor harmless for any liability
|
|
162
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
163
|
+
accepting any such warranty or additional liability.
|
|
164
|
+
|
|
165
|
+
END OF TERMS AND CONDITIONS
|
|
166
|
+
|
|
167
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
168
|
+
|
|
169
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
170
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
171
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
172
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
173
|
+
recommend that a file or class name and description of purpose be included on
|
|
174
|
+
the same "printed page" as the copyright notice for easier identification within
|
|
175
|
+
third-party archives.
|
|
176
|
+
|
|
177
|
+
Copyright (c) 2025 KevinQiu
|
|
178
|
+
|
|
179
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
180
|
+
you may not use this file except in compliance with the License.
|
|
181
|
+
You may obtain a copy of the License at
|
|
182
|
+
|
|
183
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
184
|
+
|
|
185
|
+
Unless required by applicable law or agreed to in writing, software
|
|
186
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
187
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
188
|
+
See the License for the specific language governing permissions and
|
|
189
|
+
limitations under the License.
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
193
|
+
Classifier: Programming Language :: Python :: 3
|
|
194
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
195
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
196
|
+
Requires-Python: >=3.8
|
|
197
|
+
Description-Content-Type: text/markdown
|
|
198
|
+
License-File: LICENSE
|
|
199
|
+
Requires-Dist: numpy>=1.20
|
|
200
|
+
Requires-Dist: opencv-python>=4.5
|
|
201
|
+
Requires-Dist: selenium>=4
|
|
202
|
+
Requires-Dist: webdriver-manager>=4
|
|
203
|
+
Requires-Dist: scikit-image
|
|
204
|
+
Requires-Dist: gradio
|
|
205
|
+
Provides-Extra: dev
|
|
206
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
207
|
+
Requires-Dist: black>=23; extra == "dev"
|
|
208
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
209
|
+
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
210
|
+
Requires-Dist: twine; extra == "dev"
|
|
211
|
+
|
|
212
|
+
<div align="center">
|
|
213
|
+
|
|
214
|
+
# ⚡️FastCDM
|
|
215
|
+
|
|
216
|
+
[**[GitHub Repo]**](https://github.com/qiubinyang/FastCDM) | [**[HuggingFace Spaces]**](https://huggingface.co/spaces)
|
|
217
|
+
|
|
218
|
+
<p>
|
|
219
|
+
<a href="https://pypi.org/project/fastcdm/">
|
|
220
|
+
<img src="https://img.shields.io/badge/pypi-v0.1.0-blue"
|
|
221
|
+
alt="PyPI package version">
|
|
222
|
+
</a>
|
|
223
|
+
<a href="https://www.python.org">
|
|
224
|
+
<img src="https://img.shields.io/badge/python-3.8%2B-blue"
|
|
225
|
+
alt="Python versions">
|
|
226
|
+
</a>
|
|
227
|
+
<a href="#">
|
|
228
|
+
<img src="https://img.shields.io/badge/license-Apache%202.0-blue"
|
|
229
|
+
alt="GitHub license">
|
|
230
|
+
</a>
|
|
231
|
+
</p>
|
|
232
|
+
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
## 🚀 Introduction
|
|
236
|
+
|
|
237
|
+
[CDM](https://github.com/opendatalab/UniMERNet/tree/main/cdm) ensures the objectivity and accuracy of evaluation by rendering predicted and ground-truth LaTeX formulas into images, and then using visual feature extraction and localization techniques to perform precise character-level matching, combined with spatial position information.
|
|
238
|
+
|
|
239
|
+
**FastCDM** aims to address performance issues. As a high-performance optimized version of the original [CDM](https://github.com/opendatalab/UniMERNet/tree/main/cdm), FastCDM employs the browser-based KaTeX rendering engine instead of traditional LaTeX compilation, resulting in significantly improved speed.
|
|
240
|
+
|
|
241
|
+
### 🎯 Project Goals
|
|
242
|
+
|
|
243
|
+
The core objective of FastCDM is to **provide a convenient user experience during the training process**, helping to advance formula recognition tasks. We are committed to:
|
|
244
|
+
- Providing simple and easy-to-use API interfaces for convenient integration of evaluation within the training loop.
|
|
245
|
+
- Supporting both real-time evaluation and batch evaluation modes.
|
|
246
|
+
- Providing visualization tools for evaluation metrics during the training process.
|
|
247
|
+
|
|
248
|
+
### Why Choose FastCDM?
|
|
249
|
+
|
|
250
|
+
1. **Extreme Performance**: Based on the KaTeX rendering engine, it is tens of times faster than the traditional LaTeX compilation process.
|
|
251
|
+
2. **Simplified Deployment**: No need to install complex LaTeX environments (ImageMagick, texlive-full, etc.).
|
|
252
|
+
3. **Accurate Evaluation**: Adopts character detection matching methods to avoid the unfairness issues associated with traditional text metrics.
|
|
253
|
+
4. **Continuous Optimization**: Supplements and refines CDM symbol support, with continuous iterative improvements.
|
|
254
|
+
5. **Easy Integration**: Provides a unified API interface for easy integration into various training frameworks. Future integration with mainstream training frameworks such as PyTorch and Transformers is planned.
|
|
255
|
+
|
|
256
|
+
### ⚠️ Note
|
|
257
|
+
|
|
258
|
+
Although KaTeX is extremely fast, it is a lightweight solution optimized for the Web and cannot support **100%** of all obscure LaTeX syntax.
|
|
259
|
+
|
|
260
|
+
For the vast majority of standard formulas, it performs perfectly. This is a reasonable and sustainable technical choice.
|
|
261
|
+
|
|
262
|
+
You can check KaTeX's support coverage here: 🔗 [KaTeX Support Table](https://katex.org/docs/support_table)
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Usage
|
|
267
|
+
|
|
268
|
+
### Installation
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
pip install fastcdm
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Quick Start
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from fastcdm import FastCDM
|
|
278
|
+
|
|
279
|
+
chromedriver_path = "driver/chromedriver"
|
|
280
|
+
|
|
281
|
+
# Initialize FastCDM evaluator
|
|
282
|
+
evaluator = FastCDM(chromedriver_path=chromedriver_path)
|
|
283
|
+
|
|
284
|
+
# Evaluate
|
|
285
|
+
cdm_score, recall, precision = evaluator.compute(gt="E = mc^2", pred="E + 1 = mc^2", visualize=False)
|
|
286
|
+
|
|
287
|
+
# Evaluate and visualize
|
|
288
|
+
cdm_score, recall, precision, vis_img = evaluator.compute(gt="E = mc^2", pred="E + 1 = mc^2", visualize=True)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Interactive Demo
|
|
292
|
+
|
|
293
|
+
We provide a visualization Demo developed with Gradio, which you can try on [HuggingFace Spaces](https://huggingface.co/spaces). You can also launch it locally:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
python3 scripts/app.py
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Contribution and Feedback
|
|
300
|
+
|
|
301
|
+
We welcome all forms of contribution, including but not limited to:
|
|
302
|
+
- Submitting issue reports
|
|
303
|
+
- Suggesting improvements
|
|
304
|
+
- Submitting code changes (please open an issue for discussion first)
|
|
305
|
+
|
|
306
|
+
Please contact us via the project's [issues](https://github.com/qiubinyang/FastCDM/issues).
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
This project is open-sourced under the Apache 2.0 license. You are free to use, modify, and distribute the code of this project under the terms of the license.
|
fastcdm-0.1.0/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ⚡️FastCDM
|
|
4
|
+
|
|
5
|
+
[**[GitHub Repo]**](https://github.com/qiubinyang/FastCDM) | [**[HuggingFace Spaces]**](https://huggingface.co/spaces)
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://pypi.org/project/fastcdm/">
|
|
9
|
+
<img src="https://img.shields.io/badge/pypi-v0.1.0-blue"
|
|
10
|
+
alt="PyPI package version">
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://www.python.org">
|
|
13
|
+
<img src="https://img.shields.io/badge/python-3.8%2B-blue"
|
|
14
|
+
alt="Python versions">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="#">
|
|
17
|
+
<img src="https://img.shields.io/badge/license-Apache%202.0-blue"
|
|
18
|
+
alt="GitHub license">
|
|
19
|
+
</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
## 🚀 Introduction
|
|
25
|
+
|
|
26
|
+
[CDM](https://github.com/opendatalab/UniMERNet/tree/main/cdm) ensures the objectivity and accuracy of evaluation by rendering predicted and ground-truth LaTeX formulas into images, and then using visual feature extraction and localization techniques to perform precise character-level matching, combined with spatial position information.
|
|
27
|
+
|
|
28
|
+
**FastCDM** aims to address performance issues. As a high-performance optimized version of the original [CDM](https://github.com/opendatalab/UniMERNet/tree/main/cdm), FastCDM employs the browser-based KaTeX rendering engine instead of traditional LaTeX compilation, resulting in significantly improved speed.
|
|
29
|
+
|
|
30
|
+
### 🎯 Project Goals
|
|
31
|
+
|
|
32
|
+
The core objective of FastCDM is to **provide a convenient user experience during the training process**, helping to advance formula recognition tasks. We are committed to:
|
|
33
|
+
- Providing simple and easy-to-use API interfaces for convenient integration of evaluation within the training loop.
|
|
34
|
+
- Supporting both real-time evaluation and batch evaluation modes.
|
|
35
|
+
- Providing visualization tools for evaluation metrics during the training process.
|
|
36
|
+
|
|
37
|
+
### Why Choose FastCDM?
|
|
38
|
+
|
|
39
|
+
1. **Extreme Performance**: Based on the KaTeX rendering engine, it is tens of times faster than the traditional LaTeX compilation process.
|
|
40
|
+
2. **Simplified Deployment**: No need to install complex LaTeX environments (ImageMagick, texlive-full, etc.).
|
|
41
|
+
3. **Accurate Evaluation**: Adopts character detection matching methods to avoid the unfairness issues associated with traditional text metrics.
|
|
42
|
+
4. **Continuous Optimization**: Supplements and refines CDM symbol support, with continuous iterative improvements.
|
|
43
|
+
5. **Easy Integration**: Provides a unified API interface for easy integration into various training frameworks. Future integration with mainstream training frameworks such as PyTorch and Transformers is planned.
|
|
44
|
+
|
|
45
|
+
### ⚠️ Note
|
|
46
|
+
|
|
47
|
+
Although KaTeX is extremely fast, it is a lightweight solution optimized for the Web and cannot support **100%** of all obscure LaTeX syntax.
|
|
48
|
+
|
|
49
|
+
For the vast majority of standard formulas, it performs perfectly. This is a reasonable and sustainable technical choice.
|
|
50
|
+
|
|
51
|
+
You can check KaTeX's support coverage here: 🔗 [KaTeX Support Table](https://katex.org/docs/support_table)
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install fastcdm
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Quick Start
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from fastcdm import FastCDM
|
|
67
|
+
|
|
68
|
+
chromedriver_path = "driver/chromedriver"
|
|
69
|
+
|
|
70
|
+
# Initialize FastCDM evaluator
|
|
71
|
+
evaluator = FastCDM(chromedriver_path=chromedriver_path)
|
|
72
|
+
|
|
73
|
+
# Evaluate
|
|
74
|
+
cdm_score, recall, precision = evaluator.compute(gt="E = mc^2", pred="E + 1 = mc^2", visualize=False)
|
|
75
|
+
|
|
76
|
+
# Evaluate and visualize
|
|
77
|
+
cdm_score, recall, precision, vis_img = evaluator.compute(gt="E = mc^2", pred="E + 1 = mc^2", visualize=True)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Interactive Demo
|
|
81
|
+
|
|
82
|
+
We provide a visualization Demo developed with Gradio, which you can try on [HuggingFace Spaces](https://huggingface.co/spaces). You can also launch it locally:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python3 scripts/app.py
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Contribution and Feedback
|
|
89
|
+
|
|
90
|
+
We welcome all forms of contribution, including but not limited to:
|
|
91
|
+
- Submitting issue reports
|
|
92
|
+
- Suggesting improvements
|
|
93
|
+
- Submitting code changes (please open an issue for discussion first)
|
|
94
|
+
|
|
95
|
+
Please contact us via the project's [issues](https://github.com/qiubinyang/FastCDM/issues).
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
This project is open-sourced under the Apache 2.0 license. You are free to use, modify, and distribute the code of this project under the terms of the license.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import cv2
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_bboxes_from_array(img_array, colors):
|
|
6
|
+
bboxes = []
|
|
7
|
+
for color in colors: # color is RGB
|
|
8
|
+
# img_array is BGR (cv2 default)
|
|
9
|
+
r, g, b = color
|
|
10
|
+
target_bgr = np.array([b, g, r], dtype=np.uint8)
|
|
11
|
+
|
|
12
|
+
# Create mask
|
|
13
|
+
mask = cv2.inRange(img_array, target_bgr, target_bgr)
|
|
14
|
+
coords = np.argwhere(mask)
|
|
15
|
+
|
|
16
|
+
if coords.size > 0:
|
|
17
|
+
y_min, x_min = coords.min(axis=0)
|
|
18
|
+
y_max, x_max = coords.max(axis=0)
|
|
19
|
+
# [xmin, ymin, xmax, ymax]
|
|
20
|
+
bboxes.append([int(x_min), int(y_min), int(x_max), int(y_max)])
|
|
21
|
+
else:
|
|
22
|
+
bboxes.append([]) # Empty list for missing token
|
|
23
|
+
return bboxes
|