def get_ast_obj(belstr, bel_version, component_type: str = "<STR_LIT>"):
ast_dict, errors = get_ast_dict(belstr, component_type)<EOL>spec = bel_specification.get_specification(bel_version)<EOL>subj = ast_dict["<STR_LIT>"]<EOL>subj_ast = add_ast_fn(subj, spec)<EOL>relation = None<EOL>obj = None<EOL>if "<STR_LIT>" in ast_dict:<EOL><INDENT>relation = ast_dict["<STR_LIT>"]["<STR_LIT:name>"]<EOL><DEDENT>if "<STR_LIT:object>" in ast_dict:<EOL><INDENT>obj = ast_dict["<STR_LIT:object>"]<EOL>obj_ast = add_ast_fn(obj, spec)<EOL>return BELAst(subj_ast, relation, obj_ast, spec)<EOL><DEDENT>elif "<STR_LIT>" in ast_dict:<EOL><INDENT>nested_subj = ast_dict["<STR_LIT>"]["<STR_LIT>"]<EOL>nested_subj_ast = add_ast_fn(nested_subj, spec)<EOL>nested_relation = ast_dict["<STR_LIT>"]["<STR_LIT>"]["<STR_LIT:name>"]<EOL>nested_obj = ast_dict["<STR_LIT>"]["<STR_LIT:object>"]<EOL>nested_obj_ast = add_ast_fn(nested_obj, spec)<EOL>return BELAst(<EOL>subj_ast,<EOL>relation,<EOL>BELAst(nested_subj_ast, nested_relation, nested_obj_ast, spec),<EOL>spec,<EOL>)<EOL><DEDENT>return BELAst(subj_ast, None, None, spec)<EOL>
Convert AST partialparse dict to BELAst