3 """! @package morphology
6 from core.form
import Form
7 from core.form_representation
import FormRepresentation
10 """! "Lemma is a Form subclass representing a form chosen by convention to designate the Lexical Entry. The lemma is usually equivalent to one of the inflected forms, the root, stem or compound phrase." (LMF).
13 """! @brief Constructor.
14 Lemma instance is owned by LexicalEntry.
15 @return A Lemma instance.
23 """! @brief Destructor.
28 """! @brief Set lexeme.
29 @param lexeme The lexeme to set.
30 @return Lemma instance.
36 """! @brief Get lexeme.
37 @return Lemma attribute 'lexeme'.
42 """! @brief Create a form representation.
43 @return FormRepresentation instance.
45 return FormRepresentation()
48 """! @brief Add a form representation to the lemma.
49 @param form_representation The FormRepresentation instance to add to the lemma.
50 @return Lemma instance.
52 self.form_representation.append(form_representation)
56 """! @brief Find variant forms.
57 This attribute is owned by FormRepresentation.
58 @param type The type to consider to retrieve the variant form.
59 @return A Python list of found FormRepresentation attributes 'variantForm'.
63 if form_representation.get_type() == type
and form_representation.get_variantForm()
is not None:
64 found_forms.append(form_representation.get_variantForm())
68 """! @brief Get all form representations maintained by the lemma.
69 @return A Python list of form representations.
71 return self.form_representation
74 """! @brief Get a given form representation maintained by the lemma.
75 @param index The index of the wanted form representation.
76 @return The wanted FormRepresentation instance.
79 return self.form_representation[index]
84 """! @brief Set variant form and type.
85 These attributes are owned by FormRepresentation.
86 @param variant_form Variant form.
87 @param type Type of variant, in range 'type_variant_range' defined in 'common/range.py'.
88 @return Lemma instance.
90 form_representation =
None
93 if repr.get_variantForm()
is None and repr.get_type()
is None:
94 form_representation = repr
96 if form_representation
is None:
100 form_representation.set_variantForm(variant_form).set_type(type)
104 """! @brief Get all variant forms of specified type.
105 This attribute is owned by FormRepresentation.
106 @return A Python list of FormRepresentation attributes 'variantForm' if type matches.
110 if repr.get_type() == type
and repr.get_variantForm()
is not None:
111 variant_forms.append(repr.get_variantForm())
115 """! @brief Set variant comment and language.
116 These attributes are owned by FormRepresentation.
117 @param comment Variant comment.
118 @param language Language of comment.
119 @return Lemma instance.
121 form_representation =
None
124 if repr.get_comment()
is None and repr.get_language()
is None:
125 form_representation = repr
127 if form_representation
is None:
131 form_representation.set_comment(comment, language)
135 """! @brief Set tone.
136 This attribute is owned by FormRepresentation.
137 @param tone The tone to set.
138 @return Lemma instance.
140 form_representation =
None
143 if repr.get_tone()
is None:
144 form_representation = repr
146 if form_representation
is None:
150 form_representation.set_tone(tone)
154 """! @brief Get all tones.
155 This attribute is owned by FormRepresentation.
156 @return A Python list of FormRepresentation attributes 'tone'.
160 if repr.get_tone()
is not None:
161 tones.append(repr.get_tone())
165 """! @brief Set geographical variant.
166 This attribute is owned by FormRepresentation.
167 @param geographical_variant The geographical variant to set.
168 @return Lemma instance.
170 form_representation =
None
173 if repr.get_geographicalVariant()
is None:
174 form_representation = repr
176 if form_representation
is None:
180 form_representation.set_geographicalVariant(geographical_variant)
184 """! @brief Set phonetic form.
185 This attribute is owned by FormRepresentation.
186 @param phonetic_form The phonetic form to set.
187 @param script_name The name of the script used to write the phonetic form, e.g. pinyin.
188 @return Lemma instance.
190 form_representation =
None
193 if repr.get_phoneticForm()
is None and repr.get_scriptName() == script_name:
194 form_representation = repr
196 if form_representation
is None:
200 form_representation.set_phoneticForm(phonetic_form)
201 if script_name
is not None:
202 form_representation.set_scriptName(script_name)
206 """! @brief Get all phonetic forms.
207 This attribute is owned by FormRepresentation.
208 @param script_name If provided, get only phonetic forms that are written using this script.
209 @return A Python list of FormRepresentation attributes 'phoneticForm'.
213 if repr.get_phoneticForm()
is not None and (script_name
is None or repr.get_scriptName() == script_name):
214 phonetic_forms.append(repr.get_phoneticForm())
215 return phonetic_forms
218 """! @brief Set contextual variation.
219 This attribute is owned by FormRepresentation.
220 @param contextual_variation The contextual variation to set.
221 @return Lemma instance.
223 form_representation =
None
226 if repr.get_contextualVariation()
is None:
227 form_representation = repr
229 if form_representation
is None:
233 form_representation.set_contextualVariation(contextual_variation)
237 """! @brief Get all contextual variations.
238 This attribute is owned by FormRepresentation.
239 @return A Python list of FormRepresentation attributes 'contextualVariation'.
241 contextual_variations = []
243 if repr.get_contextualVariation()
is not None:
244 contextual_variations.append(repr.get_contextualVariation())
245 return contextual_variations
248 """! @brief Set spelling variant.
249 This attribute is owned by FormRepresentation.
250 @param spelling_variant The spelling variant to set.
251 @return Lemma instance.
253 form_representation =
None
256 if repr.get_spellingVariant()
is None:
257 form_representation = repr
259 if form_representation
is None:
263 form_representation.set_spellingVariant(spelling_variant)
267 """! @brief Get all spelling variants.
268 This attribute is owned by FormRepresentation.
269 @return A Python list of FormRepresentation attributes 'spellingVariant'.
271 spelling_variants = []
273 if repr.get_spellingVariant()
is not None:
274 spelling_variants.append(repr.get_spellingVariant())
275 return spelling_variants
278 """! @brief Set citation form.
279 This attribute is owned by FormRepresentation.
280 @param citation_form The citation form to set.
281 @param script_name The name of the script used to write the citation form, e.g. devanagari.
282 @return Lemma instance.
284 form_representation =
None
287 if repr.get_citationForm()
is None and repr.get_scriptName() == script_name:
288 form_representation = repr
290 if form_representation
is None:
294 form_representation.set_citationForm(citation_form)
295 if script_name
is not None:
296 form_representation.set_scriptName(script_name)
300 """! @brief Get all citation forms.
301 This attribute is owned by FormRepresentation.
302 @param script_name If provided, get only citation forms that are written using this script.
303 @return A Python list of FormRepresentation attributes 'citationForm'.
307 if repr.get_citationForm()
is not None and (script_name
is None or repr.get_scriptName() == script_name):
308 citation_forms.append(repr.get_citationForm())
309 return citation_forms
312 """! @brief Set dialect.
313 This attribute is owned by FormRepresentation.
314 @param dialect The dialect to set.
315 @return Lemma instance.
317 form_representation =
None
320 if repr.get_dialect()
is None:
321 form_representation = repr
323 if form_representation
is None:
327 form_representation.set_dialect(dialect)
331 """! @brief Set transliteration.
332 This attribute is owned by FormRepresentation.
333 @param transliteration The transliteration to set.
334 @return Lemma instance.
336 form_representation =
None
339 if repr.get_transliteration()
is None:
340 form_representation = repr
342 if form_representation
is None:
346 form_representation.set_transliteration(transliteration)
350 """! @brief Get all transliterations.
351 This attribute is owned by FormRepresentation.
352 @return A Python list of FormRepresentation attributes 'transliteration'.
354 transliterations = []
356 if repr.get_transliteration()
is not None:
357 transliterations.append(repr.get_transliteration())
358 return transliterations
361 """! @brief Set script name.
362 This attribute is owned by FormRepresentation.
363 @param script_name The script name to set.
364 @return Lemma instance.
366 form_representation =
None
369 if repr.get_scriptName()
is None:
370 form_representation = repr
372 if form_representation
is None:
376 form_representation.set_scriptName(script_name)
379 def set_audio(self, media_type, file_name, author, quality, start_position, duration, external_reference, audio_file_format):
380 """! @brief Set audio resource.
381 Attributes 'mediaType', 'fileName', 'author', 'quality', 'startPosition', 'durationOfEffectiveSpeech', 'externalReference', 'audioFileFormat' are owned by Material/Audio, which is owned by FormRepresentation.
382 @param media_type The media type to set.
383 @param file_name Name of the audio file.
384 @param author Author of the recording.
385 @param quality Quality of the recording, in range 'quality_range' defined in 'common/range.py'.
386 @param start_position Start position of the form in the recording, in format 'Thh:mm:ss,msms', e.g. "T00:05:00".
387 @param duration Duration of the effcetive speech, in format 'PThhHmmMssS', e.g. "PT00:05:00".
388 @param external_reference Reference of the audio file, if not directly provided.
389 @param audio_file_format Format of the audio file, e.g. "wav".
390 @return Lemma instance.
395 form_representation.set_audio(media_type, file_name, author, quality, start_position, duration, external_reference, audio_file_format)
def create_form_representation
Create a form representation.
def set_lexeme
Set lexeme.
def get_variant_forms
Get all variant forms of specified type.
def get_lexeme
Get lexeme.
def set_dialect
Set dialect.
def find_form_representations
Find variant forms.
def get_spelling_variants
Get all spelling variants.
def set_audio
Set audio resource.
def set_variant_form
Set variant form and type.
def set_geographical_variant
Set geographical variant.
def get_contextual_variations
Get all contextual variations.
def get_form_representation
Get a given form representation maintained by the lemma.
def set_phonetic_form
Set phonetic form.
def get_citation_forms
Get all citation forms.
def set_script_name
Set script name.
def set_spelling_variant
Set spelling variant.
def set_contextual_variation
Set contextual variation.
def add_form_representation
Add a form representation to the lemma.
def get_form_representations
Get all form representations maintained by the lemma.
"Lemma is a Form subclass representing a form chosen by convention to designate the Lexical Entry...
def set_citation_form
Set citation form.
def get_tones
Get all tones.
def get_phonetic_forms
Get all phonetic forms.
def get_transliterations
Get all transliterations.
def set_variant_comment
Set variant comment and language.
def set_transliteration
Set transliteration.