3 """! @package morphology
6 from core.form
import Form
7 from core.form_representation
import FormRepresentation
8 from utils.attr
import check_attr_range
9 from common.range
import person_range, anymacy_range, grammaticalNumber_range, clusivity_range
10 from config.mdf
import pd_person, pd_anymacy, pd_grammaticalNumber, pd_clusivity
13 """! "Word Form is a Form subclass representing a form that a lexeme can take when used in a sentence or a phrase." (LMF)
16 """! @brief Constructor.
17 WordForm instances are owned by LexicalEntry.
18 @return A WordForm instance.
34 """! @brief Destructor.
39 """! @brief Create a form representation.
40 @return FormRepresentation instance.
42 return FormRepresentation()
45 """! @brief Add a form representation to the word form.
46 @param form_representation The FormRepresentation instance to add to the word form.
47 @return WordForm instance.
49 self.form_representation.append(form_representation)
53 """! @brief Get all form representations maintained by the word form.
54 @return A Python list of form representations.
56 return self.form_representation
59 """! @brief Set written form.
60 This attribute is owned by Representation.
61 @param written_form Written form.
62 @param script_name Script used for the written form.
63 @return WordForm instance.
65 form_representation =
None
68 if repr.get_writtenForm()
is None:
69 form_representation = repr
71 if form_representation
is None:
75 form_representation.set_writtenForm(written_form, script_name)
79 """! @brief Get all written forms.
80 This attribute is owned by Representation.
81 @param script_name If this argument is given, get written form only if written using this script.
82 @return A Python list of FormRepresentation attributes 'writtenForm'.
86 if repr.get_writtenForm(script_name)
is not None:
87 written_forms.append(repr.get_writtenForm(script_name))
91 """! @brief Set variant form.
92 This attribute is owned by FormRepresentation.
93 @param variant_form Variant form.
94 @return WordForm instance.
96 form_representation =
None
99 if repr.get_variantForm()
is None:
100 form_representation = repr
102 if form_representation
is None:
106 form_representation.set_variantForm(variant_form)
110 """! @brief Get all variant forms.
111 This attribute is owned by FormRepresentation.
112 @return A Python list of FormRepresentation attributes 'variantForm'.
116 if repr.get_variantForm()
is not None:
117 variant_forms.append(repr.get_variantForm())
121 """! @brief Set grammatical person.
122 @param person The grammatical person to set.
123 @return WordForm instance.
125 error_msg =
"Person value '%s' is not allowed" % str(person)
127 value =
check_attr_range(person, person_range, error_msg, mapping=pd_person)
132 """! @brief Get grammatical person.
133 @return WordForm attribute 'person'.
138 """! @brief Set grammatical anymacy.
139 @param anymacy The grammatical anymacy to set.
140 @return WordForm instance.
142 error_msg =
"Anymacy value '%s' is not allowed" % str(anymacy)
144 value =
check_attr_range(anymacy, anymacy_range, error_msg, mapping=pd_anymacy)
149 """! @brief Get anymacy.
150 @return WordForm attribute 'anymacy'.
155 """! @brief Set grammatical number.
156 @param grammatical_number The grammatical number to set.
157 @return WordForm instance.
159 error_msg =
"Grammatical number value '%s' is not allowed" % grammatical_number
161 value =
check_attr_range(grammatical_number, grammaticalNumber_range, error_msg, mapping=pd_grammaticalNumber)
166 """! @brief Get grammatical number.
167 @return WordForm attribute 'grammaticalNumber'.
172 """! @brief Set grammatical clusivity.
173 @param clusivity The grammatical clusivity to set.
174 @return WordForm instance.
176 error_msg =
"Clusivity value '%s' is not allowed" % clusivity
178 value =
check_attr_range(clusivity, clusivity_range, error_msg, mapping=pd_clusivity)
183 """! @brief Get grammatical clusivity.
184 @return WordForm attribute 'clusivity'.
def check_attr_range
Check that attribute value is in specified range.