MCPcopy Create free account
hub / github.com/DeepL/deepl-python / create_multilingual_glossary

Method create_multilingual_glossary

deepl/deepl_client.py:125–158  ·  view source on GitHub ↗

Creates a glossary with given name with all of the specified dictionaries, each with their own language pair and entries. The glossary may be used in the translate_text functions. The available glossary language pairs can be queried using get_glossary_languages(). Gl

(
        self,
        name: str,
        glossary_dicts: List[MultilingualGlossaryDictionaryEntries],
    )

Source from the content-addressed store, hash-verified

123 return output if multi_input else output[0]
124
125 def create_multilingual_glossary(
126 self,
127 name: str,
128 glossary_dicts: List[MultilingualGlossaryDictionaryEntries],
129 ) -> MultilingualGlossaryInfo:
130 """Creates a glossary with given name with all of the specified
131 dictionaries, each with their own language pair and entries. The
132 glossary may be used in the translate_text functions.
133
134 The available glossary language pairs can be queried using
135 get_glossary_languages(). Glossaries apply to languages, not specific
136 language variants. A glossary for a language applies to any variant
137 of that language: a glossary with target language EN may be used to
138 translate texts into both EN-US and EN-GB.
139
140 This function requires the glossary entries for each dictionary to be
141 provided as a dictionary of source-target terms. To create a glossary
142 from a CSV file downloaded from the DeepL website, see
143 create_glossary_from_csv().
144
145 :param name: user-defined name to attach to glossary.
146 :param dictionaries: a list of MultilingualGlossaryDictionaryEntries
147 which each contains entries for a particular language pair
148 :return: GlossaryInfo containing information about created glossary.
149
150 :raises ValueError: If the glossary name is empty, or entries are
151 empty or invalid.
152 :raises DeepLException: If source and target language pair are not
153 supported for glossaries.
154 """
155 if any(map(lambda d: not d.entries, glossary_dicts)):
156 raise ValueError("glossary entries must not be empty")
157
158 return self._create_multilingual_glossary(name, glossary_dicts)
159
160 def create_multilingual_glossary_from_csv(
161 self,

Callers 6

test_glossary_createFunction · 0.80
__init__Method · 0.80

Calls 1

Tested by 6

test_glossary_createFunction · 0.64
__init__Method · 0.64