コード例 #1
0
ファイル: azul.py プロジェクト: vcha/sp2013.11-731
def main():
    with open('model.pickle') as f:
        vectorizer, model = pickle.load(f)

    for hyp1, hyp2, ref in sentences():
        f1 = features.extract(ref, hyp1)
        f2 = features.extract(ref, hyp2)
        f = features.diff(f2, f1)
        if f['min_match'] == f['min_match2'] == f['min_match3'] == 0:
            print 0
            continue
        score = model.predict(vectorizer.transform((f,))) # w . (f_2 - f_1)
        if score > 0:
            print 1
        else:
            print -1
コード例 #2
0
ファイル: train.py プロジェクト: vcha/sp2013.11-731
def training_data(sentence_fn, score_fn):
    for (hyp1, hyp2, ref), score in izip(sentences(sentence_fn), scores(score_fn)):
        f1 = features.extract(ref, hyp1)
        f2 = features.extract(ref, hyp2)
        yield features.diff(f2, f1), score # score = f2 > f1