forked from cfpb/regulations-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_layers.py
60 lines (45 loc) · 1.94 KB
/
generate_layers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from regparser import api_stub
import regparser.layer.table_of_contents
from regparser.layer import external_citations
from regparser.layer import internal_citations
from regparser.layer import interpretations
from regparser.layer import table_of_contents
from regparser.layer import terms
from regparser.layer import key_terms
from regparser.tree.struct import NodeEncoder
def generate_external_citations(reg_json):
""" Generate the enxternal citations layer """
layer_generator = external_citations.ExternalCitationParser(reg_json)
layer = layer_generator.build()
print NodeEncoder().encode(layer)
def generate_internal_citations(reg_json):
""" Generate the internal ciations layer. """
layer_generator = internal_citations.InternalCitationParser(reg_json)
layer = layer_generator.build()
print NodeEncoder().encode(layer)
def generate_table_of_contents(reg_json):
""" Generate the Table of Contents layer """
layer_generator = table_of_contents.TableOfContentsLayer(reg_json)
toc = layer_generator.build()
print NodeEncoder().encode(toc)
def generate_interpretations(reg):
""" Generate the Interpretations layer """
layer_generator = interpretations.Interpretations(reg)
print NodeEncoder().encode(layer_generator.build())
def generate_terms(reg):
""" Generate the Terms layer """
layer_generator = terms.Terms(reg)
print NodeEncoder().encode(layer_generator.build())
def generate_key_terms(reg):
""" Generate the key terms layer """
layer_generator = key_terms.KeyTerms(reg)
layer_generator.build()
print NodeEncoder().encode(layer_generator.build())
if __name__ == "__main__":
reg_json = api_stub.get_regulation_as_json('/tmp/xtree.json')
#generate_table_of_contents(reg_json)
#generate_internal_citations(reg_json)
#generate_external_citations(reg_json)
#generate_interpretations(reg_json)
#generate_terms(reg_json)
generate_key_terms(reg_json)