def __init__(self, rs3_filepath=None, name=None, namespace='rst',
                 tokenize=True, precedence=False):
        """
        Creates an RSTGraph from a RS3 XML file and adds metadata to it
        (filename of the RS3 file, names and types of allowed RST
        relations).

        Parameters
        ----------
        rs3_filepath : str or None
            Absolute or relative path to the RS3 file to be parsed.
            If no path is given, return an empty RSTGraph.
        name : str or None
            the name or ID of the graph to be generated. If no name is
            given, the basename of the input file is used.
        namespace : str
            the namespace of the document (default: rst)
        tokenize : bool
            If True, the RST segments (i.e. nuclei and satellites) will
            be tokenized and added as additonal token nodes to the
            document graph (with edges from the respective RST segments).
        precedence : bool
            If True (and if tokenize == True), add precedence relation edges
            (root precedes token1, which precedes token2 etc.)
        """
        # super calls __init__() of base class DiscourseDocumentGraph
        super(RSTGraph, self).__init__(namespace=namespace)

        self.ns = namespace
        if not rs3_filepath:
            return  # create empty document graph

        self.name = name if name else os.path.basename(rs3_filepath)

        # __rst2graph() will find/set the root node later on

        self.segments = []
        self.tokenized = False
        self.tokens = []
        self.edus = []

        utf8_parser = etree.XMLParser(encoding="utf-8")
        rs3_xml_tree = etree.parse(rs3_filepath, utf8_parser)
        self.relations = extract_relationtypes(rs3_xml_tree)
        self.__rst2graph(rs3_xml_tree)

        if tokenize:
            self.__tokenize_segments()
            self.tokenized = True
            if precedence:
                self.add_precedence_relations()

        # the nodes representing EDUs (elementary discourse units)
        # will be stored here (to keep them even after merging graphs)
        if self.ns+':edus' not in self.node[self.root]['metadata']:
            self.node[self.root]['metadata'][self.ns+':edus'] = self.edus
def __init__ ( self , rs3_filepath = None , name = None , namespace = 'rst' , tokenize = True , precedence = False ) : super ( RSTGraph , self ) . __init__ ( namespace = namespace ) self . ns = namespace if not rs3_filepath : return self . name = name if name else os . path . basename ( rs3_filepath ) self . segments = [ ] self . tokenized = False self . tokens = [ ] self . edus = [ ] utf8_parser = etree . XMLParser ( encoding = "utf-8" ) rs3_xml_tree = etree . parse ( rs3_filepath , utf8_parser ) self . relations = extract_relationtypes ( rs3_xml_tree ) self . __rst2graph ( rs3_xml_tree ) if tokenize : self . __tokenize_segments ( ) self . tokenized = True if precedence : self . add_precedence_relations ( ) if self . ns + ':edus' not in self . node [ self . root ] [ 'metadata' ] : self . node [ self . root ] [ 'metadata' ] [ self . ns + ':edus' ] = self . edus
Creates an RSTGraph from a RS3 XML file and adds metadata to it
        (filename of the RS3 file, names and types of allowed RST
        relations).

        Parameters
        ----------
        rs3_filepath : str or None
            Absolute or relative path to the RS3 file to be parsed.
            If no path is given, return an empty RSTGraph.
        name : str or None
            the name or ID of the graph to be generated. If no name is
            given, the basename of the input file is used.
        namespace : str
            the namespace of the document (default: rst)
        tokenize : bool
            If True, the RST segments (i.e. nuclei and satellites) will
            be tokenized and added as additonal token nodes to the
            document graph (with edges from the respective RST segments).
        precedence : bool
            If True (and if tokenize == True), add precedence relation edges
            (root precedes token1, which precedes token2 etc.)