예제 #1
0
 def from_dict(schema, raw):
     ex_id = raw['exid']
     kb = KB.from_dict(schema.attributes, raw['kb'])
     agent = raw['agent']
     role = raw['role']
     prev_turns = raw['prev_turns']
     prev_roles = raw['prev_roles']
     target = raw['target']
     candidates = raw['candidates']
     scores = raw['results']
     return EvalExample(ex_id, kb, agent, role, prev_turns, prev_roles,
                        target, candidates, scores)
예제 #2
0
 def from_dict(schema, raw):
     alphas = []
     # compatibility with older data format
     if schema is not None:
         attributes = schema.attributes
     else:
         assert 'attributes' in raw
     if 'attributes' in raw:
         attributes = [Attribute.from_json(raw_attr) for raw_attr in raw['attributes']]
     if 'alphas' in raw:
         alphas = raw['alphas']
     return Scenario(raw['uuid'], attributes, [KB.from_dict(attributes, kb) for kb in raw['kbs']], alphas)
예제 #3
0
    def from_dict(cls, schema, raw):
        scenario_attributes = None
        if schema is not None:
            scenario_attributes = schema.attributes
        if 'attributes' in raw.keys():
            scenario_attributes = [
                Attribute.from_json(a) for a in raw['attributes']
            ]

        if scenario_attributes is None:
            raise ValueError(
                "No scenario attributes found. "
                "Either schema must not be None (and have valid attributes) or "
                "scenario dict must have valid attributes field.")
        kb_list = [KB.from_dict(scenario_attributes, kb) for kb in raw['kbs']]
        return cls(raw['uuid'], scenario_attributes, kb_list)