示例#1
0
    def test_intervening_characters(self):
        inst = self.xc[0]
        gloss_tokens = glosses(inst)
        morph_tokens  = morphemes(inst)

        # Check for the intervening characters between
        # the first two morphs from the language line
        ichars = intervening_characters(morph_tokens[0],morph_tokens[1])

        # The intervening character should be a hyphen.
        self.assertEqual('-', ichars)

        # Now, check for the first two of the gloss line.
        gchars = intervening_characters(gloss_tokens[0], gloss_tokens[1])

        self.assertEqual('.', gchars)

        # And make sure that what is between the second and third
        # language morphemes is just whitespace.

        wchars = intervening_characters(morph_tokens[1], morph_tokens[2])

        self.assertEqual(' ', wchars)

        nochars = intervening_characters(morph_tokens[1], morph_tokens[1])

        self.assertEqual('', nochars)
示例#2
0
文件: tests.py 项目: rgeorgi/intent
    def set_bilingual_align_test(self):
        """
        Set the bilingual alignment manually, and ensure that it is read back correctly.
        """

        a = Alignment([(1,1),(1,2),(2,8),(4,3),(5,7),(6,5)])
        set_bilingual_alignment(self.igt, trans(self.igt), glosses(self.igt), a, INTENT_ALN_MANUAL)
        get_trans_glosses_alignment(self.igt, INTENT_ALN_MANUAL)
示例#3
0
    def morph_align_test(self):
        inst = self.xc[0]

        gloss_tokens = glosses(inst)
        morph_tokens = morphemes(inst)

        morph_align(gloss_tokens, morph_tokens)

        self.assertEqual(gloss_tokens[0].alignment, morph_tokens[0].id)
        self.assertEqual(gloss_tokens[1].alignment, morph_tokens[0].id)
        self.assertEqual(gloss_tokens[2].alignment, morph_tokens[0].id)
        self.assertEqual(gloss_tokens[3].alignment, morph_tokens[1].id)
        self.assertEqual(gloss_tokens[4].alignment, morph_tokens[1].id)
        self.assertEqual(gloss_tokens[7].alignment, morph_tokens[2].id)
        self.assertEqual(gloss_tokens[8].alignment, morph_tokens[3].id)
示例#4
0
    def more_morph_align_test(self):
        inst = self.xc[1]

        # Align the gloss/lang words (Needed for aligning morphs)
        add_gloss_lang_alignments(inst)

        gloss_tokens = glosses(inst)
        morph_tokens = morphemes(inst)

        # Do the alignment
        morph_align(gloss_tokens, morph_tokens)

        # Assert that the glosses are aligned...
        self.assertIsNotNone(gloss_tokens[0].alignment)

        self.assertEquals(gloss_tokens[11].alignment, morph_tokens[6].id)
        self.assertEquals(gloss_tokens[12].alignment, morph_tokens[6].id)
        self.assertEquals(gloss_tokens[13].alignment, morph_tokens[7].id)
        self.assertEquals(gloss_tokens[14].alignment, morph_tokens[7].id)
示例#5
0
文件: tests.py 项目: rgeorgi/intent
 def glosses_test(self):
     """
     Test that the glosses are rendered correctly.
     """
     self.assertEqual(len(glosses(self.igt)), 10)
     self.assertEqual(tier_text(glosses(self.igt)), 'I Nom child Dat rice Acc eat Caus Pst Dec')