Exemplo n.º 1
0
    def test_normalize_parse_tree(self):
        num_matches = 0
        for parse_tree, s, e in TEILiteParser.pRegion.scanString(self.tei_data1):
            num_matches = num_matches + 1
            nparse_tree = TEILiteParser.normalizeParseTree(parse_tree.asList())
            self.assertTrue(nparse_tree['type'] == 'p')
            self.assertTrue(nparse_tree['id'] != None)
        self.assertEqual(num_matches, 6)

        num_matches = 0
        for parse_tree, s, e in TEILiteParser.headRegion.scanString(self.tei_data1):
            num_matches = num_matches + 1
            nparse_tree = TEILiteParser.normalizeParseTree(parse_tree.asList())
            self.assertTrue(nparse_tree['type'] == 'head')
            self.assertTrue(nparse_tree['id'] != None)
        self.assertEqual(num_matches, 5)

        num_matches = 0
        for parse_tree, s, e in TEILiteParser.sssRegion.scanString(self.tei_data1):
            num_matches = num_matches + 1
            nparse_tree = TEILiteParser.normalizeParseTree(parse_tree.asList())
            self.assertTrue(nparse_tree['type'] == 'subsubsection')
            self.assertTrue(nparse_tree['id'] != None)
        self.assertEqual(num_matches, 2)

        num_matches = 0
        for parse_tree, s, e in TEILiteParser.ssRegion.scanString(self.tei_data1):
            num_matches = num_matches + 1
            nparse_tree = TEILiteParser.normalizeParseTree(parse_tree.asList())
            self.assertTrue(nparse_tree['type'] == 'subsection')
            self.assertTrue(nparse_tree['id'] != None)
        self.assertTrue(num_matches, 1)

        num_matches = 0
        for parse_tree, s, e in TEILiteParser.sRegion.scanString(self.tei_data1):
            num_matches = num_matches + 1
            nparse_tree = TEILiteParser.normalizeParseTree(parse_tree.asList())
            self.assertTrue(nparse_tree['type'] == 'section')
            self.assertTrue(nparse_tree['id'] != None)
        self.assertTrue(num_matches, 2)