def get_list_and_features(h): lst = []; features = [0, 0, 0, 0, 0, 0] current_h = h; while current_h.phrase is not None: # print current_h lst.append(current_h.phrase.english); features[1] += current_h.phrase.several_logprob[0] # translation feature 1 features[2] += current_h.phrase.several_logprob[1] # translation feature 2 features[3] += current_h.phrase.several_logprob[2] # translation feature 3 features[4] += current_h.phrase.several_logprob[3] # translation feature 4 current_h = current_h.predecessor lst.reverse() features[0] = get_lm_logprob(lst) features[5] = ibm_model_1_score(ibm_t, f, lst) return (lst, features)
def get_list_and_features(h, idx_self): lst = []; features = [0, 0, 0, 0, 0, 0, 0] current_h = h; while current_h.phrase is not None: # print current_h lst.append(current_h.phrase.english) # features[1] += current_h.distortionPenalty features[1] += current_h.phrase.several_logprob[0] # translation feature 1 features[2] += current_h.phrase.several_logprob[1] # translation feature 2 features[3] += current_h.phrase.several_logprob[2] # translation feature 3 features[4] += current_h.phrase.several_logprob[3] # translation feature 4 current_h = current_h.predecessor lst.reverse() features[0] = get_lm_logprob(lst) # language model score features[5] = ibm_model_1_score(ibm_t, f, lst) features[6] = len(lst) - len(french[idx_self]) return (lst, features)