Community search and query system and method based on knowledge graph

By using a knowledge graph-based community search query system, and leveraging community search optimization modules and semantic parsing technology, the problem of traditional search methods failing to understand user intent is solved, resulting in more accurate search results.

CN120950746APending Publication Date: 2025-11-14NAVAL UNIV OF ENG PLA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510852739.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Traditional search methods fail to deeply understand user query intent, resulting in inaccurate or low-relevance search results, especially in complex queries and ambiguous issues.

Method used

A knowledge graph-based community search query system is adopted. The system identifies natural language question elements through semantic parsing and template matching modules, performs community search using a community search optimization module, generates query statements, and executes the query in the knowledge graph. The matching accuracy is improved by combining community search threshold constraint method or maximum community metric constraint method.

Benefits of technology

It can deeply understand users' query intent, support more complex query needs, provide search results that better match users' intent, and improve the accuracy and relevance of search results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120950746A_ABST
    Figure CN120950746A_ABST
Patent Text Reader

Abstract

The invention discloses a community search query system and method based on a knowledge graph, and the method comprises the steps: receiving a natural language question inputted by a user, and recognizing the natural language question inputted by the user according to a preset element category in a network search engine knowledge graph to obtain a natural language question element, matching the natural language question element with a semantic template in a preset template library in a network search engine knowledge graph to obtain a natural language question element matching template; performing community search on the natural language question element matching template through a community search threshold constraint method or a maximum community measurement constraint method to obtain an optimal community subgraph of natural language question elements; generating a query statement according to the natural language question element matching template, and searching in the optimal community subgraph of the natural language question element according to the query statement to obtain an answer corresponding to the natural language question input by the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of knowledge graphs and semantic analysis, specifically to a community search and query system and method based on knowledge graphs. Background Technology

[0002] With the rapid development of internet technology, users' needs for information retrieval have evolved from simple keyword matching to a deeper understanding of query intent. Traditional search methods can no longer meet users' growing information demands; they expect search engines to more accurately understand their query intent and provide more relevant and accurate search results. Therefore, semantic query algorithms based on knowledge graphs have emerged, aiming to provide a more intelligent and personalized search experience by understanding users' query intent and context.

[0003] Traditional search methods include directory-based search and keyword search. Directory-based search organizes information according to certain categories or themes, forming a directory structure, which users can browse to find the information they need. While it provides a relatively systematic retrieval method for information in specific fields or topics, it requires prior information classification and organization, and may not be flexible enough for rapidly changing information or cross-field information retrieval. Keyword-based search is the most common and basic search method. Users enter one or more keywords, and the search engine searches for relevant information in its database based on these keywords, sorts it according to a certain ranking algorithm (such as PageRank), and then displays it to the user. However, this method cannot understand the user's true needs, and the results may be inaccurate or not highly relevant when dealing with complex queries and ambiguous problems.

[0004] A knowledge graph is a structured database used to store information about entities (such as people, places, and events) and their attributes and relationships. In a knowledge graph, entities are interconnected through relationships, forming a complex network structure that reveals the inherent connections between knowledge. Semantic analysis is a natural language processing technique used to extract meaningful information and relationships from text. In knowledge graph-based semantic queries, semantic analysis techniques are used to understand the user's query intent, context, and semantics, thereby more accurately matching information within the knowledge graph. Knowledge graphs provide rich entity and relationship information for semantic search, enabling search engines to understand the user's query intent more deeply. Simultaneously, semantic search techniques help computers extract meaningful entities and relationships from user queries, thus more accurately matching information within the knowledge graph. Therefore, combining the rich information of knowledge graphs with the deep understanding capabilities of semantic search can provide users with more accurate search results that better match their intent. Summary of the Invention

[0005] This invention provides both a knowledge graph-based community search and query system and a knowledge graph-based community search and query method. Both systems and methods are capable of deeply understanding the user's query intent. Through the rich entity and relationship information in the knowledge graph, not only can more complex semantic reasoning and query processing be performed to support more complex query needs, but the system can also more accurately grasp the user's query requirements and provide search results that better match the user's intent.

[0006] To achieve this objective, the present invention provides a knowledge graph-based community search and query system, characterized in that it comprises: The semantic parsing and template matching module is used to receive natural language questions input by users, identify natural language question elements based on the preset element categories in the knowledge graph of the web search engine, and match the natural language question elements with semantic templates in the preset template library in the knowledge graph of the web search engine to obtain natural language question element matching templates. The community search optimization module is used to perform community search on the matching template of natural language question elements by using the community search threshold constraint method or the maximum community metric constraint method to obtain the optimal community subgraph of natural language question elements; The query generation and execution module is used to generate query statements based on the matching template of natural language question elements, and to search the optimal community subgraph of natural language question elements according to the query statements to obtain the answer corresponding to the natural language question entered by the user.

[0007] Furthermore, the method for identifying natural language question elements from user input based on preset element categories in the knowledge graph of a web search engine includes: the element types of the knowledge graph include semantic concepts, semantic entities, semantic attributes, and semantic operators; when identifying elements in the natural language question, the natural language question is split into multiple words; the type of each word is classified according to the element types of the knowledge graph; and the classified word types are used as natural language question elements.

[0008] Furthermore, methods for breaking down natural language questions into multiple words include: search engine parsers automatically breaking down natural language questions into multiple words using the forward maximum matching method.

[0009] Furthermore, the method for matching natural language question elements with semantically structured templates in the preset template library of the web search engine knowledge graph to obtain natural language question element matching templates includes: calculating the number of each element type in the natural language question, determining candidate templates based on the number of each element type, and checking whether the natural language question elements form a subgraph based on the candidate templates. When it is determined that the natural language question elements form a subgraph based on the candidate templates, the natural language question elements are matched with the candidate templates.

[0010] Furthermore, the method for checking whether the elements of the natural language problem form a subgraph according to the candidate template includes: representing the elements in the natural language problem as nodes and edges in an undirected graph according to the candidate template; when the nodes and edges in the undirected graph formed by the elements in the natural language problem are related, it indicates that the elements of the natural language problem form a subgraph according to the candidate template, and the elements of the natural language problem match the candidate template.

[0011] Furthermore, the method of performing community search on the matching template of natural language question elements through the maximum community metric constraint to obtain the optimal community subgraph of natural language question elements includes: representing the elements in the knowledge graph and the associations between them as an undirected graph, where G(V, E) represents the undirected graph G, V represents the set of nodes in the undirected graph G, and E represents the set of edges in the undirected graph G. For any set of nodes H⊆V, the derived subgraph of any set of nodes H to G is represented as G[H], the set of nodes in G[H] is the corresponding set of nodes H, and the set of edges is (Ha×Hb)∩E, where Ha is the a-th node in the set of nodes H, Hb is the b-th node in the set of nodes H, deg_G(v) represents the degree of node v in the undirected graph G, and G[H] is a subgraph of the undirected graph G. There exist deg_(G[H])(v)≤deg_G(v), deg_(G[H]) (v) represents the degree of node v in the subgraph G[H]. d(G[H]) is taken as the minimum degree of the subgraph (G[H]). When d(G[H]) is maximized, the community search result is most accurate. For an undirected graph G(V,E), when node v_0∈V, node set H⊆V, node v_0∈H, G[H] is a connected subgraph, and d(G[H]) = min{deg_G (v)|v∈H}, d(G[H]) is maximized among all possible choices of H, and the community subgraph G[H] is the optimal community subgraph for the natural language problem elements.

[0012] Furthermore, the method of performing community search on the templates matched by natural language question elements using the community search threshold constraint method to obtain the optimal community corresponding to the natural language question elements includes: representing the elements in the knowledge graph and the associations between them as an undirected graph, where G(V,E) represents the undirected graph G, V represents the node set of the undirected graph G, and E represents the edge set of the undirected graph G. For any node set H1⊆V, the derived subgraph of any node set H1 with respect to G is represented as G[H1], the node set of G[H1] is the corresponding node set H1, and the edge set is (Hc×Hd)∩E, where Hc is the c-th node in the node set H1, and Hd is the d-th node in the node set H1. For a node v1 in the undirected graph G, let m(G,v1) represent its maximum possible minimum degree, and H(G,v1) represent any community in the undirected graph G with this minimum degree, where there exists 0 ≤ m(G,v1). ≤degG(v1), where degG(v1) is the degree of node v1 in the undirected graph G. For an undirected graph G(V,E), when node v1_0∈V, node set H1⊆V, v1_0∈H1, and G[H1] is a connected subgraph, and d(G[H1])≥k, k is the minimum node degree of the preset community subgraph G[H1], and the community subgraph G[H1] is the optimal community subgraph for natural language problem elements.

[0013] Furthermore, the method for generating query statements based on natural language question element matching templates includes: all templates in the template library predefine strategies for generating query statements, and the natural language question element matching templates automatically generate query statements based on these strategies.

[0014] Furthermore, the knowledge graph-based community search and query method of the knowledge graph-based community search and query system includes the following steps: The system receives natural language questions input by users, identifies natural language question elements based on preset element categories in the knowledge graph of the web search engine, and matches the natural language question elements with semantic templates in the preset template library within the knowledge graph of the web search engine to obtain natural language question element matching templates. By using the community search threshold constraint method or the maximum community metric constraint method, community search is performed on the matching template of natural language question elements to obtain the optimal community subgraph of natural language question elements. A query statement is generated based on the matching template of the natural language question elements. The answer corresponding to the natural language question entered by the user is obtained by searching the optimal community subgraph of the natural language question elements according to the query statement.

[0015] The beneficial effects of this invention are as follows: In knowledge graph-based semantic queries, this invention can deeply understand the user's query intent. Through the rich entity and relationship information in the knowledge graph, it can not only perform more complex semantic reasoning and query processing, thereby supporting more complex query needs, but also more accurately grasp the user's query needs and provide search results that better match the user's intent. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments disclosed in this invention, the accompanying drawings of the embodiments will be briefly described below. These drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention.

[0017] Figure 1 A semantic query flowchart provided for embodiments of the present invention; Figure 2 This is a schematic diagram of a network diagram provided in an embodiment of the present invention; Figure 3 This invention provides a local search solution to the CSK problem in an embodiment of the invention. Figure 4 This invention provides a local search solution to the CST problem in an embodiment of the invention. Figure 5 This is a structural schematic diagram provided for an embodiment of the present invention. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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 a part of the embodiments of the present invention, not all of them. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to represent selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0019] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments: Example 1 like Figure 5 As shown, a knowledge graph-based community search and query system includes: The semantic parsing and template matching module is used to receive natural language questions input by users, identify natural language question elements based on the preset element categories in the knowledge graph of the web search engine, and match the natural language question elements with semantic templates in the preset template library in the knowledge graph of the web search engine to obtain natural language question element matching templates. The community search optimization module is used to perform community search on the matching template of natural language question elements by using the community search threshold constraint method or the maximum community metric constraint method to obtain the optimal community subgraph of natural language question elements; The query generation and execution module is used to generate query statements based on the matching template of natural language question elements, and to search the optimal community subgraph of natural language question elements according to the query statements to obtain the answer corresponding to the natural language question entered by the user.

[0020] Natural language questions entered by users are open-ended inquiries or instructions that users make in everyday spoken or written language when using a search engine, and that require the computer to understand and process.

[0021] The knowledge graph of a web search engine pre-defined element categories include entities (such as people, places, events, and other objects related to reality), attributes (which are information describing the specific characteristics or properties of an entity, such as "capital" or "date of birth"), relationships (semantic bonds connecting multiple entities, such as "located in" or "born in"), and concepts (used to classify entities hierarchically, such as "country" or "scientist").

[0022] Figure 1 This is a semantic query flowchart provided in an embodiment of the present invention. The semantic query process includes: receiving a natural language question input by the user; identifying elements (concepts, entities, attributes, and various operators) in the knowledge graph based on the parser; matching the identified results with templates in the template library; if the match is successful, constructing a query statement based on the template definition; executing the query in the database; and returning the answer to the user. The knowledge graph-based parser uses elements in the knowledge graph as a dictionary, including concepts, entities, attributes, operators, etc. The parser operates in a "forward maximum matching" manner. The identified element types include concepts, entities, attributes, range operators, fuzzy operators, most operators, Boolean operators, and other elements. Therefore, the type of word is also determined during word segmentation. Various operators have the same meaning in different domains, such as "greater than", "less than", and "maximum". Users can also define domain-specific operators for attributes, for example, the operator "heavier than (greater than)" can be defined on the attribute "weight".

[0023] In some technical solutions, the method for identifying the natural language problem elements of the user input according to the preset element categories in the knowledge graph of the network search engine includes: the element types of the knowledge graph include the concept of word meaning, the entity of word meaning, the attribute of word meaning, and the operator of word meaning. When identifying the elements in the natural language problem, the natural language problem is split into multiple words, and the type of each word is classified according to the element types of the knowledge graph, and the classified word types are used as the natural language problem elements. By dividing the elements of the natural language problem, the redundant descriptions of the user for the natural language problem are removed, the structure of the natural language problem is simplified, which is conducive to the network search engine quickly and accurately searching for answers for the keyword fields of the natural language problem.

[0024] In some embodiments, taking "What is Einstein's date of birth?" as a natural language problem input by the user, the words in the natural language problem include "Einstein" and "date of birth". "Einstein" is a person who has existed in reality and belongs to the entity type. "Date of birth" is used to describe Einstein's personal information characteristics and belongs to the attribute type. That is, the elements in this natural language problem include one entity and one attribute.

[0025] In some technical solutions, the method for splitting a natural language problem into multiple words includes: the parser of the search engine automatically splits the natural language problem into multiple words by the forward maximum matching method.

[0026] The forward maximum matching method starts from the first character and scans the text in the order from left to right. Each time, it tries to match the longest word in the predefined vocabulary for segmentation. The forward maximum matching method can split the natural language problem into a relatively small number of words, which is convenient for template matching. In some embodiments, for the natural language problem "Einstein's date of birth", starting from the first character and searching for the longest matchable word in the predefined dictionary from left to right, the word sequence can be obtained: "Einstein", "of", "date of birth".

[0027] In some technical solutions, the method for matching the natural language problem elements with the semantic structured templates in the preset template library of the network search engine knowledge graph to obtain the matching templates of the natural language problem elements includes: calculating the quantity of each element type in the natural language problem, determining the candidate templates according to the quantity of each element type, and checking whether the natural language problem elements form a subgraph according to the candidate templates. When it is determined that the natural language problem elements form a subgraph according to the candidate templates, the natural language problem elements are matched with the candidate templates.

[0028] The preset template library is a predefined collection of structured text patterns used to quickly match or generate standardized content for specific scenarios. The templates in the library are structured text frames containing placeholders, including sentence patterns, etc., used to quickly generate standardized output by replacing variables. In some embodiments, for the natural language question "Einstein's birth date," the natural language question contains an entity and an attribute. The content of the template matching the natural language question also includes an entity and an attribute, with the content being "What is the 'attribute' of the 'entity'?", where "entity" and "attribute" are placeholders.

[0029] In some technical solutions, methods for checking whether natural language problem elements form a subgraph based on candidate templates include: representing the elements in the natural language problem as nodes and edges in an undirected graph based on the candidate template; when the nodes and edges in the undirected graph formed by the elements in the natural language problem are related, it indicates that the natural language problem elements have formed a subgraph based on the candidate template, and the natural language problem elements match the candidate template.

[0030] Figure 2 This is an example of an undirected graph. An undirected graph consists of nodes and edges. In the graph, letters a, b, c, d, e, etc. represent the nodes of the undirected graph, and the lines connecting the nodes are the edges of the undirected graph. Edges represent the connections between the nodes.

[0031] For the natural language problem "Einstein's birth date", in the undirected graph: the element "Einstein" is an entity node and "birth date" is an attribute node, and they are connected by edges (such as "of" to indicate the membership relationship between entity nodes and attribute nodes); when the node and edge associations in the undirected graph representation of the natural language problem are consistent with those in the candidate template (such as the predefined "'entity'-'attribute'" subgraph), it indicates that the natural language element and the template have been successfully matched.

[0032] In some technical solutions, the optimal community subgraph for natural language question elements is obtained by performing community search on the matching template using the maximum community metric constraint method. This method involves representing elements in a knowledge graph and their relationships as an undirected graph, where G(V, E) represents the undirected graph G, V represents the set of nodes in G, and E represents the set of edges in G. For any set of nodes H⊆V, the derived subgraph of any set of nodes H from G is represented as G[H]. The set of nodes in G[H] is the corresponding set of nodes H, and the set of edges is (Ha×Hb)∩E, where Ha is the a-th node in set H, Hb is the b-th node in set H, deg_G(v) represents the degree of node v in undirected graph G, and G[H] is a subgraph of undirected graph G. There exist deg_(G[H])(v)≤deg_G(v), deg_(G[H]) (v) represents the degree of node v in the subgraph G[H]. d(G[H]) is taken as the minimum degree of the subgraph G[H]. When d(G[H]) is maximized, the community search result is most accurate. For an undirected graph G(V, E), when node v_0∈V, node set H⊆V, node v_0∈H, G[H] is a connected subgraph, and d(G[H]) = min{deg_G(v)|v∈H}, d(G[H]) is maximized among all possible choices of H, and the community subgraph G[H] is the optimal community subgraph for the natural language question element. By maximizing the minimum degree d(G[H]) of the community subgraph, we ensure that the nodes in the retrieved connected community subgraph have strong correlations, thus obtaining the optimal community subgraph for the natural language question element.

[0033] In one embodiment, Figure 2 As an example of an undirected graph, Figure 2 The undirected graph shown is represented as G(V, E). The set V is {a, b, c, d, e, f, g, h, i, j, k, l, m, n}. All the connections between nodes a~m form the edge set E. Let a, b, c, d, e be a node set H. The derived subgraph of node set H from G is the subgraph composed of a, b, c, d, e and the edges of a, b, c, d, e. Ha×Hb is the edge between node a and node b.

[0034] The goal of the Constrained Community Metric (CSM) method is to find the optimal community for a given node. Its main challenge lies in the non-monotonicity of the community metric δ(•). Methods that solve this by brute-force enumeration have exponential time complexity. This system employs a more efficient bottom-up approach, the steps of which include: Step 1: Expand the search space starting from the query point v_0.

[0035] Step 2: Generate a candidate node set C in this query space.

[0036] Step 3: Find the final answer in the candidate node set using the maximum kernel algorithm.

[0037] Figure 4 A graph of local search solutions for the CSM problem, including: S1: When the system starts, input undirected graph data: vertex set V, edge set E, and initial node v_0.

[0038] S2: The system checks whether the input data satisfies the following conditions: in the undirected graph G(V,E), node v_0∈V, node set H⊆V, node v_0∈H, G[H] is a connected subgraph, and d(G[H]) = min{deg_G (v)|v∈H}. If yes, proceed to step S3; otherwise, return an error message and terminate the process.

[0039] S3: Call the spaceGeneration function to process the input data and generate a structured space S, which contains the neighborhood topology of node v_0.

[0040] S4: The candidateGeneration function filters nodes in space S that meet preset conditions to form a candidate set C.

[0041] S5: Perform a global search in the candidate set C using the maximum kernel algorithm. If a stable solution satisfying the community constraint is found, proceed to step S6; otherwise, return to step S3 to adjust the space parameters.

[0042] S6: Return the optimal community subgraph.

[0043] In some technical solutions, the method of performing community search on the templates matched by natural language question elements to obtain the optimal community corresponding to the natural language question elements through community search threshold constraint method includes: representing the elements in the knowledge graph and the associations between the elements as an undirected graph, where G(V,E) represents the undirected graph G, V represents the node set of the undirected graph G, and E represents the edge set of the undirected graph G. For any node set H1⊆V, the derived subgraph of any node set H1 with respect to G is represented as G[H1], the node set of G[H1] is the corresponding node set H1, and the edge set is (Hc×Hd)∩E, where Hc is the c-th node in the node set H1, and Hd is the d-th node in the node set H1. For a node v1 in the undirected graph G, let m(G,v1) represent its maximum possible minimum degree, and H(G,v1) represent any community in the undirected graph G with this minimum degree, where there exists 0 ≤ m(G,v1). ≤degG(v1), where degG(v1) is the degree of node v1 in the undirected graph G. For an undirected graph G(V, E), when node v1_0∈V, node set H1⊆V, v1_0∈H1, and G[H1] is a connected subgraph, and d(G[H1])≥k, k is the minimum node degree of the preset community subgraph G[H1]. The community subgraph G[H1] is the optimal community subgraph for natural language question elements. By setting a minimum degree threshold k and community subgraph connectivity constraints, the matching accuracy between natural language question elements and knowledge graph elements is improved, ensuring that the community nodes in the retrieved community subgraph have strong semantic connections, thereby locking in the optimal answer corresponding to the question element.

[0044] The community search threshold constraint method (CST(k)) consists of the following three steps: Step 1: The algorithm checks whether the current subgraph already satisfies the necessary conditions of CST(k).

[0045] Step 2: The algorithm executes `candidateGeneration()`. This involves exploring the neighbors of the current node set and generating a candidate answer set C, which may contain a solution to the problem. In most cases, step 2 has found a valid solution and the algorithm can terminate. If not, proceed to step 3.

[0046] Step 3: The algorithm uses a global search k-kernel method to find its derived subgraph and return the result.

[0047] Figure 3 The local search solution graph for the CST(k) problem includes: S1: The system initializes and inputs undirected graph data: vertex set V, edge set E, starting node v1_0, and minimum degree threshold k for the community. The value of k is preset as the minimum degree standard in community structure analysis; the specific value can be set according to the network size and application scenario.

[0048] S2: Use upperBound(G) as the upper bound of the degree distribution of graph G (preset as the maximum degree of the node or the threshold of k-kernel decomposition). If k > upperBound(G), execute step S6 to end the process; otherwise, execute step S3.

[0049] S3: During the candidate solution generation phase, execute C ← candidateGeneration(G, v1_0, k) to generate a set of candidate answers C containing v1_0 and with a minimum degree ≥ k.

[0050] S4: Determine if a feasible solution has been found. If the candidate answer set C satisfies the community constraint (for an undirected graph G(V, E), when the node v1_0∈V, the node set H1⊆V, v1_0∈H1, G[H1] is a connected subgraph, and d(G[H1])≥k), execute step S6 to end; otherwise, execute step S5.

[0051] S5: The k-core global search phase performs a global search in the k-core structure of the induced subgraph G(C) of the candidate answer set C.

[0052] S6: Return the optimal community subgraph.

[0053] Most existing methods directly study the mapping from questions to knowledge graphs. While this directly yields results, it struggles to provide targeted analysis for semantic problems. This approach improves semantic understanding performance through community search, which aims to find the optimal community to which a knowledge graph node belongs. Knowledge graphs are complex networks with community structures; that is, a network can be divided into several communities where nodes within a community are tightly connected, while nodes outside the community are sparsely connected. In real semantic networks, community structure is closely linked to node semantics; nodes within a community describe the relevant features of that node. Entity semantic computation based on semantic networks provides fundamental support for higher-level semantic computation. The goal of semantic understanding is to find the most likely community to which a given node belongs. The quality of a semantic community is evaluated by the cohesion of its internal nodes. A common measure of cohesion is minimum degree, which is the minimum degree of the derived subgraph of nodes within that community. A good semantic community is one with a large minimum degree.

[0054] A straightforward approach to community finding is considered to be global search. However, this method is not very efficient because determining the community structure of a given node requires searching the entire network, making global search extremely complex. Note that in the worst case, the entire network might be the optimal community. This occurs when the entire network constitutes a complete graph.

[0055] Both the CSM and CST problems can have multiple solutions. In fact, the CST problem can produce solutions of an exponential size with respect to the size of the undirected graph. Figure 2 Let's take the semantic network in the example. Suppose the query point is 'a'. In the CSM problem, H = {a,b,c,d,e} is the final optimal community because d(G[H]) = 3, while the minimum degree of other candidate communities is less than 3. In the CST(k) problem, when k=3, its solution is still H. If k = 2, the problem will have multiple solutions, including {a,b,d}, {a,d,e}, and {a,b,c,d,e}, etc.

[0056] In some technical solutions, methods for generating query statements based on natural language question element matching templates include: templates in a template library pre-define query statement generation strategies, and the natural language question element matching template automatically generates query statements according to these strategies. By using pre-defined templates and automated query generation strategies, the efficiency of query statement output is improved, and the time it takes for users to obtain results for natural language questions is shortened.

[0057] Once the template is determined, the next step is to generate query statements on the underlying storage. The method for generating query statements is determined by the template, and each template defines its own strategy for generating query statements. For example, for the template "entity + attribute", the query target is the attribute table, and the fields "entity_id" and "attr_id" are the results identified by the preceding parser. Therefore, the final query language generated is "select attr_value from attribute where entity_id =EID and attr_id = AID". The correspondence between query language generation strategies and templates is shown in Table 1.

[0058] Table 1. Correspondence between query language generation strategies and templates In some embodiments, for the natural language question "What is Einstein's date of birth?", the natural language question contains an entity and an attribute. The content of the template matching the natural language question also includes an entity and an attribute. The templates in the template library all predefine a strategy for generating query statements. The strategy is to replace the "entity" placeholder in the template content "What is the 'attribute' of 'entity'?" with Einstein, and replace the "attribute" placeholder with the date of birth. Based on the generated query statement "What is the 'date of birth' of 'Einstein'?", the query is performed in the optimal community subgraph and the specific date of Einstein's birth is returned as the answer to the natural language question.

[0059] Example 2 According to the knowledge graph-based community search and query system, a knowledge graph-based community search and query method includes the following steps: The system receives natural language questions input by users, identifies natural language question elements based on preset element categories in the knowledge graph of the web search engine, and matches the natural language question elements with semantic templates in the preset template library within the knowledge graph of the web search engine to obtain natural language question element matching templates. By using the community search threshold constraint method or the maximum community metric constraint method, community search is performed on the matching template of natural language question elements to obtain the optimal community subgraph of natural language question elements. A query statement is generated based on the matching template of the natural language question elements. The answer corresponding to the natural language question entered by the user is obtained by searching the optimal community subgraph of the natural language question elements according to the query statement.

[0060] Example 3 The present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, is described as described in Embodiment 2.

[0061] This invention can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented in whole or in part as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0062] It will be readily understood by those skilled in the art that the above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, combinations, substitutions, improvements, etc., made under the spirit and principles of the present invention are included within the protection scope of the present invention.

Claims

1. A community search and query system based on knowledge graphs, characterized in that, It includes: The semantic parsing and template matching module is used to receive natural language questions input by users, identify natural language question elements based on the preset element categories in the knowledge graph of the web search engine, and match the natural language question elements with semantic templates in the preset template library in the knowledge graph of the web search engine to obtain natural language question element matching templates. The community search optimization module is used to perform community search on the matching template of natural language question elements by using the community search threshold constraint method or the maximum community metric constraint method to obtain the optimal community subgraph of natural language question elements; The query generation and execution module is used to generate query statements based on the matching template of natural language question elements, and to search the optimal community subgraph of natural language question elements according to the query statements to obtain the answer corresponding to the natural language question entered by the user.

2. The knowledge graph-based community search and query system according to claim 1, characterized in that, The method for identifying natural language question elements based on preset element categories in the knowledge graph of a web search engine includes: the element types of the knowledge graph include semantic concepts, semantic entities, semantic attributes, and semantic operators. When identifying elements in a natural language question, the natural language question is split into multiple words, and the type of each word is classified according to the element types of the knowledge graph. The classified word types are used as natural language question elements.

3. The knowledge graph-based community search and query system according to claim 2, characterized in that, Methods for breaking down natural language questions into multiple words include: search engine parsers automatically breaking down natural language questions into multiple words using the forward maximum matching method.

4. The knowledge graph-based community search and query system according to claim 1, characterized in that, The method for matching natural language question elements with semantically structured templates in the pre-set template library of the knowledge graph of the web search engine to obtain natural language question element matching templates includes: calculating the number of each element type in the natural language question, determining candidate templates based on the number of each element type, and checking whether the natural language question elements form a subgraph based on the candidate templates. When it is determined that the natural language question elements form a subgraph based on the candidate templates, the natural language question elements are matched with the candidate templates.

5. A community search and query system based on knowledge graphs according to claim 4, characterized in that, The method for checking whether natural language problem elements form a subgraph based on candidate templates includes: representing the elements in the natural language problem as nodes and edges in an undirected graph based on the candidate templates; when the nodes and edges in the undirected graph formed by the elements in the natural language problem are related, it indicates that the natural language problem elements form a subgraph based on the candidate templates, and the natural language problem elements match the candidate templates.

6. The knowledge graph-based community search and query system according to claim 1, characterized in that, The method of performing community search on the matching template of natural language question elements using the maximum community metric constraint to obtain the optimal community subgraph of natural language question elements includes: representing the elements in the knowledge graph and the associations between them as an undirected graph, where G(V, E) represents the undirected graph G, V represents the set of nodes in the undirected graph G, and E represents the set of edges in the undirected graph G. For any set of nodes H⊆V, the derived subgraph of any set of nodes H to G is represented as G[H], where the set of nodes in G[H] is the corresponding set of nodes H, and the set of edges is (Ha×Hb)∩E, where Ha is the a-th node in the set of nodes H, Hb is the b-th node in the set of nodes H, deg_G(v) represents the degree of node v in the undirected graph G, and G[H] is a subgraph of the undirected graph G, and there exists deg_(G[H])(v)≤deg_G (v), deg_(G[H])(v) represents the degree of node v in subgraph G[H]. d(G[H]) is taken as the minimum degree of subgraph (G[H]). When d(G[H]) is maximized, the community search result is most accurate. For an undirected graph G(V,E), when node v_0∈V, node set H⊆V, node v_0∈H, G[H] is a connected subgraph, and d(G[H]) = min{deg_G (v)|v∈H}, d(G[H]) is maximized among all possible choices of H, and the community subgraph G[H] is the optimal community subgraph for the natural language problem elements.

7. A community search and query system based on knowledge graphs according to claim 1, characterized in that, The method of performing community search on the templates matching natural language question elements using the community search threshold constraint method to obtain the optimal community corresponding to the natural language question elements includes: representing the elements in the knowledge graph and the associations between them as an undirected graph, where G(V,E) represents the undirected graph G, V represents the set of nodes in the undirected graph G, and E represents the set of edges in the undirected graph G. For any set of nodes H1⊆V, the derived subgraph of any set of nodes H1 with respect to G is represented as G[H1], the set of nodes in G[H1] is the corresponding set of nodes H1, and the set of edges is (Hc×Hd)∩E, where Hc is the c-th node in the set of nodes H1, and Hd is the d-th node in the set of nodes H1. For a node v1 in the undirected graph G, let m(G,v1) represent its maximum possible minimum degree, and H(G,v1) represent any community in the undirected graph G with this minimum degree, where there exists 0 ≤ m(G,v1). ≤degG(v1), where degG(v1) is the degree of node v1 in the undirected graph G. For an undirected graph G(V,E), when node v1_0∈V, node set H1⊆V, v1_0∈H1, and G[H1] is a connected subgraph, and d(G[H1])≥k, k is the minimum node degree of the preset community subgraph G[H1], and the community subgraph G[H1] is the optimal community subgraph for natural language problem elements.

8. A community search and query system based on knowledge graphs according to claim 1, characterized in that, The method for generating query statements based on natural language question element matching templates includes: the templates in the template library all predefine strategies for generating query statements, and the natural language question element matching templates automatically generate query statements according to the strategies for generating query statements.

9. The community search and query method based on knowledge graphs according to claim 1, characterized in that, It includes the following steps: The system receives natural language questions input by users, identifies natural language question elements based on preset element categories in the knowledge graph of the web search engine, and matches the natural language question elements with semantic templates in the preset template library within the knowledge graph of the web search engine to obtain natural language question element matching templates. By using the community search threshold constraint method or the maximum community metric constraint method, community search is performed on the matching template of natural language question elements to obtain the optimal community subgraph of natural language question elements. A query statement is generated based on the matching template of the natural language question elements. The answer corresponding to the natural language question entered by the user is obtained by searching the optimal community subgraph of the natural language question elements according to the query statement.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method of claim 9.