MCPcopy Create free account
hub / github.com/LHRLAB/ChatKBQA / test_text_converter

Function test_text_converter

components/expr_parser.py:268–303  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

266 return ' '.join(norm_toks)
267
268def test_text_converter():
269 # dataset = load_json('outputs/grailqa_v1.0_dev.json')
270 dataset = load_json('outputs/grailqa_v1.0_train.json')
271 import random
272 random.seed(123)
273 random.shuffle(dataset)
274
275 templates = set()
276 for i, data in enumerate(dataset[:100]):
277 s_expr = data['s_expression']
278 question = data['question']
279 ast = parse_s_expr(data['s_expression'])
280 skeleton = ast.skeleton_form()
281 templates.add(skeleton)
282 textual_expr = ast.textual_form()
283
284 simplified_expr = simplify_textual_form(textual_expr)
285 # if ('AND' in skeleton):
286 # sim_skeleton = skeleton.replace('AND SCHEMA', '')
287 # if 'AND' in sim_skeleton:
288 # print('------------------------------')
289 # print(question)
290 # print(s_expr)
291 # if ('COMP' in skeleton):
292 print(f'----------------{i}--------------')
293 print(question)
294 print(s_expr)
295 print(textual_expr)
296 print(simplified_expr)
297
298 # print(len(templates))
299 # for t in templates:
300 # if 'COMP' in t:
301 # print(t)
302 # # if 'ARG' in t:
303 # # print(t)
304

Callers

nothing calls this directly

Calls 5

parse_s_exprFunction · 0.85
simplify_textual_formFunction · 0.85
skeleton_formMethod · 0.80
load_jsonFunction · 0.70
textual_formMethod · 0.45

Tested by

no test coverage detected