Exemplo n.º 1
0
    def test_to_conllu_with_deps_str(self):
        emptynode = EmptyNode(
            main_index=1,
            sub_index=2,
            deps='1:Foo|2:Bar')

        self.assertEqual(
            '1.2\t_\t_\t_\t_\t_\t_\t_\t1:Foo|2:Bar\t_',
            emptynode.to_conllu())
Exemplo n.º 2
0
    def test_to_conllu_with_deps_tuple(self):
        emptynode = EmptyNode(
            main_index=1,
            sub_index=2,
            deps=((1, 'Foo'), (2, 'Bar')))

        self.assertEqual(
            '1.2\t_\t_\t_\t_\t_\t_\t_\t1:Foo|2:Bar\t_',
            emptynode.to_conllu())
Exemplo n.º 3
0
    def test_to_conllu_with_feats_as_tuple(self):
        emptynode = EmptyNode(
            main_index=1,
            sub_index=2,
            feats=(('Foo', ('Bar',)), ('Baz', ('Qux', 'Zet'))))

        self.assertEqual(
            '1.2\t_\t_\t_\t_\tFoo=Bar|Baz=Qux,Zet\t_\t_\t_\t_',
            emptynode.to_conllu())
Exemplo n.º 4
0
    def test_to_conllu_with_feats_as_str(self):
        emptynode = EmptyNode(
            main_index=1,
            sub_index=2,
            feats='Foo=Bar|Baz=Qux')

        self.assertEqual(
            '1.2\t_\t_\t_\t_\tFoo=Bar|Baz=Qux\t_\t_\t_\t_',
            emptynode.to_conllu())
Exemplo n.º 5
0
    def test_to_conllu_of_sentence_with_all_attributes(self):
        emptynode = EmptyNode(
            main_index=1,
            sub_index=2,
            form='Form',
            lemma='Lemma',
            upos=UposTag.X,
            xpos='XPOS',
            feats='Feat=Foo',
            deps='0:Bar',
            misc='Misc')

        self.assertEqual(
            '1.2\tForm\tLemma\tX\tXPOS\tFeat=Foo\t_\t_\t0:Bar\tMisc',
            emptynode.to_conllu())
Exemplo n.º 6
0
    def test_to_conllu_raises_error_with_unsupported_deps_type(self):
        emptynode = EmptyNode(deps=[1, 'Foo'])

        with self.assertRaises(NotImplementedError):
            emptynode.to_conllu()
Exemplo n.º 7
0
    def test_to_conllu_raises_error_with_unsupported_feats_type(self):
        emptynode = EmptyNode(feats=['Foo', 'Bar'])

        with self.assertRaises(NotImplementedError):
            emptynode.to_conllu()
Exemplo n.º 8
0
 def test_to_conllu_of_invalid_sentence_with_no_attributes(self):
     emptynode = EmptyNode()
     self.assertEqual(
         'None.None\t_\t_\t_\t_\t_\t_\t_\t_\t_', emptynode.to_conllu())