Knowledge base query method and system combining semantic understanding and question template
By combining semantic understanding models and question templates, a sentence template library and domain dictionary are constructed, solving the query problem that is difficult for non-technical personnel to parse complex questions, and achieving high efficiency and accuracy in natural language queries.
Patent Information
- Application Number
- CN202210475088.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-04-29
AI Technical Summary
Existing technologies struggle to efficiently retrieve domain knowledge bases using standardized query languages. Non-technical personnel cannot accurately analyze complex or specialized questions, and the structures of knowledge bases vary greatly across different industries, resulting in weak domain adaptability for semantic understanding models.
By combining semantic understanding models and question templates, a sentence template library and a domain dictionary are constructed. Question parsing templates are generated through dependency relationship analysis, and template matching is performed to generate query statements.
It enables non-technical personnel to query the knowledge base using natural language, improving the freedom and convenience of queries and enhancing the adaptability and accuracy for complex problems.
Smart Images

Figure CN115374258B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing and query, in particular to a knowledge base query method and system combining semantic understanding and question templates. BACKGROUND
[0002] With the rapid development of big data related technologies, various industries have accumulated rich data resources, which contain a large amount of domain knowledge. After processing and storing these knowledge, domain knowledge bases are formed, which can meet the knowledge needs of domain-related businesses. However, due to the complexity of the structure of the domain knowledge base and the diversity of the content, non-technical personnel cannot retrieve the knowledge content in the knowledge base through standardized query languages. Therefore, a knowledge base query method that can analyze and understand natural language will effectively improve the efficiency and convenience of the query.
[0003] The key to obtaining the semantic of the natural language form of the question through the semantic understanding model is to parse the question components and the dependency relationship between the question components. The semantic dependency technology divides the question into phrase combinations through the syntax tree and represents the context relationship between the phrases, thereby realizing the understanding of the semantic of the sentence. The semantic understanding model has the characteristics of intelligence and universality, and has stronger generalization ability for more general questions. However, it has the disadvantage of weak parsing ability for professional problems or complex problems in the domain. The sentence pattern template and the domain dictionary have stronger domain adaptability, but the construction process requires a large amount of human and time resources.
[0004] Since domain problems usually have high complexity and professionalism, it is difficult for the sentence pattern template library to completely cover and accurately represent the sample space of actual problems. Moreover, due to the differences in content and structure of knowledge bases in different industries, it is difficult to construct a model for parsing the question through a domain-universal semantic understanding model. The query intention of the natural language question mainly reflects in the semantic content and the semantic structure, and it is difficult to accurately match the query intention with the sentence pattern templates in the sentence pattern template library. SUMMARY
[0005] The present application aims to provide a knowledge base query method combining semantic understanding and question templates, which can realize the function of non-technical personnel querying the knowledge base through natural language, and improve the freedom and convenience of the query.
[0006] According to the first aspect of the present application, a knowledge base query method combining semantic understanding and question templates is provided, which includes the following steps:
[0007] Step 1, constructing a sentence pattern template library based on preset sentence pattern template categories and sentence pattern template elements, wherein the sentence pattern template categories represent the purpose attributes of the question query, and the sentence pattern template elements are semantic blocks, which represent different question components and their roles in the question;
[0008] Step 2, constructing a domain dictionary based on domain corpus, and the keywords stored in the domain dictionary are set to be labeled according to the sentence pattern template elements, marking the sentence pattern template elements corresponding to the keywords;
[0009] Step 3, performing word segmentation processing on the input question, and marking the sentence pattern element type of the word segmentation result in combination with the domain dictionary;
[0010] Step 4, performing dependency relationship analysis on the word segmentation result marked with the sentence pattern element type, determining the dependency relationship between the multiple semantic blocks, and recombining and sorting the semantic blocks according to the dependency relationship to generate a question analysis template;
[0011] Step 5, matching the question analysis template in the sentence pattern template library constructed in step 1 to obtain the matched final target sentence pattern template;
[0012] Step 6, filling the phrases contained in each semantic block in the question analysis template corresponding to step 4 into the query sentence corresponding to the target sentence pattern template of step 5 to generate a complete query sentence; and
[0013] Step 7, querying the knowledge base according to the query sentence generated in step 6 to return an answer.
[0014] In optional embodiments, the sentence pattern templates are set to be divided into query entities, query entity attributes, and query entity relationships according to the query purpose, respectively denoted as a first template I: query entity; a second template II: query entity attribute; and a third template III: query query entity relationship.
[0015] In optional embodiments, the semantic blocks in the sentence pattern elements include the following types:
[0016] 1) subject semantic block, which defines the phrases of entities, entity attributes, and entity relationships in the sentence;
[0017] 2) question semantic block, which defines the question words or question phrases in the sentence;
[0018] 3) restriction semantic block, which defines the restrictive words or phrases in the sentence;
[0019] 4) auxiliary semantic block, which defines the mood auxiliary words in the sentence.
[0020] In the optional embodiment, in the step 1, under each sentence pattern template category, different semantic blocks of the sentence pattern template elements are combined to generate the sentence pattern templates under different sentence pattern template categories, and a sentence pattern template library of all sentence pattern template categories is constructed;
[0021] Each sentence pattern template is expressed as follows:
[0022] < Sentence pattern template > := (subject semantic block, [restriction semantic block], [question semantic block], [auxiliary semantic block]).
[0023] In the optional embodiment, in the process of constructing the domain dictionary, the following processing is included:
[0024] The domain-related corpus is subjected to word segmentation processing, and keywords are extracted, and each keyword is labeled with the sentence pattern template element type in combination with the sentence pattern template element type;
[0025] For the keywords labeled with the subject semantic block, the type of the entity, the entity attribute or the entity relationship is further labeled.
[0026] In the optional embodiment, the word segmentation processing is performed on the input question, and the sentence pattern template element type to which the word segmentation result belongs is labeled in combination with the domain dictionary, including:
[0027] The word segmentation is optimized by using the domain dictionary in combination with the reverse maximum matching algorithm, the grammar analysis result is obtained by re-splicing through the domain dictionary, and the sentence pattern template element type to which the word segmentation result belongs is labeled.
[0028] In the optional embodiment, the step 5, the question analysis template is matched in the sentence pattern template library constructed in the step 1 to obtain the final target sentence pattern template, including:
[0029] Based on the semantic blocks of the question analysis template, each sentence pattern template in the sentence pattern template library is traversed to obtain the similarity threshold value of the question analysis template and each sentence pattern template in the sentence pattern template library; the similarity threshold value is the final template similarity obtained by weighted summation of the semantic block similarity, the template length similarity and the semantic block order similarity.
[0030] The similarity threshold values are arranged in descending order, and the sentence pattern template corresponding to the highest value of the similarity threshold value is taken as the final target sentence pattern template.
[0031] According to the second aspect of the object of the application, a knowledge base query system combining semantic understanding and question templates is further provided, including:
[0032] One or more processors;
[0033] a memory storing instructions operable to be executed by the one or more processors, the instructions, when executed by the one or more processors, implement the knowledge base query method combining the semantic understanding and the question template.
[0034] The third aspect according to the object of the present application also proposes a server, comprising:
[0035] one or more processors;
[0036] a memory storing instructions operable to be executed by the one or more processors, the instructions, when executed by the one or more processors, implement the knowledge base query method combining the semantic understanding and the question template.
[0037] The knowledge base query method combining the semantic understanding model and the question template proposed by the present application can realize the function that non-technical personnel can query the knowledge base in the form of natural language by analyzing the query intention of the natural language question, including the analysis of the semantic content of the question and the analysis of the semantic structure.
[0038] Compared with the prior art, the present application has the following remarkable beneficial effects:
[0039] (1) The semantic understanding model with dependency analysis as the core is combined with the domain dictionary to analyze the sentence content and the sentence structure of the question, and the query intention of the question is obtained;
[0040] (2) Three types of question template types are constructed by summarizing the question patterns of the natural language in the domain, and the components of the question template are composed of four semantic blocks, and the question template library constructed according to the three types of question template types can better cover and represent the sample space of the actual problem;
[0041] (3) The knowledge base query method proposed by the present application obtains the dependency relationship between the semantic blocks based on the dependency relationship analysis, recombines and sorts the semantic blocks according to the dependency relationship, generates the analysis template of the question, and then proposes the template matching algorithm for the question analysis template, which considers the semantic block similarity, the template length similarity and the semantic block order similarity, and can more accurately match the query intention and the question template.
[0042] It should be understood that all combinations of the aforementioned concepts and additional concepts described in greater detail below can be seen as part of the subject matter of the present disclosure as long as such concepts are not mutually contradictory in their implementation. In addition, all combinations of the claimed subject matter are considered part of the subject matter of the present disclosure.
[0043] The foregoing and other aspects, embodiments and features of the present teachings can be better understood from the following detailed description taken in conjunction with the drawings. Other aspects, embodiments and features of the present teachings will be apparent from the detailed description and the drawings. BRIEF DESCRIPTION OF DRAWINGS
[0044] The accompanying drawings are not intended to be drawn to scale. In the drawings, each identical, or nearly identical, component that is illustrated in various figures is represented with a like numeral. For purposes of clarity, not every component is called out in every drawing. Embodiments of various aspects of the present teachings will now be described, by way of example only, with reference to the drawings in which:
[0045] Figure 1 is a flowchart of a knowledge base query method of an exemplary embodiment of the present teachings, which combines a semantic understanding model and a sentence pattern template.
[0046] Figure 2 is a schematic diagram of dependency analysis of an exemplary embodiment of the present teachings. DETAILED DESCRIPTION
[0047] In order to more clearly understand the technical content of the present teachings, specific embodiments are shown and described with reference to the accompanying drawings.
[0048] Aspects of the present teachings are described in the disclosure by reference to the drawings, in which a number of illustrative embodiments are shown. The embodiments of the disclosure need not necessarily include all aspects of the present teachings. It should be understood that various concepts and embodiments introduced above and those described below can be implemented in any of numerous ways, as the disclosed concepts and embodiments are not limited to any particular manner of implementation. Additionally, some aspects of the present teachings can be utilized independently, or in any suitable combination with other aspects of the present teachings.
[0049] In combination Figure 1 The process of the knowledge base query method of the illustrated example that combines semantic understanding and question sentence templates includes the following steps:
[0050] Step 1, based on a preset sentence pattern template category and a sentence pattern template element, a sentence pattern template library is constructed; wherein the sentence pattern template category represents a purpose attribute of a question query, and the sentence pattern template element is a semantic block, which represents different question components and their roles in a question;
[0051] Step 2, based on corpus in a domain, a domain dictionary is constructed, and the keywords stored in the domain dictionary are set to be labeled according to the sentence pattern template elements, marking the sentence pattern template elements corresponding to the keywords;
[0052] Step 3, performing word segmentation on the input question sentence, and marking the word segmentation result with the type of the sentence pattern element according to the domain dictionary;
[0053] Step 4, performing dependency analysis on the word segmentation result marked with the type of the sentence pattern element, determining the dependency relationship between the semantic blocks, and recombining and sorting the semantic blocks according to the dependency relationship to generate a question analysis template;
[0054] Step 5, matching the question analysis template in step 4 in the sentence pattern template library constructed in step 1 to obtain a matched final target sentence pattern template;
[0055] Step 6, filling the phrases contained in the semantic blocks in the question analysis template in step 4 into the query sentence corresponding to the target sentence pattern template in step 5 to generate a complete query sentence; and
[0056] Step 7, querying the knowledge base according to the query sentence generated in step 6 to return an answer.
[0057] Preferably, the sentence pattern templates are divided into query entities, query entity attributes, and query entity relationships according to the query purpose, and are respectively denoted as a first template I: query entity; a second template II: query entity attribute; and a third template III: query query entity relationship.
[0058] Preferably, the semantic blocks in the sentence pattern element include the following types:
[0059] 1) a subject semantic block defining the phrases of entities, entity attributes, and entity relationships in a sentence;
[0060] 2) a question semantic block defining the interrogative words or phrases in a sentence;
[0061] 3) a restriction semantic block defining the restrictive words or phrases in a sentence;
[0062] 4) an auxiliary semantic block defining the mood auxiliaries in a sentence.
[0063] Preferably, in step 1, different semantic blocks of the sentence pattern element are combined under each sentence pattern category to generate sentence pattern templates under different sentence pattern categories, and a sentence pattern template library of all sentence pattern categories is constructed;
[0064] wherein each sentence pattern template is expressed as:
[0065] <Sentence pattern template> := (subject semantic block, [restriction semantic block], [question semantic block], [auxiliary semantic block]).
[0066] Preferably, in the field of constructing a dictionary process, the following processing is included:
[0067] The corpus related to the field is segmented, keywords are extracted, and the sentence pattern template element type corresponding to each keyword is labeled in combination with the sentence pattern template element type;
[0068] Among them, for the keywords with the subject semantic block labeled sentence pattern template element type, further includes labeling the type of entity, entity attribute or entity relationship.
[0069] Preferably, the input question is segmented, and the sentence pattern template element type to which the segmented result belongs is labeled in combination with the field dictionary, including:
[0070] First, the input question is segmented;
[0071] Then, the words and / or phrases obtained by the segmentation processing are optimized by utilizing the field dictionary in combination with the reverse maximum matching algorithm, re-spliced by the field dictionary, and the syntax analysis result is obtained and the sentence pattern template element type to which it belongs is labeled.
[0072] Preferably, the step 5, according to the question analysis template, matches in the sentence pattern template library constructed in the step 1, and obtains the matched final target sentence pattern template, including:
[0073] Based on the semantic block of the question analysis template, each sentence pattern template in the sentence pattern template library is traversed to obtain the similarity threshold of the question analysis template and each sentence pattern template in the sentence pattern template library; the similarity threshold is the semantic block similarity, the template length similarity and the semantic block order similarity, and the final template similarity is obtained by weighted summation;
[0074] The similarity threshold is arranged in descending order, and the sentence pattern corresponding to the highest value of the similarity threshold is taken as the final target sentence pattern of the matching.
[0075] Next, we will combine specific examples to more specifically implement the foregoing embodiments of the present application.
[0076] A, constructing a sentence pattern template category
[0077] Since the knowledge existing in the knowledge base mainly includes knowledge entities, entity attributes and entity relationships. Therefore, in the embodiments of the present application, the type of sentence pattern template is divided into three types, which correspond to different query purposes, including:
[0078] 1) Query entity;
[0079] 2) Query entity attribute;
[0080] 3) Query entity relationship.
[0081] For example, the type of the question "What is the latest loan interest rate of the Industrial and Commercial Bank?" is querying entity attribute, in which "Industrial and Commercial Bank" represents an entity and "loan interest rate" is an attribute thereof.
[0082] As an optional classification manner, an entity is usually configured as a noun or a specific object.
[0083] An entity attribute refers to attribute information of a certain aspect or dimension of an entity, and an entity relationship refers to a relationship attribute of an entity.
[0084] B. Constructing sentence pattern elements
[0085] In the embodiments of the present application, a sentence pattern element is defined as a different semantic block, representing the role attribute of different question components and text components in a sentence.
[0086] As an optional manner, the types of the sentence pattern elements specifically include:
[0087] 1) Subject semantic block: the semantic block corresponds to a phrase of an entity, an entity attribute and an entity relationship in a sentence;
[0088] 2) Question semantic block: the semantic block corresponds to a question word or a question phrase in a sentence, such as "how much", "long and short", "how" and the like;
[0089] 3) Restriction semantic block: the semantic block corresponds to a restrictive word or phrase in a sentence, such as a time adverbial, a place adverbial, a range adverbial and the like;
[0090] 4) Auxiliary semantic block: the semantic block corresponds to a mood auxiliary word and the like in a sentence.
[0091] For example, in the question "What is the latest loan interest rate of the Industrial and Commercial Bank?", "Industrial and Commercial Bank" and "loan interest rate" are subject semantic blocks, "how much" is a question semantic block, "latest" is a restriction semantic block, and "is" and "of" are auxiliary semantic blocks.
[0092] C. Constructing a sentence pattern template library
[0093] In the embodiments of the present application, a sentence pattern template is constructed by summarizing the sentence patterns of domain questions.
[0094] As described above, the types of the sentence pattern templates include querying an entity, querying an entity attribute and querying an entity relationship.
[0095] Thus, under each type of the sentence pattern templates, different sentence pattern elements are combined to generate different sentence pattern templates, thereby obtaining a sentence pattern template library of all types of the sentence pattern templates.
[0096] As an optional embodiment, each sentence pattern template in the sentence pattern template library has the following general form:
[0097] < Sentence Pattern Template > :: = (Subject Semantic Block, [Restriction Semantic Block], [Question Semantic Block], [Auxiliary Semantic Block]).
[0098] D. Constructing the domain dictionary
[0099] In the embodiments of the present application, the domain dictionary is constructed in a semi-automatic manner.
[0100] As an optional manner, the process of constructing the domain dictionary includes:
[0101] The corpus related to the domain is processed for word segmentation, for example, the keywords are extracted by using the tfidf unsupervised algorithm, and the types of the corresponding sentence pattern template elements are labeled.
[0102] Among them, it is particularly noted that for the keywords whose labeled types are subject semantic blocks, the types of the corresponding entities, entity attributes or entity relationships are further labeled.
[0103] For example, when processing the corpus, for the keyword "Industrial and Commercial Bank", the corresponding entity in the financial domain is of the type "bank".
[0104] E. Lexical analysis
[0105] The input question is subjected to lexical analysis, mainly to complete the word segmentation and part-of-speech tagging.
[0106] As an optional embodiment, the process of lexical analysis includes:
[0107] First, the input question is subjected to word segmentation, which can be based on forward word segmentation or reverse word segmentation to obtain the word segmentation result; then, each phrase obtained by the word segmentation result is labeled with the type of the sentence pattern template element to which it belongs.
[0108] In another embodiment, in order to avoid the possibility that long words may be segmented too finely, the reverse maximum matching algorithm can be used for word segmentation optimization in combination with the domain dictionary, the domain dictionary is used for re-splicing, and the type of the sentence pattern template element to which it belongs is labeled.
[0109] For example, for the input question, the threshold value k is pre-set, for example, k is set to 2 or 3, then k words are cut from the last word, the k words are matched with the domain dictionary first, if no matching word is found, the leftmost word of the k words is removed, then the k-1 words are matched with the dictionary, the above process is continued until the matching is successful, or the k-1 words are not matched, then the kth word is taken as an independent word, then the length of the divided word is moved forward, and k words are cut and processed again, until all the words are divided.
[0110] For example, "loan interest rate" can be divided into "loan" and "interest rate", and combined into "loan interest rate" through the constructed domain dictionary.
[0111] F, dependency analysis
[0112] In the embodiment of the application, on the basis of the morphological analysis obtaining the divided words and the sentence pattern element type to which the divided words belong, the dependency relationship between the semantic blocks in the question is analyzed by using a dependency analysis model, and the semantic blocks are recombined and sorted according to the dependency relationship, to generate an analysis template of the question.
[0113] For example, the dependency relationship analysis of the question "What is the latest loan interest rate of the Industrial and Commercial Bank of China?" is shown in the following table. Figure 2 The arrow between the phrases indicates the dependency direction, and the type of the dependency relationship is marked, for example, "latest" points to "loan interest rate" through the center relationship, and the semantic block order is "subject semantic block", "auxiliary semantic block", "subject semantic block", "limit semantic block", "auxiliary semantic block", and "question semantic block", and the analysis template of the question is:
[0114] (subject semantic block, auxiliary semantic block, subject semantic block, limit semantic block, auxiliary semantic block, question semantic block)
[0115] G, template matching
[0116] The generated question analysis template is matched in the sentence pattern template library, the semantic block similarity, the template length similarity and the semantic block order similarity of the question analysis template are calculated, and the final template similarity is obtained by weighted summation.
[0117] In the optional embodiment, the semantic block similarity is defined as f 1i , the template length similarity is f 2i , and the semantic block order similarity is f 3i, i = 1, 2, 3, …, n, n represents the total number of question templates in the question template library, then the semantic blocks of the question analysis template are calculated, and the similarity threshold of the question analysis template and each question template in the question template library is obtained by traversing calculation of the question analysis template and each question template in the question template library; the similarity threshold is the final template similarity obtained by weighted summation of the semantic block similarity, the template length similarity and the semantic block order similarity;
[0118] The similarity thresholds are arranged in descending order, and the question template corresponding to the highest value of the similarity threshold is taken as the final target question template of matching.
[0119] Wherein, f 1i represents the semantic block similarity of the question analysis template and the i-th question template in the question template library, and represents the similarity of the semantic blocks between the two.
[0120] f 2i represents the template length similarity of the question analysis template and the i-th question template in the question template library, and represents the similarity of the length of the semantic blocks between the two.
[0121] f 3i represents the semantic block order similarity of the question analysis template and the i-th question template in the question template library, and represents the similarity of the order of the semantic blocks between the two.
[0122] The final template similarity f = a f 1i + b f 2i + c f 3i , wherein a, b and c respectively represent the weight values of the semantic block similarity, the template length similarity and the semantic block order similarity, a, b and c respectively take values in [0, 1], and do not include the number, a + b + c = 1.
[0123] As an optional way, the value process of f 1i includes:
[0124] Define the type number of the semantic blocks contained in the question analysis template as P1, and define the type number of the semantic blocks contained in the i-th question template as P2;
[0125] The semantic block similarity f 1i is calculated in the following way:
[0126] f 1i = 1- [|P1-P2| / P1].
[0127] The smaller the difference between the two is, the higher the semantic block similarity is.
[0128] As an optional way, the value process of f 2i includes:
[0129] The number of semantic blocks contained in the question analysis template is defined as Q1, and the number of semantic blocks contained in the i-th question template is defined as Q2;
[0130] The template length similarity f is calculated in the following manner 2i :
[0131] F 2i =1-[|Q1-Q2| / Q1].
[0132] The smaller the number gap between the two is, the higher the template length similarity is.
[0133] As an optional manner, the value process of f 3i includes:
[0134] First, the order of the semantic blocks contained in the question analysis template and the order of the semantic blocks contained in the i-th question template are determined;
[0135] Then, the semantic blocks contained in the i-th question template are compared one by one from the first semantic block contained in the question analysis template, if any semantic block type of the i-th question template is matched with the type of the first semantic block, the matching degree corresponding to the first semantic block is valued as 0; if the j-th semantic block type contained in the i-th question template is matched with the type of the first semantic block, the matching degree corresponding to the first semantic block is valued as (1 / Q1)*(j / Q2), and the semantic blocks in the i-th question template are deleted, that is, the semantic blocks before the j-th semantic block are discarded; then, the second semantic block contained in the question analysis template is started to be matched on the basis of the i-th question template after the deletion, until all the semantic blocks in the question analysis template are compared, thereby obtaining the matching degree values corresponding to all the semantic blocks in the question analysis template, and adding the matching degree values corresponding to all the semantic blocks, the total matching degree, that is, the semantic block order similarity f 3i is obtained.
[0136] The semantic block order similarity f
[0137] H, knowledge query
[0138] The phrases contained in each semantic block in the corresponding question analysis template are filled into the query sentence corresponding to the finally obtained target sentence template (that is, the sentence template of the question), to generate a complete query sentence; the knowledge base is queried according to the generated query sentence, and the answer is returned.
[0139] According to the embodiments disclosed in the present application, a knowledge base query system combining semantic understanding and question templates is also proposed, which includes:
[0140] one or more processors;
[0141] The memory stores operable instructions that, when executed by one or more processors, implement the knowledge base query method combining semantic understanding and question templates as described in the foregoing embodiments.
[0142] According to embodiments disclosed in this invention, a server is also provided, comprising:
[0143] One or more processors;
[0144] The memory stores operable instructions that, when executed by one or more processors, implement the knowledge base query method combining semantic understanding and question templates as described in the foregoing embodiments.
[0145] Therefore, this invention, by combining a semantic understanding model and a sentence template-based knowledge base query method, enables non-technical users to query the knowledge base in natural language, improving the freedom and convenience of the query. The semantic understanding model, with dependency analysis at its core, has stronger generalization ability for more general questions, while sentence templates enhance the adaptability of the query method to complex domains. The combination of these two approaches significantly improves recall and accuracy when querying specialized or complex questions.
[0146] While the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Those skilled in the art can make various modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention shall be determined by the claims.
Claims
1. A knowledge base query method combining semantic understanding and question templates, characterized in that, The method comprises the following steps: Step 1, constructing a sentence pattern template library based on preset sentence pattern template categories and sentence pattern template elements, wherein the sentence pattern template categories represent the purpose attributes of the question queries, and the sentence pattern template elements are semantic blocks representing different question components and their roles in the question; Step 2, constructing a domain dictionary based on domain corpus, wherein the keywords stored in the domain dictionary are set to be labeled according to the sentence pattern template elements, and the sentence pattern template elements corresponding to the keywords are marked; Step 3, performing word segmentation processing on the input question, and marking the sentence pattern template element types to which the word segmentation results belong in combination with the domain dictionary; Step 4, performing dependency relationship analysis on the word segmentation results marked with the sentence pattern template element types, determining the dependency relationships between the semantic blocks, and recombining and sorting the semantic blocks according to the dependency relationships to generate a question analysis template; Step 5, matching the question analysis template in step 4 in the sentence pattern template library constructed in step 1 to obtain a matched final target sentence pattern template; Step 6, filling the phrases contained in the semantic blocks in the question analysis template corresponding to step 4 into the query sentence corresponding to the target sentence pattern template in step 5 to generate a complete query sentence; and Step 7, querying the knowledge base according to the query sentence generated in step 6 to return an answer. The sentence pattern templates are set to be divided into query entities, query entity attributes and query entity relationships according to the query purposes, and are respectively denoted as a first template I: query entity, a second template II: query entity attribute, and a third template III: query entity relationship.
2. The semantic understanding and question template combined knowledge base query method according to claim 1, characterized in that, The semantic blocks in the sentence pattern template elements include the following types: 1) a subject semantic block defining the phrases of entities, entity attributes and entity relationships in a sentence; 3. The method according to claim 2, wherein, 2) a question semantic block defining the question words or question phrases in a sentence; 3) a restriction semantic block defining the restrictive words or phrases in a sentence; 4) an auxiliary semantic block defining the mood auxiliary words in a sentence. In step 1, different semantic blocks of the sentence pattern template elements are combined to generate sentence pattern templates under different sentence pattern template categories, and a sentence pattern template library of all sentence pattern template categories is constructed; wherein each sentence pattern template is expressed as follows:
4. The method of claim 3, wherein the semantic understanding and question template combination knowledge base query method is characterized in that, <Sentence pattern template> := (subject semantic block, [restriction semantic block], [question semantic block], [auxiliary semantic block]). In the process of constructing the domain dictionary, the following processing is included: performing word segmentation processing on the domain-related corpus, extracting keywords, and marking the sentence pattern template element types corresponding to each keyword in combination with the sentence pattern template element types; 5. The method of claim 3, wherein the semantic understanding and question template combination knowledge base query method is characterized in that, wherein for the keywords marked with the subject semantic blocks, the types of the entities, entity attributes or entity relationships are further marked. The word segmentation processing on the input question and the marking of the sentence pattern template element types to which the word segmentation results belong in combination with the domain dictionary comprise: 6. The method of claim 3, wherein the semantic understanding and question template combination knowledge base query method is characterized by, The field dictionary is combined with the reverse maximum matching algorithm to optimize word segmentation, the field dictionary is used for re-splicing, a syntax analysis result is obtained, and a sentence type template element type is marked.
7. The semantic understanding and question template combined knowledge base query method according to claim 6, characterized in that, The step 5 matches the sentence type template library constructed in the step 1 according to the question analysis template to obtain a matched final target sentence type template, and the final target sentence type template comprises: Based on the semantic block of the question analysis template, each sentence type template in the sentence type template library is traversed to obtain a similarity threshold of the question analysis template and each sentence type template in the sentence type template library; the similarity threshold is a final template similarity obtained by weighted summation of semantic block similarity, template length similarity and semantic block order similarity; The similarity thresholds are arranged in descending order, and a sentence type template corresponding to the highest value of the similarity threshold is taken as the final target sentence type template.
8. A knowledge base query system combining semantic understanding and question templates, characterized in that, It comprises: one or more processors; a memory storing executable instructions, which, when executed by the one or more processors, implement the knowledge base query method combining semantic understanding and question templates according to any one of claims 1-7.
9. A server, characterized by It comprises: one or more processors; a memory storing executable instructions, which, when executed by the one or more processors, implement the knowledge base query method combining semantic understanding and question templates according to any one of claims 1-7.
Citation Information
Patent Citations
Space-time full-element semantic query service system and method
CN107491556A
Knowledge graph question and answer training and application service system with automatically generated template
CN111339269A