mt-polygon-simplification/thesis/results-benchmark/gen-tex.py

65 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/python
2019-08-07 15:34:59 +02:00
import os
tex_template = """
\\begin{{figure}}[!htb]
2019-08-07 15:34:59 +02:00
\\centering
\\includegraphics[width=.75\\linewidth]{{./results-benchmark/{filename}}}
\\caption{{{caption}}}
\\label{{fig:{label}}}
\\end{{figure}}
"""
caption_template = '{chart} benchmark result of {device} device with {browser} browser on dataset "{data}" {highQual}.'
devices = {
'win': 'Windows',
2019-08-08 21:25:39 +02:00
'mac': 'MacBook Pro',
'ubu': 'Ubuntu',
'iph': 'iPhone'
2019-08-07 15:34:59 +02:00
}
browsers = {
'ffox': 'Firefox',
'chro': 'Chrome',
'edge': 'Edge',
'safa': 'Safari'
}
data = {
'simplify': 'Simplify.js example',
'bavaria': 'Bavaria outline'
}
chart = {
'vs': 'Simplify.wasm vs. Simplify.js',
2019-08-08 21:25:39 +02:00
'stack': 'Simplify.wasm runtime analysis',
'jsstack': 'Turf.js simplify'
2019-08-07 15:34:59 +02:00
}
highQual = {
2019-08-08 21:25:39 +02:00
'true': 'with high quality mode',
'false': 'without high quality mode'
2019-08-07 15:34:59 +02:00
}
for filename in os.listdir(os.path.dirname(os.path.realpath(__file__))):
if not filename.endswith('.png'):
continue
label = filename.split('.')[0]
parts = label.split('_')
caption = caption_template.format(
device=devices[parts[0]],
browser=browsers[parts[1]],
data=data[parts[2]],
chart=chart[parts[3]],
highQual=highQual[parts[4]]
)
content = tex_template.format(
filename=filename, caption=caption, label=label)
with open(label + '.tex', 'w') as file:
file.write(content)