Key information query method for military equipment knowledge graph
By using the entity linking and sorting methods of the longest common substring matching and the longest prefix matching in the military equipment knowledge graph, combined with the query method of template matching, the efficiency and accuracy of querying natural language problems in the military equipment field is solved, and efficient query of key information of military equipment is achieved.
Patent Information
- Application Number
- CN202210068070.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-20
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2042-01-20
AI Technical Summary
In the field of military equipment, natural language problems are limited in form, lack of open source of knowledge, and it is difficult to conduct large-scale training with deep learning methods, resulting in inaccuracy and inefficiency of answers.
The entity linking method based on the longest common substring matching and the longest prefix matching sorting method, combined with the key information query method of template matching, entities, relationships and attributes are directly extracted from natural language query statements to form a graph query statement to realize the key information query of military equipment.
Without the need for data sets and algorithm training, four typical query statements of military equipment can be effectively answered, improving query efficiency and accuracy.
Smart Images

Figure CN114357143B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of key information query of knowledge graphs, and in particular to a key information query method for military equipment knowledge graphs. Background Art
[0002] The core of the knowledge graph question answering task (KGQA) is to map natural language questions into graph database query statements. The methods to solve this problem can be divided into two categories: methods based on semantic parsing and methods based on information retrieval.
[0003] In open question answering of general knowledge graphs, the semantic parsing method and information retrieval method using deep neural networks can achieve good results.
[0004] Compared with open-domain question answering, the question forms in the military equipment field are limited, lack a large number of open knowledge sources, have high requirements for the accuracy of the answers, and are difficult to train on a large scale using deep learning methods. Summary of the invention
[0005] According to an embodiment of the present invention, a key information query method for a military equipment knowledge graph is provided, comprising the following steps:
[0006] Obtain a natural language query statement, and based on the longest common substring matching, perform entity linking between the entities involved in the natural language query statement and the existing entities in the military equipment knowledge graph to obtain multiple entity linking results;
[0007] Based on the longest prefix match, multiple entity link results are sorted and the best entity link result is selected;
[0008] Create a query template library based on the feature types in the natural language query statement;
[0009] Based on template matching, the elements in the natural language query statement are matched with the query template library, and the corresponding elements in the natural language query statement are filled into the corresponding graph query statement template in the query template library to form a complete graph query statement. After the graph query, the query result is obtained.
[0010] Further, the specific steps of entity linking are as follows:
[0011] Traverse all vocabulary sets of the natural language query sentence after word segmentation processing to obtain the character string of each vocabulary set;
[0012] Traverse all entity sets in the military equipment knowledge graph and obtain the string of each entity set;
[0013] Create an entity link result dictionary, calculate the length of the longest common substring of the string of each vocabulary set and the string of each entity set, and obtain the lengths of multiple longest common substrings;
[0014] Create multiple string dictionaries, and store the key-value pairs formed by the length of each longest common substring and the corresponding string of each entity set in the multiple string dictionaries;
[0015] Arrange multiple string dictionaries in descending order according to the length of their common substrings;
[0016] Traverse multiple string dictionaries, and if the length of the longest common substring in the multiple string dictionaries is greater than two, store the key-value pairs formed by the strings of the first three entity sets with the longest common substring length in the multiple string dictionaries and the strings of each vocabulary set into the entity link result dictionary;
[0017] Returns a dictionary of entity linking results.
[0018] Further, the specific steps for sorting are as follows:
[0019] Traverse each string of the first three entity sets with the longest common substring length in multiple string dictionaries,
[0020] Create a dictionary of the longest common prefix results. For each string, set I = 0, 1, 2, ..., len(x), where len(x) is the string length of a word in the natural language query statement, and traverse each element i in I;
[0021] If i> the length of each string of the first three entity sets, or x[i]≠y[i], where x[i] represents the i-th element of a string set of a vocabulary in the natural language query statement, and y[i] represents the i-th element of the string set of the first three entity sets, then store the key-value pair formed by each element i and each string into the dictionary of the longest common prefix result;
[0022] Calculate the optimal entity linking result from the dictionary of the longest common prefix results;
[0023] Returns the best entity linking result.
[0024] Furthermore, element types include: entity words, relationship words, and attribute words.
[0025] Further, the specific steps for matching are as follows:
[0026] Extract all entity words, relation words, and attribute words in natural language query statements, and apply the query template library to judge the entity words, relation words, and attribute words:
[0027] If the natural language query contains only one entity word, it is a simple entity query;
[0028] If the natural language query contains only one entity word and attribute word, it is an entity attribute query;
[0029] If the natural language query contains only one entity word and a relation word, it is an entity relation query;
[0030] If the natural language query statement contains only two entity words and a relation word, it is an entity statistics query.
[0031] According to the key information query method for the military equipment knowledge graph according to the embodiment of the present invention, through the entity linking method based on the longest common substring matching, the entity linking result sorting method based on the longest prefix, and the key information query method based on template matching, it is possible to answer four typical query statements for military equipment without the need for data sets and algorithm training.
[0032] It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the technology as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The present invention is a flowchart of a key information query method for a military equipment knowledge graph according to an embodiment of the present invention.
[0034] Figure 2 The present invention is a flowchart of query module matching of a key information query method for a military equipment knowledge graph according to an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings to further illustrate the present invention.
[0036] First, combine Figure 1 A key information query method for a military equipment knowledge graph according to an embodiment of the present invention is described, which is used to answer four typical query statements for military equipment and has a wide range of application scenarios.
[0037] like Figure 1 As shown, the key information query method for the military equipment knowledge graph according to the embodiment of the present invention has the following steps:
[0038] In S1, Figure 1 As shown, a natural language query statement is obtained, and based on the longest common substring matching, entity links are performed between the entities involved in the natural language query statement and the existing entities in the military equipment knowledge graph to obtain multiple entity link results.
[0039] Defining a Collection is the set of all words after the natural language query is segmented. is the set of all entities in the military equipment knowledge graph, string gather A word in the string gather A word in .
[0040] The longest common substring match is to solve a string , so that ,and The maximum length of ,in:
[0041]
[0042]
[0043] Defining a two-dimensional array , Represented in string and string In and The longest common substring ending with Length.
[0044] The following recursive formula can be constructed:
[0045]
[0046] initialization
[0047] Apply the recursive formula to iterate from bottom to top , and finally get the longest common substring and its length .
[0048] Further, the specific steps of entity linking are as follows:
[0049] Traverse all vocabulary sets of the natural language query sentence after word segmentation processing to obtain the character string of each vocabulary set;
[0050] Traverse all entity sets in the military equipment knowledge graph and obtain the string of each entity set;
[0051] Create an entity link result dictionary, calculate the length of the longest common substring of the string of each vocabulary set and the string of each entity set, and obtain the lengths of multiple longest common substrings;
[0052] Create multiple string dictionaries, and store the key-value pairs formed by the length of each longest common substring and the corresponding string of each entity set in the multiple string dictionaries;
[0053] Arrange multiple string dictionaries in descending order according to the length of their common substrings;
[0054] Traverse multiple string dictionaries, and if the length of the longest common substring in the multiple string dictionaries is greater than two, store the key-value pairs formed by the strings of the first three entity sets with the longest common substring length in the multiple string dictionaries and the strings of each vocabulary set into the entity link result dictionary;
[0055] Returns a dictionary of entity linking results.
[0056] In S2, if Figure 1 As shown, based on the longest prefix match, multiple entity link results are sorted and the best entity link result is selected.
[0057] Further, the specific steps for sorting are as follows:
[0058] Traverse each string of the first three entity sets with the longest common substring length in multiple string dictionaries,
[0059] Create a dictionary of the longest common prefix results. For each string, set I = 0, 1, 2, ..., len(x), where len(x) is the string length of a word in the natural language query statement, and traverse each element i in I;
[0060] If i>the length of each string of the first three entity sets, or x[i]≠y[i], where x[i] represents the i-th element of a string set of a vocabulary in the natural language query statement, and y[i] represents the i-th element of the string set of the first three entity sets, then store the key-value pair formed by each element i and each string into the dictionary of the longest common prefix result;
[0061] Calculate the optimal entity linking result from the dictionary of the longest common prefix results;
[0062] Returns the best entity linking result.
[0063] In S3, such as Figure 1 As shown, a query template library is created according to the element types in the natural language query sentence. In this embodiment, the element types include: entity words, relationship words, and attribute words.
[0064] In S4, Figure 1As shown, based on template matching, the elements in the natural language query statement are matched with the query template library, and the corresponding elements in the natural language query statement are filled into the corresponding graph query statement template in the query template library to form a complete graph query statement. After the graph query, the query result is obtained.
[0065] The query template library is shown in the following table:
[0066] Serial number Query Type Natural language query elements Graph query statement template Natural language query example Graph query statement example 1 Simple entity query <e> < / e> match(T) whereT.name=E return T SH-60 match(w) where w.name="SH-60 anti-submarine helicopter"return w 2 Entity attribute query <e> < / e> match(T) whereT.name=E return TP What is the maximum weight of the SH-60? match(T:`table`) where T.name="SH-60 anti-submarine helicopter" return distinct T.WeightMax 3 Entity relationship query <e> <r> < / r> < / e> match(T)-[r:R]-(s)where T.name=Ereturn s.name What aircraft can the Kuznetsov take off and land? match(T:`table`)-[r:takeoff and landing]-(s) where T.name="Kuznetsov aircraft carrier" return distincts.name 4 Entity Statistics Query <e1> <e2> <r> < / r> < / e2> < / e1> match p=(T1)-[r:R]->(T2) where T1.name=E1 and T2.name=E2 return count(T1) How many SH-60 takeoffs and landings can Kuznetsov support? match p=(T1:`table1`)-[r:R]->(T2:`table2`)where T1.name="Kuznetsov aircraft carrier" andT2.name="SH-60 anti-submarine helicopter" return count(p)
[0067] Further, the specific steps for matching are as follows:
[0068] Extract all entity words, relation words, and attribute words in natural language query statements, and apply the query template library to judge the entity words, relation words, and attribute words.
[0069] If the natural language query statement contains only one entity word, it is a simple entity query. The entity word is substituted into the corresponding graph query statement template to generate a complete graph query statement. After the graph query, the entity name and attribute information can be returned.
[0070] If the natural language query statement contains only one entity word and one attribute word, it is an entity attribute query. The entity word and attribute word are substituted into the corresponding graph query statement template to generate a complete graph query statement. After the graph query, the attribute value information of the entity can be returned.
[0071] If the natural language query statement contains only one entity word and a relationship word, it is an entity relationship query. The entity word and relationship word are substituted into the corresponding graph query statement template to generate a complete graph query statement. After the graph query, other entity information related to the entity can be returned.
[0072] If the natural language query statement contains only two entity words and a relationship word, it is an entity statistical query. The entity words and relationship words are substituted into the corresponding graph query statement template to generate a complete graph query statement. After the graph query, the number of objects that satisfy the relationship can be returned.
[0073] If none of the above conditions are met, the query fails.
[0074] The following is a detailed description using entity attribute query as an example.
[0075] Taking entity attribute query as an example, when the user inputs the natural language query sentence "What is the maximum weight of SH-60", it can be identified that the sentence contains one entity: "SH-60 anti-submarine helicopter" and one attribute: "maximum weight". Based on this, the natural language query elements can be judged as: <e> , the template of the graph query statement to be used is: match(T) where T.name=E return T.P. Substitute the recognized entity names and attribute names into the query template, and the query statement obtained is: match(T:`table`) where T.name="SH-60 Anti-submarine Helicopter" return distinct T.WeightMax.
[0076] The key information query process for the military equipment knowledge graph is as follows.
[0077] In the search box, enter the natural language query statement. For example: "What is the maximum weight of SH-60?".
[0078] Apply the word segmentation tool to segment the natural language query statement. The word segmentation result is: ["SH-60", "的", "最大重量", "是", "多少"]. Remove the stop words and only keep the nouns. The result is: ["SH-60", "最大重量", "多少"].
[0079] Entity linking. Apply the entity linking method based on the longest common substring matching to link each noun recognized in the previous step with the existing entities in the graph one by one. The result is: the entity linked to "SH-60" is [SH-60 Anti-submarine Helicopter, SH-60 Helix A], and neither "最大重量" (Maximum Weight) nor "多少" (How much) is linked to an entity.
[0080] Sort the entity linking results. Apply the entity linking result sorting method based on the longest prefix to sort the entities in the list, and select the entity ranked first in the sorting result as the correct linked entity. The sorting result is: [SH-60 Anti-submarine Helicopter, SH-60 Helix A], and the correct linked entity is: SH-60 Anti-submarine Helicopter.
[0081] Attribute name and relationship name recognition. Apply the pre-trained bert model to calculate the similarity between each of the other unlinked words in the entity linking and the attribute table and relationship table in the graph one by one, and select the attribute or relationship with the maximum similarity. The result is: the similarity between "最大重量" (Maximum Weight) and the attribute table is 0.996, the similarity between "多少" (How much) and the attribute table is 0.235, the similarity between "最大重量" (Maximum Weight) and the relationship table is 0.168, and the similarity between "多少" (How much) and the relationship table is 0.356. It shows that "最大重量" (Maximum Weight) is an attribute, and "多少" (How much) is neither an attribute nor a relationship.
[0082] Query template matching. Match the entity words, relationship words, and attribute words identified in the above steps with the natural language query elements in the query template library. If the corresponding template can be matched, fill the entity name, relationship name, and attribute name into the graph query statement template to form a complete graph query statement. For example, in the above steps, only one entity and one attribute are identified, and the natural language query element is <e>< / e> , corresponding to template 2 entity attribute query, fill the entity "SH-60 anti-submarine helicopter" and the attribute "maximum weight" into the graph query statement template, and the complete query statement is match(T:`table`)where T.name=” SH-60 anti-submarine helicopter” return distinct T.WeightMax.
[0083] Output graph query results. Apply the complete graph query statement, query the results, and display them.
[0084] Above, refer to Figure 1~2 A key information query method for a military equipment knowledge graph according to an embodiment of the present invention is described. Through an entity linking method based on the longest common substring matching, an entity linking result sorting method based on the longest prefix, and a key information query method based on template matching, it is possible to answer four typical query statements for military equipment without the need for data sets and algorithm training.
[0085] It should be noted that, in this specification, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprises..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0086] Although the content of the present invention has been described in detail through the above preferred embodiments, it should be appreciated that the above description should not be considered as a limitation of the present invention. After reading the above content, it will be apparent to those skilled in the art that various modifications and substitutions of the present invention will occur. Therefore, the protection scope of the present invention should be limited by the appended claims. < / e>
Claims
1. A key information query method for military equipment knowledge graph, characterized in that: The following steps are included: Obtain a natural language query statement, and based on the longest common substring matching, perform entity linking on the entities involved in the natural language query statement and the existing entities in the military equipment knowledge graph to obtain multiple entity linking results; Based on the longest prefix match, the multiple entity link results are sorted to select the best entity link result; Creating a query template library according to the element type in the natural language query statement; Based on template matching, the elements in the natural language query statement are matched with the query template library, and the corresponding elements in the natural language query statement are filled into the corresponding graph query statement template in the query template library to form a complete graph query statement. After graph query, the query result is obtained; The specific steps of entity linking are as follows: Traversing all vocabulary sets of the natural language query sentence after word segmentation processing to obtain a character string of each vocabulary set; Traversing all entity sets in the military equipment knowledge graph to obtain a character string for each entity set; Creating the entity linking result dictionary, calculating the length of the longest common substring of each string of the vocabulary set and each string of the entity set, and obtaining the lengths of multiple longest common substrings; Creating a plurality of string dictionaries, and storing a key-value pair formed by the length of each of the longest common substrings and the corresponding string of each of the entity sets in the plurality of string dictionaries; Arrange the multiple string dictionaries in descending order according to the length of the common substrings; Traversing the multiple string dictionaries, if the length of the longest common substring in the multiple string dictionaries is greater than two, storing the key-value pairs formed by the first three strings of the entity sets with the longest common substring length in the multiple string dictionaries and the strings of each vocabulary set into the entity linking result dictionary; Return the entity link result dictionary; The specific steps of matching are as follows: Extract all entity words, relation words, and attribute words in the natural language query sentence, and apply the query template library to judge the entity words, relation words, and attribute words: If the natural language query sentence contains only one entity word, it is a simple entity query; If the natural language query sentence contains only one entity word and one attribute word, it is an entity attribute query; If the natural language query sentence contains only one entity word and a relation word, it is an entity relation query; If the natural language query statement contains only two entity words and a relation word, it is an entity statistical query.
2. The key information query method for military equipment knowledge graph according to claim 1 is characterized in that: The specific steps of sorting are as follows: Traverse each string of the first three entity sets with the longest common substring length in the multiple string dictionaries, Create a dictionary of the longest common prefix results. For each string, set I = 0, 1, 2, ..., len(x), where len(x) is the string length of a word in the natural language query statement, and traverse each element i in I; If i>the length of each string of the first three entity sets, or x[i]≠y[i], where x[i] represents the i-th element of a string set of a vocabulary in the natural language query statement, and y[i] represents the i-th element of the string set of the first three entity sets, then the key-value pairs formed by each element i and each string are stored in the dictionary of the longest common prefix result; Calculate the optimal entity link result from the dictionary of the longest common prefix results; Return the optimal entity link result.
3. The key information query method for military equipment knowledge graph according to claim 1 is characterized in that: The element types include: entity words, relationship words, and attribute words.
Citation Information
Patent Citations
Mapping knowledge domain questioning and answering system and method based on template matching technique
CN105868313A
Question answering system construction method and system based on military domain knowledge graph
CN113806513A
