6 from core.representation
import Representation
7 from resources.audio
import Audio
8 from utils.attr
import check_attr_type, check_attr_range
9 from common.range
import type_variant_range
12 """! "Form Representation is a class representing one variant orthography of a Form." (LMF)
15 """! @brief Constructor.
16 FormRepresentation instances are owned by Form.
17 @return A FormRepresentation instance.
41 """! @brief Destructor.
42 Release Audio instances.
44 if self.
audio is not None:
50 """! @brief Get speakers.
51 @return FormRepresentation private attribute '__speaker', a Python list of Speaker instances.
56 """! @brief Set written form and script.
57 @param written_form The written form to set.
58 @param script_name Script used for the written form.
59 @return FormRepresentation instance.
61 error_msg =
"Written form value '%s' is not allowed" % written_form
64 if script_name
is not None:
69 """! @brief Get written form.
70 @param script_name If this argument is given, get written form only if written using this script.
71 @return The filtered Representation attribute 'writtenForm'.
77 """! @brief Set variant form.
78 @param variant_form The variant form to set.
79 @return FormRepresentation instance.
81 error_msg =
"Variant form value '%s' is not allowed" % variant_form
87 """! @brief Get variant form.
88 @return FormRepresentation attribute 'variantForm'.
93 """! @brief Set variant type.
94 @param type Type of variant, in range 'type_variant_range' defined in 'common/range.py'.
95 @return FormRepresentation instance.
97 error_msg =
"Variant type value '%s' is not allowed" % type
107 """! @brief Get variant type.
108 @return FormRepresentation attribute 'type'.
113 """! @brief Set variant form comment.
114 @param comment Comment about the variant form.
115 @param language Language used for the comment.
116 @return FormRepresentation instance.
118 error_msg =
"Variant form comment value '%s' is not allowed" % comment
122 if language
is not None:
127 """! @brief Get variant form comment.
128 @param language If this argument is given, get comment only if written in this language.
129 @return The filtered Representation attribute 'comment'.
137 """! @brief Set language used for comment.
138 @param language Language used for the comment.
139 @return FormRepresentation instance.
141 error_msg =
"Language value '%s' is not allowed" % language
148 """! @brief Get language used for comment.
149 @return Representation attribute 'language'.
154 """! @brief Set tone.
155 @param tone The tone to set.
156 @return FormRepresentation instance.
158 error_msg =
"Tone value '%s' is not allowed" % tone
164 """! @brief Get tone.
165 @return FormRepresentation attribute 'tone'.
170 """! @brief Set geographical variant.
171 @param geographical_variant The geographical variant to set.
172 @return FormRepresentation instance.
174 error_msg =
"Geographical variant value '%s' is not allowed" % geographical_variant
180 """! @brief Get geographical variant.
181 @return FormRepresentation attribute 'geographicalVariant'.
186 """! @brief Set phonetic form.
187 @param phonetic_form The phonetic form to set.
188 @return FormRepresentation instance.
190 error_msg =
"Phonetic form value '%s' is not allowed" % phonetic_form
196 """! @brief Get phonetic form.
197 @return FormRepresentation attribute 'phoneticForm'.
202 """! @brief Set contextual variation.
203 @param contextualVariation The contextual variation to set.
204 @return FormRepresentation instance.
206 error_msg =
"Contextual variation value '%s' is not allowed" % contextual_variation
212 """! @brief Get contextual variation.
213 @return FormRepresentation attribute 'contextualVariation'.
218 """! @brief Set spelling variant.
219 @param spelling_variant The spelling variant to set.
220 @return FormRepresentation instance.
222 error_msg =
"Spelling variant value '%s' is not allowed" % spelling_variant
228 """! @brief Get spelling variant.
229 @return FormRepresentation attribute 'spellingVariant'.
234 """! @brief Set citation form.
235 @param citation_form The citation form to set.
236 @return FormRepresentation instance.
238 error_msg =
"Citation form value '%s' is not allowed" % citation_form
244 """! @brief Get citation form.
245 @return FormRepresentation attribute 'citationForm'.
250 """! @brief Set dialect.
251 @param dialect The dialect to set.
252 @return FormRepresentation instance.
254 error_msg =
"Dialect value '%s' is not allowed" % dialect
260 """! @brief Get dialect.
261 @return FormRepresentation attribute 'dialect'.
266 """! @brief Set transliteration.
267 @param transliteration The transliteration to set.
268 @return FormRepresentation instance.
270 error_msg =
"Transliteration value '%s' is not allowed" % transliteration
276 """! @brief Get transliteration.
277 @return FormRepresentation attribute 'transliteration'.
282 """! @brief Set script name.
283 @param script_name The script name to set.
284 @return FormRepresentation instance.
286 error_msg =
"Script name value '%s' is not allowed" % script_name
292 """! @brief Get script name.
293 @return Representation attribute 'scriptName'.
298 """! @brief Create an Audio instance.
299 @return Audio instance.
304 """! @brief Get the audio resource maintained by the form representation.
305 @return Audio instance.
309 def set_audio(self, media_type, file_name, author, quality, start_position, duration, external_reference, audio_file_format):
310 """! @brief Set audio resource.
311 Attributes 'mediaType', 'fileName', 'author', 'quality', 'startPosition', 'durationOfEffectiveSpeech', 'externalReference', 'audioFileFormat' are owned by Material/Audio.
312 @param media_type The media type to set.
313 @param file_name Name of the audio file.
314 @param author Author of the recording.
315 @param quality Quality of the recording, in range 'quality_range' defined in 'common/range.py'.
316 @param start_position Start position of the form in the recording, in format 'Thh:mm:ss,msms', e.g. "T00:05:00".
317 @param duration Duration of the effcetive speech, in format 'PThhHmmMssS', e.g. "PT00:05:00".
318 @param external_reference Reference of the audio file, if not directly provided.
319 @param audio_file_format Format of the audio file, e.g. "wav".
320 @return FormRepresentation instance.
325 if media_type
is not None:
326 self.audio.set_mediaType(media_type)
327 if file_name
is not None:
328 self.audio.set_fileName(file_name)
329 if author
is not None:
330 self.audio.set_author(author)
331 if quality
is not None:
332 self.audio.set_quality(quality)
333 if start_position
is not None:
334 self.audio.set_startPosition(start_position)
335 if duration
is not None:
336 self.audio.set_durationOfEffectiveSpeech(duration)
337 if external_reference
is not None:
338 self.audio.set_externalReference(external_reference)
339 if audio_file_format
is not None:
340 self.audio.set_audioFileFormat(audio_file_format)
def check_attr_type
Check that attribute value is of specified type.
def check_attr_range
Check that attribute value is in specified range.