コード例 #1
0
ファイル: treetests.py プロジェクト: rgeorgi/intent
    def failed_insertion_test(self):
        t = IdTree.fromstring('''(ROOT
  (SBARQ
    (WHNP (WDT What) (NP (NN kind) (PP (IN of) (NP (NNP work,)))))
    (SQ (VP (VBZ then?)))))''')
        tgt_w = create_words_tier_from_string('kam-a na them lis-no-kha hou')
        aln = Alignment([(1, 3), (2, 5), (4, 1), (5, 5)])

        project_ps(t, tgt_w, aln)
コード例 #2
0
ファイル: treetests.py プロジェクト: rgeorgi/intent
    def ordering_test(self):
        """
        This particular tree structure results in changing a child of a tree while iterating through
        the children and required a fix such that if such a change is detected, we start iterating
        over the children again, so we're not holding onto a stale pointer.

        """
        src_t = IdTree.fromstring('''(ROOT (FRAG
                                            (ADVP (RB Probably))
                                            (SBAR (S
                                                    (NP (PRP you))
                                                    (VP (VBP find)
                                                        (ADJP (JJ something))
                                                    )
                                                  )
                                            )
                                           ))''')

        tgt_t = IdTree.fromstring('''(ROOT (FRAG
                                                (VBP chitt-u-m)
                                                (ADVP (RB hola))
                                                (UNK ni)
                                                (UNK hou)
                                                (VBP chitt-u-m)
                                            ))''')
        tgt_w = create_words_tier_from_string('''chitt-u-m hola ni hou chitt-u-m''')
        aln = Alignment([(1,2),(3,1),(3,5)])

        proj = project_ps(src_t, tgt_w, aln)

        self.assertTrue(tgt_t.similar(proj))
コード例 #3
0
ファイル: treetests.py プロジェクト: rgeorgi/intent
    def test_projection(self):
        proj = project_ps(self.t, create_words_tier_from_string("rhoddodd yr athro lyfr i'r bachgen ddoe"), self.aln)

        # Reassign the ids after everything has moved around.
        proj.assign_ids()

        self.assertEqual(self.proj, proj)
コード例 #4
0
ファイル: treetests.py プロジェクト: rgeorgi/intent
    def ctn_merge_2_test(self):
        src_t = IdTree.fromstring('''(ROOT
                                      (UCP
                                        (S
                                          (NP (PRP They))
                                          (VP
                                            (VBP are)
                                            (RB also)
                                            (ADJP
                                              (RB too)
                                              (JJ lazy)
                                              (S
                                                (VP
                                                  (TO to)
                                                  (VP (VB take) (NP (PRP it)) (ADVP (RB out,))))))))
                                        (CC and)
                                        (SBAR
                                          (IN so)
                                          (S
                                            (NP (PRP they))
                                            (VP (VBP do) (RB not) (VP (VB drink) (NP (NN it.))))))))''')
        tgt_w = create_words_tier_from_string('loĩs-ma yaŋ hunci-suma kat-a-ŋs-e kina u-tus-u-kV-nɨŋ')
        aln = Alignment([(16, 6), (3, 2), (7, 1), (15, 3), (9, 3), (11, 3), (12, 6), (14, 6), (13, 6), (4, 3), (5, 3)])

        proj = project_ps(src_t, tgt_w, aln)
        self.assertEqual(len(proj.leaves()), 6)
コード例 #5
0
ファイル: treetests.py プロジェクト: rgeorgi/intent
    def test_duplicates(self):
        """
        Test the case where an English word aligns to multiple language words.

        """
        src_t = IdTree.fromstring('(ROOT (SBARQ (WHNP (WP Who)) (SQ (VP (VBZ else?)))))')
        tgt_w = create_words_tier_from_string('sa-lo sa-lo')
        tgt_t = IdTree.fromstring('(ROOT (SBARQ (WHNP (WP sa-lo) (WP sa-lo))))')
        aln = Alignment([(1,1),(1,2)])

        result = project_ps(src_t, tgt_w, aln)

        self.assertTrue(tgt_t.similar(result))