def trees_from(text, part, parent_label): """Build a tree for the appendix section. It will have children for each appendix. Text is the text of the entire regulation, while part is the regulation's part (e.g. 1520.)""" children = [] for begin, end in carving.appendices(text): title, appendix = utils.title_body(text[begin:end]) appendix_letter = carving.get_appendix_letter(title, part) label = parent_label + [appendix_letter] sections = carving.appendix_sections(appendix, appendix_letter) if sections: child = paragraph_tree(appendix_letter, sections, appendix, label, title) else: child = generic_tree(appendix, label, title) children.append(child) return children
def trees_from(text, part, parent_label): """Build a tree for the appendix section. It will have children for each appendix. Text is the text of the entire regulation, while part is the regulation's part (e.g. 1520.)""" children = [] for begin, end in carving.appendices(text): title, appendix = utils.title_body(text[begin:end]) appendix_letter = carving.get_appendix_letter(title, part) label = parent_label + [appendix_letter] sections = carving.appendix_sections(appendix, appendix_letter) if sections: child = paragraph_tree( appendix_letter, sections, appendix, label, title) else: child = generic_tree(appendix, label, title) children.append(child) return children
def test_get_appendix_letter(self): self.assertEqual( "A", carving.get_appendix_letter("Appendix A to Part 511", 511)) self.assertEqual( "ZQR", carving.get_appendix_letter("Appendix ZQR to Part 10101", 10101))
def test_get_appendix_letter(self): self.assertEqual( "A", carving.get_appendix_letter("Appendix A to Part 511", 511)) self.assertEqual( "ZQR", carving.get_appendix_letter("Appendix ZQR to Part 10101", 10101))