Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Commit 2bc2503

Browse files
committed
Added new tests for dependency parsing of tagged sentences and file.
1 parent 7fddc1b commit 2bc2503

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/test_depparser.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,39 @@ def check_dep_parse_file(tokenize=False):
7171
def 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\tPRP\t1\tSUB\n'm\tVBP\t-1\tROOT\ngoing\tVBG\t1\tVC\nto\tTO\t2\tVMOD\nthe\tDT\t5\tNMOD\nmarket\tNN\t3\tPMOD\n.\t.\t1\tP\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\tPRP\t1\tSUB', 'am\tVBP\t-1\tROOT',
91+
'going\tVBG\t1\tVC', 'to\tTO\t2\tVMOD',
92+
'the\tDT\t5\tNMOD', 'market\tNN\t3\tPMOD',
93+
'.\t.\t1\tP', '', 'Are\tVBP\t-1\tROOT',
94+
'you\tPRP\t0\tSUB', 'going\tVBG\t0\tVMOD',
95+
'to\tTO\t4\tVMOD', 'come\tVB\t2\tVMOD',
96+
'with\tIN\t4\tVMOD', 'me\tPRP\t5\tPMOD',
97+
'?\t.\t0\tP', '']
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

Comments
 (0)