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

Function simplify_textual_form

components/expr_parser.py:247–266  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

245 # print(ast.logical_form_with_type())
246
247def simplify_textual_form(expr):
248 toks = expr.split(' ')
249
250 norm_toks = []
251 for t in toks:
252 # normalize entity
253 if t.startswith('m.'):
254 pass
255 elif 'XMLSchema' in t:
256 pass
257 elif '.' in t:
258 meta_relations = t = t.split('.')
259 t = meta_relations[-1]
260 if '.' in t:
261 t = t.replace('.', ' , ')
262 if '_' in t:
263 t = t.replace('.', ' , ')
264 # normalize type
265 norm_toks.append(t)
266 return ' '.join(norm_toks)
267
268def test_text_converter():
269 # dataset = load_json('outputs/grailqa_v1.0_dev.json')

Callers 1

test_text_converterFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_text_converterFunction · 0.68