def test_appendices(self):
        sect1 = "Some \n"
        appa = "Appendix A to Part 222 Title\nContent\ncontent\n\n"
        appb = "Appendix Q to Part 222 More Info\n\nContent content\n"
        supp = "Supplement I The Interpretations\n\nAppendix Q\n"
        supp += "Interpretations about appendix Q"

        apps = carving.appendices(sect1 + appa + appb + supp)
        self.assertEqual(2, len(apps))
        self.assertEqual((len(sect1), len(sect1+appa)), apps[0])
        self.assertEqual((len(sect1+appa), len(sect1+appa+appb)), apps[1])
Exemple #2
0
    def test_appendices(self):
        sect1 = "Some \n"
        appa = "Appendix A to Part 222 Title\nContent\ncontent\n\n"
        appb = "Appendix Q to Part 222 More Info\n\nContent content\n"
        supp = "Supplement I The Interpretations\n\nAppendix Q\n"
        supp += "Interpretations about appendix Q"

        apps = carving.appendices(sect1 + appa + appb + supp)
        self.assertEqual(2, len(apps))
        self.assertEqual((len(sect1), len(sect1 + appa)), apps[0])
        self.assertEqual((len(sect1 + appa), len(sect1 + appa + appb)),
                         apps[1])
Exemple #3
0
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
Exemple #4
0
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