7 from utils.io
import EOL
8 from common.defs
import VERNACULAR, ENGLISH, NATIONAL, REGIONAL
11 partOfSpeech_tex = dict({
15 "affirmative particle" :
"affm",
20 "comparative particle" :
"cmpar",
21 "conditional particle" :
"cond",
22 "conjunction" :
"cnj",
23 "coordinating conjunction" :
"lnk",
24 "declarative punctuation" :
"decl",
25 "demonstrative determiner" :
"dem",
27 "existential pronoun" :
"exist",
29 "impersonal verb" :
"vimp",
30 "interjection" :
"intj",
31 "interrogative determiner" :
"int",
32 "interrogative particle" :
"q",
33 "intransitive verb" :
"vi",
36 "negative particle" :
"neg",
40 "participle adjective" :
"part",
41 "possessive pronoun" :
"poss",
42 "possessive relative pronoun" :
"possr",
43 "postposition" :
"post",
44 "preposition" :
"prep",
45 "presentative pronoun" :
"loc",
47 "proper noun" :
"propn",
48 "reciprocal pronoun" :
"rec",
49 "reflexive determiner" :
"rflx",
50 "reflexive verb" :
"vr",
51 "relative determiner" :
"rel",
53 "transitive verb" :
"vt",
58 paradigmLabel_tex = dict({
62 def lmf_to_tex(lexical_entry, font=None, partOfSpeech_mapping=partOfSpeech_tex, languages=[VERNACULAR, ENGLISH, NATIONAL, REGIONAL]):
63 """! @brief Function to convert LMF lexical entry information to be written into LaTeX commands.
64 @param lexical_entry The Lexical Entry LMF instance to display.
65 @param font A Python dictionary describing fonts to use for different languages.
66 @param partOfSpeech_mapping A Python dictionary giving abbreviations for LMF part of speech values.
67 @param languages A list of languages to consider for LaTeX layout (all by default).
68 @return A string representing the lexical entry in LaTeX format.
70 import output.tex
as tex
73 font = config.xml.font
76 tex_entry += tex.format_lexeme(lexical_entry, font)
78 tex_entry += tex.format_audio(lexical_entry, font)
80 tex_entry += tex.format_part_of_speech(lexical_entry, font, mapping=partOfSpeech_mapping)
82 senses = lexical_entry.get_senses()
83 senses.sort(key=
lambda sense: sense.get_senseNumber(integer=
True))
85 if sense.get_senseNumber()
is not None:
86 tex_entry += sense.get_senseNumber() +
") "
88 tex_entry += tex.format_definitions(sense, font, languages)
90 tex_entry += tex.format_lt(sense, font)
91 tex_entry += tex.format_sc(sense, font)
92 tex_entry += tex.format_rf(sense, font)
94 tex_entry += tex.format_examples(sense, font)
96 tex_entry += tex.format_usage_notes(sense, font)
98 tex_entry += tex.format_encyclopedic_informations(sense, font)
100 tex_entry += tex.format_restrictions(sense, font)
102 tex_entry += tex.format_lexical_functions(lexical_entry, font)
104 tex_entry += tex.format_related_forms(lexical_entry, font)
106 tex_entry += tex.format_variant_forms(lexical_entry, font)
108 tex_entry += tex.format_borrowed_word(lexical_entry, font)
110 tex_entry += tex.format_etymology(lexical_entry, font)
112 tex_entry += tex.format_paradigms(lexical_entry, font)
114 tex_entry += tex.format_table(lexical_entry, font)
116 tex_entry += tex.format_semantic_domains(lexical_entry, font)
118 tex_entry += tex.format_bibliography(lexical_entry, font)
120 tex_entry += tex.format_picture(lexical_entry, font)
122 tex_entry += tex.format_notes(lexical_entry, font)
124 tex_entry += tex.format_source(lexical_entry, font)
126 tex_entry += tex.format_status(lexical_entry, font)
128 tex_entry += tex.format_date(lexical_entry, font)
130 tex_entry = tex.handle_reserved(tex_entry)
131 tex_entry = tex.handle_quotes(tex_entry)
132 tex_entry = tex.handle_fv(tex_entry, font)
133 tex_entry = tex.handle_fn(tex_entry, font)
135 tex_entry = tex.handle_pinyin(tex_entry)
136 tex_entry = tex.handle_caps(tex_entry)
137 return tex_entry + EOL
def lmf_to_tex
Function giving order in which information must be written in LaTeX and mapping between LMF represent...