当前位置: 首页>>代码示例>>Python>>正文


Python py2neo.Relationship方法代码示例

本文整理汇总了Python中py2neo.Relationship方法的典型用法代码示例。如果您正苦于以下问题:Python py2neo.Relationship方法的具体用法?Python py2neo.Relationship怎么用?Python py2neo.Relationship使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py2neo的用法示例。


在下文中一共展示了py2neo.Relationship方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: insert_one_data

# 需要导入模块: import py2neo [as 别名]
# 或者: from py2neo import Relationship [as 别名]
def insert_one_data(arr):
    start = look_and_create(arr[0])
    items = [arr[2]] if isinstance(arr[2], str) else arr[2]
    for name in items:
        end = look_and_create(name)
        r = Relationship(start, arr[1], end, name=arr[1])   
        graph.create(r) 
开发者ID:liuyuzhangolvz,项目名称:novel-kg,代码行数:9,代码来源:mongo2neo.py

示例2: insertAiroData

# 需要导入模块: import py2neo [as 别名]
# 或者: from py2neo import Relationship [as 别名]
def insertAiroData(self, data):
        print("Inserting node data!")
        bssidNodes, stationNodes = data[0][0], data[0][1]
        for b in bssidNodes:
            try:
                bNode = Node(b['type'], name=b['name'], bssid=b['bssid'], oui=b['oui'], encryption=b["encryption"], speed=b['speed'], channel=b['channel'], auth=b['auth'], cipher=b['cipher'], lan=b['lan'])
                bNode.add_label("Device")
                self.graph.create(bNode)
            except ClientError:
                pass
        
        for essids, s in stationNodes:
            sNode = self.graph.nodes.match("Device", bssid=s['bssid']).first()
            if sNode is None:
                sNode = Node(s["type"], name=s['name'], bssid=s['bssid'], FirstTimeSeen=s['fts'], LastTimeSeen=s['lts'],Power=s['pwr'], NumPackets=s['pkts'], Association=s['assoc'], oui=s['oui'])
                sNode.add_label("Device")
            else:
                sNode['FirstTimeSeen'] = s['fts']
                sNode['LastTimeSeen'] = s['lts']
                sNode['Power'] = s['pwr']
                sNode['NumPackets'] = s['pkts']
                sNode['Association'] =s['assoc']
                self.graph.push(sNode)
                sNode = self.graph.nodes.match("Device", bssid=s['bssid']).first()

            for essid in essids: 
                nExisting = self.graph.nodes.match("Device", name=essid).first()
                if len(essid) > 0:
                    newProbe = Node("AP", name=essid)
                    newProbe.add_label("Device")
                    self.graph.create(Relationship(sNode, "Probes", nExisting or newProbe))
            
            if s['assoc'] is not None:
                aExisting = self.graph.nodes.match("Device", bssid=s['assoc']).first()
                newAssoc = Node("AP", bssid=s['assoc'])
                newAssoc.add_label("Device")
                self.graph.create(Relationship(sNode, "AssociatedTo", aExisting or newAssoc))
        
        print("Database updated!") 
开发者ID:daddycocoaman,项目名称:BeaconGraph,代码行数:41,代码来源:neoHandler.py

示例3: add_to_memory

# 需要导入模块: import py2neo [as 别名]
# 或者: from py2neo import Relationship [as 别名]
def add_to_memory(self, question="question", userid="A0001"):
        """Add user question to memory.
        将用户当前对话加入信息记忆。

        Args:
            question: 用户问题。
                Defaults to "question".
            userid: 用户唯一标识。
                Defaults to "userid".
        """
        previous_node = self.graph.find_one("Memory", "qa_id", self.qa_id)
        self.qa_id = get_current_time()
        node = Node("Memory", question=question, userid=userid, qa_id=self.qa_id)
        if previous_node:
            relation = Relationship(previous_node, "next", node)
            self.graph.create(relation)
        else:
            self.graph.create(node)

    # def extract_navigation(self, question):
        """Extract navigation from question。从问题中抽取导航地点。
        从导航地点列表选取与问题匹配度最高的地点。
        QA匹配模式:(模糊匹配/全匹配)

        Args:
            question: User question. 用户问题。
        """
        # result = dict(question=question, name='', content=self.iformat(random_item(self.do_not_know)), \
            # context="", tid="", ftid="", url="", behavior=0, parameter="", txt="", img="", button="", valid=1)
        
        # 模式1:模糊匹配
        # temp_sim = 0
        # sv1 = synonym_cut(question, 'wf')
        # if not sv1:
            # return result
        # for location in self.locations:
            # sv2 = synonym_cut(location, 'wf')
            # if sv2:
                # temp_sim = similarity(sv1, sv2, 'j')
            # 匹配加速,不必选取最高相似度,只要达到阈值就终止匹配
            # if temp_sim > 0.92:
                # print("Navigation location: " + location + " Similarity Score: " + str(temp_sim))
                # result["content"] = location
                # result["context"] = "user_navigation"
                # result["behavior"] = int("0x001B", 16)
                # return result
        
        # 模式2:全匹配,判断“去”和地址关键词是就近的动词短语情况
        # for location in self.locations:
            
            # keyword = "去" + location
            # if keyword in question:
                # print("Original navigation")
                # result["name"] = keyword
                # result["content"] = location
                # result["context"] = "user_navigation"
                # result["behavior"] = int("0x001B", 16)
                # return result
        # return result 
开发者ID:Decalogue,项目名称:chat,代码行数:61,代码来源:qa.py


注:本文中的py2neo.Relationship方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。