本文整理汇总了Python中regparser.tree.struct.Node.text方法的典型用法代码示例。如果您正苦于以下问题:Python Node.text方法的具体用法?Python Node.text怎么用?Python Node.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类regparser.tree.struct.Node
的用法示例。
在下文中一共展示了Node.text方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_definitions_scopes
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_definitions_scopes(self):
t = Terms(None)
node = Node(label=['1000', '22', 'a', '5'])
node.text = 'For the purposes of this part, blah blah'
self.assertEqual([('1000',), ('1000', Node.INTERP_MARK)],
t.definitions_scopes(node))
t.subpart_map = {
'SubPart 1': ['a', '22'],
'Other': []
}
node.text = 'For the purposes of this subpart, yada yada'
self.assertEqual([('1000', 'a'), ('1000', '22'),
('1000', 'a', Node.INTERP_MARK), ('1000', '22', Node.INTERP_MARK)],
t.definitions_scopes(node))
node.text = 'For the purposes of this section, blah blah'
self.assertEqual([('1000', '22'), ('1000', '22', Node.INTERP_MARK)],
t.definitions_scopes(node))
node.text = 'For the purposes of this paragraph, blah blah'
self.assertEqual([('1000','22','a','5'),
('1000','22','a','5',Node.INTERP_MARK)],
t.definitions_scopes(node))
node.text = 'Default'
self.assertEqual([('1000',), ('1000', Node.INTERP_MARK)],
t.definitions_scopes(node))
示例2: test_create_xml_changes_child_stars
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_create_xml_changes_child_stars(self):
labels_amended = [Amendment('PUT', '200-2-a')]
xml = etree.fromstring("<ROOT><P>(a) Content</P><STARS /></ROOT>")
n2a = Node('(a) Content', label=['200', '2', 'a'],
source_xml=xml.xpath('//P')[0])
n2b = Node('(b) Content', label=['200', '2', 'b'])
n2 = Node('n2', label=['200', '2'], children=[n2a, n2b])
root = Node('root', label=['200'], children=[n2])
notice_changes = changes.NoticeChanges()
build.create_xml_changes(labels_amended, root, notice_changes)
self.assertTrue('200-2-a' in notice_changes.changes)
self.assertTrue(1, len(notice_changes.changes['200-2-a']))
change = notice_changes.changes['200-2-a'][0]
self.assertEqual('PUT', change['action'])
self.assertFalse('field' in change)
n2a.text = n2a.text + ":"
n2a.source_xml.text = n2a.source_xml.text + ":"
notice_changes = changes.NoticeChanges()
build.create_xml_changes(labels_amended, root, notice_changes)
self.assertTrue('200-2-a' in notice_changes.changes)
self.assertTrue(1, len(notice_changes.changes['200-2-a']))
change = notice_changes.changes['200-2-a'][0]
self.assertEqual('PUT', change['action'])
self.assertEqual('[text]', change.get('field'))
示例3: test_create_xml_changes_child_stars
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_create_xml_changes_child_stars():
labels_amended = [Amendment('PUT', '200-?-2-a')]
with XMLBuilder("ROOT") as ctx:
ctx.P("(a) Content")
ctx.STARS()
n2a = Node('(a) Content', label=['200', '2', 'a'],
source_xml=ctx.xml.xpath('//P')[0])
n2b = Node('(b) Content', label=['200', '2', 'b'])
n2 = Node('n2', label=['200', '2'], children=[n2a, n2b])
root = Node('root', label=['200'], children=[n2])
notice_changes = changes.NoticeChanges()
fetch.create_xml_changes(labels_amended, root, notice_changes)
data = notice_changes[None]
assert '200-2-a' in data
assert len(data['200-2-a']) == 1
change = data['200-2-a'][0]
assert change['action'] == 'PUT'
assert 'field' not in change
n2a.text = n2a.text + ":"
n2a.source_xml.text = n2a.source_xml.text + ":"
notice_changes = changes.NoticeChanges()
fetch.create_xml_changes(labels_amended, root, notice_changes)
data = notice_changes[None]
assert '200-2-a' in data
assert len(data['200-2-a']) == 1
change = data['200-2-a'][0]
assert change['action'] == 'PUT'
assert change.get('field') == '[text]'
示例4: test_create_xml_changes_child_stars
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_create_xml_changes_child_stars(self):
labels_amended = [Amendment('PUT', '200-?-2-a')]
with XMLBuilder("ROOT") as ctx:
ctx.P("(a) Content")
ctx.STARS()
n2a = Node('(a) Content', label=['200', '2', 'a'],
source_xml=ctx.xml.xpath('//P')[0])
n2b = Node('(b) Content', label=['200', '2', 'b'])
n2 = Node('n2', label=['200', '2'], children=[n2a, n2b])
root = Node('root', label=['200'], children=[n2])
notice_changes = changes.NoticeChanges()
amendments.create_xml_changes(labels_amended, root, notice_changes)
data = notice_changes.changes_by_xml[None]
self.assertIn('200-2-a', data)
self.assertTrue(1, len(data['200-2-a']))
change = data['200-2-a'][0]
self.assertEqual('PUT', change['action'])
self.assertNotIn('field', change)
n2a.text = n2a.text + ":"
n2a.source_xml.text = n2a.source_xml.text + ":"
notice_changes = changes.NoticeChanges()
amendments.create_xml_changes(labels_amended, root, notice_changes)
data = notice_changes.changes_by_xml[None]
self.assertIn('200-2-a', data)
self.assertTrue(1, len(data['200-2-a']))
change = data['200-2-a'][0]
self.assertEqual('PUT', change['action'])
self.assertEqual('[text]', change.get('field'))
示例5: test_create_xml_changes_child_stars
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_create_xml_changes_child_stars(self):
labels_amended = [Amendment("PUT", "200-2-a")]
xml = etree.fromstring("<ROOT><P>(a) Content</P><STARS /></ROOT>")
n2a = Node("(a) Content", label=["200", "2", "a"], source_xml=xml.xpath("//P")[0])
n2b = Node("(b) Content", label=["200", "2", "b"])
n2 = Node("n2", label=["200", "2"], children=[n2a, n2b])
root = Node("root", label=["200"], children=[n2])
notice_changes = changes.NoticeChanges()
build.create_xml_changes(labels_amended, root, notice_changes)
self.assertTrue("200-2-a" in notice_changes.changes)
self.assertTrue(1, len(notice_changes.changes["200-2-a"]))
change = notice_changes.changes["200-2-a"][0]
self.assertEqual("PUT", change["action"])
self.assertFalse("field" in change)
n2a.text = n2a.text + ":"
n2a.source_xml.text = n2a.source_xml.text + ":"
notice_changes = changes.NoticeChanges()
build.create_xml_changes(labels_amended, root, notice_changes)
self.assertTrue("200-2-a" in notice_changes.changes)
self.assertTrue(1, len(notice_changes.changes["200-2-a"]))
change = notice_changes.changes["200-2-a"][0]
self.assertEqual("PUT", change["action"])
self.assertEqual("[text]", change.get("field"))
示例6: test_process_with_results
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_process_with_results(self):
pm = ParagraphMarkers(None)
for m, nt, l in (('(c)', Node.REGTEXT, ['c']),
('(vi)', Node.REGTEXT, ['c', 'vi']),
('ii.', Node.INTERP, ['ii', Node.INTERP_MARK]),
('A.', Node.INTERP, ['ii', 'A', Node.INTERP_MARK]),
('(a)', Node.APPENDIX, ['111', 'A', 'a']),
('a.', Node.APPENDIX, ['111', 'A', 'a'])):
expected_result = [{"text": m, "locations": [0]}]
node = Node(m + " Paragraph", label=l, node_type=nt)
self.assertEqual(pm.process(node), expected_result)
# whitespace is ignored
node.text = "\n" + node.text
self.assertEqual(pm.process(node), expected_result)
示例7: test_is_exclusion
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_is_exclusion(self):
t = Terms(None)
n = Node('ex ex ex', label=['1111', '2'])
self.assertFalse(t.is_exclusion('ex', n))
t.scoped_terms = {('1111',): [Ref('abc', '1', (0, 0))]}
self.assertFalse(t.is_exclusion('ex', n))
t.scoped_terms = {('1111',): [Ref('ex', '1', (0, 0))]}
self.assertFalse(t.is_exclusion('ex', n))
n.text = u'Something something the term “ex” does not include potato'
self.assertTrue(t.is_exclusion('ex', n))
t.scoped_terms = {('1111',): [Ref('abc', '1', (0, 0))]}
self.assertFalse(t.is_exclusion('ex', n))
示例8: test_is_exclusion
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_is_exclusion(self):
"""There are certain indicators that a definition _should not_ be
considered the definition of that term. For example, exclusions to a
general definition should not replace the original. We can also
explicitly ignore chunks of text when finding definitions.."""
t = Terms(None)
n = Node('ex ex ex', label=['1111', '2'])
self.assertFalse(t.is_exclusion('ex', n))
t.scoped_terms = {('1111',): [Ref('abc', '1', 0)]}
self.assertFalse(t.is_exclusion('ex', n))
t.scoped_terms = {('1111',): [Ref('ex', '1', 0)]}
self.assertFalse(t.is_exclusion('ex', n))
n.text = u'Something something the term “ex” does not include potato'
self.assertTrue(t.is_exclusion('ex', n))
t.scoped_terms = {('1111',): [Ref('abc', '1', 0)]}
self.assertFalse(t.is_exclusion('ex', n))
settings.IGNORE_DEFINITIONS_IN['1111'] = ['phrase with abc in it']
self.assertFalse(t.is_exclusion('abc', n))
n.text = "Now the node has a phrase with abc in it, doesn't it?"
self.assertTrue(t.is_exclusion('abc', n))
示例9: test_process_with_results
# 需要导入模块: from regparser.tree.struct import Node [as 别名]
# 或者: from regparser.tree.struct.Node import text [as 别名]
def test_process_with_results(self):
pm = ParagraphMarkers(None)
for m, nt, l in (
("(c)", Node.REGTEXT, ["c"]),
("(vi)", Node.REGTEXT, ["c", "vi"]),
("ii.", Node.INTERP, ["ii", Node.INTERP_MARK]),
("A.", Node.INTERP, ["ii", "A", Node.INTERP_MARK]),
("(a)", Node.APPENDIX, ["111", "A", "a"]),
("a.", Node.APPENDIX, ["111", "A", "a"]),
):
expected_result = [{"text": m, "locations": [0]}]
node = Node(m + " Paragraph", label=l, node_type=nt)
self.assertEqual(pm.process(node), expected_result)
# whitespace is ignored
node.text = "\n" + node.text
self.assertEqual(pm.process(node), expected_result)