Question and answer method, system and device based on water conservancy engineering knowledge graph and medium
Patent Information
- Application Number
- CN202511161445.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2045-08-19
AI Technical Summary
一方面,多数系统难以精准理解用户的专业查询意图,尤其在处理涉及多节点、多关系的复杂问题时,常因无法有效关联知识图谱中的实体与关系,导致查询结果片面或偏离需求
本申请提供的基于水利工程知识图谱的问答方法中,通过将水利工程非结构化数据转化为结构化三元组并实现双存储备份,提升了数据利用率与安全性;借助MCP服务架构及专业配置的检索功能,保障了服务高效稳定运行;通过ES模糊匹配与Neo4j模式过滤结合的方式,增强了问题理解的精准性;依托专业适配的Cypher语句生成与多级验证机制,确保了查询的准确性与安全性;通过动态关系识别与验证,提升了对水利工程实时变化场景的适应能力;最终以符合行业习惯的自然语言呈现结果,有效提升了水利知识复用效率与用户体验,为水利行业应急预案制定、供取水计划优化等决策提供了高效、精准的知识支持。
Smart Images

Figure CN121279403B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence technology, and more specifically relates to a question-answering method, system, device and medium based on a knowledge graph of water conservancy engineering. Background Technology
[0002] Against the backdrop of accelerated digital transformation, the water conservancy industry is placing higher demands on the depth and breadth of data utilization. The accuracy, real-time nature, comprehensiveness, and intelligence level of data directly affect the quality of solutions to livelihood issues such as emergency response planning and water supply optimization. The efficient reuse of water conservancy knowledge is the core foundation supporting these decisions. However, the water conservancy industry currently faces significant technical bottlenecks in knowledge management and question-and-answer interaction, making it difficult to meet the actual needs of digital transformation.
[0003] Existing technologies have significant limitations in water conservancy data processing. Traditional methods are weak in converting unstructured data such as water conservancy project construction documents and monitoring data reports, often failing to efficiently extract key information and construct standardized knowledge associations. This results in a large amount of valuable water conservancy knowledge being stored in a scattered manner and difficult to reuse. Furthermore, the data storage methods are singular, lacking multi-source collaboration and backup mechanisms, which not only fails to guarantee data security but also makes it difficult to support rapid queries in complex scenarios, severely restricting the quality of knowledge graph construction and application efficiency.
[0004] The shortcomings of existing technologies are more pronounced in the implementation of the core functions of question-answering systems. On the one hand, most systems struggle to accurately understand the user's professional query intent, especially when dealing with complex problems involving multiple nodes and relationships. They often fail to effectively connect entities and relationships within the knowledge graph, leading to incomplete or misleading query results. On the other hand, query statement generation lacks professional adaptability. It cannot automatically generate accurate graph database query statements by incorporating characteristics such as labels and attributes specific to water conservancy projects. Furthermore, it lacks multi-level verification mechanisms for query security and efficiency, making it highly susceptible to query errors or performance bottlenecks.
[0005] Furthermore, existing technologies lack sufficient support for the dynamic and specialized nature of water conservancy knowledge. Traditional systems primarily focus on storing and retrieving static knowledge, making it difficult to identify and process the dynamic relationships prevalent in water conservancy projects. This results in insufficient support for decision-making scenarios with high real-time requirements. Simultaneously, at the result presentation level, the standardized terminology and expression habits of the water conservancy industry are often overlooked. The returned information lacks structured integration, requiring users to perform secondary processing before practical application, severely impacting the efficiency and experience of knowledge reuse. Summary of the Invention
[0006] To address the above problems, the present invention aims to provide a question-answering method, system, device, and medium based on a knowledge graph of water conservancy engineering. This method transforms unstructured water conservancy engineering data into structured triples and stores them in both Elasticsearch (ES) and Neo4j. It establishes an MCP service architecture with professional retrieval functions, combines ES fuzzy matching with Neo4j pattern filtering to accurately understand questions, generates and verifies professionally adapted Cypher statements, identifies and verifies dynamic relationships, and presents the results in industry-standard natural language. This effectively improves the utilization rate, query accuracy, and reuse efficiency of water conservancy knowledge, providing efficient support for water conservancy decision-making.
[0007] To achieve the above objectives, the present invention employs the following technical solution: Firstly, embodiments of this application provide a question-answering method based on a knowledge graph of water conservancy engineering, including: Using algorithmic processing tools, unstructured data from water conservancy projects are converted into structured data to construct graph relation triples, which are then simultaneously saved to the ES search engine and the Neo4j database. Build a knowledge graph-based MCP service and connect it to a custom graph service. Configure the MCP plugin to connect to the Neo4j instance via the Bolt protocol and configure graph retrieval-related services. To obtain questions related to water conservancy projects, keyword matching is performed in the ES search engine to obtain fuzzy matching knowledge. The Neo4j database schema is retrieved, and after formatting the ES query results, irrelevant nodes and relationships in the graph schema are filtered out. The required query nodes and related relationships are determined in combination with the questions related to water conservancy projects. Based on the required query nodes and related relationships, combined with water conservancy engineering-related issues and graph data, generate syntactically correct Cypher statements and check and verify them. According to the Cypher statement, the read_neo4j_cypherMCP service is iteratively called to obtain node relationship data. The graph relationship is determined to be a fixed relationship or a dynamic relationship through rule identification. If it is a dynamic relationship, the relationship variable is obtained by calling the rule data to determine whether the relationship is valid. Relationship data that does not meet the requirements of the starting node exploration is filtered out, and water conservancy engineering related node relationship data containing start, relation, and end attributes is generated. Based on the relationship data of relevant nodes in water conservancy projects, list the relevant entities and relationships, and all attributes of the entities involved in the relationships, and generate natural language feedback to the user.
[0008] In an optional implementation, the step of using algorithmic processing tools to convert unstructured water conservancy project data into structured data to construct graph relation triples, and simultaneously saving them to the ES search engine and the Neo4j database, includes: Acquire unstructured data of water conservancy projects, including construction documents and monitoring data reports of water conservancy projects; Using Python algorithm processing tools, unstructured data from water conservancy projects are converted into structured data; For water conservancy project construction documents, extract engineering design parameters and key information on construction progress to construct graph relationship triples; For monitoring data reports of water conservancy projects, extract water level, flow rate indicators and their corresponding time and location information to construct a ternary graph relationship.
[0009] In one optional implementation, the MCP service includes performance monitoring and optimization functions for real-time monitoring of the service's operating status, response time, and resource utilization indicators when processing water conservancy project data, and automatically adjusting service parameters according to the business needs of the water conservancy industry using preset optimization strategies.
[0010] In an optional implementation, the configuration map retrieval related services include: Configure the get-neo4j-schema service to set the schema for retrieving Neo4j databases; Configure the read-neo4j–cypher service to query information from the graph database; Configure the write-neo4j-cypher service to update graph data in the database.
[0011] In an optional implementation, the process of obtaining water conservancy project-related questions involves: performing keyword matching in the Elasticsearch search engine to obtain fuzzy matching knowledge; retrieving the Neo4j database schema; formatting the Elasticsearch query results and filtering irrelevant nodes and relationships in the graph schema; and determining the required query nodes and related relationships based on the water conservancy project-related questions. The system retrieves user-input questions related to water conservancy projects through a question-and-answer interface. Based on issues related to water conservancy projects, keyword matching is performed in ES search. ES full-text search function is used to obtain a knowledge set of fuzzy matching keywords related to water conservancy projects, and ES search results are generated. The ES search results include knowledge entries of keywords and related information. Retrieve the schema of the Neo4j database to obtain the structural information of the knowledge graph of water conservancy projects in the graph database, including node types, relation types, and attributes of each node and relation; The ES search results are formatted and the Neo4j database schema is filtered according to the graph schema to remove nodes and relationships that are not related to water conservancy engineering issues, and a filtered graph schema is generated. Based on the relevant issues of water conservancy projects and the filtered graph schema, determine whether the node to be queried is in the ES search results; if not, expand the search scope or adjust the search strategy; if so, filter out the relevant graph nodes and relationship information.
[0012] In an optional implementation, the step of generating a syntactically correct Cypher statement based on the required query nodes and related relationships, combined with water conservancy project-related issues and atlas data, and then checking and verifying it, includes: Based on the required query nodes and related relationships, and combined with the labels, attributes, and relationships information of water conservancy engineering-related issues and graph data, extract entities, relationships, and query intent; Based on the knowledge graph schema and predefined statement templates, combined with the extracted entities, relationships and query intent, a matching statement template is selected; The extracted entities, relationships, and related attributes are populated into the matching statement template to generate a syntactically correct Cypher query statement; For the generated Cypher statements, first check if the syntax of the statements is correct to ensure that it conforms to the syntax rules of the Neo4j database; then verify whether the entities, relations and attributes involved in the statements exist accurately in the knowledge graph; finally, perform data consistency verification.
[0013] In an optional implementation, the step involves iteratively calling the `read_neo4j_cypherMCP` service to obtain node relationship data based on the Cypher statement. The system then identifies whether the graph relationship is fixed or dynamic through rule recognition. If it is dynamic, it retrieves relationship variables by calling rule data to determine if the relationship is valid, and filters out relationship data that does not meet the requirements of the starting node exploration. This generates water conservancy project-related node relationship data containing `start`, `relation`, and `End` attributes, including: The Cypher statement is passed as a parameter and the read_neo4j_cypherMCP service is called iteratively to execute the Cypher statement in the Neo4j graph database and retrieve the water conservancy project node relationship data related to the user's problem from the Neo4j database. The node relationship data of the water conservancy project is analyzed, and the relationship of the graph is determined to be fixed or dynamic through rule matching. If it is a dynamic relationship, find the corresponding relationship variable and rule expression in the rule data, obtain the conditions for the relationship to be valid, and determine whether the dynamic relationship is valid in the current context based on the conditions of the dynamic relationship. If true, filter out relational data that does not meet the requirements for exploring the starting node, retain relational data that meets the requirements, and retain the start, relation, and end attributes in the relational data to generate relational data of nodes related to water conservancy projects.
[0014] Secondly, embodiments of this application also provide a question-answering system based on a knowledge graph of water conservancy engineering, including: The data conversion and synchronization module is used to convert unstructured water conservancy project data into structured data using algorithm processing tools, construct graph relation triples, and synchronously save them to the ES search engine and Neo4j database. The service setup and configuration module is used to build a knowledge graph-based MCP service and connect to a custom graph service. It configures the MCP plugin to connect to the Neo4j instance via the Bolt protocol and configures graph retrieval-related services. The retrieval and filtering module is used to obtain questions related to water conservancy projects, perform keyword matching in the ES search engine to obtain fuzzy matching knowledge, retrieve the Neo4j database schema, format the ES query results and filter irrelevant nodes and relationships in the graph schema, and combine the questions related to water conservancy projects to determine the required query nodes and related relationships. The intent recognition and statement generation module is used to generate grammatically correct Cypher statements based on the required query nodes and related relationships, combined with water conservancy engineering-related issues and graph data, and then check and verify them. The relationship analysis and data acquisition module is used to iteratively call the read_neo4j_cypherMCP service to obtain node relationship data according to the Cypher statement, identify whether the graph relationship is a fixed relationship or a dynamic relationship through rule identification, and if it is a dynamic relationship, obtain the relationship variable by calling the rule data to determine whether the relationship is valid, and filter out the relationship data that does not meet the starting node exploration, and generate water conservancy project related node relationship data containing start, relation, and end attributes; The integration and feedback module is used to list the relevant entities and relationships, as well as all attributes of the entities involved in the relationships, based on the relationship data of the nodes related to the water conservancy project, and generate natural language feedback to the user.
[0015] Thirdly, embodiments of this application also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the question-and-answer method based on the knowledge graph of water conservancy engineering as described in any of the above.
[0016] Fourthly, embodiments of this application also provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the question-and-answer method based on the knowledge graph of water conservancy engineering as described in any of the above claims.
[0017] As can be seen from the above technical solutions, the present invention has the following advantages: The question-answering method based on a knowledge graph of water conservancy engineering provided in this application improves data utilization and security by transforming unstructured water conservancy engineering data into structured triples and implementing dual storage backup; it ensures efficient and stable service operation by leveraging the MCP service architecture and professionally configured retrieval functions; it enhances the accuracy of question understanding by combining ES fuzzy matching and Neo4j pattern filtering; it ensures the accuracy and security of queries by relying on professionally adapted Cypher statement generation and multi-level verification mechanisms; it improves the adaptability to real-time changes in water conservancy engineering scenarios through dynamic relationship identification and verification; and it presents the results in natural language that conforms to industry conventions, effectively improving the efficiency of water conservancy knowledge reuse and user experience, and providing efficient and accurate knowledge support for decision-making such as emergency plan formulation and water supply and withdrawal plan optimization in the water conservancy industry.
[0018] This application transforms unstructured data from water conservancy projects into structured triples and stores them simultaneously on Elasticsearch and Neo4j for dual backup. This not only improves the utilization rate of unstructured data but also enhances the security and reliability of data storage, laying the foundation for efficient subsequent queries.
[0019] This application establishes a knowledge graph-based MCP service and configures professional search functions. It combines the Bolt protocol to achieve efficient connection with Neo4j, and also has service monitoring and optimization capabilities, ensuring the stability and response efficiency of the system when processing water conservancy data, and improving the professionalism and adaptability of knowledge retrieval.
[0020] This application combines ES keyword fuzzy matching with Neo4j pattern filtering to accurately filter irrelevant nodes and relationships. It also combines water conservancy professional issues to determine the required query elements, effectively improving the understanding of users' professional intent and reducing interference from irrelevant information.
[0021] This application generates adapted Cypher statements based on the characteristics of water conservancy, and ensures syntactic correctness, entity relationship accuracy and data consistency through a multi-level verification mechanism. It also supports dynamic relationship identification and verification, which enhances the adaptability to real-time changes in water conservancy projects and ensures the reliability of query results.
[0022] This application presents complete entity attributes and relationship information in natural language that conforms to the terminology and expression habits of the water conservancy industry, avoiding secondary processing by users, significantly improving the reuse efficiency of water conservancy knowledge and user experience, and providing direct and effective knowledge support for water conservancy decision-making. Attached Figure Description
[0023] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating the question-and-answer method based on a knowledge graph of water conservancy engineering provided in this application.
[0025] Figure 2 A schematic diagram of the question-answering system based on a knowledge graph of water conservancy engineering provided in this application.
[0026] Figure 3 A schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0027] The various embodiments of this disclosure will be described more fully in the detailed steps of the question-answering method based on the knowledge graph of water conservancy engineering described below. This disclosure may have various embodiments, and adjustments and changes may be made therein. However, it should be understood that there is no intention to limit the various embodiments of this disclosure to the specific embodiments disclosed herein, but rather this disclosure should be understood to cover all adjustments, equivalents, and / or alternatives falling within the spirit and scope of the various embodiments of this disclosure.
[0028] To facilitate a clear description of the technical solutions in the embodiments of this application, some terms and technologies involved in the embodiments of this application will be briefly introduced below: Elasticsearch: An open-source distributed search and analytics engine (based on Apache Lucene) that supports near real-time (NRT) data processing for full-text search, log analysis, and big data aggregation. Typical applications include log monitoring (ELK stack) and product search engines.
[0029] Knowledge graph: A structured semantic network that describes real-world concepts and their relationships through entities, relations, and attributes. Core objective: To transform unstructured data into machine-understandable, interconnected knowledge.
[0030] MCP: Model Context Protocol (MCP) is an open-source protocol launched by Anthropic. It aims to enable the integration of large language models with external data sources and tools, and to establish a secure, bidirectional connection between large models and data sources. It standardizes the way applications provide context to LLMs.
[0031] Neo4j: Neo4j is a leading native graph database that uses an attribute graph model (nodes, relationships, attributes) to store data and is optimized for handling complex relationships. Compared to traditional relational databases, its advantage lies in millisecond-level traversal of deep relationships (such as multi-hop queries in social networks or fraud detection), and it relies on the declarative query language Cypher to intuitively express graph patterns (e.g., MATCH (a:User)-[:FRIEND]->(b) RETURN b.name). Typical applications include real-time recommendation systems, knowledge graph construction, and risk control analysis, making it irreplaceable, especially in scenarios that require revealing hidden relationships between data.
[0032] In the following, the terms “comprising” or “may include”, which may be used in various embodiments of this disclosure, indicate the presence of the disclosed functions, operations, or elements, and do not limit the addition of one or more functions, operations, or elements. Furthermore, as used in various embodiments of this disclosure, the terms “comprising,” “having,” and their cognates are intended only to indicate a particular feature, number, step, operation, element, component, or combination of the foregoing, and should not be construed as primarily excluding the presence of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing, or the possibility of adding one or more combinations of the foregoing.
[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] Please see Figure 1 The diagram shows a flowchart of a question-answering method based on a knowledge graph of water conservancy engineering in a specific embodiment. The method includes: S1: Use algorithm processing tools to convert unstructured water conservancy project data into structured data, construct graph relation triples, and simultaneously save them to the ES search engine and Neo4j database.
[0035] In a specific implementation, unstructured data such as water conservancy project construction documents and monitoring data reports are first collected. These data come from a wide range of sources, including on-site project records, design unit documents, and data uploaded by monitoring equipment.
[0036] Then, using Python algorithm processing tools, the unstructured data is transformed. For water conservancy project construction documents, key information such as engineering design parameters and construction progress is extracted to construct graph relationship triples; for monitoring data reports, indicators such as water level and flow rate, along with their corresponding time and location information, are extracted to construct graph relationship triples.
[0037] Finally, the transformed structured data is synchronously saved to both the ES search engine and the Neo4j graph database to achieve dual data backup and ensure data security and availability.
[0038] S2: Build a knowledge graph-based MCP service and connect it to a custom graph service. Configure the MCP plugin to connect to the Neo4j instance via the Bolt protocol and configure graph retrieval-related services.
[0039] In a specific implementation, a knowledge graph-based MCP service is first built, and a custom graph service is accessed via HTTP with SSE to ensure the efficiency and stability of the service.
[0040] Then, Claude is connected to the locally running Neo4j instance via the Bolt protocol to achieve graph database connectivity and interaction. Simultaneously, service performance monitoring and optimization functions are enabled to monitor service running status, response time, and resource utilization in real time, and automatically adjust service parameters based on the business needs of the water conservancy industry.
[0041] Finally, for graph retrieval scenarios, three core services are configured: the get-neo4j-schema service for retrieving Neo4j database schemas, the read-neo4j-cypher service for graph database queries, and the write-neo4j-cypher service for graph data updates, ensuring that the service architecture adapts to the needs of water conservancy knowledge retrieval.
[0042] S3: Obtain questions related to water conservancy projects, perform keyword matching in the ES search engine to obtain fuzzy matching knowledge, retrieve the Neo4j database schema, format the ES query results, filter irrelevant nodes and relationships in the graph schema, and determine the required query nodes and related relationships based on the questions related to water conservancy projects.
[0043] In a specific implementation, after receiving user-input questions related to water conservancy projects through a question-and-answer interface, a scenario-based knowledge matching process is initiated: First, the full-text search function of the Elasticsearch search engine is used to perform fuzzy matching based on the keywords of the question to obtain the relevant knowledge set as the Elasticsearch search results; the Elasticsearch search results include knowledge entries of keywords and related information.
[0044] The system synchronously searches the Neo4j database schema to obtain structural information such as node types, relationship types, and attributes of the graph. It then formats the Elasticsearch search results, filtering out nodes and relationships irrelevant to the user's question based on the graph schema, and generates a filtered graph schema.
[0045] Then, by combining the user's question with the filtered schema, it is determined whether the required query node is in the Elasticsearch results. If it does not exist, the query scope is expanded or the strategy is adjusted. If it exists, the relevant graph nodes and relationship information are accurately filtered out to complete the initial analysis of the user's query intent.
[0046] S4: Generate grammatically correct Cypher statements based on the required query nodes and related relationships, combined with water conservancy project-related issues and graph data, and check and verify them.
[0047] In a specific implementation, the core entities, relationships, and query intent are first extracted based on the determined query nodes and relationships, combined with the user's question and the labels, attributes, and relationships information of the graph data.
[0048] Then, based on the knowledge graph schema and the preset water conservancy professional statement template, the matching template is selected and the entity, relationship and attribute information is filled in to automatically generate Cypher query statements.
[0049] Finally, a multi-level verification mechanism is used to ensure the reliability of the statement: first, the syntax is checked to see if it conforms to Neo4j rules; then, the entities, relations and attributes in the statement are verified to actually exist in the graph; and finally, data consistency verification is performed to ensure the security and accuracy of the query.
[0050] S5: According to the Cypher statement, iteratively call the read_neo4j_cypherMCP service to obtain node relationship data, identify whether the graph relationship is a fixed relationship or a dynamic relationship through rule recognition, if it is a dynamic relationship, obtain the relationship variable by calling the rule data to determine whether the relationship is valid, and filter out the relationship data that does not meet the starting node exploration, and generate water conservancy project related node relationship data containing start, relation, and end attributes.
[0051] In a specific implementation, the validated Cypher statement is used as a parameter to iteratively call the read_neo4j_cypherMCP service to perform queries in the Neo4j database and obtain node relationship data. A rule recognition mechanism is then activated to determine whether the graph relationships are fixed or dynamic through rule matching. If dynamic, the rule data is retrieved to obtain the relationship variables and their conditions for validity. This is then combined with the real-time status of the water conservancy project (such as water level changes and flow fluctuations) to verify the validity of the relationship. Relationship data that does not meet the requirements for exploring the starting node is filtered out, retaining only valid relationship data containing start, relation, and end attributes. This generates node relationship data related to the water conservancy project, achieving accurate adaptation to dynamic changing scenarios of the water conservancy project.
[0052] S6: Based on the relationship data of relevant nodes in the water conservancy project, list the relevant entities and relationships, and all attributes of the entities involved in the relationships, and generate natural language feedback to the user.
[0053] In a specific implementation, based on the relationship data of relevant nodes in water conservancy projects, all relevant entities (including complete attributes), relationships between entities, and attribute information of entities involved in those relationships are automatically listed. Combining water conservancy industry terminology and expression habits, this information is structured and integrated. Natural language processing technology is used to transform the technical graph data into intuitive expressions that conform to industry understanding. Finally, the processed results are fed back to the user, achieving efficient knowledge reuse and easy-to-understand presentation.
[0054] As can be seen, the question-answering method based on the knowledge graph of water conservancy engineering fully utilizes the technical features of natural language processing, rule management, knowledge matching, knowledge graph, ES search engine, and MCP service. In the data preparation stage, unstructured data is converted into structured data using Python algorithm processing tools, graph relationship triples are constructed and saved to ES and Neo4j. In the service preparation stage, the MCP service is built and plugins are configured to connect to the Neo4j instance and perform graph retrieval. In the graph retrieval stage, relevant information is obtained through ES retrieval and Neo4j pattern retrieval, the results are formatted and filtered, and the nodes and relationships to be queried are determined based on the user's question. In the intent recognition and statement generation stage, the entities, relationships, and query intent in the user's question are accurately understood, and syntactically correct Cypher statements are generated and verified. Finally, node relationship data is obtained by iteratively calling the MCP service, rule recognition and relationship filtering are performed, relevant entities, relationships, and attributes are listed, and the user's question is answered in natural language.
[0055] In this embodiment, unstructured water conservancy project data is transformed into structured triples using Python tools and stored in both Elasticsearch (ES) and Neo4j, achieving secure data backup and efficient utilization. Neo4j is connected via the MCP service architecture and Bolt protocol, with professional retrieval services configured and performance monitored and optimized in real time to ensure stable and efficient system operation. Combining ES keyword fuzzy matching and Neo4j pattern filtering, user query intent is accurately identified and key node relationships are filtered. Cypher statements are generated and verified based on water conservancy professional characteristics, and dynamic relationship identification and verification adapt to real-time changing scenarios, ensuring accurate and reliable queries. Finally, complete information is presented in natural language that conforms to industry conventions, significantly improving the efficiency of water conservancy knowledge reuse and decision support capabilities, providing precise and efficient knowledge services for livelihood issues such as emergency plan formulation and water supply and withdrawal plan optimization.
[0056] like Figure 2 As shown, the following are embodiments of the question-answering system based on the knowledge graph of water conservancy engineering provided in this disclosure. This system and the question-answering method based on the knowledge graph of water conservancy engineering in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the question-answering system based on the knowledge graph of water conservancy engineering, please refer to the embodiments of the question-answering method based on the knowledge graph of water conservancy engineering described above.
[0057] A question-answering system based on a knowledge graph of water conservancy engineering includes: The data conversion and synchronization module is used to convert unstructured water conservancy project data into structured data using algorithm processing tools, construct graph relation triples, and synchronously save them to the ES search engine and Neo4j database. The service setup and configuration module is used to build a knowledge graph-based MCP service and connect to a custom graph service. It configures the MCP plugin to connect to the Neo4j instance via the Bolt protocol and configures graph retrieval-related services. The retrieval and filtering module is used to obtain questions related to water conservancy projects, perform keyword matching in the ES search engine to obtain fuzzy matching knowledge, retrieve the Neo4j database schema, format the ES query results and filter irrelevant nodes and relationships in the graph schema, and combine the questions related to water conservancy projects to determine the required query nodes and related relationships. The intent recognition and statement generation module is used to generate grammatically correct Cypher statements based on the required query nodes and related relationships, combined with water conservancy engineering-related issues and graph data, and then check and verify them. The relationship analysis and data acquisition module is used to iteratively call the read_neo4j_cypherMCP service to obtain node relationship data according to the Cypher statement, identify whether the graph relationship is a fixed relationship or a dynamic relationship through rule identification, and if it is a dynamic relationship, obtain the relationship variable by calling the rule data to determine whether the relationship is valid, and filter out the relationship data that does not meet the starting node exploration, and generate water conservancy project related node relationship data containing start, relation, and end attributes; The integration and feedback module is used to list the relevant entities and relationships, as well as all attributes of the entities involved in the relationships, based on the relationship data of the nodes related to the water conservancy project, and generate natural language feedback to the user.
[0058] The question-answering system based on the knowledge graph of water conservancy engineering provided in this embodiment transforms unstructured water conservancy data into structured triples and stores them in two ways. It builds an MCP service to achieve efficient retrieval, combines ES and Neo4j to accurately understand questions, generates and verifies professional Cypher statements and handles dynamic relationships, and finally presents the results in industry-standard language, effectively improving the utilization rate of water conservancy knowledge, query accuracy and decision support efficiency.
[0059] Figure 3 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0060] The question-answering method based on a knowledge graph of water conservancy engineering provided in this application can be applied to electronic devices. Those skilled in the art will understand that the electronic device structure involved in the embodiments of this invention does not constitute a limitation on the electronic device. An electronic device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements. In the embodiments of this invention, the electronic device includes, but is not limited to, laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of this application described and / or claimed herein.
[0061] Electronic devices may include processors, external memory interfaces, internal memory, universal serial bus (USB) interfaces, charging management modules, power management modules, batteries, wireless communication modules, audio modules, speakers, microphones, sensor modules, buttons, cameras, displays, and SIM card interfaces, etc.
[0062] A processor may include one or more processing units, such as: a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.
[0063] The processor can serve as the nerve center and command center of an electronic device. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0064] The processor may also include memory for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. This memory can store instructions or data that the processor has just used or that are used repeatedly. If the processor needs to use the instruction or data again, it can retrieve it directly from this memory. This avoids repeated accesses, reduces processor latency, and thus improves system efficiency.
[0065] An external storage interface (ESI) can be used to connect external memory cards, such as microSD cards, to expand the storage capacity of electronic devices. The external memory card communicates with the processor through the ESI to perform data storage functions, such as saving music and video files on the external memory card.
[0066] Internal memory can be used to store computer executable program code, which includes instructions. The processor executes various functional applications and data processing of electronic devices by running the instructions stored in internal memory. Internal memory can include a program storage area and a data storage area. Internal memory can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0067] Wireless communication functionality in electronic devices can be achieved through antennas, wireless communication modules, modem processors, and baseband processors.
[0068] Wireless communication modules can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.
[0069] Electronic devices can implement audio functions through audio modules, speakers, receivers, microphones, headphone jacks, and application processors.
[0070] Electronic devices can achieve shooting functions through ISPs, cameras, video codecs, GPUs, displays, and application processors.
[0071] Electronic devices can achieve display functions through GPUs, displays, and application processors.
[0072] A GPU is a microprocessor for image processing, connected to the display screen and application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering. A processor may include one or more GPUs, which execute program instructions to generate or modify display information.
[0073] A display screen is used to display images, videos, etc. A display screen includes a display panel.
[0074] The aforementioned electronic device realizes the question-answering method based on water conservancy engineering knowledge graphs in this application, which transforms unstructured water conservancy engineering data into structured triples and stores them in both ES and Neo4j. It builds an MCP service architecture, configures professional search functions, combines ES fuzzy matching and Neo4j pattern filtering to accurately understand questions, generates and verifies professionally adapted Cypher statements and identifies and processes dynamic relationships, and finally presents the results in industry-standard natural language. This achieves the beneficial effects of improving the utilization rate of water conservancy knowledge, query accuracy and reuse efficiency, and providing efficient support for water conservancy decision-making.
[0075] The storage medium provided in this application stores a program product capable of implementing a question-and-answer method based on a knowledge graph of water conservancy engineering.
[0076] Question-answering methods based on knowledge graphs for water conservancy engineering include: Using algorithmic processing tools, unstructured data from water conservancy projects are converted into structured data to construct graph relation triples, which are then simultaneously saved to the ES search engine and the Neo4j database. Build a knowledge graph-based MCP service and connect it to a custom graph service. Configure the MCP plugin to connect to the Neo4j instance via the Bolt protocol and configure graph retrieval-related services. To obtain questions related to water conservancy projects, keyword matching is performed in the ES search engine to obtain fuzzy matching knowledge. The Neo4j database schema is retrieved, and after formatting the ES query results, irrelevant nodes and relationships in the graph schema are filtered out. The required query nodes and related relationships are determined in combination with the questions related to water conservancy projects. Based on the required query nodes and related relationships, combined with water conservancy engineering-related issues and graph data, generate syntactically correct Cypher statements and check and verify them. According to the Cypher statement, the read_neo4j_cypherMCP service is iteratively called to obtain node relationship data. The graph relationship is determined to be a fixed relationship or a dynamic relationship through rule identification. If it is a dynamic relationship, the relationship variable is obtained by calling the rule data to determine whether the relationship is valid. Relationship data that does not meet the requirements of the starting node exploration is filtered out, and water conservancy engineering related node relationship data containing start, relation, and end attributes is generated. Based on the relationship data of relevant nodes in water conservancy projects, list the relevant entities and relationships, and all attributes of the entities involved in the relationships, and generate natural language feedback to the user.
[0077] In some possible implementations, the question-answering method based on a knowledge graph of water conservancy engineering disclosed herein can be implemented as a program product, which includes program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure.
[0078] The storage medium disclosed herein may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0079] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A question-answering method based on a knowledge graph of water conservancy engineering, characterized in that, include: Using algorithmic processing tools, unstructured data from water conservancy projects are converted into structured data to construct graph relation triples, which are then simultaneously saved to the ES search engine and the Neo4j database. Build a knowledge graph-based MCP service and connect it to a custom graph service. Configure the MCP plugin to connect to the Neo4j instance via the Bolt protocol and configure graph retrieval-related services. To obtain questions related to water conservancy projects, keyword matching is performed in the ES search engine to obtain fuzzy matching knowledge. The Neo4j database schema is retrieved, and after formatting the ES query results, irrelevant nodes and relationships in the graph schema are filtered out. The required query nodes and related relationships are determined in combination with the questions related to water conservancy projects. Based on the required query nodes and related relationships, combined with water conservancy engineering-related issues and graph data, generate syntactically correct Cypher statements and check and verify them. According to the Cypher statement, the read_neo4j_cypherMCP service is iteratively called to obtain node relationship data. The graph relationship is determined to be a fixed relationship or a dynamic relationship through rule identification. If it is a dynamic relationship, the relationship variable is obtained by calling the rule data to determine whether the relationship is valid. Relationship data that does not meet the requirements of the starting node exploration is filtered out, and water conservancy engineering related node relationship data containing start, relation, and end attributes is generated. Based on the relationship data of relevant nodes in water conservancy projects, list the relevant entities and relationships, and all attributes of the entities involved in the relationships, and generate natural language feedback to the user; The process involves iteratively calling the `read_neo4j_cypherMCP` service to obtain node relationship data based on the Cypher statement. It then uses rule recognition to determine whether the graph relationship is fixed or dynamic. If it's dynamic, it retrieves relationship variables by calling rule data to determine if the relationship is valid, and filters out relationship data that doesn't meet the initial node exploration criteria. This generates water conservancy project-related node relationship data containing `start`, `relation`, and `End` attributes, including: The Cypher statement is passed as a parameter and the read_neo4j_cypherMCP service is called iteratively to execute the Cypher statement in the Neo4j graph database and retrieve the water conservancy project node relationship data related to the user's problem from the Neo4j database. The node relationship data of the water conservancy project is analyzed, and the graph relationship is determined to be a fixed relationship or a dynamic relationship through rule matching. If it is a dynamic relationship, find the corresponding relationship variable and rule expression in the rule data, obtain the conditions for the relationship to be valid, and determine whether the dynamic relationship is valid in the current context based on the conditions of the dynamic relationship. If true, filter out relational data that does not meet the requirements for exploring the starting node, retain relational data that meets the requirements, and retain the start, relation, and end attributes in the relational data to generate relational data of nodes related to water conservancy projects.
2. The question-answering method based on a knowledge graph of water conservancy engineering according to claim 1, characterized in that, The process involves using algorithmic processing tools to convert unstructured water conservancy project data into structured data, constructing graph relation triples, and simultaneously saving them to the Elasticsearch search engine and the Neo4j database, including: Acquire unstructured data of water conservancy projects, including construction documents and monitoring data reports of water conservancy projects; Using Python algorithm processing tools, unstructured data from water conservancy projects are converted into structured data; For water conservancy project construction documents, extract engineering design parameters and key information on construction progress to construct graph relationship triples; For monitoring data reports of water conservancy projects, extract water level, flow rate indicators and their corresponding time and location information to construct a ternary graph relationship.
3. The question-answering method based on a knowledge graph of water conservancy engineering according to claim 1, characterized in that, The MCP service includes performance monitoring and optimization functions, which are used to monitor the service's operating status, response time, and resource utilization indicators in real time when processing water conservancy project data, and automatically adjust service parameters according to the business needs of the water conservancy industry using preset optimization strategies.
4. The question-answering method based on a knowledge graph of water conservancy engineering according to claim 1, characterized in that, The configuration map retrieval related services include: Configure the get-neo4j-schema service to set the schema for retrieving Neo4j databases; Configure the read-neo4j–cypher service to query information from the graph database; Configure the write-neo4j-cypher service to update graph data in the database.
5. The question-answering method based on a knowledge graph of water conservancy engineering according to claim 1, characterized in that, The process of obtaining water conservancy engineering-related questions involves: performing keyword matching in the Elasticsearch search engine to acquire fuzzy matching knowledge; retrieving the Neo4j database schema; formatting the Elasticsearch query results and filtering irrelevant nodes and relationships in the graph schema; and combining the water conservancy engineering-related questions to determine the required query nodes and related relationships, including: The system retrieves user-input questions related to water conservancy projects through a question-and-answer interface. Based on issues related to water conservancy projects, keyword matching is performed in the ES search engine. Using ES's full-text search function, a knowledge set of fuzzy matching keywords related to water conservancy projects is obtained, and ES search results are generated. The ES search results include knowledge entries of keywords and related information. Retrieve the schema of the Neo4j database to obtain the structural information of the knowledge graph of water conservancy projects in the graph database, including node types, relation types, and attributes of each node and relation; The ES search results are formatted and the Neo4j database schema is filtered according to the graph schema to remove nodes and relationships that are not related to water conservancy engineering issues, and a filtered graph schema is generated. Based on the relevant issues of water conservancy projects and the filtered graph schema, determine whether the node to be queried is in the ES search results; if not, expand the search scope or adjust the search strategy; if so, filter out the relevant graph nodes and relationship information.
6. The question-answering method based on a knowledge graph of water conservancy engineering according to claim 5, characterized in that, The process of generating syntactically correct Cypher statements based on the required query nodes and related relationships, combined with water conservancy project-related issues and graph data, and then checking and verifying them includes: Based on the required query nodes and related relationships, and combined with the labels, attributes, and relationships information of water conservancy engineering-related issues and graph data, extract entities, relationships, and query intent; Based on the knowledge graph schema and predefined statement templates, combined with the extracted entities, relationships and query intent, a matching statement template is selected; The extracted entities, relationships, and related attributes are populated into the matching statement template to generate a syntactically correct Cypher query statement; For the generated Cypher statements, first check if the syntax of the statements is correct to ensure that it conforms to the syntax rules of the Neo4j database; then verify whether the entities, relations and attributes involved in the statements exist accurately in the knowledge graph; finally, perform data consistency verification.
7. A question-answering system based on a knowledge graph of water conservancy engineering, characterized in that, The system employs the question-and-answer method based on the knowledge graph of water conservancy engineering as described in any one of claims 1 to 6; The system includes: The data conversion and synchronization module is used to convert unstructured water conservancy project data into structured data using algorithm processing tools, construct graph relation triples, and synchronously save them to the ES search engine and Neo4j database. The service setup and configuration module is used to build a knowledge graph-based MCP service and connect to a custom graph service, configure the MCP plugin to connect to the Neo4j instance via the Bolt protocol, and configure graph retrieval-related services. The retrieval and filtering module is used to obtain questions related to water conservancy projects, perform keyword matching in the ES search engine to obtain fuzzy matching knowledge, retrieve the Neo4j database schema, format the ES query results and filter irrelevant nodes and relationships in the graph schema, and combine the questions related to water conservancy projects to determine the required query nodes and related relationships. The intent recognition and statement generation module is used to generate grammatically correct Cypher statements based on the required query nodes and related relationships, combined with water conservancy engineering-related issues and graph data, and then check and verify them. The relationship analysis and data acquisition module is used to iteratively call the read_neo4j_cypherMCP service to obtain node relationship data according to the Cypher statement, identify whether the graph relationship is a fixed relationship or a dynamic relationship through rule identification, and if it is a dynamic relationship, obtain the relationship variable by calling the rule data to determine whether the relationship is valid, and filter out the relationship data that does not meet the starting node exploration, and generate water conservancy project related node relationship data containing start, relation, and end attributes; The integration and feedback module is used to list the relevant entities and relationships, as well as all attributes of the entities involved in the relationships, based on the relationship data of the nodes related to the water conservancy project, and generate natural language feedback to the user.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the question-answering method based on the knowledge graph of water conservancy engineering as described in any one of claims 1 to 6.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the question-answering method based on the knowledge graph of water conservancy engineering as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Complex information retrieval system and method
CN118779364A
Concurrent automatic adaptive storage of datasets in graph databases
US20190220546A1