calculating lexical semantic orientation following Turney & Littman (2003), using word2vec & PPMI.
last update: 20th April, 2022 author: PENG Limin
参考 Turney and Littman (2003) ,使用余弦相似度 (cosine similarity) 和正点交互熵 (positive pointwise mutual information, PPMI) 计算特定语域中全部词语的语义倾向 (semantic orientation)。
与 Turney and Littman (2003) 不同的是,余弦相似度使用的词向量由 word2vec 计算得来,而非 LSA (latent semantic analysis)。此外,使用了 PPMI,而非原文的PMI。
Turney and Littman (2003) 对语义倾向的抽象定义由下式给出:
它衡量了特定词语
在
word2vec 模型将每个词语表示为一个向量,$\vec{v}=(v_1,v_2,...,v_k)$ 和
cos_SO 和 PPMI_SO 计算函数:gen_SO_df(df,filename,P,N,min_count=6) (line 53)
term-term co-occurence matrix 词语-词语共现矩阵计算函数: build_ttm(sentence,posword,negword,vocab,ttm) (line 131)
PPMI_SO 计算函数: calc_PPMI_SO(ttm,vocab,Pwords,Nwords) (line 199)
cos_SO 计算函数: calc_cosine_SO(model, Pwords, Nwords,vocab) (line 475)
句子语调计算函数: calc_SO(row,weight_dict,rules=True) (line 66)
- figs: 存放图片
- results: 存放各种计算结果,主要是 pandas dataframe 和对应的 pkl 文件
- models: 存放训练过的 w2v 模型
- 自定义词典
- notDict.txt: 知网否定词词典
- degreeDict.txt: 知网程度副词词典
- stopwords.txt: 百度停用词词典
- sougou_caijing: 搜狗财经词库
- sougou_jinrong: 搜狗金融词库
- pbc_add.txt: mpr 里一些特定表述
- 情感词典