Exemplo n.º 1
0
    def test_get_region_id(self):
        # Write TEI tests for subsubsection, subsection, and section
        parser = TEILiteParser()
        expected_ids = {'subsubsection': ['1', '2'],
                         'subsection': ['1'],
                         'section': ['1', '9']}

        for region_type in expected_ids.keys():
            production = parser.getGrammarForUnit(region_type)

            ids = []
            match_forest = production.scanString(self.tei_data1)

            subtree_idx = 0
            for subtree, s, e in match_forest:
                new_id = parser.getRegionID(subtree, region_type, subtree_idx)
                ids.append(new_id)
                subtree_idx = subtree_idx + 1

            i = 0
            for id in ids:
                self.assertEqual(id, expected_ids[region_type][i])
                i = i + 1