Пример #1
0
def format_definitions(sense, font, languages):
    result = ""
    for language in languages:
        if len(sense.find_definitions(language)) != 0:
            for definition in sense.find_definitions(language):
                if language == config.xml.vernacular:
                    result += font[VERNACULAR](definition) + ". "
                elif language == config.xml.national:
                    result += font[NATIONAL](tex.handle_font(definition)) + ". "
                elif language == config.xml.regional:
                    # Do not display Tibetan for now (dr)
                    pass #result += "\\textit{[Regnl: " + font[REGIONAL](definition) + "]}. "
                else:
                    result += definition + ". "
        elif len(sense.find_glosses(language)) != 0:
            for gloss in sense.find_glosses(language):
                if language == config.xml.vernacular:
                    result += font[VERNACULAR](gloss) + ". "
                elif language == config.xml.national:
                    result += font[NATIONAL](tex.handle_font(gloss)) + ". "
                elif language == config.xml.regional:
                    # Do not display Tibetan for now (gr)
                    pass #result += "\\textit{[Regnl: " + font[REGIONAL](gloss) + "]}. "
                else:
                    result += gloss + ". "
        if len(sense.get_translations(language)) != 0:
            for translation in sense.get_translations(language):
                if language == config.xml.national:
                    result += font[NATIONAL](translation) + ". "
                elif language == config.xml.regional:
                    result += "\\textbf{rr:}\\textit{[Regnl: " + translation + "]}. "
                else:
                    result += translation + ". "
    return result
Пример #2
0
def format_usage_notes(sense, font):
    result = ""
    for usage in sense.find_usage_notes(language=config.xml.vernacular):
        result += "\\textit{UsageVer:} " + font[VERNACULAR](usage) + " "
    for usage in sense.find_usage_notes(language=config.xml.English):
        result += "\\textit{Usage:} " + usage + " "
    for usage in sense.find_usage_notes(language=config.xml.national):
        result += "\\textit{UsageNat:} " + font[NATIONAL](tex.handle_font(usage)) + " "
    for usage in sense.find_usage_notes(language=config.xml.regional):
        result += "\\textit{[" + font[REGIONAL](usage) + "]} "
    return result
Пример #3
0
def format_encyclopedic_informations(sense, font):
    result = ""
    for information in sense.find_encyclopedic_informations(language=config.xml.vernacular):
        result += font[VERNACULAR](information) + " "
    for information in sense.find_encyclopedic_informations(language=config.xml.English):
        result += information + " "
    for information in sense.find_encyclopedic_informations(language=config.xml.national):
        result += font[NATIONAL](tex.handle_font(information)) + " "
    for information in sense.find_encyclopedic_informations(language=config.xml.regional):
        # Do not display Tibetan for now (er)
        pass #result += "\\textit{[" + font[REGIONAL](information) + "]} "
    return result
Пример #4
0
def format_examples(sense, font):
    result = ""
    for context in sense.get_contexts():
        result += u"\u00B6 "
        for example in context.find_written_forms(config.xml.vernacular):
            result += font[VERNACULAR](example) + EOL
        for example in context.find_written_forms(config.xml.English):
            result += example + EOL
        for example in context.find_written_forms(config.xml.national):
            result += "\\textit{" + font[NATIONAL](tex.handle_font(example)) + "}" + EOL
        for example in context.find_written_forms(config.xml.regional):
            # Do not display Tibetan for now (xr)
            pass #result += "\\textit{[" + font[REGIONAL](example) + "]}" + EOL
    return result
Пример #5
0
def format_examples_compact(sense, font):
    import output.tex as tex
    result = ""
    for context in sense.get_contexts():
        result += u"\u00B6 "
        for example in context.find_written_forms(config.xml.vernacular, script_name="ipa"):
            result += font[VERNACULAR](example) + EOL
        for example in context.find_written_forms(config.xml.vernacular, script_name="devanagari"): # xv_dev
            result += font[NATIONAL](example) + EOL
        for example in context.find_written_forms(config.xml.English):
            result += font[ENGLISH](example) + EOL
        for example in context.find_written_forms(config.xml.national):
            result += font[NATIONAL](tex.handle_font(example)) + EOL
        for example in context.find_written_forms(config.xml.regional):
            result += "\\textit{[" + font[REGIONAL](example) + "]}" + EOL
    return result
Пример #6
0
def format_examples(sense, font, languages=None):
    import output.tex as tex
    result = ""
    if languages is None:
        languages = [config.xml.vernacular, config.xml.English, config.xml.national, config.xml.regional]
    for context in sense.get_contexts():
        ref = ""
        if context.get_speakerID() is not None and context.get_speakerID() != "F4":
            ref = "[" + context.get_speakerID() + "] "
        tmp = ""
        for language in languages:
            for example in context.find_written_forms(language):
                if language == config.xml.vernacular:
                    tmp += "\\sn " + font[VERNACULAR](handle_tilde(ref + example)) + EOL
                elif language == config.xml.national:
                    tmp += "\\trans \\textit{" + font[NATIONAL](tex.handle_font(example)) + "}" + EOL
                elif language == config.xml.regional:
                    tmp += "\\trans \\textit{[" + font[REGIONAL](example) + "]}" + EOL
                else: # language == config.xml.English
                    tmp += "\\trans " + example + EOL
        # LaTeX does not support empty examples
        if len(tmp) != 0:
            result += "\\begin{exe}" + EOL + tmp + "\\end{exe}" + EOL
    return result