def test_get_appendix_section_number(self): self.assertEqual( "2", carving.get_appendix_section_number("A-2--Title Stuff", 'A')) self.assertEqual( "50", carving.get_appendix_section_number("QQ-50--Title Stuff", 'QQ')) self.assertEqual( "21(b)", carving.get_appendix_section_number(u"A-21(b)—A Model form", 'A')) self.assertEqual( "21(B)", carving.get_appendix_section_number(u"A-21(B)—A Model form", 'A'))
def paragraph_tree(appendix_letter, sections, text, label, title=None): """Use the paragraph parser to parse through each section in this appendix.""" if not sections: return Node(text, label=label, title=title, node_type=Node.APPENDIX) children = [] for begin, end in sections: seg_title, section_text = utils.title_body(text[begin:end]) sec_num = carving.get_appendix_section_number( seg_title, appendix_letter) exclude = [(pc.full_start, pc.full_end) for pc in internal_citations(section_text, Label(part=label[0]))] child = parParser.build_tree( section_text, exclude=exclude, label=label + [sec_num], title=seg_title) children.append(child) return Node(text[:sections[0][0]], children, label, title, Node.APPENDIX)