williamleif / socialsent

Code and data for inducing domain-specific sentiment lexicons.
Apache License 2.0
195 stars 75 forks source link

Reference for a lexicon induction method #19

Open ndrmahmoudi opened 5 years ago

ndrmahmoudi commented 5 years ago

Hi @williamleif,

I really like that you have provided a reference for each of lexicon induction method. Can you let please let me know where you have adopted dist function from?

def dist(embeds, positive_seeds, negative_seeds, **kwargs):
    polarities = {}
    sim_mat = similarity_matrix(embeds, **kwargs)
    for i, w in enumerate(embeds.iw):
        if w not in positive_seeds and w not in negative_seeds:
            pol = sum(sim_mat[embeds.wi[p_seed], i] for p_seed in positive_seeds)
            pol -= sum(sim_mat[embeds.wi[n_seed], i] for n_seed in negative_seeds)
            polarities[w] = pol
    return polarities

Regards Nader