6 from core.definition
import Definition
7 from morphosyntax.paradigm
import Paradigm
8 from mrd.context
import Context
9 from mrd.subject_field
import SubjectField
10 from mrd.equivalent
import Equivalent
13 """! "Sense is a class representing one meaning of a lexical entry. The Sense class allows for hierarchical senses in that a sense may be more specific than another sense of the same lexical entry." (LMF)
16 """! @brief Constructor.
17 Sense instances are owned by LexicalEntry.
18 @param id IDentifier. If not provided, default value is 0.
19 @return A Sense instance.
44 """! @brief Destructor.
45 Release Definition, Sense, Equivalent, Context, SubjectField, Paradigm instances.
50 for sense
in self.
sense:
67 """! @brief IDentifier.
68 @return Sense attribute 'id'.
73 """! @brief Set sense number.
74 @param sense_number The sense number to set.
75 @return Sense instance.
81 """! @brief Get sense number.
82 @integer If True, return a numerical value.
83 @return Sense attribute 'senseNumber'.
92 """! @brief Create a definition.
93 @return Definition instance.
98 """! @brief Add a definition to the sense.
99 @param definition The Definition instance to add to the sense.
100 @return Sense instance.
102 self.definition.append(definition)
106 """! @brief Get all definitions maintained by the sense.
107 @return A Python list of definitions.
112 """! @brief Get the previously registered Definition instance.
113 @return The last element of Sense attribute 'definition'.
119 """! @brief Find definitions.
120 This attribute is owned by Definition.
121 @param language The language to consider to retrieve the definition.
122 @return A Python list of found Definition attributes 'definition'.
124 found_definitions = []
126 if definition.get_language() == language
and definition.get_definition()
is not None:
127 found_definitions.append(definition.get_definition())
128 return found_definitions
131 """! @brief Set definition and language.
132 These attributes are owned by Definition.
133 @param definition Definition.
134 @param language Language of definition.
135 @return Sense instance.
140 if inst.get_language() == language
and inst.get_definition()
is None:
147 if inst.get_language()
is None and inst.get_definition()
is None:
155 instance.set_definition(definition, language)
159 """! @brief Find glosses.
160 This attribute is owned by Definition.
161 @param language The language to consider to retrieve the gloss.
162 @return A Python list of found Definition attributes 'gloss'.
166 if definition.get_language() == language
and definition.get_gloss()
is not None:
167 found_glosses.append(definition.get_gloss())
171 """! @brief Set gloss and language.
172 These attributes are owned by Definition.
174 @param language Language of gloss.
175 @return Sense instance.
180 if inst.get_language() == language
and inst.get_gloss()
is None:
187 if inst.get_language()
is None and inst.get_gloss()
is None:
195 instance.set_gloss(gloss, language)
198 def set_note(self, note, type=None, language=None):
199 """! @brief Set note, note type and language.
200 These attributes are owned by Statement, which is owned by Definition.
201 @param note Note to set.
202 @param type Type of the note.
203 @param language Language used for the note.
204 @return Sense instance.
209 if definition
is None:
212 definition.set_note(note, type, language)
216 """! @brief Find notes.
217 This attribute is owned by Statement, which owned by Definition.
218 @param type Type of the note to consider to retrieve the note.
219 @param language If this argument is given, find note only if written in this language.
220 @return A Python list of found Statement attributes 'notes'.
224 found_notes += definition.find_notes(type, language)
228 """! @brief Set usage note and language.
229 These attributes are owned by Statement, which is owned by Definition.
230 @param usage_note Usage note to set.
231 @param language Language used for the usage note.
232 @return Sense instance.
237 if definition
is None:
240 definition.set_usage_note(usage_note, language)
244 """! @brief Find usage notes.
245 This attribute is owned by Statement, which owned by Definition.
246 @param language Language to consider to retrieve the usage note.
247 @return A Python list of found Statement attributes 'usageNote'.
251 found_notes += definition.find_usage_notes(language)
255 """! @brief Set encyclopedic information and language.
256 These attributes are owned by Statement, which is owned by Definition.
257 @param encyclopedic_information Encyclopedic information to set.
258 @param language Language used for the encyclopedic information.
259 @return Sense instance.
264 if definition
is None:
267 definition.set_encyclopedic_information(encyclopedic_information, language)
271 """! @brief Find encyclopedic informations.
272 This attribute is owned by Statement, which owned by Definition.
273 @param language Language to consider to retrieve the encyclopedic informations.
274 @return A Python list of found Statement attributes 'encyclopedicInformation'.
276 found_informations = []
278 found_informations += definition.find_encyclopedic_informations(language)
279 return found_informations
282 """! @brief Set restriction and language.
283 These attributes are owned by Statement, which is owned by Definition.
284 @param restriction Restriction to set.
285 @param language Language used for the restriction.
286 @return Sense instance.
291 if definition
is None:
294 definition.set_restriction(restriction, language)
298 """! @brief Find restrictions.
299 This attribute is owned by Statement, which owned by Definition.
300 @param language Language to consider to retrieve the restriction.
301 @return A Python list of found Statement attributes 'restriction'.
303 found_restrictions = []
305 found_restrictions += definition.find_restrictions(language)
306 return found_restrictions
309 """! @brief Set source language (in English).
310 Attribute 'borrowedWord' is owned by Statement, which is owned by Definition.
311 @param borrowed_word Source language.
312 @return Sense instance.
317 if definition
is None:
320 definition.set_borrowed_word(borrowed_word)
324 """! @brief Get source language (in English).
325 This attribute is owned by Statement, which is owned by Definition.
326 @return Statement attribute 'borrowedWord'.
329 if definition.get_borrowed_word()
is not None:
331 return definition.get_borrowed_word()
334 """! @brief Set loan word.
335 Attribute 'writtenForm' is owned by Statement, which is owned by Definition.
336 @param written_form Loan word.
337 @return Sense instance.
342 if definition
is None:
345 definition.set_written_form(written_form)
349 """! @brief Get loan word.
350 This attribute is owned by Statement, which is owned by Definition.
351 @return Statement attribute 'writtenForm'.
354 if definition.get_written_form()
is not None:
356 return definition.get_written_form()
359 """! @brief Set etymology.
360 Attribute 'etymology' is owned by Statement, which is owned by Definition.
361 @param etymology Etymology.
362 @return Sense instance.
367 if definition
is None:
370 definition.set_etymology(etymology)
374 """! @brief Get etymology.
375 This attribute is owned by Statement, which is owned by Definition.
376 @return The first found Statement attribute 'etymology'.
379 if definition.get_etymology()
is not None:
380 return definition.get_etymology()
383 """! @brief Set etymology comment and language.
384 Attributes 'etymologyComment' and 'termSourceLanguage' are owned by Statement, which is owned by Definition.
385 @param etymology_comment Etymology comment.
386 @param term_source_language Language of the comment.
387 @return Sense instance.
392 if definition
is None:
395 definition.set_etymology_comment(etymology_comment, term_source_language)
399 """! @brief Get etymology comment.
400 This attribute is owned by Statement, which is owned by Definition.
401 @param term_source_language The language of the etymology comment to retrieve.
402 @return The first found Statement attribute 'etymologyComment'.
405 if definition.get_etymology_comment(term_source_language)
is not None:
406 return definition.get_etymology_comment(term_source_language)
409 """! @brief Get language used for the etymology comment.
410 This attribute is owned by Statement, which is owned by Definition.
411 @return Statement attribute 'termSourceLanguage'.
416 if definition
is not None:
417 return definition.get_term_source_language()
420 """! @brief Set etymology gloss.
421 Attribute 'etymologyGloss' is owned by Statement, which is owned by Definition.
422 @param etymology_gloss Etymology gloss.
423 @return Sense instance.
428 if definition
is None:
431 definition.set_etymology_gloss(etymology_gloss)
435 """! @brief Get etymology gloss.
436 This attribute is owned by Statement, which is owned by Definition.
437 @return Statement attribute 'etymologyGloss'.
442 if definition
is not None:
443 return definition.get_etymology_gloss()
446 """! @brief Set etymology source.
447 Attribute 'etymologySource' is owned by Statement, which is owned by Definition.
448 @param etymology_source Etymology source.
449 @return Sense instance.
454 if definition
is None:
457 definition.set_etymology_source(etymology_source)
461 """! @brief Get etymology source.
462 This attribute is owned by Statement, which is owned by Definition.
463 @return Statement attribute 'etymologySource'.
468 if definition
is not None:
469 return definition.get_etymology_source()
472 """! @brief Set scientific name.
473 Attribute 'scientificName' is owned by Statement, which is owned by Definition.
474 @param scientific_name Scientific name.
475 @return Sense instance.
480 if definition
is None:
483 definition.set_scientific_name(scientific_name)
487 """! @brief Get scientific name.
488 This attribute is owned by Statement, which is owned by Definition.
489 @return Statement attribute 'scientificName'.
494 if definition
is not None:
495 return definition.get_scientific_name()
498 """! @brief Create a paradigm.
499 @return Paradigm instance.
504 """! @brief Add a paradigm to the sense.
505 @param paradigm The Paradigm instance to add to the sense.
506 @return Sense instance.
508 self.paradigm.append(paradigm)
512 """! @brief Get all paradigms maintained by the sense.
513 @return A Python list of paradigms.
518 """! @brief Get the previously registered Paradigm instance.
519 @return The last element of Sense attribute 'paradigm'.
525 """! @brief Set paradigm label.
526 Attribute 'paradigmLabel' is owned by Paradigm.
527 @param paradigm_label Paradigm label.
528 @return Sense instance.
535 """! @brief Set paradigm form and language.
536 Attributes 'paradigm' and 'language' are owned by Paradigm.
537 @param paradigm_form Paradigm form.
538 @param language Language used for the paradigm form.
539 @return Sense instance.
541 paradigm_label =
None
545 if paradigm
is not None:
547 paradigm_label = paradigm.get_paradigmLabel()
548 if paradigm.get_paradigm()
is not None or (paradigm.get_language()
is not None and paradigm.get_language() != language):
555 paradigm.set_paradigm(paradigm_form)
556 if language
is not None:
557 paradigm.set_language(language)
559 if paradigm_label
is not None and paradigm.get_paradigmLabel()
is None:
560 paradigm.set_paradigmLabel(paradigm_label)
564 """! @brief Set morphology.
565 Attribute 'morphology' is owned by Paradigm.
566 @param morphology Morphology.
567 @return Sense instance.
572 if item.get_morphology()
is None:
579 paradigm.set_morphology(morphology)
583 """! @brief Create a context and add it to the list.
584 @param reference The context reference to set. If not provided, default value is None.
585 @return Context instance.
587 context = Context(reference)
588 self.context.append(context)
592 """! @brief Get all contexts maintained by the sense.
593 @return A Python list of contexts.
598 """! @brief Get the previously registered Context instance.
599 @return The last element of Sense attribute 'context'.
605 """! @brief Create a Context instance and set its reference.
606 Attribute 'targets' is owned by Context.
607 @param reference The example reference to set. If not provided, default value is None.
608 @return Sense instance.
614 """! @brief Set written form, language and script of a new Context instance.
615 Attributes 'writtenForm', 'language' and 'scriptName' are owned by TextRepresentation, which is owned by Context.
616 @param written_form The written form to set.
617 @param language Language used for the written form.
618 @param script_name The name of the script used to write the example, e.g. devanagari.
619 @return Sense instance.
624 if context
is None or len(context.get_text_representations()) != 0:
626 context.set_written_form(written_form, language, script_name)
629 def add_example(self, written_form, language=None, script_name=None):
630 """! @brief Set written form, language and script of an existing Context instance.
631 Attributes 'writtenForm', 'language' and 'scriptName' are owned by TextRepresentation, which is owned by Context.
632 @param written_form The written form to set.
633 @param language Language used for the written form.
634 @param script_name The name of the script used to write the example, e.g. devanagari.
635 @return Sense instance.
642 context.set_written_form(written_form, language, script_name)
646 """! @brief Set comment of an existing Context instance.
647 Attribute 'comment' is owned by TextRepresentation, which is owned by Context.
648 @param comment The comment to set.
649 @return Sense instance.
656 context.set_comment(comment)
660 """! @brief Create a subject field and add it to the list.
661 @return SubjectField instance.
663 subject_field = SubjectField()
664 self.subject_field.append(subject_field)
668 """! @brief Get all subject fields maintained by the sense.
669 @return A Python list of subject fields.
674 """! @brief Create a SubjectField instance and set its semantic domain and language.
675 Attributes 'semanticDomain' and 'language' are owned by SubjectField.
676 @param semantic_domain The semantic domain to set.
677 @param language Language used to describe the semantic domain.
678 @return Sense instance.
684 """! @brief Create an equivalent and add it to the list.
685 @return Equivalent instance.
687 equivalent = Equivalent()
688 self.equivalent.append(equivalent)
692 """! @brief Get all equivalents maintained by the sense.
693 @return A Python list of equivalents.
698 """! @brief Create an Equivalent instance and set its translation and language.
699 Attributes 'translation' and 'language' are owned by Equivalent.
700 @param translation The translation to set.
701 @param language Language used for the translation.
702 @return Sense instance.
708 """! @brief Get all translations.
709 This attribute is owned by Equivalent.
710 @param language If this argument is given, get only translations that are described using this language.
711 @return A Python list of filtered Equivalent attributes 'translation'.
715 if equivalent.get_translation(language)
is not None:
716 translations.append(equivalent.get_translation(language))
paradigm
Paradigm instances are owned by Sense There is zero to many Paradigm instances per Sense...
def set_morphology
Set morphology.
def get_last_paradigm
Get the previously registered Paradigm instance.
def set_etymology_comment
Set etymology comment and language.
definition
Definition instances are owned by Sense There is zero to many Definition instances per Sense...
def set_paradigm_label
Set paradigm label.
def add_paradigm
Add a paradigm to the sense.
def set_example_comment
Set comment of an existing Context instance.
def set_etymology
Set etymology.
def get_paradigms
Get all paradigms maintained by the sense.
def set_gloss
Set gloss and language.
def find_notes
Find notes.
def get_translations
Get all translations.
def set_restriction
Set restriction and language.
def set_usage_note
Set usage note and language.
def get_scientific_name
Get scientific name.
def get_etymology_gloss
Get etymology gloss.
def find_definitions
Find definitions.
def get_etymology_source
Get etymology source.
def create_and_add_context
Create a context and add it to the list.
def get_senseNumber
Get sense number.
def add_definition
Add a definition to the sense.
def find_encyclopedic_informations
Find encyclopedic informations.
def create_and_add_subject_field
Create a subject field and add it to the list.
def set_etymology_source
Set etymology source.
def set_definition
Set definition and language.
def get_contexts
Get all contexts maintained by the sense.
def get_written_form
Get loan word.
equivalent
Equivalent instances are owned by Sense There is zero to many Equivalent instances per Sense...
"Sense is a class representing one meaning of a lexical entry. The Sense class allows for hierarchica...
def create_and_add_example
Set written form, language and script of a new Context instance.
def get_definitions
Get all definitions maintained by the sense.
def get_last_context
Get the previously registered Context instance.
def set_note
Set note, note type and language.
def set_etymology_gloss
Set etymology gloss.
def find_usage_notes
Find usage notes.
def get_etymology
Get etymology.
def get_subject_fields
Get all subject fields maintained by the sense.
def set_semantic_domain
Create a SubjectField instance and set its semantic domain and language.
def get_term_source_language
Get language used for the etymology comment.
def find_restrictions
Find restrictions.
subject_field
SubjectField instances are owned by Sense There is zero to many SubjectField instances per Sense...
sense
Sense instances are owned by Sense There is zero to many Sense instances per Sense.
def set_paradigm_form
Set paradigm form and language.
def create_paradigm
Create a paradigm.
def set_written_form
Set loan word.
context
Context instances are owned by Sense There is zero to many Context instances per Sense.
def create_definition
Create a definition.
def add_example
Set written form, language and script of an existing Context instance.
def set_borrowed_word
Set source language (in English).
def find_glosses
Find glosses.
def create_example
Create a Context instance and set its reference.
def set_encyclopedic_information
Set encyclopedic information and language.
def set_translation
Create an Equivalent instance and set its translation and language.
def get_borrowed_word
Get source language (in English).
def set_scientific_name
Set scientific name.
def get_equivalents
Get all equivalents maintained by the sense.
def get_last_definition
Get the previously registered Definition instance.
def get_etymology_comment
Get etymology comment.
def set_senseNumber
Set sense number.
def create_and_add_equivalent
Create an equivalent and add it to the list.