如何在Grakn中使用Python客户端计算connectedcomponent

2024-05-29 02:44:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用Python客户端获取集群(或连接的组件)。我可以通过以下方式使用graql实现:

compute cluster in [company, c2c], using connected-component, where contains=V86179944;

我也可以使用Python运行查询:

query = "compute cluster in [company, c2c], using connected-component, where contains=V86179944;"
with GraknClient(uri="localhost:48555") as client:
    with client.session(keyspace=keyspace) as session:
        with session.transaction().read() as transaction:
            answer_iterator = transaction.query(query)
            # What to do here??          

但是,我不知道如何访问结果。根据python client docs,有两种获得结果的方法:

  • 反复
  • 使用collect_concepts()

当我迭代时,我不能使用.map()我得到AttributeError: 'ConceptSet' object has no attribute 'map'

当我尝试collect_concepts时,我得到GraknError: Only use .collect_concepts on ConceptMaps returned by query()


Tags: inclientsessionaswithquerycompanytransaction
1条回答
网友
1楼 · 发布于 2024-05-29 02:44:31

map()collect_concepts(将在下一版本的客户端Python中removed)是ConceptMap应答类型的方法。作为compute cluster查询的结果返回的是ConceptSet答案类型ConceptSet具有set()方法,该方法在集群计算后返回概念的ID集

Here您将找到查询类型及其相应的答案类型,here您将在^{上找到有关set()方法的文档

相关问题 更多 >

    热门问题