def tex_eng(lexical_entry, font): """<lx> (pronunciation: <lc>; with the copula verb: <lc <type="with copula">>) TAB <ps> TAB Tone: <np <type="tone">>. <df>. <dn>u"\u3002" Local Chinese dialect: <gr>u"\u3002" <xv> <xe> <xn> """ import output.tex as tex tex_entry = "" # Do not display lexical entry if lexeme is '???' or '*' if lexical_entry.get_lexeme() == "???" or lexical_entry.get_lexeme() == "*": return tex_entry tex_entry = (r"""%s%s%s%s\hspace{4pt} Tone: %s.""" + EOL + "%s%s%s%s" + EOL) % \ (format_lexeme(lexical_entry, config.xml.font),\ tex.format_audio(lexical_entry, font).replace('$', "\\dollar"),\ format_uid(lexical_entry, font),\ format_part_of_speech(lexical_entry, config.xml.English),\ format_tone(lexical_entry, config.xml.font),\ format_etymology(lexical_entry, font=config.xml.font, language=config.xml.English),\ format_senses(lexical_entry, font, language=config.xml.English),\ format_paradigm(lexical_entry, font=config.xml.font, language=config.xml.English),\ format_related_forms(lexical_entry, font, language=config.xml.English)) # Special formatting tex_entry = tex.handle_caps(tex_entry).replace("textsc", "mytextsc") # Handle reserved characters and fonts tex_entry = tex.handle_reserved(tex_entry) tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_fv(tex_entry, font) tex_entry = tex.handle_fn(tex_entry, font) tex_entry = tex.handle_fi(tex_entry) return tex_entry
def tex_eng(lexical_entry, font): """<lx> (pronunciation: <lc>; with the copula verb: <lc <type="with copula">>) TAB <ps> TAB Tone: <np <type="tone">>. <df>. <dn>u"\u3002" Local Chinese dialect: <gr>u"\u3002" <xv> <xe> <xn> """ import output.tex as tex tex_entry = "" # Do not display lexical entry if lexeme is '???' or '*' if lexical_entry.get_lexeme() == "???" or lexical_entry.get_lexeme( ) == "*": return tex_entry tex_entry = (r"""%s%s%s%s\hspace{4pt} Tone: %s.""" + EOL + "%s%s%s%s" + EOL) % \ (format_lexeme(lexical_entry, config.xml.font),\ tex.format_audio(lexical_entry, font).replace('$', "\\dollar"),\ format_uid(lexical_entry, font),\ format_part_of_speech(lexical_entry, config.xml.English),\ format_tone(lexical_entry, config.xml.font),\ format_etymology(lexical_entry, font=config.xml.font, language=config.xml.English),\ format_senses(lexical_entry, font, language=config.xml.English),\ format_paradigm(lexical_entry, font=config.xml.font, language=config.xml.English),\ format_related_forms(lexical_entry, font, language=config.xml.English)) # Special formatting tex_entry = tex.handle_caps(tex_entry).replace("textsc", "mytextsc") # Handle reserved characters and fonts tex_entry = tex.handle_reserved(tex_entry) tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_fv(tex_entry, font) tex_entry = tex.handle_fn(tex_entry, font) tex_entry = tex.handle_fi(tex_entry) return tex_entry
def lmf2tex(lexical_entry, font): import output.tex as tex tex_entry = "" # lexeme, id and phonetic variants tex_entry += tex.format_lexeme(lexical_entry, font) # sound tex_entry += tex.format_audio(lexical_entry, font) # part of speech tex_entry += tex.format_part_of_speech(lexical_entry, font) # grammatical notes tex_entry += tex.format_notes(lexical_entry, font) # Order by sense number senses = lexical_entry.get_senses() senses.sort(key=lambda sense: sense.get_senseNumber(integer=True)) for sense in senses: if sense.get_senseNumber() is not None: tex_entry += sense.get_senseNumber() + ") " # definition/gloss and translation tex_entry += tex.format_definitions(sense, font, languages=[ config.xml.vernacular, config.xml.French, config.xml.national ]) # example tex_entry += tex.format_examples(sense, font) # usage note tex_entry += tex.format_usage_notes(sense, font) # encyclopedic information tex_entry += tex.format_encyclopedic_informations(sense, font) # restriction tex_entry += tex.format_restrictions(sense, font) # synonym, antonym, morphology, related form tex_entry += tex.format_related_forms(lexical_entry, font) # borrowed word tex_entry += tex.format_borrowed_word(lexical_entry, font) # etymology tex_entry += tex.format_etymology(lexical_entry, font) # paradigms tex_entry += tex.format_paradigms(lexical_entry, font) tex_entry += tex.format_paradigms(lexical_entry, font) # semantic domain tex_entry += tex.format_semantic_domains(lexical_entry, font) # source tex_entry += tex.format_source(lexical_entry, font) # status tex_entry += tex.format_status(lexical_entry, font) # date tex_entry += tex.format_date(lexical_entry, font) # Handle reserved characters and fonts tex_entry = tex.handle_reserved(tex_entry) tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_fv(tex_entry, font) tex_entry = tex.handle_fn(tex_entry, font) # Special formatting tex_entry = tex.handle_pinyin(tex_entry) tex_entry = tex.handle_caps(tex_entry) return tex_entry + EOL
def lmf2tex(lexical_entry, font): tex_entry = "" if lmf2tex.is_first_entry: tex_entry += "\\setlength{\\parskip}{-0.5cm}" + EOL lmf2tex.is_first_entry = False # lexeme, id and phonetic variants tex_entry += format_lexeme(lexical_entry, font) # sound tex_entry += tex.format_audio(lexical_entry, font) # part of speech tex_entry += tex.format_part_of_speech(lexical_entry, font) # grammatical notes tex_entry += format_notes(lexical_entry, font) # Order by sense number senses = lexical_entry.get_senses() senses.sort(key=lambda sense: sense.get_senseNumber(integer=True)) for sense in senses: if sense.get_senseNumber() is not None: # In LaTeX, "\ding{202}" represents '➊' character, "\ding{203}" '➋' character, etc. code = 201 + int(sense.get_senseNumber()) tex_entry += "\ding{" + str(code) + "} " # paradigms tex_entry += format_paradigms(sense, font) # definition/gloss and translation tex_entry += format_definitions(sense, font, languages=[config.xml.vernacular, config.xml.French, config.xml.national]) # example tex_entry += format_examples(sense, font) # usage note tex_entry += format_usage_notes(sense, font) # encyclopedic information tex_entry += format_encyclopedic_informations(sense, font) # restriction tex_entry += tex.format_restrictions(sense, font) # synonym, antonym, morphology, related form tex_entry += tex.format_related_forms(lexical_entry, font, language=config.xml.French) # borrowed word tex_entry += tex.format_borrowed_word(lexical_entry, font) # etymology tex_entry += tex.format_etymology(lexical_entry, font) # paradigms tex_entry += tex.format_paradigms(lexical_entry, font) # semantic domain tex_entry += tex.format_semantic_domains(lexical_entry, font) # source tex_entry += tex.format_source(lexical_entry, font) # status tex_entry += tex.format_status(lexical_entry, font) # date tex_entry += tex.format_date(lexical_entry, font) # Special formatting tex_entry = tex.handle_pinyin(tex_entry) tex_entry = tex.handle_caps(tex_entry) # Handle reserved characters and fonts tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_reserved(tex_entry) tex_entry = tex.handle_fv(tex_entry, font) tex_entry = tex.handle_fn(tex_entry, font) return tex_entry + EOL
def lmf2tex(lexical_entry, font): import output.tex as tex tex_entry = "" # lexeme, id and phonetic variants tex_entry += tex.format_lexeme(lexical_entry, font) # sound tex_entry += tex.format_audio(lexical_entry, font) # part of speech tex_entry += tex.format_part_of_speech(lexical_entry, font) # grammatical notes tex_entry += tex.format_notes(lexical_entry, font) # Order by sense number senses = lexical_entry.get_senses() senses.sort(key=lambda sense: sense.get_senseNumber(integer=True)) for sense in senses: if sense.get_senseNumber() is not None: tex_entry += sense.get_senseNumber() + ") " # definition/gloss and translation tex_entry += tex.format_definitions(sense, font, languages=[config.xml.vernacular, config.xml.French, config.xml.national]) # example tex_entry += tex.format_examples(sense, font) # usage note tex_entry += tex.format_usage_notes(sense, font) # encyclopedic information tex_entry += tex.format_encyclopedic_informations(sense, font) # restriction tex_entry += tex.format_restrictions(sense, font) # synonym, antonym, morphology, related form tex_entry += tex.format_related_forms(lexical_entry, font) # borrowed word tex_entry += tex.format_borrowed_word(lexical_entry, font) # etymology tex_entry += tex.format_etymology(lexical_entry, font) # paradigms tex_entry += tex.format_paradigms(lexical_entry, font) tex_entry += tex.format_paradigms(lexical_entry, font) # semantic domain tex_entry += tex.format_semantic_domains(lexical_entry, font) # source tex_entry += tex.format_source(lexical_entry, font) # status tex_entry += tex.format_status(lexical_entry, font) # date tex_entry += tex.format_date(lexical_entry, font) # Handle reserved characters and fonts tex_entry = tex.handle_reserved(tex_entry) tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_fv(tex_entry, font) tex_entry = tex.handle_fn(tex_entry, font) # Special formatting tex_entry = tex.handle_pinyin(tex_entry) tex_entry = tex.handle_caps(tex_entry) return tex_entry + EOL
def lmf_to_tex(lexical_entry, font=None, partOfSpeech_mapping=partOfSpeech_tex, languages=[VERNACULAR, ENGLISH, NATIONAL, REGIONAL]): """! @brief Function to convert LMF lexical entry information to be written into LaTeX commands. @param lexical_entry The Lexical Entry LMF instance to display. @param font A Python dictionary describing fonts to use for different languages. @param partOfSpeech_mapping A Python dictionary giving abbreviations for LMF part of speech values. @param languages A list of languages to consider for LaTeX layout (all by default). @return A string representing the lexical entry in LaTeX format. """ import output.tex as tex # Define font if font is None: font = config.xml.font tex_entry = "" # lexeme and id tex_entry += tex.format_lexeme(lexical_entry, font) # sound tex_entry += tex.format_audio(lexical_entry, font) # part of speech tex_entry += tex.format_part_of_speech(lexical_entry, font, mapping=partOfSpeech_mapping) # Order by sense number senses = lexical_entry.get_senses() senses.sort(key=lambda sense: sense.get_senseNumber(integer=True)) for sense in senses: if sense.get_senseNumber() is not None: tex_entry += sense.get_senseNumber() + ") " # definition/gloss and translation tex_entry += tex.format_definitions(sense, font, languages) # TODO tex_entry += tex.format_lt(sense, font) tex_entry += tex.format_sc(sense, font) tex_entry += tex.format_rf(sense, font) # example tex_entry += tex.format_examples(sense, font) # usage note tex_entry += tex.format_usage_notes(sense, font) # encyclopedic information tex_entry += tex.format_encyclopedic_informations(sense, font) # restriction tex_entry += tex.format_restrictions(sense, font) # TODO tex_entry += tex.format_lexical_functions(lexical_entry, font) # synonym, antonym, morphology, related form tex_entry += tex.format_related_forms(lexical_entry, font) # variant form tex_entry += tex.format_variant_forms(lexical_entry, font) # borrowed word tex_entry += tex.format_borrowed_word(lexical_entry, font) # etymology tex_entry += tex.format_etymology(lexical_entry, font) # paradigms tex_entry += tex.format_paradigms(lexical_entry, font) # TODO tex_entry += tex.format_table(lexical_entry, font) # semantic domain tex_entry += tex.format_semantic_domains(lexical_entry, font) # bibliography tex_entry += tex.format_bibliography(lexical_entry, font) # TODO tex_entry += tex.format_picture(lexical_entry, font) # notes tex_entry += tex.format_notes(lexical_entry, font) # source tex_entry += tex.format_source(lexical_entry, font) # status tex_entry += tex.format_status(lexical_entry, font) # date tex_entry += tex.format_date(lexical_entry, font) # Handle reserved characters and fonts tex_entry = tex.handle_reserved(tex_entry) tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_fv(tex_entry, font) tex_entry = tex.handle_fn(tex_entry, font) # Special formatting tex_entry = tex.handle_pinyin(tex_entry) tex_entry = tex.handle_caps(tex_entry) return tex_entry + EOL
def lmf2tex(lexical_entry, font): import output.tex as tex tex_entry = "" if lmf2tex.is_first_entry: tex_entry += "\\setlength{\\parskip}{-0.5cm}" + EOL lmf2tex.is_first_entry = False # lexeme and id tex_entry += format_lexeme(lexical_entry, config.xml.font) # TODO: phonetic variants ? or variant form ? # sound tex_entry += tex.format_audio(lexical_entry, config.xml.font) # part of speech tex_entry += tex.format_part_of_speech(lexical_entry, config.xml.font) # grammatical notes tex_entry += format_notes(lexical_entry, config.xml.font) # Order by sense number senses = lexical_entry.get_senses() senses.sort(key=lambda sense: sense.get_senseNumber(integer=True)) for sense in senses: if sense.get_senseNumber() is not None: # In LaTeX, "\ding{202}" represents '➊' character, "\ding{203}" '➋' character, etc. code = 201 + int(sense.get_senseNumber()) tex_entry += "\ding{" + str(code) + "} " # definition/gloss and translation tex_entry += tex.format_definitions(sense, config.xml.font, languages=[ config.xml.vernacular, config.xml.English, config.xml.national ]) # example tex_entry += format_examples_compact(sense, config.xml.font) # usage note tex_entry += tex.format_usage_notes(sense, config.xml.font) # encyclopedic information tex_entry += tex.format_encyclopedic_informations( sense, config.xml.font) # restriction tex_entry += tex.format_restrictions(sense, config.xml.font) # synonym, antonym, morphology, related form tex_entry += tex.format_related_forms(lexical_entry, config.xml.font) # TODO: variant form? tex_entry += tex.format_variant_forms(lexical_entry, config.xml.font) # borrowed word tex_entry += tex.format_borrowed_word(lexical_entry, config.xml.font) # etymology tex_entry += tex.format_etymology(lexical_entry, config.xml.font) # paradigms tex_entry += format_paradigms(lexical_entry, config.xml.font) # semantic domain tex_entry += tex.format_semantic_domains(lexical_entry, config.xml.font) # TODO? bibliography tex_entry += tex.format_bibliography(lexical_entry, config.xml.font) # source tex_entry += tex.format_source(lexical_entry, config.xml.font) # status tex_entry += tex.format_status(lexical_entry, config.xml.font) # date tex_entry += tex.format_date(lexical_entry, config.xml.font) # Handle reserved characters and fonts tex_entry = handle_reserved(tex_entry) tex_entry = tex.handle_quotes(tex_entry) tex_entry = tex.handle_fv(tex_entry, config.xml.font) tex_entry = tex.handle_fn(tex_entry, config.xml.font) # Special formatting tex_entry = tex.handle_pinyin(tex_entry) tex_entry = tex.handle_caps(tex_entry) return tex_entry + EOL