analyser.py 文件源码

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

项目:trf 作者: aistairc 项目源码 文件源码
def calc_rs_pos(self) -> Dict[str, float]:
        """Calculate the ratio of each pos of words in input text
        Returns:
            float: the ratio of each pos of words in input text
        """
        pos = []
        # TODO: It may take a long time when the number of sentences are large
        for sentence in self.sentences:
            juman_result = self.juman.analysis(sentence)
            pos += [mrph.hinsi for mrph in juman_result.mrph_list()]
        pos_counter = Counter(pos)
        total = sum(pos_counter.values())
        return {name: float(num) / total for name, num in pos_counter.items()}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号