def test_parse_postscript_alice_bug_002(self): options = 0 # options |= (BIT_RWALL | BIT_CAPS) options &= ~BIT_STRIP tokens, links = parse_postscript(alice_bug_002, options, sys.stdout) self.assertEqual(29, len(tokens), tokens)
def test_parse_postscript_gutenchildren_bug_002(self): options = BIT_NO_LWALL | BIT_NO_PERIOD | BIT_STRIP tokens, links = parse_postscript(gutenberg_children_bug_002, options, sys.stdout) print(tokens) self.assertEqual(12, len(tokens)) self.assertEqual(6, len(links))
def test_parse_postscript_all_walls(self): """ test_parse_postscript """ # print(__doc__, sys.stderr) options = 0 options |= (BIT_RWALL | BIT_CAPS) options &= ~BIT_STRIP tokens, links = parse_postscript(self.post_all_walls, options, sys.stdout) pm = parse_metrics(tokens) self.assertEqual(1.0, pm.completely_parsed_ratio) self.assertEqual(0.0, pm.completely_unparsed_ratio) self.assertEqual(1.0, pm.average_parsed_ratio)
def test_get_link_set(self): # post_all_walls = "[(LEFT-WALL)(Dad[!])(was.v-d)(not.e)(a)(parent.n)(before)(.)(RIGHT-WALL)]" \ # "[[0 7 2 (Xp)][0 1 0 (Wd)][1 2 0 (Ss*s)][2 5 1 (Osm)][2 3 0 (EBm)]" \ # "[4 5 0 (Ds**c)][5 6 0 (Mp)][7 8 0 (RW)]][0]" expected_set = {(1, 2), (2, 5), (2, 3), (4, 5), (5, 6)} options = BIT_NO_LWALL | BIT_NO_PERIOD | BIT_STRIP | BIT_PARSE_QUALITY tokens, links = parse_postscript(self.post_all_walls, options, sys.stdout) result_set = get_link_set(tokens, links, options) print(expected_set) print(result_set) self.assertTrue(result_set == expected_set)
def test_parse_postscript_alice_bug_001(self): """ test_parse_postscript """ # print(__doc__, sys.stderr) options = 0 # options |= (BIT_RWALL | BIT_CAPS) options &= ~BIT_STRIP tokens, links = parse_postscript(alice_bug_001, options, sys.stdout) self.assertEqual(15, len(tokens)) for link in links: self.assertTrue(link[0] < 15 and link[1] < 15, str(link))
def test_parse_postscript_gutenchildren_bug(self): """ test_parse_postscript """ # print(__doc__, sys.stderr) options = 0 # options |= (BIT_RWALL | BIT_CAPS) # options &= ~BIT_STRIP tokens, links = parse_postscript(gutenberg_children_bug, options, sys.stdout) self.assertEqual(18, len(tokens)) pm = parse_metrics(tokens) self.assertEqual(0.0, pm.completely_parsed_ratio) self.assertEqual(0.0, pm.completely_unparsed_ratio) self.assertEqual(0.9411764705882353, float(pm.average_parsed_ratio))