public QueryResult SearchVertexes(ContextManager contextMgmt, List <NLUEntity> entities) { QueryResult responseContent = new QueryResult(false, "Failed", ResponseItemType.Other); if (entities == null && entities.Count == 0) { responseContent = this.msgGenerator.GenerateErrorMessage("无法查找到对应节点,请确定输入的限定条件正确"); contextMgmt.ExitDialog(); } else { NLUEntity firstEntity = entities[0]; List <Vertex> results = new List <Vertex>(); if (firstEntity.GetEntityType() == "NodeName") { Vertex vertex = dsFrame.SearchGraph(firstEntity.GetEntityValue(), contextMgmt.GetSecnarioName(), contextMgmt.GetSavedAttributes()); results.Add(vertex); } else if (firstEntity.GetEntityType() == "Label") { results = dsFrame.SearchGraphByLabel(firstEntity.GetEntityValue(), contextMgmt.GetSecnarioName(), contextMgmt.GetSavedAttributes()); } if (results == null || results.Count == 0) { responseContent = this.msgGenerator.GenerateErrorMessage("无法查找到对应节点,请确定输入的限定条件正确"); contextMgmt.ExitDialog(); } else { string headMessage = ""; if (entities.Count > 1) { headMessage = firstEntity.GetEntityValue(); for (int i = 1; i < entities.Count; i++) { NLUEntity entity = entities[i]; if (entity.GetEntityType() == "RelationType") { HashSet <string> relationTypeSet = new HashSet <string>(); relationTypeSet.Add(entity.GetEntityValue()); List <Vertex> children = new List <Vertex>(); foreach (Vertex vertex in results) { Dictionary <string, List <Vertex> > childrenDict = dsFrame.GetChildren(vertex, relationTypeSet, contextMgmt.GetSavedAttributes(), contextMgmt.GetSecnarioName()); if (childrenDict != null) { List <Vertex> currentChildren = childrenDict[entity.GetEntityValue()]; children.AddRange(currentChildren); } } if (children != null && children.Count > 0) { headMessage += "的" + entity.GetEntityValue(); results = children; } } else if (entity.GetEntityType() == "Label") { List <Vertex> newResults = new List <Vertex>(); foreach (Vertex vertex in results) { if (vertex.label == entity.GetEntityValue()) { newResults.Add(vertex); } } if (newResults.Count > 0) { headMessage += "的" + entity.GetEntityValue(); results = newResults; } } } } if (results.Count == 1) { Vertex vertex = results[0]; if (vertex.isLeaf()) { responseContent = this.msgGenerator.GenerateEndVertexMessage(vertex); contextMgmt.ExitDialog(); } else { List <DialogSlot> validSlots = GetValidSlots(contextMgmt); if (validSlots == null || validSlots.Count() == 0) { contextMgmt.StartDialog(); responseContent = GetChildren(contextMgmt, vertex, null); } else { contextMgmt.SetSlots(validSlots); contextMgmt.EnterSlotFilling(); responseContent = this.msgGenerator.GenerateSlotMessage(validSlots[0]); } } } else { contextMgmt.StartDialog(); responseContent = GetMessageForVertexes(contextMgmt, results); } if (!string.IsNullOrWhiteSpace(headMessage) && responseContent.success) { responseContent.responseMessage = headMessage + ":\n" + responseContent.responseMessage; } } } return(responseContent); }