3 """! @package morphology
6 from core.form
import Form
7 from core.form_representation
import FormRepresentation
8 from common.range
import semanticRelation_range
9 from utils.attr
import check_attr_type, check_attr_range
12 """! "Related Form is a Form subclass representing a word form or a morph that can be related to the Lexical Entry. There is no asumption that the Related Form is associated with the Sense class in the Lexical Entry." (LMF)
15 """! @brief Constructor.
16 RelatedForm instances are owned by LexicalEntry.
17 @param lexeme Related lexeme. If not provided, default value is None.
18 @return A RelatedForm instance.
30 """! @brief Destructor.
36 """! @brief Set semantic relation.
37 @param semantic_relation The semantic relation to set.
38 @return RelatedForm instance.
40 error_msg =
"Semantic relation value '%s' is not allowed" % semantic_relation
44 value =
check_attr_range(semantic_relation, semanticRelation_range, error_msg)
49 """! @brief Get semantic relation.
50 @return RelatedForm attribute 'semanticRelation'.
55 """! @brief Get related LexicalEntry lexeme.
56 @return RelatedForm attribute 'targets'.
61 """! @brief Set pointer to the related lexical entry instance. This function can only be called once the full dictionary has been parsed.
62 @param lexical_entry The related LexicalEntry.
63 @return RelatedForm instance.
69 """! @brief Get related LexicalEntry.
70 @return RelatedForm private attribute '__lexical_entry'.
75 """! @brief Create and add a form representation to the related form.
76 @param written_form The written form to set.
77 @param language Language used for the written form.
78 @return RelatedForm instance.
80 self.form_representation.append(FormRepresentation().set_writtenForm(written_form).set_language(language))
84 """! @brief Find written forms.
85 This attribite is owned by FormRepresentation.
86 @param language The language to consider to retrieve the written forms.
87 @return A Python list of found FormRepresentation attributes 'writtenForm'.
89 found_written_forms = []
90 for form_representation
in self.form_representation:
91 if form_representation.get_language() == language:
92 found_written_forms.append(form_representation.get_writtenForm())
93 return found_written_forms
def check_attr_type
Check that attribute value is of specified type.
def check_attr_range
Check that attribute value is in specified range.