def parse_hs2015(heilman_filepath):
    """convert the output of the Heilman and Sagae (2015) discourse parser
    into a nltk.ParentedTree instance.

    Parameters
    ----------
    heilman_filepath : str
        path to a file containing the output of Heilman and Sagae's 2015
        discourse parser

    Returns
    -------
    parented_tree : nltk.ParentedTree
        nltk.ParentedTree representation of the given Heilman/Sagae RST tree
    edus : list(list(unicode))
        a list of EDUs, where each EDU is represented as
        a list of tokens
    """
    with open(heilman_filepath, 'r') as parsed_file:
        heilman_json = json.load(parsed_file)

    edus = heilman_json['edu_tokens']

    # the Heilman/Sagae parser can theoretically produce more than one parse,
    # but I've never seen more than one, so we'll just the that.
    scored_rst_tree = heilman_json['scored_rst_trees'][0]
    tree_str = scored_rst_tree['tree']

    parented_tree = nltk.ParentedTree.fromstring(tree_str)
    _add_edus_to_tree(parented_tree, edus)
    return parented_tree, edus
def parse_hs2015 ( heilman_filepath ) : with open ( heilman_filepath , 'r' ) as parsed_file : heilman_json = json . load ( parsed_file ) edus = heilman_json [ 'edu_tokens' ] scored_rst_tree = heilman_json [ 'scored_rst_trees' ] [ 0 ] tree_str = scored_rst_tree [ 'tree' ] parented_tree = nltk . ParentedTree . fromstring ( tree_str ) _add_edus_to_tree ( parented_tree , edus ) return parented_tree , edus
convert the output of the Heilman and Sagae (2015) discourse parser
    into a nltk.ParentedTree instance.

    Parameters
    ----------
    heilman_filepath : str
        path to a file containing the output of Heilman and Sagae's 2015
        discourse parser

    Returns
    -------
    parented_tree : nltk.ParentedTree
        nltk.ParentedTree representation of the given Heilman/Sagae RST tree
    edus : list(list(unicode))
        a list of EDUs, where each EDU is represented as
        a list of tokens