# -*- coding:utf-8 -*-
import numpy as np
from q84 import make_word_index
from q86 import get_word_vector
from q88 import cosine_similarity, output_similar

ppmi_file = 'ppmi.txt'
matrix_file = 'matrix_d'
target_word = ['Spain', 'Madrid', 'Athens']

def make_target_vec(t_idx):
    v1 = np.array(get_word_vector('Spain', t_idx))
    v2 = np.array(get_word_vector('Madrid', t_idx))
    v3 = np.array(get_word_vector('Athens', t_idx))
    return v1 - v2 + v3

def  main():
    t_idx = make_word_index(ppmi_file, 0)
    target_vec = make_target_vec(t_idx)
    sim_dict = cosine_similarity(target_vec, t_idx)
    output_similar(10, sim_dict)

if __name__ == '__main__':
    main()
