Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- Dockerfile +39 -0
- LICENSE +21 -0
- app.py +66 -0
- policy.xml +40 -0
Dockerfile
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ubuntu:22.04
|
2 |
+
|
3 |
+
RUN apt-get update && apt-get install -y \
|
4 |
+
python3 \
|
5 |
+
python3-pip \
|
6 |
+
wget \
|
7 |
+
unzip \
|
8 |
+
imagemagick \
|
9 |
+
libmagickwand-dev
|
10 |
+
|
11 |
+
# Create a new directory and set it as the working directory
|
12 |
+
WORKDIR /code
|
13 |
+
|
14 |
+
COPY ./app.py /code/app.py
|
15 |
+
COPY ./policy.xml /code/policy.xml
|
16 |
+
|
17 |
+
RUN cp /code/policy.xml /etc/ImageMagick-6/policy.xml
|
18 |
+
RUN useradd -m -u 1000 user
|
19 |
+
USER user
|
20 |
+
ENV HOME=/home/user \
|
21 |
+
PATH=/home/user/.local/bin:$PATH
|
22 |
+
|
23 |
+
WORKDIR $HOME/app
|
24 |
+
|
25 |
+
COPY --chown=user . $HOME/app
|
26 |
+
|
27 |
+
|
28 |
+
RUN wget https://github.com/acl-org/aclpubcheck/archive/refs/heads/main.zip
|
29 |
+
RUN unzip main.zip
|
30 |
+
RUN cd aclpubcheck-main
|
31 |
+
RUN pip install -e ./aclpubcheck-main
|
32 |
+
|
33 |
+
|
34 |
+
RUN pip install gradio==3.34.0
|
35 |
+
|
36 |
+
|
37 |
+
EXPOSE 7860
|
38 |
+
|
39 |
+
CMD ["python3", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2023 Andrea Santilli
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
app.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import re
|
3 |
+
import subprocess
|
4 |
+
import argparse
|
5 |
+
|
6 |
+
def remove_color_codes(text):
|
7 |
+
color_pattern = re.compile(r'\x1b\[\d+m')
|
8 |
+
clean_text = re.sub(color_pattern, '', text)
|
9 |
+
return clean_text
|
10 |
+
|
11 |
+
|
12 |
+
def to_html(document):
|
13 |
+
lines = document.split('\n')
|
14 |
+
formatted_lines = []
|
15 |
+
|
16 |
+
for line in lines:
|
17 |
+
if line.startswith("Error"):
|
18 |
+
formatted_line = f'<span style="color: red;">{line}</span>'
|
19 |
+
elif line.startswith("Warning"):
|
20 |
+
formatted_line = f'<span style="color: yellow;">{line}</span>'
|
21 |
+
elif line.startswith("Parsing Error:"):
|
22 |
+
formatted_line = f'<span style="color: yellow;">{line}</span>'
|
23 |
+
elif line == "All Clear!":
|
24 |
+
formatted_line = f'<span style="color: green;">{line}</span>'
|
25 |
+
else:
|
26 |
+
formatted_line = line
|
27 |
+
|
28 |
+
formatted_lines.append(formatted_line)
|
29 |
+
|
30 |
+
formatted_document = '<br>'.join(formatted_lines)
|
31 |
+
return formatted_document
|
32 |
+
|
33 |
+
|
34 |
+
def upload_file(file, paper_type):
|
35 |
+
command = f"python3 aclpubcheck-main/aclpubcheck/formatchecker.py --paper_type {paper_type} {file.name}"
|
36 |
+
out = subprocess.run(command, shell=True, stdout=subprocess.PIPE, text=True, stderr=subprocess.STDOUT)
|
37 |
+
return to_html(remove_color_codes(out.stdout))
|
38 |
+
|
39 |
+
|
40 |
+
with gr.Blocks() as demo:
|
41 |
+
header = """
|
42 |
+
<div align="center">
|
43 |
+
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/7/72/Association_for_Computational_Linguistics_logo.svg/2880px-Association_for_Computational_Linguistics_logo.svg.png" alt="acl-logo" width=100px/>
|
44 |
+
<h1>ACL Pubcheck Tool</h1>
|
45 |
+
</div>
|
46 |
+
"""
|
47 |
+
gr.HTML(header)
|
48 |
+
gr.Markdown("Drop or upload your paper here to have it checked for [ACL conferences](https://www.aclweb.org/) guidelines.")
|
49 |
+
dropdown = gr.Dropdown(
|
50 |
+
["long", "short", "demo", "other"], label="Paper type", value="long"
|
51 |
+
)
|
52 |
+
file_output = gr.File(file_types=[".pdf"])
|
53 |
+
button = gr.Button("Check your PDF!", variant="primary")
|
54 |
+
out = gr.HTML()
|
55 |
+
gr.Markdown(
|
56 |
+
"This graphical interface is using the official [aclpubcheck tool](https://github.com/acl-org/aclpubcheck). Check the [repo for more information.](https://github.com/teelinsan/aclpubcheck-gui)")
|
57 |
+
button.click(upload_file, [file_output, dropdown], out)
|
58 |
+
|
59 |
+
|
60 |
+
if __name__ == '__main__':
|
61 |
+
parser = argparse.ArgumentParser()
|
62 |
+
parser.add_argument('--host', default="0.0.0.0", type=str)
|
63 |
+
parser.add_argument('--port', default=7860, type=int)
|
64 |
+
args = parser.parse_args()
|
65 |
+
|
66 |
+
demo.launch(server_name=args.host, server_port=args.port)
|
policy.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!DOCTYPE policymap [
|
3 |
+
<!ELEMENT policymap (policy)+>
|
4 |
+
<!ELEMENT policy (#PCDATA)>
|
5 |
+
<!ATTLIST policy domain (delegate|coder|filter|path|resource) #IMPLIED>
|
6 |
+
<!ATTLIST policy name CDATA #IMPLIED>
|
7 |
+
<!ATTLIST policy rights CDATA #IMPLIED>
|
8 |
+
<!ATTLIST policy pattern CDATA #IMPLIED>
|
9 |
+
<!ATTLIST policy value CDATA #IMPLIED>
|
10 |
+
]>
|
11 |
+
<policymap>
|
12 |
+
<!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
|
13 |
+
<policy domain="resource" name="memory" value="256MiB"/>
|
14 |
+
<policy domain="resource" name="map" value="512MiB"/>
|
15 |
+
<policy domain="resource" name="width" value="16KP"/>
|
16 |
+
<policy domain="resource" name="height" value="16KP"/>
|
17 |
+
<policy domain="resource" name="area" value="128MB"/>
|
18 |
+
<policy domain="resource" name="disk" value="1GiB"/>
|
19 |
+
<!-- <policy domain="resource" name="file" value="768"/> -->
|
20 |
+
<!-- <policy domain="resource" name="thread" value="4"/> -->
|
21 |
+
<!-- <policy domain="resource" name="throttle" value="0"/> -->
|
22 |
+
<!-- <policy domain="resource" name="time" value="3600"/> -->
|
23 |
+
<!-- <policy domain="system" name="precision" value="6"/> -->
|
24 |
+
<!-- not needed due to the need to use explicitly by mvg: -->
|
25 |
+
<!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
|
26 |
+
<!-- use curl -->
|
27 |
+
<policy domain="delegate" rights="none" pattern="URL" />
|
28 |
+
<policy domain="delegate" rights="none" pattern="HTTPS" />
|
29 |
+
<policy domain="delegate" rights="none" pattern="HTTP" />
|
30 |
+
<!-- in order to avoid to get image with password text -->
|
31 |
+
<policy domain="path" rights="none" pattern="@*"/>
|
32 |
+
<policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/>
|
33 |
+
<!-- disable ghostscript format types -->
|
34 |
+
<policy domain="coder" rights="none" pattern="PS" />
|
35 |
+
<policy domain="coder" rights="none" pattern="PS2" />
|
36 |
+
<policy domain="coder" rights="none" pattern="PS3" />
|
37 |
+
<policy domain="coder" rights="none" pattern="EPS" />
|
38 |
+
<policy domain="coder" rights="read|write" pattern="PDF" />
|
39 |
+
<policy domain="coder" rights="none" pattern="XPS" />
|
40 |
+
</policymap>
|