senticnet.py 文件源码

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

项目:hoot 作者: CatalystOfNostalgia 项目源码 文件源码
def sentics_api(self, concept, parsed_graph=None):
        """
        Return sentics of a concept.
        If you pass a parsed graph, the method do not load the rdf again.
        """
        concept_sentics_uri = self.concept_base_uri + concept + "/sentics"
        sentics = {
            "pleasantness": 0,
            "attention": 0,
            "sensitivity": 0,
            "aptitude": 0
        }

        if parsed_graph is None:
            graph = rdflib.Graph()
            parsed_graph = graph.parse(concept_sentics_uri, format="xml")

        result, _ = self._output(concept_sentics_uri)

        sentics["pleasantness"] = result[3]
        sentics["attention"] = result[0]
        sentics["sensitivity"] = result[1]
        sentics["aptitude"] = result[2]

        return sentics
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号