MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / __init__

Method __init__

NLP/Text2SQL-BASELINE/text2sql/utils/ast_util.py:99–139  ·  view source on GitHub ↗
(self, ast_def, custom_primitive_type_checkers={})

Source from the content-addressed store, hash-verified

97 # pylint: disable=too-few-public-methods
98
99 def __init__(self, ast_def, custom_primitive_type_checkers={}):
100 # type: (asdl.Module, str) -> None
101 self.ast_def = ast_def
102
103 visitor = ASTWrapperVisitor()
104 visitor.visit(ast_def)
105
106 self.constructors = visitor.constructors
107 self.sum_types = visitor.sum_types
108 self.product_types = visitor.product_types
109 self.seq_fragment_constructors = {}
110 self.primitive_type_checkers = {
111 **self.default_primitive_type_checkers,
112 **custom_primitive_type_checkers
113 }
114 self.custom_primitive_types = set(custom_primitive_type_checkers.keys())
115 self.primitive_types = set(self.primitive_type_checkers.keys())
116
117 # Product types and constructors:
118 # no need to decide upon a further type for these.
119 self.singular_types = {} # type: Dict[str, SingularType]
120 self.singular_types.update(self.constructors)
121 self.singular_types.update(self.product_types)
122
123 # IndexedSets for each sum type
124 self.sum_type_vocabs = {
125 name: sorted(t.name for t in sum_type.types)
126 for name, sum_type in self.sum_types.items()
127 }
128 self.constructor_to_sum_type = {
129 constructor.name: name
130 for name, sum_type in self.sum_types.items()
131 for constructor in sum_type.types
132 }
133 self.seq_fragment_constructor_to_sum_type = {
134 constructor.name: name
135 for name, sum_type in self.sum_types.items()
136 for constructor in sum_type.types
137 }
138 self.fieldless_constructors = sorted(
139 visitor.fieldless_constructors.keys())
140
141 @property
142 def types(self):

Callers 1

__init__Method · 0.45

Calls 4

ASTWrapperVisitorClass · 0.85
keysMethod · 0.80
itemsMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected