6 from utils.attr
import check_attr_type
7 from core.statement
import Statement
10 """! "Definition is a class representing a narrative description of a sense. It is provided to help human users understand the meaning of a lexical entry. A Sense instance can have zero to many definitions. Each Definition instance may be associated with zero to many Text Representation instances in order to manage the text defintion in more than one language or script. In addition, the narrative description can be expressed in a different language or script than the one in the Lexical Entry instance." (LMF)
13 """! @brief Constructor.
14 Definition instances are owned by Sense.
15 @return A Definition instance.
29 """! @brief Destructor.
30 Release TextRepresentation and Statement instances.
33 del text_representation
40 """! @brief Set language used for definition and gloss.
41 @param language Language used for definition and gloss.
42 @return Definition instance.
44 error_msg =
"Language value '%s' is not allowed" % language
51 """! @brief Get language used for definition and gloss.
52 @return Definition attribute 'language'.
57 """! @brief Set definition.
58 @param definition Definition.
59 @param language Language used for the definition.
60 @return Definition instance.
63 if language
is not None:
68 """! @brief Get definition.
69 @param language If this argument is given, get definition only if written in this language.
70 @return The filtered Definition attribute 'definition'.
78 """! @brief Set gloss.
80 @param language Language used for the gloss.
81 @return Definition instance.
84 if language
is not None:
89 """! @brief Get gloss.
90 @param language If this argument is given, get gloss only if written in this language.
91 @return The filtered Definition attribute 'gloss'.
99 """! @brief Create a Statement instance.
100 @return Statement instance.
105 """! @brief Add a Statement instance to this Definition instance.
106 @param statemement The Statement instance to add to the Definition instance.
107 @return Definition instance.
109 self.statement.append(statement)
113 """! @brief Get all Statement instances maintained by this Definition instance.
114 @return A Python list of Statement instances.
119 """! @brief Get the previously registered statement.
120 @return The last element of Definition attribute 'statement'.
125 def set_note(self, note, type=None, language=None):
126 """! @brief Set note, note type and language.
127 These attributes are owned by Statement.
128 @param note Note to set.
129 @param type Type of the note.
130 @param language Language used for the note.
131 @return Definition instance.
137 if statement.get_note()
is None:
143 if statement.get_language() == language
and statement.get_note()
is None:
150 if statement.get_language()
is None and statement.get_note()
is None:
158 instance.set_note(note, type, language)
162 """! @brief Find notes.
163 This attribute is owned by Statement.
164 @param type The type to consider to retrieve the note.
165 @param language If this argument is given, find note only if written in this language.
166 @return A Python list of found Statement attributes 'note'.
170 if statement.get_note(type, language)
is not None:
171 found_notes.append(statement.get_note(type, language))
175 """! @brief Set usage note and language.
176 These attributes are owned by Statement.
177 @param usage_note Usage note to set.
178 @param language Language used for the usage note.
179 @return Definition instance.
184 if statement.get_language() == language
and statement.get_usageNote()
is None:
191 if statement.get_language()
is None and statement.get_usageNote()
is None:
199 instance.set_usageNote(usage_note, language)
203 """! @brief Find usage notes.
204 This attribute is owned by Statement.
205 @param language The language to consider to retrieve the usage note.
206 @return A Python list of found Statement attributes 'usageNote'.
210 if statement.get_usageNote(language)
is not None:
211 found_notes.append(statement.get_usageNote(language))
215 """! @brief Set encyclopedic information and language.
216 These attributes are owned by Statement.
217 @param encyclopedic_information Encyclopedic information to set.
218 @param language Language used for the encyclopedic information.
219 @return Definition instance.
224 if statement.get_language() == language
and statement.get_encyclopedicInformation()
is None:
231 if statement.get_language()
is None and statement.get_encyclopedicInformation()
is None:
239 instance.set_encyclopedicInformation(encyclopedic_information, language)
243 """! @brief Find encyclopedic informations.
244 This attribute is owned by Statement.
245 @param language The language to consider to retrieve the encyclopedic information.
246 @return A Python list of found Statement attributes 'encyclopedicInformation'.
248 found_informations = []
250 if statement.get_encyclopedicInformation(language)
is not None:
251 found_informations.append(statement.get_encyclopedicInformation(language))
252 return found_informations
255 """! @brief Set restriction and language.
256 These attributes are owned by Statement.
257 @param restriction Restriction to set.
258 @param language Language used for the restriction.
259 @return Definition instance.
264 if statement.get_language() == language
and statement.get_restriction()
is None:
271 if statement.get_language()
is None and statement.get_restriction()
is None:
279 instance.set_restriction(restriction, language)
283 """! @brief Find restrictions.
284 This attribute is owned by Statement.
285 @param language The language to consider to retrieve the restriction.
286 @return A Python list of found Statement attributes 'restriction'.
288 found_restrictions = []
290 if statement.get_restriction(language)
is not None:
291 found_restrictions.append(statement.get_restriction(language))
292 return found_restrictions
295 """! @brief Set source language (in English).
296 Attribute 'borrowedWord' is owned by the first Statement.
297 @param borrowed_word Source language.
298 @return Definition instance.
303 if statement
is None:
306 statement.set_borrowedWord(borrowed_word)
310 """! @brief Get source language (in English).
311 This attribute is owned by the first Statement.
312 @return Statement attribute 'borrowedWord'.
317 if statement
is not None:
318 return statement.get_borrowedWord()
321 """! @brief Set loan word.
322 Attribute 'writtenForm' is owned by the first Statement.
323 @param written_form Loan word.
324 @return Definition instance.
329 if statement
is None:
332 statement.set_writtenForm(written_form)
336 """! @brief Get loan word.
337 This attribute is owned by the first Statement.
338 @return Statement attribute 'writtenForm'.
343 if statement
is not None:
344 return statement.get_writtenForm()
347 """! @brief Set etymology.
348 Attribute 'etymology' is owned by the first Statement.
349 @param etymology Etymology.
350 @return Definition instance.
355 if statement
is None:
358 statement.set_etymology(etymology)
362 """! @brief Get etymology.
363 This attribute is owned by the first Statement.
364 @return Statement attribute 'etymology'.
369 if statement
is not None:
370 return statement.get_etymology()
373 """! @brief Set etymology comment and language.
374 Attributes 'etymologyComment' and 'termSourceLanguage' are owned by the first Statement.
375 @param etymology_comment Etymology comment.
376 @param term_source_language Language of the comment.
377 @return Definition instance.
382 if statement
is None:
385 statement.set_etymologyComment(etymology_comment, term_source_language)
389 """! @brief Get etymology comment.
390 This attribute is owned by the first Statement.
391 @param term_source_language The language of the etymology comment to retrieve.
392 @return Statement attribute 'etymologyComment'.
397 if statement
is not None:
398 return statement.get_etymologyComment(term_source_language)
401 """! @brief Get language used for the etymology comment.
402 This attribute is owned by the first Statement.
403 @return Statement attribute 'termSourceLanguage'.
408 if statement
is not None:
409 return statement.get_termSourceLanguage()
412 """! @brief Set etymology gloss.
413 Attribute 'etymologyGloss' is owned by the first Statement.
414 @param etymology_gloss Etymology gloss.
415 @return Definition instance.
420 if statement
is None:
423 statement.set_etymologyGloss(etymology_gloss)
427 """! @brief Get etymology gloss.
428 This attribute is owned by the first Statement.
429 @return Statement attribute 'etymologyGloss'.
434 if statement
is not None:
435 return statement.get_etymologyGloss()
438 """! @brief Set etymology source.
439 Attribute 'etymologySource' is owned by the first Statement.
440 @param etymology_source Etymology source.
441 @return Definition instance.
446 if statement
is None:
449 statement.set_etymologySource(etymology_source)
453 """! @brief Get etymology source.
454 This attribute is owned by the first Statement.
455 @return Statement attribute 'etymologySource'.
460 if statement
is not None:
461 return statement.get_etymologySource()
464 """! @brief Set scientific name.
465 Attribute 'scientficName' is owned by the first Statement.
466 @param scientific_name Scientific name.
467 @return Definition instance.
472 if statement
is None:
475 statement.set_scientificName(scientific_name)
479 """! @brief Get scientific name.
480 This attribute is owned by the first Statement.
481 @return Statement attribute 'scientificName'.
486 if statement
is not None:
487 return statement.get_scientificName()
def get_etymology_comment
Get etymology comment.
def get_statements
Get all Statement instances maintained by this Definition instance.
def create_statement
Create a Statement instance.
def set_etymology_gloss
Set etymology gloss.
def check_attr_type
Check that attribute value is of specified type.
def get_scientific_name
Get scientific name.
def find_notes
Find notes.
text_representation
TextRepresentation instances are owned by Definition There is zero to many TextRepresentation instanc...
"Definition is a class representing a narrative description of a sense. It is provided to help human ...
def find_encyclopedic_informations
Find encyclopedic informations.
def get_first_statement
Get the previously registered statement.
def get_language
Get language used for definition and gloss.
def get_borrowed_word
Get source language (in English).
def find_usage_notes
Find usage notes.
def get_definition
Get definition.
def set_etymology_source
Set etymology source.
def get_etymology_source
Get etymology source.
def set_etymology
Set etymology.
def get_written_form
Get loan word.
statement
Statement instances are owned by Definition There is zero to many Statement instances per Definition...
def set_written_form
Set loan word.
def set_encyclopedic_information
Set encyclopedic information and language.
def get_etymology_gloss
Get etymology gloss.
def get_term_source_language
Get language used for the etymology comment.
def add_statement
Add a Statement instance to this Definition instance.
def set_language
Set language used for definition and gloss.
def set_definition
Set definition.
def get_etymology
Get etymology.
def set_usage_note
Set usage note and language.
def find_restrictions
Find restrictions.
def set_note
Set note, note type and language.
def set_etymology_comment
Set etymology comment and language.
def set_restriction
Set restriction and language.
def set_borrowed_word
Set source language (in English).
def set_scientific_name
Set scientific name.