@lru_cache(maxsize=<NUM_LIT>)<EOL>def corenlp_to_xmltree(s, prune_root=True):
<EOL>s = get_as_dict(s)<EOL>if not ("<STR_LIT>" in s and isinstance(s["<STR_LIT>"], list)):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>try:<EOL><INDENT>dep_parents = list(map(int, s["<STR_LIT>"]))<EOL><DEDENT>except Exception:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>b = min(dep_parents)<EOL>if b != <NUM_LIT:0>:<EOL><INDENT>dep_parents = list(map(lambda j: j - b, dep_parents))<EOL><DEDENT>root = corenlp_to_xmltree_sub(s, dep_parents, <NUM_LIT:0>)<EOL>if prune_root:<EOL><INDENT>for c in root:<EOL><INDENT>if len(c) == <NUM_LIT:0>:<EOL><INDENT>root.remove(c)<EOL><DEDENT><DEDENT>if len(root) == <NUM_LIT:1>:<EOL><INDENT>root = root.findall("<STR_LIT>")[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return XMLTree(root, words=s["<STR_LIT>"])<EOL>
Transforms an object with CoreNLP dep_path and dep_parent attributes into
an XMLTree. Will include elements of any array having the same dimensiion
as dep_* as node attributes. Also adds special word_idx attribute
corresponding to original sequence order in sentence.