示例#1
0
def apply_relation(target_dist, landmark_dist, relation, negated, objects):
    global relation_word_classifiers
    if relation  not in relation_word_classifiers: 
        relation = "UNK_REL"
        negated = False
        
    combined = Distribution()
    for t in objects:
        for l in objects:
            if t == l: continue
            if negated:
                features = get_relational_features(objects[l], objects[t])
            else:
                features = get_relational_features(objects[t], objects[l])
                
            p = logreg.classify_obj(relation, relation_word_classifiers, features.values())
            combined.add(make_id(t,l), target_dist.get(t) * landmark_dist.get(l) * p)    
            
    combined.marginalise()
    return combined