-
Notifications
You must be signed in to change notification settings - Fork 0
/
tex2txt
executable file
·90 lines (88 loc) · 3.97 KB
/
tex2txt
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
if [ -z $1 ]
then
echo "No inut file given"
echo "USAGE: tex2txt file.tex"
exit 0
fi
sed 's/cref/ref/g' $1 \
| sed 's/eqref/ref/g' \
| sed 's/\\footnote/ \\footnote/g' \
| sed 's/labelref/ref/g' \
| sed 's/\\right\.//g' \
| sed 's/a\.e\.//g' \
| sed 's/F\.-in\.//g' \
| sed 's/subseq\.//g' \
| sed 's/F\.-in\.//g' \
| sed 's/\[Proof/\[proof/g' \
| sed 's/\\citeyear/2020 \\citeyear/g' \
| sed 's/\\citeauthor/the person \\citeauthor/g' \
| sed 's/\\textendash\\/-/g' \
| sed 's/the \\ref/the chapter \\ref/g' \
| sed 's/with \\ref/with chapter \\ref/g' \
| sed 's/With \\ref/With section \\ref/g' \
| sed 's/Assume \\ref/Assume the section \\ref/g' \
| sed 's/assume \\ref/assume the section \\ref/g' \
| sed 's/in the \\ref/in the chapter \\ref/g' \
| sed 's/in \\ref/in the paragraph \\ref/3;P;D' \
| sed 's/in \\ref/in the section \\ref/2;P;D' \
| sed 's/in \\ref/in the chapter \\ref/g' \
| sed 's/to \\ref/to the chapter \\ref/g' \
| sed 's/from \\ref/from the chapter \\ref/g' \
| sed 's/see \\ref/see the chapter \\ref/g' \
| sed 's/see~\\ref/see the chapter~\\ref/g' \
| sed 's/by \\ref/by the expression \\ref/g' \
| sed 's/By \\ref/By the expression \\ref/g' \
| sed 's/to \\ref/to the expression \\ref/g' \
| sed 's/in~\\ref/in the chapter \\ref/g' \
| sed 's/of~\\ref/of the chapter \\ref/g' \
| sed 's/In \\ref/In the paragraph \\ref/g' \
| sed 's/In~\\ref/In the paragraph \\ref/g' \
| sed 's/The \\ref/The reference \\ref/g' \
| sed 's/of \\ref/of the link \\ref/g' \
| sed 's/\. \\ref/\. The chapters \\ref/g' \
| sed 's/\, \\ref/\, the section \\ref/g' \
| sed 's/for instance~\\cite/for instance the reference~\\cite/5;P;D' \
| sed 's/in~\\cite/in the reference~\\cite/4;P;D' \
| sed 's/in~\\cite/in the book~\\cite/3;P;D' \
| sed 's/in~\\cite/on the website~\\cite/2;P;D' \
| sed 's/in~\\cite/in the article~\\cite/g' \
| sed 's/see~\\cite/see the reference~\\cite/4;P;D' \
| sed 's/see~\\cite/see the book~\\cite/3;P;D' \
| sed 's/see~\\cite/see the book~\\cite/2;P;D' \
| sed 's/see~\\cite/see the article~\\cite/g' \
| sed 's/c.f.~\\cite/c.f. the article~\\cite/g' \
| sed 's/In~\\cite/In the book~\\cite/g' \
| sed 's/from~\\cite/from the dataset~\\cite/g' \
| sed 's/From~\\cite/From the dataset~\\cite/g' \
| sed 's/using~\\cite/using the dataset~\\cite/g' \
| sed 's/Using~\\cite/Using the dataset~\\cite/g' \
| sed 's/and~\\cite/and the dataset~\\cite/g' \
| sed 's/And~\\cite/And the dataset~\\cite/g' \
| sed 's/following~\\cite/following the previous work~\\cite/g' \
| sed 's/Following~\\cite/Following the previous work~\\cite/g' \
| sed 's/by~\\cite/by the paper~\\cite/g' \
| sed 's/By~\\cite/By the paper~\\cite/g' \
| sed 's/of~\\cite/of the link~\\cite/g' \
| sed 's/and~\\cite/and in the literature~\\cite/g' \
| sed 's/with~\\cite/with the reference~\\cite/g' \
| sed 's/to~\\cite/to the reference~\\cite/g' \
| sed 's/e.g.,~\\cite/e.g., the reference \\cite/g' \
| sed 's/\[Proof/\[proof/g' \
| perl -p0e "s/\\\\item/-/gs" \
| perl -p0e "s/\\\\label{(.*?)}//gs" \
| perl -p0e "s/(\\\\begin{equation})(.*?)(?:(\.)(.*?\\\\end{equation})|(\\\\end{equation}))/\1\2\3\4\5\3/gs" \
| perl -p0e "s/(\\\\begin{align})(.*?)(?:(\.)(.*?\\\\end{align})|(\\\\end{align}))/\1\2\3\4\5\3/gs" \
| sed 's/\\begin{equation}/the mathematical equation\\begin{equation}/g' \
| sed 's/\\begin{align}/the mathematical equation\\begin{align}/g' \
| detex -n -r -l -e "algorithm,align,aligned,array,bmatrix,displaymath,eqnarray,equation,floatfig,floating,longtable,picture,pmatrix,psfrags,pspicture,smallmatrix,smallpmatrix,tabular,table,tikzpicture,verbatim,vmatrix,wrapfigure,lstlisting"\
| sed 's/noun/X/g' \
| sed 's/ / /g' \
| sed 's/ \./\./g' \
| sed 's/ ,/,/g' \
| sed 's/ )/)/g' \
| sed 's/ :/:/g' \
| sed 's/^[ ]*//g' \
| sed 's/[[:space:]]the mathematical equation[[:space:]]/the mathematical equation/g' \
| sed -e 's/[[:space:]]*$//' \
| sed '/^$/N;/^\n$/D'