Ejemplo n.º 1
0
 def create_related_form(self, lexeme, semantic_relation):
     """! @brief Create a related form.
     @param lexeme Related lexeme.
     @param semantic_relation The semantic relation existing between this lexical entry and the related lexeme to create.
     @return RelatedForm instance.
     """
     return RelatedForm(lexeme).set_semanticRelation(semantic_relation)
Ejemplo n.º 2
0
 def create_and_add_related_form(self, lexeme, semantic_relation):
     """! @brief Create and add a related form to the lexical entry.
     @param lexeme Related lexeme.
     @param semantic_relation The semantic relation existing between this lexical entry and the related lexeme to create.
     @return LexicalEntry instance.
     """
     # Check if this related form already exists
     for related_form in self.get_related_forms():
         if related_form.get_lexeme() == lexeme:
             return self
     self.related_form.append(
         RelatedForm(lexeme).set_semanticRelation(semantic_relation))
     return self
Ejemplo n.º 3
0
 def test_add_link(self):
     from morphology.related_form import RelatedForm
     input = Element("RelatedForm", targets="lx")
     form = RelatedForm()
     form.set_lexical_entry(LexicalEntry(id="lx_id"))
     # Create output element and sub-elements
     output = Element("RelatedForm", targets="lx")
     sub = SubElement(output, "a")
     sub.attrib["href"] = "lx_id1"
     # Fill in text
     sub.text = "lx"
     result = add_link(form, input)
     self.assertEqual(result[0], form)
     self.assertEqual(tostring(result[1]), tostring(output))