From 077885637db1f8cd6323b75e26328692d8b909c9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 22 Oct 2014 10:18:43 +1100 Subject: [PATCH] * Add test for reading in POS tags --- tests/test_read_pos.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/test_read_pos.py diff --git a/tests/test_read_pos.py b/tests/test_read_pos.py new file mode 100644 index 000000000..5590679b1 --- /dev/null +++ b/tests/test_read_pos.py @@ -0,0 +1,15 @@ +import py.test +from spacy.pos_util import realign_tagged +from spacy.pos_util import _parse_line + +def test_realign(): + rules = [",", "can't", "``"] + tagged = "``/`` I/PRP ca/MD n't/RB" + assert realign_tagged(rules, tagged) == "``I/``_PRP can't/MD_RB" + + +def test_parse_line(): + line = "Pierre/NNP Vinken,/NNP_, isn't/VBZ_RB 61/CD years/NNS old./RB_.\n" + tokens, tags = _parse_line(line, '/') + assert len(tokens) == len(tags) + assert len(tokens) == 9