7 from config.tex
import lmf_to_tex, partOfSpeech_tex
8 from config.mdf
import mdf_semanticRelation, pd_grammaticalNumber, pd_person, pd_anymacy, pd_clusivity
9 from utils.io
import open_read, open_write, EOL, ENCODING
10 from utils.error_handling
import OutputError, Warning
11 from common.defs
import VERNACULAR, ENGLISH, NATIONAL, REGIONAL
17 """! @brief Read file contents.
18 @param filename The name of the file with full path containing information to read, for instance the LaTeX header of the document: 'user/config/header.tex'.
19 @return A Python string containing read information.
22 if filename
is not None:
24 contents = file.read()
29 """! @brief Insert references to paradigms.
30 @param lexical_entry The targeted Lexical Entry LMF instance.
31 @return A string representing the references in LaTeX format.
34 part_of_speech = lexical_entry.get_partOfSpeech()
35 spelling_variant =
None
36 if len(lexical_entry.get_spelling_variants()) != 0:
37 spelling_variant = lexical_entry.get_spelling_variants()[0]
38 if spelling_variant
is None:
40 main_entry = lexical_entry.get_main_entry()
41 if main_entry
is not None:
42 if len(main_entry.get_spelling_variants()) != 0:
43 spelling_variant = main_entry.get_spelling_variants()[0]
44 if spelling_variant
is not None:
45 if part_of_speech ==
"transitive verb":
46 text +=
"\\hfill\\break See: \\ref{" + spelling_variant +
".vt}" + EOL
47 text +=
"\\ref{" + spelling_variant +
".vt.eng}" + EOL
48 elif part_of_speech ==
"intransitive verb":
49 text +=
"\\hfill\\break See: \\ref{" + spelling_variant +
".vi}" + EOL
50 text +=
"\\ref{" + spelling_variant +
".vi.eng}" + EOL
51 elif part_of_speech ==
"reflexive verb":
52 text +=
"\\hfill\\break See: \\ref{" + spelling_variant +
".vr}" + EOL
53 text +=
"\\ref{" + spelling_variant +
".vr.eng}" + EOL
56 def tex_write(object, filename, preamble=None, introduction=None, lmf2tex=lmf_to_tex, font=None, items=lambda lexical_entry: lexical_entry.get_lexeme(), sort_order=
None, paradigms=[], tables=[], title=
None, tex_language=
None):
57 """! @brief Write a LaTeX file.
58 Note that the lexicon must already be ordered at this point. Here, parameters 'items' and 'sort_order' are only used to define chapters.
59 @param object The LMF instance to convert into LaTeX output format.
60 @param filename The name of the LaTeX file to write with full path, for instance 'user/output.tex'.
61 @param preamble The name of the LaTeX file with full path containing the LaTeX header of the document, for instance 'user/config/japhug.tex'. Default value is None.
62 @param introduction The name of the LaTeX file with full path containing the LaTeX introduction of the document, for instance 'user/config/introduction.tex'. Default value is None.
63 @param lmf2tex A function giving the mapping from LMF representation information that must be written to LaTeX commands, in a defined order. Default value is 'lmf_to_tex' function defined in 'pylmflib/config/tex.py'. Please refer to it as an example.
64 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
65 @param items Lambda function giving the item to sort. Default value is 'lambda lexical_entry: lexical_entry.get_lexeme()', which means that the items to sort are lexemes.
66 @param sort_order Default value is 'None', which means that the LaTeX output is alphabetically ordered.
67 @param paradigms A Python list of LaTeX filenames with full path containing the paradigms in LaTeX format. Default value is an empty list.
68 @param tables The name of the LaTeX file with full path containing some notes to add at the end of the LaTeX document, for instance 'user/config/conclusion.tex'. Default value is None.
69 @param title A Python string containing the title of the LaTeX document. Default value is None.
70 @param tex_language A Python string giving the default language to set in LaTeX.
75 font = config.xml.font
81 tex_file.write(
"\\title{" + title +
"}" + EOL)
82 if tex_language
is not None:
83 tex_file.write(
"\setdefaultlanguage{" + tex_language +
"}" + EOL)
85 tex_file.write(EOL +
"\\begin{document}" + EOL)
86 tex_file.write(
"\\maketitle" + EOL)
87 tex_file.write(
"\\newpage" + EOL)
89 if introduction
is not None:
90 tex_file.write(
"\\markboth{INTRODUCTION}{}" + EOL * 2)
93 tex_file.write(EOL +
"\\def\\mytextsc{\\bgroup\\obeyspaces\\mytextscaux}" + EOL)
94 tex_file.write(
"\\def\\mytextscaux#1{\\mytextscauxii #1\\relax\\relax\\egroup}" + EOL)
95 tex_file.write(
"\\def\\mytextscauxii#1{%" + EOL)
96 tex_file.write(
"\\ifx\\relax#1\\else \\ifcat#1\\@sptoken{} \\expandafter\\expandafter\\expandafter\\mytextscauxii\\else" + EOL)
97 tex_file.write(
"\\ifnum`#1=\\uccode`#1 {\\normalsize #1}\\else {\\footnotesize \\uppercase{#1}}\\fi \\expandafter\\expandafter\\expandafter\\mytextscauxii\\expandafter\\fi\\fi}" + EOL * 2)
99 tex_file.write(
"\\setlength\\parindent{0cm}" + EOL)
102 audio_path = config.xml.audio_path
103 graphic_path = os.path.abspath(
'.')
104 if os.name !=
'posix':
106 audio_path = audio_path.replace(
"\\",
"/")
107 graphic_path = graphic_path.replace(
"\\",
"/")
108 tex_file.write(EOL +
"\\addmediapath{" + audio_path.rstrip(
"/") +
"}" + EOL)
109 tex_file.write(
"\\addmediapath{" + audio_path +
"mp3}" + EOL)
110 tex_file.write(
"\\addmediapath{" + audio_path +
"wav}" + EOL)
111 tex_file.write(
"\\graphicspath{{" + graphic_path +
"/pylmflib/output/img/}}" + EOL * 2)
113 tex_file.write(
"\\newpage" + EOL)
114 tex_file.write(
"\\begin{multicols}{2}" + EOL * 2)
115 if sort_order
is None:
117 sort_order = dict([(c, ord(c))
for c
in string.lowercase])
118 up = dict([(c, ord(c) + 32)
for c
in string.uppercase])
119 sort_order.update(up)
120 sort_order.update({
'':0,
' ':0})
122 if object.__class__.__name__ ==
"LexicalResource":
123 for lexicon
in object.get_lexicons():
124 previous_character =
''
125 current_character =
''
127 for lexical_entry
in lexicon.get_lexical_entries():
129 if lexical_entry.find_related_forms(
"main entry") == []
and lexical_entry.get_independentWord()
is not False:
132 current_character = items(lexical_entry)[0]
133 if sort_order[items(lexical_entry)[0:1]]:
134 current_character = items(lexical_entry)[0:1]
135 if sort_order[items(lexical_entry)[0:2]]:
136 current_character = items(lexical_entry)[0:2]
144 if ( (type(sort_order)
is not type(dict()))
and ((previous_character ==
'')
or (sort_order(current_character) != sort_order(previous_character))) ) \
145 or ( (type(sort_order)
is type(dict()))
and (int(sort_order[current_character]) != int(sort_order[previous_character])) ):
147 previous_character = current_character
148 tex_file.write(
"\\newpage" + EOL)
150 if type(sort_order)
is not type(dict()):
151 title +=
' ' + font[NATIONAL](current_character)
153 for key,value
in sorted(sort_order.items(), key=
lambda x: x[1]):
154 if int(value) == int(sort_order[current_character]):
155 title +=
' ' + font[VERNACULAR](key)
156 tex_file.write(
"\\section*{\\centering-" +
handle_reserved(title) +
" -}" + EOL)
158 tex_file.write(lmf2tex(lexical_entry, font))
159 if len(paradigms) != 0:
161 tex_file.write(
"\\lhead{\\firstmark}" + EOL)
162 tex_file.write(
"\\rhead{\\botmark}" + EOL)
166 for related_form
in lexical_entry.get_related_forms(
"subentry"):
167 if related_form.get_lexical_entry()
is not None:
168 tex_file.write(lmf2tex(related_form.get_lexical_entry(), font))
169 if len(paradigms) != 0:
174 print Warning(
"Cannot sort item %s" % items(lexical_entry).encode(ENCODING))
179 raise OutputError(object,
"Object to write must be a Lexical Resource.")
181 tex_file.write(
"\end{multicols}" + EOL)
183 for filename
in paradigms:
185 tex_file.write(
"\\newpage" + EOL)
186 tex_file.write(
"\markboth{paradigms}{}" + EOL)
190 for filename
in tables:
192 tex_file.write(
"\\newpage" + EOL)
195 tex_file.write(
"\end{document}" + EOL)
201 """Replace '{xxx}' by '\ipa{xxx}' in 'un', 'xn', 'gn', 'dn', 'en'.
204 pattern =
r"([^\\\|]*){([^}]*)}(.*)"
205 while re.match(pattern, text):
206 text = re.sub(pattern,
r"\1" +
r"\\ipa{" +
r"\2" +
"}" +
r"\3", text)
210 """ Handle reserved characters $ & % # _ ^ except \ { }.
212 if text.find(
"$") != -1:
213 text = text.replace(
'$',
'\$')
215 if text.find(
"\\dollar") != -1:
216 text = text.replace(
"\\dollar",
'$')
217 if text.find(
"& ") != -1:
218 text = text.replace(
'& ',
'\& ')
219 if text.find(
"%") != -1:
220 text = text.replace(
'%',
'\%')
221 if text.find(
"#") != -1:
222 text = text.replace(
'#',
'\#')
223 if text.find(
"_") != -1:
224 text = text.replace(
'_',
"\string_")
225 if text.find(
"^") != -1:
226 text = text.replace(
'^',
"U+005E")
230 """Replace 'fi:xxx' and '|fi{xxx}' by \\textit{xxx}.
233 if text.find(
"fi:") != -1:
234 pattern =
r"(\w*)fi:([^\s\.,)]*)(\w*)"
235 text = re.sub(pattern,
r"\1" +
r"\\textit{" +
r"\2" +
"}" +
r"\3", text)
236 if text.find(
"|fi{") != -1:
237 pattern =
r"(\w*)\|fi{([^}]*)}(\w*)"
238 text = re.sub(pattern,
r"\1" +
r"\\textit{" +
r"\2" +
"}" +
r"\3", text)
242 """Replace 'fv:xxx' and '|fv{xxx}' by font[VERNACULAR](xxx).
245 if text.find(
"fv:") != -1:
247 pattern =
r"(\w*)fv:([^\s\.,)]*)(\w*)"
248 text = re.sub(pattern,
r"\1" +
r"%s" % font[VERNACULAR](
r"\2").replace(
'\\',
r'\\').replace(
r'\\2',
r"\2") +
r"\3", text)
249 if text.find(
"|fv{") != -1:
250 pattern =
r"(\w*)\|fv{([^}]*)}(\w*)"
251 text = re.sub(pattern,
r"\1" +
r"%s" % font[VERNACULAR](
r"\2").replace(
'\\',
r'\\').replace(
r'\\2',
r"\2") +
r"\3", text)
255 """Replace 'fn:xxx' and '|fn{xxx}' by font[NATIONAL](xxx).
258 if text.find(
"fn:") != -1:
259 pattern =
r"(\w*)fn:([^\s\.,)]*)(\w*)"
260 text = re.sub(pattern,
r"\1" +
r"%s" % font[NATIONAL](
r"\2").replace(
'\\',
r'\\').replace(
r'\\2',
r"\2") +
r"\3", text)
261 if text.find(
"|fn{") != -1:
262 pattern =
r"(\w*)\|fn{([^}]*)}(\w*)"
263 text = re.sub(pattern,
r"\1" +
r"%s" % font[NATIONAL](
r"\2").replace(
'\\',
r'\\').replace(
r'\\2',
r"\2") +
r"\3", text)
267 """Replace '@xxx' by '\\textcolor{gray}{xxx}' in 'lx', 'dv', 'xv' fields (already in API).
270 if text.find(
"@") != -1:
271 text = re.sub(
r"(\w*)@(\w*)",
r"\1" +
r"\\textcolor{gray}{" +
r"\2" +
"}", text)
275 """Handle small caps.
276 Replace '°xxx' by '\textsc{xxx}' in translated examples.
279 if text.encode(
"utf8").find(
"°") != -1:
281 text = re.sub(
r"(\w*)°([^\s\.,)+/:\#\_]*)(\w*)",
r"\1" +
r"\\textsc{" +
r"\2" +
"}" +
r"\3", text.encode(
"utf8")).decode(
"utf8")
285 """Hanlde quotation marks.
286 Replace each "xxx" by ``xxx".
289 pattern =
r"""^([^\"]*)\"([^\"]*)\".*"""
290 result = re.match(pattern, text)
294 text += result.group(1) +
r"``" + result.group(2) +
"\""
295 end = end.replace(result.group(1) +
"\"" + result.group(2) +
"\"",
"")
296 result = re.match(pattern, end)
303 """! @brief Transform unique identifier of a lexical entry in ASCII format.
304 @param lexical_entry The targeted Lexical Entry LMF instance.
305 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
306 @return A string representing the unique identifier in LaTeX format.
309 text = lexical_entry.get_id()
310 if text.find(
"\\") != -1:
311 text = text.replace(
'\\',
u"£")
312 if text.find(
"{") != -1:
313 text = text.replace(
'{',
'\{')
314 if text.find(
"}") != -1:
315 text = text.replace(
'}',
'\}')
319 """! @brief Display hyperlink to a lexical entry in LaTeX format.
320 @param lexical_entry The targeted Lexical Entry LMF instance.
321 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
322 @return A string representing the hyperlink in LaTeX format.
324 result =
"\\hyperlink{" +
format_uid(lexical_entry, font) +
"}{" + font[VERNACULAR](lexical_entry.get_lexeme())
325 if lexical_entry.get_homonymNumber()
is not None:
326 result +=
" \\textsubscript{" + str(lexical_entry.get_homonymNumber()) +
"}"
331 """! @brief 'lx', 'hm' and 'lc' fields are flipped if 'lc' field has data.
332 @param lexical_entry The current Lexical Entry LMF instance.
333 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
334 @return A string representing lexeme in LaTeX format.
337 lexeme = font[VERNACULAR](lexical_entry.get_lexeme())
338 if lexical_entry.is_subentry():
339 result +=
"\\subparagraph{\\dollar\\blacksquare\\dollar "
341 result +=
"\\paragraph{\\hspace{-0.5cm} "
342 if lexical_entry.get_homonymNumber()
is not None:
344 lexeme +=
" \\textsubscript{" + str(lexical_entry.get_homonymNumber()) +
"}"
345 if lexical_entry.get_contextual_variations()
is not None and len(lexical_entry.get_contextual_variations()) != 0:
347 for var
in lexical_entry.get_contextual_variations():
348 result +=
" " + font[VERNACULAR](var)
349 result +=
" (from: " + lexeme +
")."
353 result +=
"} \\hypertarget{" +
format_uid(lexical_entry, font) +
"}{}" + EOL
354 if not lexical_entry.is_subentry():
355 result +=
"\markboth{" + lexeme +
"}{}" + EOL
359 """! @brief Embed sound file into PDF.
360 @param lexical_entry The current Lexical Entry LMF instance.
361 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
362 @return A string embedding sound in LaTeX format.
365 from os.path
import basename, isfile
367 from pylmflib
import options
370 if not options.audio:
372 for form_representation
in lexical_entry.get_form_representations():
373 if form_representation.get_audio()
is not None:
377 file_name = form_representation.get_audio().get_fileName().replace(
".wav",
".mp3")
379 if os.name ==
'posix':
381 file_path.append(config.xml.audio_path + file_name)
382 file_path.append(config.xml.audio_path +
"mp3/" + file_name)
383 file_path.append(config.xml.audio_path +
"wav/" + file_name)
386 audio_path = config.xml.audio_path.replace(
"/",
"\\")
387 file_path.append(audio_path + file_name)
388 file_path.append(audio_path +
"mp3\\" + file_name)
389 file_path.append(audio_path +
"wav\\" + file_name)
391 for audio_file
in file_path:
392 if isfile(audio_file):
396 print Warning(
"Sound file '%s' encountered for lexeme '%s' does not exist" % (file_name.encode(ENCODING), lexical_entry.get_lexeme().encode(ENCODING)))
398 file_name = file_name.replace(
'-',
'\string-')
399 result +=
"\includemedia[" + EOL +\
400 "\taddresource=" + file_name +
"," + EOL +\
401 "\tflashvars={" + EOL +\
402 "\t\tsource=" + file_name + EOL +\
403 "\t\t&autoPlay=true" + EOL +\
404 "\t\t&autoRewind=true" + EOL +\
405 "\t\t&loop=false" + EOL +\
406 "\t\t&hideBar=true" + EOL +\
407 "\t\t&volume=1.0" + EOL +\
408 "\t\t&balance=0.0" + EOL +\
409 "}]{\includegraphics[scale=0.5]{sound.jpg}}{APlayer.swf}"
411 result +=
" \\hspace{0.1cm}" + EOL
415 """! @brief Display part of speech in LaTeX format.
416 @param lexical_entry The current Lexical Entry LMF instance.
417 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
418 @param mapping A Python dictionary giving the mapping between LMF part of speech LexicalEntry attribute value and LaTeX layout.
419 @param language Language to consider to display part of speech.
420 @return A string representing part of speech in LaTeX format.
423 if lexical_entry.get_partOfSpeech()
is not None:
426 result +=
"\\textit{" + mapping[lexical_entry.get_partOfSpeech()] +
"}. "
428 result +=
"\\textit{" + mapping[(language, lexical_entry.get_partOfSpeech())] +
"}. "
430 print Warning(
"Part of speech value '%s' encountered for lexeme '%s' is not defined in configuration" % (lexical_entry.get_partOfSpeech().encode(ENCODING), lexical_entry.get_lexeme().encode(ENCODING)))
434 """! @brief Glosses are supplanted by definitions.
435 @param sense The current Sense LMF instance.
436 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
437 @param languages A list of languages to consider for definitions and glosses (all by default).
438 @return A string representing glosses and definitions in LaTeX format.
441 if languages
is None:
442 languages = [config.xml.vernacular, config.xml.English, config.xml.national, config.xml.regional]
443 for language
in languages:
444 if len(sense.find_definitions(language)) != 0:
445 for definition
in sense.find_definitions(language):
446 if language == config.xml.vernacular:
447 result += font[VERNACULAR](definition) +
". "
448 elif language == config.xml.national:
449 result += font[NATIONAL](
handle_font(definition)) +
". "
450 elif language == config.xml.regional:
451 result +=
"\\textit{[Regnl: " + font[REGIONAL](definition) +
"]}. "
453 result += definition +
". "
454 elif len(sense.find_glosses(language)) != 0:
455 for gloss
in sense.find_glosses(language):
456 if language == config.xml.vernacular:
457 result += font[VERNACULAR](gloss) +
". "
458 elif language == config.xml.national:
459 result += font[NATIONAL](
handle_font(gloss)) +
". "
460 elif language == config.xml.regional:
461 result +=
"\\textit{[Regnl: " + font[REGIONAL](gloss) +
"]}. "
463 result += gloss +
". "
464 if len(sense.get_translations(language)) != 0:
465 for translation
in sense.get_translations(language):
466 if language == config.xml.national:
467 result += font[NATIONAL](translation) +
". "
468 elif language == config.xml.regional:
469 result +=
"\\textbf{rr:}\\textit{[Regnl: " + translation +
"]}. "
471 result += translation +
". "
475 """! @brief Display 'lt' in LaTeX format.
476 @param sense The current Sense LMF instance.
477 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
478 @return A string representing 'lt' in LaTeX format.
484 """! @brief Display 'sc' in LaTeX format.
485 @param sense The current Sense LMF instance.
486 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
487 @return A string representing 'sc' in LaTeX format.
493 """! @brief Display 'rf' in LaTeX format.
494 @param lexical_entry The current Sense LMF instance.
495 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
496 @return A string representing 'rf' in LaTeX format.
502 """! @brief Display examples in LaTeX format.
503 @param sense The current Sense LMF instance.
504 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
505 @param languages A list of languages to consider for examples (all by default).
506 @return A string representing examples in LaTeX format.
509 if languages
is None:
510 languages = [config.xml.vernacular, config.xml.English, config.xml.national, config.xml.regional]
511 for context
in sense.get_contexts():
513 for language
in languages:
514 for example
in context.find_written_forms(language):
515 if language == config.xml.vernacular:
516 tmp +=
"\\sn " + font[VERNACULAR](example) + EOL
517 elif language == config.xml.national:
518 tmp +=
"\\trans \\textit{" + font[NATIONAL](
handle_font(example)) +
"}" + EOL
519 elif language == config.xml.regional:
520 tmp +=
"\\trans \\textit{[" + font[REGIONAL](example) +
"]}" + EOL
522 tmp +=
"\\trans " + example + EOL
525 result +=
"\\begin{exe}" + EOL + tmp +
"\\end{exe}" + EOL
529 """! @brief Display usage notes in LaTeX format.
530 @param sense The current Sense LMF instance.
531 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
532 @return A string representing usage notes in LaTeX format.
535 for usage
in sense.find_usage_notes(language=config.xml.vernacular):
536 result +=
"\\textit{VerUsage:} " + font[VERNACULAR](usage) +
" "
537 for usage
in sense.find_usage_notes(language=config.xml.English):
538 result +=
"\\textit{Usage:} " + usage +
" "
539 for usage
in sense.find_usage_notes(language=config.xml.national):
540 result +=
"\\textit{" + font[NATIONAL](
handle_font(usage)) +
"} "
541 for usage
in sense.find_usage_notes(language=config.xml.regional):
542 result +=
"\\textit{[" + font[REGIONAL](usage) +
"]} "
546 """! @brief Display encyclopedic informations in LaTeX format.
547 @param sense The current Sense LMF instance.
548 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
549 @return A string representing encyclopedic informations in LaTeX format.
552 for information
in sense.find_encyclopedic_informations(language=config.xml.vernacular):
553 result += font[VERNACULAR](information) +
" "
554 for information
in sense.find_encyclopedic_informations(language=config.xml.English):
555 result += information +
" "
556 for information
in sense.find_encyclopedic_informations(language=config.xml.national):
557 result += font[NATIONAL](
handle_font(information)) +
" "
558 for information
in sense.find_encyclopedic_informations(language=config.xml.regional):
559 result +=
"\\textit{[" + font[REGIONAL](information) +
"]} "
563 """! @brief Display restrictions in LaTeX format.
564 @param sense The current Sense LMF instance.
565 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
566 @return A string representing restrictions in LaTeX format.
569 for restriction
in sense.find_restrictions(language=config.xml.vernacular):
570 result +=
"\\textit{VerRestrict:} " + font[VERNACULAR](restriction) +
" "
571 for restriction
in sense.find_restrictions(language=config.xml.English):
572 result +=
"\\textit{Restrict:} " + restriction +
" "
573 for restriction
in sense.find_restrictions(language=config.xml.national):
574 result +=
"\\textit{" + font[NATIONAL](restriction) +
"} "
575 for restriction
in sense.find_restrictions(language=config.xml.regional):
576 result +=
"\\textit{[" + font[REGIONAL](restriction) +
"]} "
580 """! @brief Display lexical functions in LaTeX format.
581 @param lexical_entry The current Lexical Entry LMF instance.
582 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
583 @return A string representing lexical functions in LaTeX format.
593 """! @brief Display related forms in LaTeX format.
594 @param lexical_entry The current Lexical Entry LMF instance.
595 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
596 @return A string representing related forms in LaTeX format.
599 for related_form
in lexical_entry.get_related_forms(mdf_semanticRelation[
"sy"]):
600 result +=
"\\textit{Syn:} "
601 if related_form.get_lexical_entry()
is not None:
602 result +=
format_link(related_form.get_lexical_entry(), font)
604 result += font[VERNACULAR](related_form.get_lexeme())
606 for related_form
in lexical_entry.get_related_forms(mdf_semanticRelation[
"an"]):
607 result +=
"\\textit{Ant:} "
608 if related_form.get_lexical_entry()
is not None:
609 result +=
format_link(related_form.get_lexical_entry(), font)
611 result += font[VERNACULAR](related_form.get_lexeme())
613 for morphology
in lexical_entry.get_morphologies():
614 result +=
"\\textit{Morph:} " + font[VERNACULAR](morphology) +
". "
615 for related_form
in lexical_entry.get_related_forms(mdf_semanticRelation[
"cf"]):
616 result +=
"\\textit{See:} "
617 if related_form.get_lexical_entry()
is not None:
618 result +=
format_link(related_form.get_lexical_entry(), font)
620 result += font[VERNACULAR](related_form.get_lexeme())
629 """! @brief Display variant forms in LaTeX format.
630 @param lexical_entry The current Lexical Entry LMF instance.
631 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
632 @return A string representing variant forms in LaTeX format.
635 for form_representation
in lexical_entry.get_form_representations():
636 if form_representation.get_variantForm()
is not None:
637 result +=
"\\textit{Variant:} " + font[VERNACULAR](form_representation.get_variantForm()) +
" "
638 if form_representation.get_comment(config.xml.English)
is not None:
639 result +=
"(" + form_representation.get_comment(config.xml.English) +
") "
640 if form_representation.get_comment(config.xml.national)
is not None:
641 result +=
"(" + font[NATIONAL](form_representation.get_comment(config.xml.national)) +
") "
642 if form_representation.get_comment(config.xml.regional)
is not None:
643 result +=
"(" + font[REGIONAL](form_representation.get_comment(config.xml.regional)) +
") "
647 """! @brief Display borrowed word in LaTeX format.
648 @param lexical_entry The current Lexical Entry LMF instance.
649 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
650 @return A string representing borrowed word in LaTeX format.
653 if lexical_entry.get_borrowed_word()
is not None:
654 result +=
"\\textit{From:} " + lexical_entry.get_borrowed_word()
655 if lexical_entry.get_written_form()
is not None:
656 result +=
" " + lexical_entry.get_written_form()
661 """! @brief Display etymology in LaTeX format.
662 @param lexical_entry The current Lexical Entry LMF instance.
663 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
664 @return A string representing etymology in LaTeX format.
667 if lexical_entry.get_etymology()
is not None:
668 result +=
"\\textit{Etym:} \\textbf{" + lexical_entry.get_etymology() +
"} "
669 if lexical_entry.get_etymology_gloss()
is not None:
670 result +=
u"\u2018" + lexical_entry.get_etymology_gloss() +
u"\u2019" +
". "
674 """! @brief Display all paradigms in LaTeX format.
675 @param lexical_entry The current Lexical Entry LMF instance.
676 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
677 @return A string representing all paradigms in LaTeX format.
680 for paradigm
in lexical_entry.find_paradigms():
681 result +=
"\\textit{Prdm:} \\textbf{" + paradigm +
"}. "
682 for paradigm
in lexical_entry.find_paradigms(grammatical_number=pd_grammaticalNumber[
"sg"]):
683 result +=
"\\textit{Sg:} \\textbf{" + paradigm +
"} "
684 for paradigm
in lexical_entry.find_paradigms(grammatical_number=pd_grammaticalNumber[
"pl"]):
685 result +=
"\\textit{Pl:} \\textbf{" + paradigm +
"} "
687 for paradigm
in lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber[
's']):
688 result +=
"\\textit{1s:} \\textbf{" + paradigm +
"} "
689 for paradigm
in lexical_entry.find_paradigms(person=pd_person[2], grammatical_number=pd_grammaticalNumber[
's']):
690 result +=
"\\textit{2s:} \\textbf{" + paradigm +
"} "
691 for paradigm
in lexical_entry.find_paradigms(person=pd_person[3], grammatical_number=pd_grammaticalNumber[
's']):
692 result +=
"\\textit{3s:} \\textbf{" + paradigm +
"} "
693 for paradigm
in lexical_entry.find_paradigms(anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber[
's']):
694 result +=
"\\textit{3sn:} \\textbf{" + paradigm +
"} "
695 for paradigm
in lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber[
'd']):
696 result +=
"\\textit{1d:} \\textbf{" + paradigm +
"} "
697 for paradigm
in lexical_entry.find_paradigms(person=pd_person[2], grammatical_number=pd_grammaticalNumber[
'd']):
698 result +=
"\\textit{2d:} \\textbf{" + paradigm +
"} "
699 for paradigm
in lexical_entry.find_paradigms(person=pd_person[3], grammatical_number=pd_grammaticalNumber[
'd']):
700 result +=
"\\textit{3d:} \\textbf{" + paradigm +
"} "
701 for paradigm
in lexical_entry.find_paradigms(anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber[
'd']):
702 result +=
"\\textit{3dn:} \\textbf{" + paradigm +
"} "
703 for paradigm
in lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber[
'p']):
704 result +=
"\\textit{1p:} \\textbf{" + paradigm +
"} "
705 for paradigm
in lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber[
'p'], clusivity=pd_clusivity[
'e']):
706 result +=
"\\textit{1px:} \\textbf{" + paradigm +
"} "
707 for paradigm
in lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber[
'p'], clusivity=pd_clusivity[
'i']):
708 result +=
"\\textit{1pi:} \\textbf{" + paradigm +
"} "
709 for paradigm
in lexical_entry.find_paradigms(person=pd_person[2], grammatical_number=pd_grammaticalNumber[
'p']):
710 result +=
"\\textit{2p:} \\textbf{" + paradigm +
"} "
711 for paradigm
in lexical_entry.find_paradigms(person=pd_person[3], grammatical_number=pd_grammaticalNumber[
'p']):
712 result +=
"\\textit{3p:} \\textbf{" + paradigm +
"} "
713 for paradigm
in lexical_entry.find_paradigms(anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber[
'p']):
714 result +=
"\\textit{3pn:} \\textbf{" + paradigm +
"} "
718 """! @brief Display a table in LaTeX format.
719 @param lexical_entry The current Lexical Entry LMF instance.
720 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
721 @return A string representing a table in LaTeX format.
726 """! @brief Display semantic domains in LaTeX format.
727 @param lexical_entry The current Lexical Entry LMF instance.
728 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
729 @return A string representing semantic domains in LaTeX format.
732 for semantic_domain
in lexical_entry.get_semantic_domains():
733 result +=
"\\textit{SD:} " + semantic_domain +
". "
741 """! @brief Display bibliography in LaTeX format.
742 @param lexical_entry The current Lexical Entry LMF instance.
743 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
744 @return A string representing bibliography in LaTeX format.
747 if lexical_entry.get_bibliography()
is not None:
748 result +=
"\\textit{Read:} " + lexical_entry.get_bibliography() +
". "
752 """! @brief Display a picture in LaTeX format.
753 @param lexical_entry The current Lexical Entry LMF instance.
754 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
755 @return A string representing a picture in LaTeX format.
761 """! @brief Display all notes in LaTeX format.
762 @param lexical_entry The current Lexical Entry LMF instance.
763 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
764 @return A string representing all notes in LaTeX format.
767 for note
in lexical_entry.find_notes(type=
"general"):
768 result +=
"\\textit{[Note: " + note +
"]} "
769 for note
in lexical_entry.find_notes(type=
"phonology"):
770 result +=
"\\textit{[Phon: " + note +
"]} "
771 for note
in lexical_entry.find_notes(type=
"grammar"):
772 result +=
"\\textit{[Gram: " + note +
"]} "
773 for note
in lexical_entry.find_notes(type=
"discourse"):
774 result +=
"\\textit{[Disc: " + note +
"]} "
775 for note
in lexical_entry.find_notes(type=
"anthropology"):
776 result +=
"\\textit{[Ant: " + note +
"]} "
777 for note
in lexical_entry.find_notes(type=
"sociolinguistics"):
778 result +=
"\\textit{[Socio: " + note +
"]} "
779 for note
in lexical_entry.find_notes(type=
"question"):
780 result +=
"\\textit{[Ques: " + note +
"]} "
784 """! @brief Display source in LaTeX format.
785 @param lexical_entry The current Lexical Entry LMF instance.
786 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
787 @return A string representing source in LaTeX format.
793 """! @brief Display status in LaTeX format.
794 @param lexical_entry The current Lexical Entry LMF instance.
795 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
796 @return A string representing status in LaTeX format.
799 if lexical_entry.get_status()
is not None:
800 result +=
"\\textit{Status:} " + lexical_entry.get_status()
804 """! @brief Do not display date in LaTeX format.
805 @param lexical_entry The current Lexical Entry LMF instance.
806 @param font A Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
807 @return An empty string.
def format_notes
Display all notes in LaTeX format.
def format_audio
Embed sound file into PDF.
def format_restrictions
Display restrictions in LaTeX format.
def format_variant_forms
Display variant forms in LaTeX format.
def format_link
Display hyperlink to a lexical entry in LaTeX format.
def format_status
Display status in LaTeX format.
def open_read
Open file in read mode (automatically decode file in unicode).
def format_bibliography
Display bibliography in LaTeX format.
def format_lexical_functions
Display lexical functions in LaTeX format.
def file_read
Read file contents.
def format_picture
Display a picture in LaTeX format.
def format_etymology
Display etymology in LaTeX format.
def format_uid
Functions to process LaTeX fields (output)
def format_lexeme
'lx', 'hm' and 'lc' fields are flipped if 'lc' field has data.
def format_usage_notes
Display usage notes in LaTeX format.
def format_examples
Display examples in LaTeX format.
def format_encyclopedic_informations
Display encyclopedic informations in LaTeX format.
def format_related_forms
Display related forms in LaTeX format.
def format_paradigms
Display all paradigms in LaTeX format.
def open_write
Open file in write mode (automatically decode file in unicode).
def insert_references
Insert references to paradigms.
def format_source
Display source in LaTeX format.
def format_rf
Display 'rf' in LaTeX format.
def tex_write
Write a LaTeX file.
def handle_font
Functions to process LaTeX layout.
def format_part_of_speech
Display part of speech in LaTeX format.
def format_date
Do not display date in LaTeX format.
def format_definitions
Glosses are supplanted by definitions.
def format_semantic_domains
Display semantic domains in LaTeX format.
def format_lt
Display 'lt' in LaTeX format.
def format_table
Display a table in LaTeX format.
def format_sc
Display 'sc' in LaTeX format.
def format_borrowed_word
Display borrowed word in LaTeX format.