49d41416e440926f0a9a8243b4d77f6f5468efe9,app/server/utils.py,JsonHandler,parse,#JsonHandler#Any#,242

Before Change


    ```
    
    def parse(self, file):
        for i, line in enumerate(file, start=1):
            try:
                j = json.loads(line)
                j["meta"] = json.dumps(j.get("meta", {}))
                yield j
            except json.decoder.JSONDecodeError:
                raise FileParseException(line_num=i, line=line)

    def render(self):
        queryset = self.project.documents.all()
        serializer = DocumentSerializer(queryset, many=True)
        filename = "_".join(self.project.name.lower().split())

After Change


    def parse(self, file):
        file = io.TextIOWrapper(file, encoding="utf-8")
        while True:
            batch = list(itertools.islice(file, IMPORT_BATCH_SIZE))
            if not batch:
                raise StopIteration
            yield [{"text": line.strip()} for line in batch]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: chakki-works/doccano
Commit Name: 49d41416e440926f0a9a8243b4d77f6f5468efe9
Time: 2019-03-12
Author: light.tree.1.13@gmail.com
File Name: app/server/utils.py
Class Name: JsonHandler
Method Name: parse


Project Name: uber/petastorm
Commit Name: 7459ce340e207f1764cf8bd94afe15bed6196fa8
Time: 2019-08-27
Author: yevgeni@uber.com
File Name: petastorm/pytorch.py
Class Name: DataLoader
Method Name: __iter__


Project Name: facebookresearch/pytext
Commit Name: 5a8868024c4ece64611ae75107b00b66e0892684
Time: 2019-05-24
Author: snl@fb.com
File Name: pytext/data/data.py
Class Name: Data
Method Name: batches


Project Name: Calamari-OCR/calamari
Commit Name: 1b305c86dc2ff6b3461c42f4428460b66a8bff8b
Time: 2020-01-31
Author: wick.chr.info@gmail.com
File Name: calamari_ocr/ocr/backends/tensorflow_backend/tensorflow_model.py
Class Name: TensorflowModel
Method Name: predict_dataset