-
Notifications
You must be signed in to change notification settings - Fork 0
/
titleify.py
51 lines (28 loc) · 1007 Bytes
/
titleify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
Merge individual files into one
select tex files as arguments
'''
import os,glob,re,sys
import numpy as np
time = os.popen('date').read()
backup = True
if backup:
os.system('git add -A')
os.system('git commit -m "%s_title"'%time)
print ('commit =', time)
classes = []
for i in 'section subsection subsubsection'.split():
for j in ['','\*']:
classes.append( r'(?<=\\%s%s\{).*?(?=})'%(i,j))
print (classes)
heading = re.compile(r'|'.join(classes))
#|\\chapter\*{0,1}\{(.*?)\}|\\paragraph\*{0,1}\{(.*?)\}')
files = glob.glob('*/combigned.tex')
for f in files:
print(f)
text = open(f,'r').read()
new = heading.sub( lambda x: str(x.group()).title().replace('Mcm','MCM').replace('Voc','VOC').replace('Tf-Idf','TF-IDF').replace('T-Sne','t-SNE').replace('Smiles','SMILES').replace('Mqn','MQN').replace('Maccs','MACCS'), text)
# print(heading.findall(new))
with open(f,'w') as replace:
replace.write(new)
print('fi')