66756de12d3f76d48774434bb210cab39a9590c0,graphbrain/agents/txt_parser.py,TxtParser,input_file,#TxtParser#,24

Before Change



    def input_file(self, file_name):
        pos = 0
        with open(file_name, "r") as f:
            text = f.read().replace("\n", " ")
            parses = self.parser.parse(text)
            for parse in parses:
                main_edge = parse["main_edge"]

                // add main edge
                if main_edge:
                    self.hg.add_to_sequence(self.sequence, pos, main_edge)
                    self.edges += 1
                    pos += 1

                    // attach text to edge
                    self.hg.set_attribute(main_edge, "text", parse["text"])

                    // add extra edges
                    for edge in parse["extra_edges"]:
                        self.add(edge)

    def report(self):
        rep_str = ("edges found: {}".format(self.edges))
        return "{}\n\n{}".format(rep_str, super().report())

After Change



    def input_file(self, file_name):
        pos = 0
        for paragraph in paragraphs(file_name):
            parses = self.parser.parse(paragraph)
            for parse in parses:
                main_edge = parse["main_edge"]

                // add main edge
                if main_edge:
                    self.hg.add_to_sequence(self.sequence, pos, main_edge)
                    self.edges += 1
                    pos += 1

                    // attach text to edge
                    self.hg.set_attribute(main_edge, "text", parse["text"])

                    // add extra edges
                    for edge in parse["extra_edges"]:
                        self.add(edge)

    def report(self):
        rep_str = ("edges found: {}".format(self.edges))
        return "{}\n\n{}".format(rep_str, super().report())
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: graphbrain/graphbrain
Commit Name: 66756de12d3f76d48774434bb210cab39a9590c0
Time: 2020-01-15
Author: telmo@telmomenezes.net
File Name: graphbrain/agents/txt_parser.py
Class Name: TxtParser
Method Name: input_file


Project Name: ufoym/deepo
Commit Name: 6dae167d1ae86dbc6c9da47447fc15b411d3aa5a
Time: 2017-12-03
Author: a@ufoym.com
File Name: scripts/make-gen-docker.py
Class Name:
Method Name: generate


Project Name: SheffieldML/GPy
Commit Name: f3f4bf67ad87c4d30e3694e251d274c3b85c81da
Time: 2015-11-09
Author: ibinbei@gmail.com
File Name: GPy/__init__.py
Class Name:
Method Name: load


Project Name: graphbrain/graphbrain
Commit Name: 02de60b01b016be9806d939fb642d365bac94627
Time: 2020-12-21
Author: telmo@telmomenezes.net
File Name: graphbrain/parsers/alpha.py
Class Name: Alpha
Method Name: __init__