ef0e833dc06eee63f0baf4bcaf1a27e47ad5f1c3,pliers/extractors/microsoft.py,MicrosoftAPIFaceExtractor,_parse_response_json,#MicrosoftAPIFaceExtractor#Any#,57

Before Change


        return ExtractorResult(None, stim, self, raw=raw)

    def _parse_response_json(self, json):
        keys = []
        values = []
        for k, v in json.items():
            if k == "faceAttributes":
                k = "face"
            if isinstance(v, dict):
                subkeys, subvalues = self._parse_response_json(v)
                keys.extend(["%s_%s" % (k, s) for s in subkeys])
                values.extend(subvalues)
            elif isinstance(v, list):
                // Hard coded to this extractor
                for attr in v:
                    if k == "hairColor":
                        keys.append("%s" % attr["color"])
                    elif k == "accessories":
                        keys.append("%s_%s" % (k, attr["type"]))
                    else:
                        continue
                    values.append(attr["confidence"])
            else:
                keys.append(k)
                values.append(v)
        return keys, values

    def _to_df(self, result):
        cols = []
        data = []

After Change


        return ExtractorResult(None, stim, self, raw=raw)

    def _parse_response_json(self, json):
        data_dict = {}
        for k, v in json.items():
            if k == "faceRectangle" and not self.rectangle:
                continue
            if k == "faceAttributes":
                k = "face"
            if isinstance(v, dict):
                subdata = self._parse_response_json(v)
                for sk, sv in subdata.items():
                    data_dict["%s_%s" % (k, sk)] = sv
            elif isinstance(v, list):
                // Hard coded to this extractor
                for attr in v:
                    if k == "hairColor":
                        key = attr["color"]
                    elif k == "accessories":
                        key = "%s_%s" % (k, attr["type"])
                    else:
                        continue
                    data_dict[key] = attr["confidence"]
            else:
                data_dict[k] = v
        return data_dict

    def _to_df(self, result):
        face_results = []
        for i, face in enumerate(result.raw):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: tyarkoni/pliers
Commit Name: ef0e833dc06eee63f0baf4bcaf1a27e47ad5f1c3
Time: 2018-02-09
Author: quinten.mcnamara@gmail.com
File Name: pliers/extractors/microsoft.py
Class Name: MicrosoftAPIFaceExtractor
Method Name: _parse_response_json


Project Name: pytorch/text
Commit Name: 2057691205de3b357a0b4d743977516b50963d28
Time: 2021-02-18
Author: cpuhrsch@fb.com
File Name: torchtext/experimental/datasets/raw/conll2000chunking.py
Class Name:
Method Name: CoNLL2000Chunking


Project Name: etal/cnvkit
Commit Name: a2712fc53806ec4ce7f838392ee07d7249f8339e
Time: 2015-08-24
Author: eric.talevich@gmail.com
File Name: cnvlib/export.py
Class Name:
Method Name: export_seg