def build_attr_dict(attr_triples):
    """
    build attribute dictionary (dict[entity][attr] = value)
    """
    d = dict()
    for e, a, v in attr_triples:
        d.setdefault(e, dict())
        d[e][a] = v
    return d