Generate json by prediction.
435744
def generate_predict_json(position1_result, position2_result, ids, passage_tokens):
    '''
    
    '''
    predict_len = len(position1_result)
    logger.debug('total prediction num is %s', str(predict_len))

    answers = {}
    for i in range(predict_len):
        sample_id = ids[i]
        passage, tokens = passage_tokens[i]
        kbest = find_best_answer_span(
            position1_result[i], position2_result[i], len(tokens), 23)
        _, start, end = kbest[0]
        answer = passage[tokens[start]['char_begin']:tokens[end]['char_end']]
        answers[sample_id] = answer
    logger.debug('generate predict done.')
    return answers
401468
def prepare(data):
    """"""
    message = data.get("message")
    sha = data.get("sha")
    tree = data.get("tree")
    tree_sha = tree.get("sha")
    return {"message": message, "sha": sha, "tree": {"sha": tree_sha}}
197803
def _fetch_json(self):
        """"""
        print("Fetching from url: " + self.graph_url)
        resp = urlopen(self.graph_url).read()
        return json.loads(resp.decode('utf-8'))
988600
def loadJson(self, data):
        """"""
        if not isinstance(data, dict):
            data = json.loads(data)
        self.__dict__.update(data)
        self.inflate() # restore objects from str values
        #if self.ports:  self._gotPorts = True
        return self
119644
def prepare(data):
    """"""
    sha = data.get("sha")
    tree = data.get("tree")
    return {"sha": sha, "tree": tree}
512765
def publish_json(self, channel, obj):
        """"""
        return self.publish(channel, json.dumps(obj))
417503
def yield_json(stream):
    
    buff = u""
    arr_count = 0
    obj_count = 0
    while True:
        buff += read_chunk(stream)

        # If we finish parsing all objs or arrays, yield a finished JSON
        # entity.
        if buff.endswith('{'):
            obj_count += 1
        if buff.endswith('['):
            arr_count += 1
        if buff.endswith(']'):
            arr_count -= 1
            if obj_count == arr_count == 0:
                json_item = copy(buff)
                buff = u""
                yield json_item
        if buff.endswith('}'):
            obj_count -= 1
            if obj_count == arr_count == 0:
                json_item = copy(buff)
                buff = u""
                yield json_item
303250
def json(self):
        """"""
        output = {}
        for filename in self.data:
            output[filename] = []

            for secret_hash in self.data[filename]:
                tmp = self.data[filename][secret_hash].json()
                del tmp['filename']  # Because filename will map to the secrets

                output[filename].append(tmp)

        return output
577827
async function generateJson(options, generatorResult) {
  const jsonPath = (
    options.jsonPath ||
    `${ path.join(options.outputDir, '/' + options.fontName) }.json`
  )

  const css = generatorResult.generateCss()
  let map = {}

  css.replace(CSS_PARSE_REGEX, (match, name, code) => map[name] = code)

  await fsAsync.writeFile(jsonPath, JSON.stringify(map, null, 4))
}
1254012
def json(self):
        """"""
        if hasattr(self, '_json'):
            return self._json
        try:
            self._json = json.loads(self.text or self.content)
        except ValueError:
            self._json = None
        return self._json
727577
def asjsonld(self):
        """"""
        source = {}
        if self.__source__:
            source.update(self.__source__)
        source.update(asjsonld(self))
        return source
1222618
def jsonise(dic):
        """"""
        d = {}
        for k, v in dic.items():
            if type(v) in abstractRequetesSQL.TYPES_PERMIS:
                d[k] = v
            else:
                try:
                    d[k] = json.dumps(v, ensure_ascii=False, cls=formats.JsonEncoder)
                except ValueError as e:
                    logging.exception("Erreur d'encodage JSON !")
                    raise e
        return d
281203
def generate_annotations_json(source_path, target_path, only_simple=False):
    # type: (str, str, bool) -> None
    """"""
    results = generate_annotations_json_string(source_path, only_simple=only_simple)
    with open(target_path, 'w') as f:
        json.dump(results, f, sort_keys=True, indent=4)
773264
def from_json(cls, json_str):
        """"""
        d = json.loads(json_str)
        return cls.from_dict(d)
1278195
def to_json(self, labels=None):
        """"""
        output = self.to_dict(labels)
        return json.dumps(output, cls=DateTimeEncoder, ensure_ascii=False)
500323
def to_json(self):
        """"""
        return {
            'network': self.network,
            'state': self.state,
            'nodes': self.node_indices,
            'cut': self.cut,
        }
565003
def dumps(obj):
    """"""
    return json.dumps(obj, indent=4, sort_keys=True, cls=CustomEncoder)