Knowledge application graph database query statement automatic generation method
By automatically generating graph database query statements, the problem of high difficulty in writing knowledge graph and graph database query statements is solved, and the automation and intelligence of query statements is realized, the operation complexity is reduced, and the real-time interactive experience of knowledge application is improved.
Patent Information
- Application Number
- CN202411564919.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, the writing of knowledge graph and graph database query statements is difficult, the professional knowledge requirements are too high, and manual writing of query statements is time-consuming and error-prone, making it difficult to meet the rapid changes and agile response of business needs.
Provides a method of automatically generating knowledge application graph database query statements, build a knowledge graph by obtaining knowledge data, configures function search statement templates and wake-up word data tables, matches the user input statements and templates, and generates graph database query statements.
Simplifies the process of creating query statements, reduces the coding burden of users, and allows non-technical personnel to conduct complex queries efficiently, ensures the correctness of query statements, dynamically adapts to different application scenarios and query needs, and significantly reduces the operation of graph databases. Complexity.
Smart Images

Figure CN119441543A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graphs and graph databases, and more specifically, to a method for automatically generating query statements for a knowledge application graph database. Background Art
[0002] In the current era of big data, knowledge graphs as a structured and semantic form of knowledge representation, and graph databases as an effective tool for efficient storage and query of such data, have been widely used in many fields, such as intelligent recommendation, financial risk control, biomedical research, etc. However, although knowledge graphs and graph database technologies provide a powerful infrastructure for information management and decision support, the full exploitation of their potential is often restricted by the difficulty and efficiency of query statement writing.
[0003] For knowledge graphs in specific industries or fields, the construction of query statements usually requires deep professional knowledge and an in-depth understanding of graph data models, which brings a high threshold for non-professional users or cross-domain researchers. In addition, graph database query languages (such as SPARQL, Cypher, etc.) have rich expressiveness to handle complex graph pattern matching and path queries, but their syntax is relatively complex. For complex query scenarios, manually writing queries may be time-consuming and error-prone. At the same time, with the rapid changes in business needs, the functions and query logic of knowledge applications need to be adjusted frequently, and traditional manual writing methods are difficult to meet the needs of such agile responses. Summary of the invention
[0004] In view of the technical problems existing in the prior art, the present invention provides a method for automatically generating query statements for a knowledge application graph database, which is used to solve the problems of complex query statements and excessively high professional knowledge requirements.
[0005] The present invention provides a method for automatically generating query statements for a knowledge application graph database, comprising:
[0006] Step S1, obtaining knowledge data in administrative approval, and constructing an administrative approval knowledge graph based on the knowledge data;
[0007] Step S2, configuring the graph knowledge application, configuring the function search statement template of each knowledge application according to the type of the knowledge application, and constructing a wake-up word data table according to the type of the knowledge application;
[0008] Step S3, according to the administrative approval knowledge graph and knowledge application configuration information, the user input statement is matched with the function search statement template to generate a graph database query statement.
[0009] The invention provides a method for automatically generating query statements for a knowledge application graph database, which has the following beneficial effects:
[0010] (1) Design functional search statement templates, predefine common query patterns and logic into reusable modules, and combine them with the wake-up word library built according to the function. Users only need to use natural language or simple instructions to trigger the corresponding query operation. This method greatly simplifies the query statement creation process, reduces the user's coding burden, and enables non-technical personnel to efficiently perform complex queries;
[0011] (2) Based on the knowledge graph and knowledge application configuration information, a graph database query statement automatic generation method is formed, which can automatically synthesize accurate graph database search statements according to the user-specified knowledge application type. This intelligent process not only ensures the correctness of the query statement and avoids human errors, but also can dynamically adapt to different application scenarios and query requirements, significantly reducing the complexity of graph database operations;
[0012] (3) Through the automatic generation mechanism, users no longer need to write queries from scratch. Instead, they can directly use preset templates and models to generate statements, which greatly shortens the query preparation time, speeds up the entire process from data request to result presentation, and improves the real-time interactive experience of knowledge application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 A flowchart of a method for automatically generating query statements for a knowledge application graph database provided by the present invention;
[0014] Figure 2 A flow chart of a method for automatically generating a graph database query statement constructed in step S3 according to an embodiment of the present invention;
[0015] Figure 3 A structural block diagram of a knowledge application graph database query statement automatic generation system provided by the present invention. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, the technical features in the various embodiments or single embodiments provided by the present invention can be arbitrarily combined with each other to form a feasible technical solution. This combination is not subject to the constraints of the sequence of steps and / or the structural composition mode, but must be based on the ability of ordinary technicians in this field to achieve. When the combination of technical solutions is contradictory or cannot be achieved, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0017] Figure 1 A flow chart of a method for automatically generating query statements for a knowledge application graph database provided by the present invention, such as Figure 1 As shown, the method includes:
[0018] Step S1, obtain the knowledge data in administrative approval, and construct an administrative approval knowledge graph based on the knowledge data.
[0019] It is understandable that the present invention can be applied to the process of administrative approval, such as the approval of qualifications and the approval of various company affairs. First, the knowledge data in administrative approval is obtained, and the administrative approval knowledge graph is constructed based on the knowledge data.
[0020] Exemplarily, the step S1, obtaining knowledge data in administrative approval, and constructing an administrative approval knowledge graph based on the knowledge data, includes:
[0021] Step S11, obtaining knowledge data in administrative approval, wherein the knowledge data includes entities, relationships and attributes involved in the administrative approval process;
[0022] Step S12, enter the knowledge data into the neo4j graph database to generate an administrative approval knowledge graph.
[0023] Step S2, configure the graph knowledge application, configure the function retrieval statement template of each knowledge application according to the type of the knowledge application, and construct a wake-up word data table according to the type of the knowledge application.
[0024] In step S2, configuring the graph knowledge application includes:
[0025] Step S21, configure graph knowledge applications, which include five application types: knowledge cards, graph exploration, time series graph exploration, association analysis, and path discovery.
[0026] Among them, knowledge cards refer to a type of knowledge application that displays brief information of an entity in the form of an information box after identifying the query entity; graph exploration refers to a type of knowledge application that displays the multi-layer association relationship network of the entity in the form of a graph visualization after identifying the entity; time series graph exploration refers to a type of knowledge application that displays the changes or history of the query subject in the form of a dynamic time series graph after identifying the entity; association analysis refers to a type of knowledge application that finds the association relationship between multiple nodes in the formed network relationship graph; path discovery refers to a type of knowledge application that finds the association relationship between two nodes in the formed network relationship graph.
[0027] After configuring the knowledge application of the graph, a function search statement template is configured for each type of knowledge application. Exemplarily, the function search statement template of each type of knowledge application is configured, including:
[0028] Step S22, when the knowledge application is a knowledge card, configure the corresponding knowledge card function search statement template: MATCH (n{`name`:'%s'}) RETURN n;
[0029] Among them, "%s" is used to match entities, n represents entities, and taking the above sample as an example, the question example is "xx's knowledge card" (the wake-up word needs to be set as a knowledge card), and all attribute information of the entity is returned.
[0030] Step S23, when the knowledge application is graph exploration, configure the graph exploration function search statement template: MATCH p = (n{`name`:'%s'})-[]-(m)RETURN p;
[0031] Among them, "%s" is used to match entities, n is the starting entity, m is the end entity, r represents the relationship between the starting entity m and the end entity, and the relationship graph p between entity n and entity m is returned in the form of a graph. Taking the above sample as an example, the question example is "xx graph exploration" (the wake-up word needs to be set to graph exploration), and the relationship graph of the entity is returned in the form of a graph.
[0032] Step S24, when the knowledge application is sequence diagram exploration, configure the sequence diagram exploration function retrieval statement template: MATCH p = (n{`name`:'%s'})-[r]-(m) WHERE r.`time` IS NOT NULL AND datetime(r.`time`)>=datetime('%s') AND NOT type(r) IN['%s'] RETURN p;
[0033] The first "%s" is used to match entities, the second "%s" is used to match the start time of the query relationship, and the time string format example is "2023-08-23T11:32:06Z". The third "%s" is used to match the relationship name not included in the returned results. n is the starting entity, m is the end entity, r represents the relationship between the starting entity m and the end entity, and the relationship graph p between entity n and entity m is returned in the form of a graph.
[0034] If there is no relationship configuration, the retrieval statement template of the sequence diagram exploration function is: MATCH p = (n{`name`:'%s'})-[r]-(m) WHERE r.`time` IS NOT NULL AND datetime(r.`time`)>=datetime('%s') RETURN p.
[0035] Taking the above sample as an example, the question example is "xx's installation record" (the wake-up word needs to be set as the installation record), and the relationship graph of the entity containing the installation time is returned in the form of a graph.
[0036] Step S25, when the knowledge application is association analysis, configure the association analysis function search statement template: MATCH(n0{`name`:'%s'}),(n1{`name`:'%s'}),(n2{`name`:'%s'})MATCH p=(n0)-[]-(n1)-[]-(n2)RETURN p;
[0037] Among them, the three "%s" are used to match entities, and the relationship diagram between entity n1 and entity n2 is returned in the form of a graph. Taking the above sample as an example, the question example is "the relationship between xx aircraft carrier and A and B" (the wake-up word needs to be set as the relationship), and the relationship diagram between A and B is returned in the form of a graph.
[0038] Step S26, when the knowledge application is path discovery, configure the path discovery function retrieval statement template: MATCH(n0{`name`:'%s'}),(n1{`name`:'%s'})MATCH p=(n0)-[]-(n1)RETURN p.
[0039] Among them, both "%s" are used to match entities, and the relationship graph between entity n0 and entity n1 is returned in the form of a graph. Taking the above sample as an example, the question example is "the relationship between A and B" (the wake-up word needs to be set as a relationship), and the relationship graph between A and B is returned in the form of a graph.
[0040] After configuring the function search sentence template for each type of knowledge application, a wake-up word is also constructed for each type of knowledge application to form a wake-up word data table, wherein the wake-up word data table includes 5 wake-up words.
[0041] Exemplarily, in step S2, building a wake-up word library according to the type of the knowledge application includes:
[0042] Constructing a wake-up word data table, wherein the wake-up word data table includes a unique index of each wake-up word, the wake-up word, and a function type;
[0043] The function type of the wake-up word is distinguished by numbers: 0 represents knowledge card, 1 represents graph exploration, 2 represents time series graph exploration, 3 represents association analysis, and 4 represents path discovery. The wake-up word is a keyword that wakes up the corresponding function. If the question contains "knowledge card", the answer returned by the model must meet the requirements of the knowledge card function reply.
[0044] Combining the above-designed data table structure and question-answering model functions, the rouse data table example is as follows:
[0045] id word type 1704383631316385793 Knowledge Cards 0 1704383650538881025 Relationship diagram 1 1710476713954873345 Relationship 3 …… …… ……
[0046] Step S3. According to the administrative approval knowledge graph and the knowledge application configuration information, match the user input statement with the function retrieval statement template to generate a graph database query statement.
[0047] Figure 2 The flowchart showing the matching of the user input statement and the function retrieval statement template is presented. In step S3, according to the administrative approval knowledge graph and the knowledge application configuration information, the user input statement is matched with the function retrieval statement template to generate a graph database query statement, including:
[0048] Step S31. Use the NER method of Hanlp to perform part-of-speech analysis on the user input statement to obtain the part-of-speech analysis result.
[0049] Taking the above sample as an example, for the input statement "knowledge card of xx", the part-of-speech analysis result is:
[0050] [{
[0051] "word": "xx",
[0052] "type": "NR"
[0053] }
[0054] {
[0055] "word": "of",
[0056] "type": "DEG"
[0057] }
[0058] {
[0059] "word": "knowledge",
[0060] "type": "NN"
[0061] }
[0062] {
[0063] "word": "card",
[0064] "type": "NN"
[0065] }
[0066] Among them, NR represents proper nouns, usually indicating place names, personal names, organization names, etc. DEG represents the genitive case "of", and its part of speech when "of" or "zhi" is used as a complement marker or nominalization marker. Its structure is: S / VP DEC{NP}, for example, college students who like traveling. NN represents other nouns, all nouns except proper nouns and time nouns.
[0067] Step S32: Match the part-of-speech analysis result with the wake-up words in the wake-up word data table to determine whether there is a wake-up word in the user input statement.
[0068] It can be understood that each word in the part-of-speech analysis result of the user input statement in step S31 is matched with each wake-up word in the wake-up word data table to determine whether there is a wake-up word in the user input statement.
[0069] Step S33: If there is a wake-up word in the user input statement and the wake-up word match is successful, execute the function matching logic.
[0070] Exemplarily, in step S33, if there is a wake-up word in the user input statement and the wake-up word match is successful, execute the function matching logic, including:
[0071] Step S331: Obtain the function type corresponding to the wake-up word according to the wake-up word matched in the user input statement. Among them, if multiple wake-up words are matched, the function with the smaller serial number among the function types of the multiple wake-up words is preferentially executed;
[0072] S332: If the function match is successful, call the retrieval statement template of the corresponding function, and match the retrieval statement template with the result of the part-of-speech type "NR" in the part-of-speech analysis result to generate the graph database retrieval statement of the corresponding function;
[0073] S333: If the function match fails, directly output the result "No data available!";
[0074] Among them, when there is a word of the part-of-speech type "NR" in the part-of-speech analysis result, the function match is successful; otherwise, the function match fails.
[0075] Step S34: If there is no wake-up word in the user input statement and the wake-up word match fails, execute the entity relationship matching logic.
[0076] Exemplarily, in step S34, if there is no wake-up word in the user input statement and the wake-up word match fails, execute the entity relationship matching logic, including:
[0077] Step S341, perform entity-relationship matching on the user input sentence to determine whether there are entities and relationships in the user input sentence; wherein, by determining whether there are words with the part-of-speech type of "NR" and "VV" in the part-of-speech analysis result, if there are words with the part-of-speech type of "NR" and "VV", then there are entities and relationships in the user input sentence; if there are no words with the part-of-speech type of "NR" or "VV", then there are no entities and relationships in the user input sentence.
[0078] Step S342: If there are entities and relationships in the user input sentence and the entity-relationship matching is successful, the entity-relationship matching logic is executed.
[0079] In step S342, if the user input sentence contains entities and relationships, and the entity-relationship matching is successful, then the entity-relationship matching logic is executed, including:
[0080] Step S3421, calling the entity relationship search statement template: MATCH({`name`:'%s'})-[r:`%s`]->(n)RETURN n, where the first "%s" is used to match the entity, and the second "%s" is used to match the relationship;
[0081] Step S3422, matching the first "%s" in the entity relationship search statement template with the result of the part-of-speech analysis whose part-of-speech type is "NR";
[0082] Step S3423, matching the second "%s" in the entity relationship search statement template with the result of the part-of-speech analysis result whose part-of-speech type is "VV";
[0083] S3424. Generate a graph database search statement corresponding to the entity relationship.
[0084] Step S343: If there is no entity or relationship in the user input sentence and the entity relationship matching fails, the entity recognition logic is executed.
[0085] In step S343, if there is no entity or relationship in the user input sentence and the entity relationship matching fails, the entity recognition logic is executed, including:
[0086] Step S3431, performing entity recognition on the user input sentence to determine whether there is an entity in the user input sentence;
[0087] S3432. If an entity is identified, call the entity search statement template (MATCH(n{`name`:'%s'}) RETURN n, where "%s" is used to match the entity) to generate a graph database search statement for the corresponding entity;
[0088] S3433. If no entity is identified, the result “No data!” is directly output.
[0089] Step S35, output the knowledge application graph database search statement.
[0090] Unfortunately, the above steps perform part-of-speech analysis on the user input sentence, match each word after the part-of-speech analysis of the user input sentence with the wake-up word, and match it with the corresponding function search sentence template, and automatically generate a knowledge application graph database search statement.
[0091] Figure 3 A knowledge application graph database query statement automatic generation system is provided, the system comprising:
[0092] Construction module 301, used to obtain knowledge data in administrative approval and construct an administrative approval knowledge graph based on the knowledge data;
[0093] Configuration module 302, used to configure graph knowledge applications, configure a function search statement template for each knowledge application according to the type of the knowledge application, and construct a wake-up word data table according to the type of the knowledge application;
[0094] The matching module 303 is used to match the user input statement with the functional search statement template according to the administrative approval knowledge graph and knowledge application configuration information to generate a graph database query statement.
[0095] It can be understood that the knowledge application graph database query statement automatic generation system provided by the present invention corresponds to the knowledge application graph database query statement automatic generation method provided by the aforementioned embodiments, and the relevant technical features of the knowledge application graph database query statement automatic generation system can refer to the relevant technical features of the knowledge application graph database query statement automatic generation method, which will not be repeated here.
[0096] An embodiment of the present invention provides a method and system for automatically generating query statements for a knowledge application graph database. By effectively encapsulating professional knowledge, constructing a knowledge graph, and designing a functional retrieval statement template, query statement templating is realized. A method for automatically generating query statements for a knowledge application graph database is proposed to realize automation and intelligence of query statements. It can automatically generate corresponding graph database retrieval statements according to the knowledge application type and obtain query results, thereby reducing the operational complexity of the graph database, improving the efficiency of knowledge utilization, and promoting the intelligent process of knowledge-driven decision-making.
[0097] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0098] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0099] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0100] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0101] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0102] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0103] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for automatically generating query statements for a knowledge application graph database, characterized in that: include: Step S1, obtaining knowledge data in administrative approval, and constructing an administrative approval knowledge graph based on the knowledge data; Step S2, configuring the graph knowledge application, configuring the function search statement template of each knowledge application according to the type of the knowledge application, and constructing a wake-up word data table according to the type of the knowledge application; Step S3, according to the administrative approval knowledge graph and knowledge application configuration information, the user input statement is matched with the function search statement template to generate a graph database query statement.
2. The method for automatically generating query statements for a knowledge application graph database according to claim 1 is characterized in that: The step S1, obtaining knowledge data in administrative approval, and constructing an administrative approval knowledge graph based on the knowledge data, includes: Step S11, obtaining knowledge data in administrative approval, wherein the knowledge data includes entities, relationships and attributes involved in the administrative approval process; Step S12, enter the knowledge data into the neo4j graph database to generate an administrative approval knowledge graph.
3. The method for automatically generating query statements for a knowledge application graph database according to claim 1 or 2, characterized in that: The step S2, configuring the graph knowledge application, includes: Step S21, configure graph knowledge applications, which include five application types: knowledge cards, graph exploration, time sequence graph exploration, association analysis, and path discovery; Knowledge cards refer to a type of knowledge application that displays brief information about an entity in the form of an information box after identifying the query entity; Graph exploration refers to a type of knowledge application that, after identifying an entity, displays the entity's multi-layer association network in a graph visualization manner; Sequence graph exploration refers to a type of knowledge application that displays the changes or processes of the query subject in the form of dynamic sequence graphs after identifying the entity; Association analysis refers to a type of knowledge application that searches for associations between multiple nodes in a formed network relationship graph; Path discovery refers to a type of knowledge application that searches for the association between two nodes in a formed network relationship graph.
4. The method for automatically generating query statements for a knowledge application graph database according to claim 3 is characterized in that: The configuration of each function search statement template of the knowledge application includes: Step S22, when the knowledge application is a knowledge card, configure the corresponding knowledge card function search statement template: MATCH (n{`name`:'%s'}) RETURN n; Among them, "%s" is used to match entities, and n represents entities; Step S23, when the knowledge application is graph exploration, configure the graph exploration function search statement template: MATCH p = (n{`name`:'%s'})-[r]-(m)RETURNp; Among them, "%s" is used to match entities, n is the starting entity, m is the end entity, r represents the relationship between the starting entity m and the end entity, and the relationship graph p between entity n and entity m is returned in the form of a graph; Step S24, when the knowledge application is sequence diagram exploration, configure the sequence diagram exploration function retrieval statement template: MATCHp = (n{`name`:'%s'})-[r]-(m)WHERE r.`time`IS NOT NULLAND datetime(r.`time`)>=datetime('%s')AND NOT type(r)IN['%s']RETURNp; The first "%s" is used to match entities, the second "%s" is used to match the start time of the query relationship, and the time string format example is "2023-08-23T11:32:06Z". The third "%s" is used to match the relationship name not included in the returned results. n is the starting entity, m is the end entity, and r represents the relationship between the starting entity m and the end entity. The relationship graph p between entity n and entity m is returned in the form of a graph. If there is no relationship configuration, the retrieval statement template of the sequence diagram exploration function is: MATCH p = (n{`name`:'%s'})-[r]-(m) WHERE r.`time` IS NOT NULL AND datetime(r.`time`)>=datetime('%s') RETURN p; Step S25, when the knowledge application is association analysis, configure the association analysis function search statement template: MATCH(n0{`name`:'%s'}),(n1{`name`:'%s'}),(n2{`name`:'%s'})MATCH p=(n0)-[]-(n1)-[]-(n2)RETURNp; Among them, the three "%s" are used to match entities, and the relationship graph p between entity n1 and entity n2 is returned in the form of a graph; Step S26, when the knowledge application is path discovery, configure the path discovery function retrieval statement template: MATCH(n0{`name`:'%s'}),(n1{`name`:'%s'})MATCH p=(n0)-[]-(n1)RETURNp. Among them, the two "%s" are used to match entities, and the relationship graph between entity n0 and entity n1 is returned in the form of a graph.
5. The method for automatically generating query statements for a knowledge application graph database according to claim 1 is characterized in that: In step S2, according to the type of the knowledge application, a wake-up word library is constructed, including: Constructing a wake-up word data table, wherein the wake-up word data table includes a unique index of each wake-up word, the wake-up word, and a function type; Among them, the functional types of wake-up words are distinguished by numbers: 0 represents knowledge cards, 1 represents graph exploration, 2 represents time series graph exploration, 3 represents association analysis, and 4 represents path discovery.
6. The method for automatically generating query statements for a knowledge application graph database according to claim 5 is characterized in that: The step S3, according to the administrative approval knowledge graph and knowledge application configuration information, matches the user input statement with the function search statement template to generate a graph database query statement, including: Step S31, using Hanlp's NER method to perform part-of-speech analysis on the user input sentence to obtain a part-of-speech analysis result; Step S32, matching the part-of-speech analysis result with the wake-up word in the wake-up word data table to determine whether the wake-up word appears in the user input sentence; Step S33, if the wake-up word appears in the user input sentence and the wake-up word matches successfully, the function matching logic is executed; Step S34: if the wake-up word does not appear in the user input sentence and the wake-up word matching fails, the entity relationship matching logic is executed; Step S35, output the knowledge application graph database search statement.
7. The method for automatically generating query statements for a knowledge application graph database according to claim 6 is characterized in that: In step S33, if the wake-up word appears in the user input sentence and the wake-up word matches successfully, the function matching logic is executed, including: Step S331, according to the wake-up word matched in the user input sentence, obtain the function type corresponding to the wake-up word, wherein, if multiple wake-up words are matched, the function with the smaller sequence number is executed first according to the sequence number of the function types of the multiple wake-up words; S332. If the function is successfully matched, the search statement template of the corresponding function is called, and the search statement template is matched with the result of the part-of-speech type "NR" in the part-of-speech analysis result to generate a graph database search statement of the corresponding function; S333. If the function matching fails, the result "No data yet!" is directly output; Among them, when there are words with a part-of-speech type of "NR" in the part-of-speech analysis results, the function matching is successful; otherwise, the function matching fails.
8. The method for automatically generating query statements for a knowledge application graph database according to claim 6 is characterized in that: In step S34, if the wake-up word does not appear in the user input sentence and the wake-up word matching fails, the entity relationship matching logic is executed, including: Step S341, performing entity-relationship matching on the user input sentence to determine whether there are entities and relationships in the user input sentence; Step S342, if there are entities and relationships in the user input sentence, and the entity relationship matching is successful, then the entity relationship matching logic is executed; Step S343, if there is no entity or relationship in the user input sentence, the entity relationship matching fails, and the entity recognition logic is executed; Among them, by judging whether there are words with part-of-speech types of "NR" and "VV" in the part-of-speech analysis results, if there are words with part-of-speech types of "NR" and "VV", there are entities and relationships in the user input sentence; if there are no words with part-of-speech types of "NR" or "VV", there are no entities and relationships in the user input sentence.
9. The method for automatically generating query statements for a knowledge application graph database according to claim 8 is characterized in that: In step S342, if there are entities and relationships in the user input sentence and the entity-relationship matching is successful, the entity-relationship matching logic is executed, including: Step S3421, calling the entity relationship search statement template: MATCH({`name`:'%s'})-[r:`%s`]->(n)RETURN n, where the first "%s" is used to match the entity, and the second "%s" is used to match the relationship; Step S3422, matching the first "%s" in the entity relationship search statement template with the result of the part-of-speech analysis result whose part-of-speech type is "NR"; Step S3423, matching the second "%s" in the entity relationship search statement template with the result of the part-of-speech analysis result whose part-of-speech type is "VV"; S3424. Generate a graph database search statement corresponding to the entity relationship.
10. The method for automatically generating query statements for a knowledge application graph database according to claim 8, characterized in that: In step S343, if there is no entity or relationship in the user input sentence and the entity relationship matching fails, the entity recognition logic is executed, including: Step S3431, performing entity recognition on the user input sentence to determine whether there is an entity in the user input sentence; S3432. If an entity is identified, the entity search statement template (MATCH(n{`name`:'%s'}) RETURN n, where "%s" is used to match the entity) is called to generate a graph database search statement for the corresponding entity; S3433. If no entity is identified, the result "No data!" is directly output.
Citation Information
Cited By
Graph database index configuration method, apparatus and device, and readable storage medium
CN121597663A