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

Function convert_parse_instance

parse_sparql_webqsp.py:607–622  ·  view source on GitHub ↗

convert a webqsp parse instance to a s_expr

(parse)

Source from the content-addressed store, hash-verified

605
606
607def convert_parse_instance(parse):
608 """convert a webqsp parse instance to a s_expr"""
609 sparql = parse['Sparql']
610 # print(parse.keys())
611 # print(parse['PotentialTopicEntityMention'])
612 # print(parse['TopicEntityMid'], parse['TopicEntityName'])
613 try:
614 s_expr = parser.parse_query(sparql, parse['TopicEntityMid'])
615 # print('---GOOD------')
616 # print(sparql)
617 # print(s_expr)
618 except AssertionError:
619 s_expr = 'null'
620 # print(parse[''])
621 parse['SExpr'] = s_expr
622 return parse, s_expr != 'null'
623
624
625def webq_s_expr_to_sparql_query(s_expr):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected