acceptability.py 文件源码

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

项目:trf 作者: aistairc 项目源码 文件源码
def _load_word_freq(self, threshold: int) -> Tuple[Dict[str, int], int]:
        n_total_words = 0
        word_freq = {}
        with open(self.rnnlm_model_path, mode='r') as f:
            for line in f:

                n_total_words += 1

                word, freq = line.split(' ')
                freq = int(freq)
                if freq > threshold:
                    word_freq[word] = freq
                else:
                    word_freq['<unk/>'] = word_freq.get('<unk/>', 0) + 1

        return (word_freq, n_total_words)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号