oov_detection.py 文件源码

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

项目:pycseg 作者: lizonghai 项目源码 文件源码
def compute_possibility(self, start_position, seg_index, oov_pattern, oov_dct, oov_ctx):
        # ???????????
        weight, j = 0, start_position
        test_word = []
        for tag in oov_pattern:
            word_content = self.words_graph.get_word(seg_index[j][0], seg_index[j][1]).content
            oov_freq = oov_dct.get_frequence(
                word_content,
                self.oov_tag_encode(tag)
            )
            #print('tag:{} word:{} freq:{} start_prob:{}'.format(
            #    tag, word_content, oov_freq, oov_ctx.prob_to_frequence(oov_ctx.start_prob[self.oov_tag_encode(tag)])))
            test_word.append(self.words_graph.get_word(seg_index[j][0], seg_index[j][1]).content)
            #????: dPOSPoss=log((double)(m_context.GetFrequency(0,m_nBestTag[i])+1))-log((double)(nFreq+1));
            poss = math.log(float(oov_ctx.prob_to_frequence(oov_ctx.start_prob[self.oov_tag_encode(tag)]))) - math.log(float(oov_freq + 1))
            weight += poss
            j += 1
        #print('compute_possibility() {} {} = {}'.format(oov_pattern, ''.join(test_word), weight))
        return weight
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号