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

Function _build

NLP/Text2SQL-BASELINE/script/schema_linking.py:110–133  ·  view source on GitHub ↗

do build Args: cells (TYPE): NULL Returns: TODO

(cells)

Source from the content-addressed store, hash-verified

108
109
110def _build(cells):
111 """do build
112 Args:
113 cells (TYPE): NULL
114 Returns: TODO
115 """
116 dct_index = defaultdict(set)
117 for cell in set(cells):
118 if type(cell) is not str:
119 continue
120 cell = cell.strip()
121 if re.match(g_date_patt, cell):
122 cell = _format_date_cell(cell)
123 cell_chars = get_char_list(cell.lower())
124 dct_index[cell.lower()].add((cell, len(cell_chars)))
125 for pos in range(len(cell_chars) - 1):
126 ## bigram 用于 ngram 检索,tri_gram、four_gram仅用于切词检索
127 bigram = cell_chars[pos: pos + 2]
128 ####tri_gram = cell_chars[pos: pos + 3]
129 ####four_gram = cell_chars[pos: pos + 4]
130 dct_index[bigram].add((cell, len(cell_chars) - 1))
131 ####dct_index[tri_gram].add((cell, len(cell_chars) - 2))
132 ####dct_index[four_gram].add(cell)
133 return dct_index
134
135
136def build_cell_index(db_dict):

Callers 1

build_cell_indexFunction · 0.85

Calls 3

_format_date_cellFunction · 0.85
get_char_listFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected