@@ -71,3 +71,39 @@ def check_dep_parse_file(tokenize=False):
7171def test_dep_parse_file ():
7272 yield check_dep_parse_file , False
7373 yield check_dep_parse_file , True
74+
75+
76+ def test_dep_parse_tagged_sentence ():
77+ from tests import depparser
78+
79+ tagged_sentence = "I/PRP 'm/VBP going/VBG to/TO the/DT market/NN ./."
80+ correct_output = "I\t PRP\t 1\t SUB\n 'm\t VBP\t -1\t ROOT\n going\t VBG\t 1\t VC\n to\t TO\t 2\t VMOD\n the\t DT\t 5\t NMOD\n market\t NN\t 3\t PMOD\n .\t .\t 1\t P\n "
81+ parsed_sentence = depparser .dep_parse_tagged_sentence (tagged_sentence )
82+
83+ assert_equal (parsed_sentence , correct_output )
84+
85+
86+ def test_dep_parse_tagged_file ():
87+
88+ from tests import depparser
89+
90+ correct_output = ['I\t PRP\t 1\t SUB' , 'am\t VBP\t -1\t ROOT' ,
91+ 'going\t VBG\t 1\t VC' , 'to\t TO\t 2\t VMOD' ,
92+ 'the\t DT\t 5\t NMOD' , 'market\t NN\t 3\t PMOD' ,
93+ '.\t .\t 1\t P' , '' , 'Are\t VBP\t -1\t ROOT' ,
94+ 'you\t PRP\t 0\t SUB' , 'going\t VBG\t 0\t VMOD' ,
95+ 'to\t TO\t 4\t VMOD' , 'come\t VB\t 2\t VMOD' ,
96+ 'with\t IN\t 4\t VMOD' , 'me\t PRP\t 5\t PMOD' ,
97+ '?\t .\t 0\t P' , '' ]
98+
99+ input_file = abspath (join (_my_dir , '..' , 'examples' , 'test_tagged.txt' ))
100+ output_file = abspath (join (_my_dir , '..' , 'examples' , 'test_tagged.dep' ))
101+
102+ # parse the file
103+ depparser .dep_parse_tagged_file (input_file , output_file )
104+
105+ # read the output file and make sure we have the expected output
106+ with open (output_file , 'r' ) as outf :
107+ output = [l .strip () for l in outf .readlines ()]
108+
109+ assert_equal (output , correct_output )
0 commit comments