explicit.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:histwords 作者: williamleif 项目源码 文件源码
def get_subembed(self, word_list, normalize=False, restrict_context=True):
        """
        Gets subembedding.
        """
        w_set = set(self.iw)
        valid_w = [word for word in word_list if word in w_set]
        new_w_indices = np.array([self.wi[word] for word in valid_w])
        if restrict_context:
            c_set = set(self.ic)
            valid_c = [word for word in word_list if word in c_set]
            new_c_indices = np.array([self.ci[word] for word in valid_c])
            new_m = self.m[new_w_indices, :]
            new_m = new_m[:, new_c_indices]
        else:
            valid_c = self.ic
            new_m = self.m[new_w_indices, :]
        return Explicit(new_m, valid_w, valid_c, normalize=normalize)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号