4 """! @package utils.tables
8 from optparse
import OptionParser
9 parser = OptionParser()
10 parser.add_option(
"-i",
"--input", dest=
"input", action=
"store", help=
"input MDF file")
11 parser.add_option(
"-e",
"--output-eng", dest=
"output_eng", action=
"store", help=
"output LaTeX file in English")
12 parser.add_option(
"-f",
"--output-fra", dest=
"output_fra", action=
"store", help=
"output LaTeX file in French")
13 options = parser.parse_args()[0]
17 in_file = open(options.input,
"r", encoding='utf-8')
18 out_eng = open(options.output_eng, "w", encoding=
'utf-8')
19 out_fra = open(options.output_fra,
"w", encoding=
'utf-8')
21 in_file = open(options.input,
"r")
22 out_eng = open(options.output_eng, "w")
23 out_fra = open(options.output_fra,
"w")
27 if os.name ==
'posix':
34 title_eng =
"""Words for which no close equivalent could be found"""
35 introduction_eng =
"""The list that follows groups words for which no close equivalents could be found. These negative pieces of information contain hints about the consultants' Na vocabulary and its 'soft shoulders'."""
36 title_fra =
"""Mots dont aucun équivalent n'a été trouvé"""
37 introduction_fra =
"""Cette liste regroupe les mots dont aucun équivalent n'a été trouvé. Même s'il ne s'agit que d'informations négatives, elles éclairent les limites du vocabulaire na des consultants."""
40 out_eng.write(
"\\section*{\\centering " + title_eng +
"}" + EOL)
41 out_fra.write(
"\\section*{\\centering " + title_fra +
"}" + EOL)
43 out_eng.write(introduction_eng + EOL)
44 out_fra.write(introduction_fra + EOL)
46 out_eng.write(
"\\begin{center}" + EOL)
47 out_fra.write(
"\\begin{center}" + EOL)
48 out_eng.write(
"\\begin{longtable}{r|l}" + EOL)
49 out_fra.write(
"\\begin{longtable}{r|l}" + EOL)
53 pattern =
r"^\\(\w{2,3}) ?(.*)$"
58 for line
in in_file.readlines():
59 result = re.search(pattern, line)
61 if result.group(1) ==
"lx" and result.group(2) ==
"*":
63 elif result.group(1) ==
"ge":
65 ge = result.group(2).replace(
'_',
"\string_")
66 elif result.group(1) ==
"gn":
68 gn = result.group(2).replace(
'_',
"\string_")
69 elif result.group(1) ==
"gf":
71 gf = result.group(2).replace(
'_',
"\string_")
76 out_eng.write(
"\\textcolor{brown}{\zh{" + gn +
"}}")
77 out_fra.write(
"\\textcolor{brown}{\zh{" + gn +
"}}")
78 out_eng.write(
" \\\\" + EOL)
79 out_fra.write(
" \\\\" + EOL)
87 out_eng.write(
"\\end{longtable}")
88 out_fra.write(
"\\end{longtable}")
89 out_eng.write(
"\\end{center}")
90 out_fra.write(
"\\end{center}")