Exemplo n.º 1
0
    def test_segment_tree_with_comment(self):
        text = "Paragraph 20(b)(2)\n1. Some suff.\n"
        text += "2. Ends with see comment 20(b)(2)-4.ii.\n"
        text += "3. Then three\ni. Sub bit\nA. More\n4. Four"

        result = interpretation.segment_tree(text, '28', ['28'])
        self.assertEqual(4, len(result.children))
def test_segment_tree_no_children():
    title = "Section 105.11 This is a section title"
    body = "Body of the interpretation's section"
    result = interpretation.segment_tree(title + "\n" + body, '105', ['105'])
    assert result.text == body
    assert result.label == ['105', '11', Node.INTERP_MARK]
    assert result.children == []
Exemplo n.º 3
0
 def test_segment_tree_label(self):
     """The section tree should include the section header as label"""
     title = "Section 105.11 This is a section title"
     body = "Body of the interpretation's section"
     non_title = "\n" + body
     result = interpretation.segment_tree(title + non_title, '105', ['105'])
     self.assertEqual(title, result.title)
    def test_segment_tree_with_comment(self):
        text = "Paragraph 20(b)(2)\n1. Some suff.\n"
        text += "2. Ends with see comment 20(b)(2)-4.ii.\n"
        text += "3. Then three\ni. Sub bit\nA. More\n4. Four"

        result = interpretation.segment_tree(text, '28', ['28'])
        self.assertEqual(4, len(result.children))
 def test_segment_tree_label(self):
     """The section tree should include the section header as label"""
     title = "Section 105.11 This is a section title"
     body = "Body of the interpretation's section"
     non_title = "\n" + body
     result = interpretation.segment_tree(title + non_title, '105', ['105'])
     self.assertEqual(title, result.title)
Exemplo n.º 6
0
 def test_segment_tree_no_children(self):
     title = "Section 105.11 This is a section title"
     body = "Body of the interpretation's section"
     non_title = "\n" + body
     result = interpretation.segment_tree(title + non_title, '105', ['105'])
     self.assertEqual(non_title, result.text)
     self.assertEqual(['105', '11', Node.INTERP_MARK], result.label)
     self.assertEqual(0, len(result.children))
Exemplo n.º 7
0
 def test_segment_tree_appendix(self):
     title = "Appendix Q - The Questions"
     body = "1. Regulation text 2. Some more i. With ii. Subparts"
     node = interpretation.segment_tree(title + "\n" + body, '100', ['100'])
     self.assertEqual(title, node.title)
     self.assertEqual(['100', 'Q', Node.INTERP_MARK], node.label)
     self.assertEqual(2, len(node.children))
     self.assertEqual(2, len(node.children[1].children))
 def test_segment_tree_no_children(self):
     title = "Section 105.11 This is a section title"
     body = "Body of the interpretation's section"
     non_title = "\n" + body
     result = interpretation.segment_tree(title + non_title, '105', ['105'])
     self.assertEqual(non_title, result.text)
     self.assertEqual(['105', '11', Node.INTERP_MARK], result.label)
     self.assertEqual(0, len(result.children))
 def test_segment_tree_appendix(self):
     title = "Appendix Q - The Questions"
     body = "1. Regulation text 2. Some more i. With ii. Subparts"
     node = interpretation.segment_tree(title + "\n" + body, '100', ['100'])
     self.assertEqual(title, node.title)
     self.assertEqual(['100', 'Q', Node.INTERP_MARK], node.label)
     self.assertEqual(2, len(node.children))
     self.assertEqual(2, len(node.children[1].children))
Exemplo n.º 10
0
    def test_segment_tree_paragraph(self):
        title = "Paragraph 3(b)"
        depth1 = "1. Inline depth and then\n"
        depth2i = "i. some "
        depth2ii = "ii. sub "
        depth2iii = "iii. sections"
        depth2 = "2. Start of line with "
        text = title + "\n" + depth1 + depth2 + depth2i + depth2ii + depth2iii
        a_tree = interpretation.segment_tree(text, '111', ['111', '3', 'b'])
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK], a_tree.label)
        self.assertEqual('Paragraph 3(b)', a_tree.title)
        self.assertEqual("", a_tree.text.strip())
        self.assertEqual(2, len(a_tree.children))

        node = a_tree.children[0]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '1'], node.label)
        self.assertEqual(depth1, node.text)
        self.assertEqual(0, len(node.children))

        node = a_tree.children[1]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2'], node.label)
        self.assertEqual(depth2, node.text)
        self.assertEqual(3, len(node.children))

        node = a_tree.children[1].children[0]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2', 'i'],
                         node.label)
        self.assertEqual(depth2i, node.text)
        self.assertEqual(0, len(node.children))

        node = a_tree.children[1].children[1]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2', 'ii'],
                         node.label)
        self.assertEqual(depth2ii, node.text)
        self.assertEqual(0, len(node.children))

        node = a_tree.children[1].children[2]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2', 'iii'],
                         node.label)
        self.assertEqual(depth2iii, node.text)
        self.assertEqual(0, len(node.children))
    def test_segment_tree_paragraph(self):
        title = "Paragraph 3(b)"
        depth1 = "1. Inline depth and then\n"
        depth2i = "i. some "
        depth2ii = "ii. sub "
        depth2iii = "iii. sections"
        depth2 = "2. Start of line with "
        text = title + "\n" + depth1 + depth2 + depth2i + depth2ii + depth2iii
        a_tree = interpretation.segment_tree(text, '111', ['111', '3', 'b'])
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK], a_tree.label)
        self.assertEqual('Paragraph 3(b)', a_tree.title)
        self.assertEqual("", a_tree.text.strip())
        self.assertEqual(2, len(a_tree.children))

        node = a_tree.children[0]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '1'], node.label)
        self.assertEqual(depth1, node.text)
        self.assertEqual(0, len(node.children))

        node = a_tree.children[1]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2'], node.label)
        self.assertEqual(depth2, node.text)
        self.assertEqual(3, len(node.children))

        node = a_tree.children[1].children[0]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2', 'i'],
                         node.label)
        self.assertEqual(depth2i, node.text)
        self.assertEqual(0, len(node.children))

        node = a_tree.children[1].children[1]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2', 'ii'],
                         node.label)
        self.assertEqual(depth2ii, node.text)
        self.assertEqual(0, len(node.children))

        node = a_tree.children[1].children[2]
        self.assertEqual(['111', '3', 'b', Node.INTERP_MARK, '2', 'iii'],
                         node.label)
        self.assertEqual(depth2iii, node.text)
        self.assertEqual(0, len(node.children))
def test_segment_tree():
    title = "Section 105.11 This is a section title"
    body = "1. Some contents\n2. Other data\ni. Hello hello"
    result = interpretation.segment_tree(title + "\n" + body, '105', ['105'])
    assert result.text == ""
    assert len(result.children) == 2

    child = result.children[0]
    assert child.text == "1. Some contents\n"
    assert child.children == []
    assert child.label == ['105', '11', Node.INTERP_MARK, '1']

    child = result.children[1]
    assert child.text == "2. Other data\n"
    assert len(child.children) == 1
    assert child.label == ['105', '11', Node.INTERP_MARK, '2']

    child = result.children[1].children[0]
    assert child.text == "i. Hello hello"
    assert child.children == []
    assert child.label == ['105', '11', Node.INTERP_MARK, '2', 'i']
Exemplo n.º 13
0
    def test_segment_tree(self):
        title = "Section 105.11 This is a section title"
        body = "1. Some contents\n2. Other data\ni. Hello hello"
        non_title = "\n" + body
        result = interpretation.segment_tree(title + non_title, '105', ['105'])
        self.assertEqual("\n", result.text)
        self.assertEqual(2, len(result.children))

        child = result.children[0]
        self.assertEqual("1. Some contents\n", child.text)
        self.assertEqual([], child.children)
        self.assertEqual(['105', '11', Node.INTERP_MARK, '1'], child.label)

        child = result.children[1]
        self.assertEqual("2. Other data\n", child.text)
        self.assertEqual(1, len(child.children))
        self.assertEqual(['105', '11', Node.INTERP_MARK, '2'], child.label)

        child = result.children[1].children[0]
        self.assertEqual("i. Hello hello", child.text)
        self.assertEqual([], child.children)
        self.assertEqual(['105', '11', Node.INTERP_MARK, '2', 'i'],
                         child.label)
    def test_segment_tree(self):
        title = "Section 105.11 This is a section title"
        body = "1. Some contents\n2. Other data\ni. Hello hello"
        non_title = "\n" + body
        result = interpretation.segment_tree(title + non_title, '105', ['105'])
        self.assertEqual("\n", result.text)
        self.assertEqual(2, len(result.children))

        child = result.children[0]
        self.assertEqual("1. Some contents\n", child.text)
        self.assertEqual([], child.children)
        self.assertEqual(['105', '11', Node.INTERP_MARK, '1'], child.label)

        child = result.children[1]
        self.assertEqual("2. Other data\n", child.text)
        self.assertEqual(1, len(child.children))
        self.assertEqual(['105', '11', Node.INTERP_MARK, '2'], child.label)

        child = result.children[1].children[0]
        self.assertEqual("i. Hello hello", child.text)
        self.assertEqual([], child.children)
        self.assertEqual(['105', '11', Node.INTERP_MARK, '2', 'i'],
                         child.label)