Text generation method, text generation device, electronic equipment and storage medium

By using tree -shaped structure storage answers in the intelligent Q & A system, and the method of querying the query by answering the answer, the knowledge base occupies a large amount of storage space, and realizes the reduction of the storage space and the improvement of query efficiency.

CN119377340APending Publication Date: 2025-01-28CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411441544.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2025-01-28

Smart Images

  • Figure CN119377340A_ABST
    Figure CN119377340A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a text generation method, a text generation device, electronic equipment and a storage medium, and belongs to the technical field of artificial intelligence. The method comprises the steps that an obtained first question text is matched with multiple question texts in a corpus set, a first answer identifier matched with the first question text is obtained, and the corpus set comprises the multiple question texts and the answer identifier corresponding to each question text; according to the first answer identifier, a first answer corresponding to the first answer identifier is obtained from a pre-constructed tree structure, the tree structure comprises a root node and multiple layers of child nodes, and each child node comprises an identifier of the child node, an identifier of a father node of the child node and a text; the root node comprises an identifier of the root node, a text and an identifier of a father node of the root node; and generating an answer text of the first question text according to the first answer. According to the embodiment of the invention, the corresponding answer is obtained from the tree structure through the identifier, so that the storage space occupied by the corpus can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text generation method, a text generation device, an electronic device and a storage medium. Background Art

[0002] With the rapid development of natural language processing technology, intelligent question and answer is currently a trend for computers and humans to communicate in the form of natural language. Users can ask questions through the intelligent question and answer system and directly obtain relevant answers, thereby realizing the dialogue between users and the intelligent question and answer system.

[0003] The answering ability of the intelligent question-answering system depends on the support of the knowledge base. The current knowledge base includes a large amount of corpus. Each corpus includes a question and the answer corresponding to the question, which occupies a large storage space. Therefore, how to reduce the space occupied by the corpus of the knowledge base has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to propose a text generation method, a text generation device, an electronic device and a storage medium, aiming to reduce the storage space occupied by the corpus.

[0005] To achieve the above object, a first aspect of an embodiment of the present application proposes a text generation method, the method comprising:

[0006] Get the first question text;

[0007] Matching the first question text with a plurality of question texts in a corpus to obtain a first answer identifier that matches the first question text, the corpus including the plurality of question texts and an answer identifier corresponding to each question text;

[0008] According to the first answer identifier, a first answer corresponding to the first answer identifier is obtained from a pre-constructed tree structure, wherein the tree structure includes a root node and multiple layers of child nodes of the root node, each of the child nodes includes the identifier of the child node, the identifier of the parent node of the child node, and the text stored in the child node; the root node includes the identifier of the root node, the text stored in the root node, and the identifier of the parent node of the root node, and the identifier of the parent node of the root node is a preset identifier;

[0009] An answer text for the first question text is generated according to the first answer.

[0010] In some embodiments, obtaining, according to the first answer identifier, a first answer corresponding to the first answer identifier from a pre-constructed tree structure includes:

[0011] Taking the node corresponding to the first answer identifier in the tree structure as an initial node, and obtaining the text of the initial node;

[0012] Determine whether the identifier of the parent node of the initial node is the preset identifier;

[0013] If the identifier of the parent node of the initial node is not the preset identifier, taking the node corresponding to the identifier of the parent node in the initial node as the initial node, obtaining the text of the initial node, and executing the step of determining whether the identifier of the parent node of the initial node is the preset identifier, until the identifier of the parent node of the initial node is the preset identifier;

[0014] A first answer is obtained according to the text of the initial node obtained each time.

[0015] In some embodiments, each of the sub-nodes further includes a level identifier of the sub-node; the root node further includes a level identifier of the root node;

[0016] The step of obtaining a first answer according to the text of the initial node obtained each time includes:

[0017] Sort the text of the initial node obtained according to the size of the level identifier of the initial node obtained to obtain the initial text;

[0018] The first answer is obtained according to the initial text.

[0019] In some embodiments, the corpus also includes an answer template corresponding to each question text, and the question text corresponds to the answer template one by one;

[0020] The obtaining the first answer according to the initial text includes:

[0021] Obtaining a first answer template corresponding to the first question text;

[0022] Each text of the initial text is added to the corresponding position in the first answer template in sequence according to the order of level identification to obtain the first answer.

[0023] In some embodiments, the corpus also includes an answer template corresponding to each question text, and the question text corresponds to the answer template one by one;

[0024] The obtaining the first answer according to the initial text includes:

[0025] Obtaining a first answer template corresponding to the first question text;

[0026] Each text of the initial text is added to the corresponding position in the first answer template in sequence according to the order of level identification to obtain the first answer.

[0027] In some embodiments, obtaining the first question text includes:

[0028] Get the initial information entered by the user;

[0029] Extracting keywords from the initial information to obtain at least one keyword;

[0030] The first question text is obtained according to the at least one keyword.

[0031] In some embodiments, extracting keywords from the initial information to obtain at least one keyword includes:

[0032] If the initial information is in text format, extracting keywords from the initial information in text format to obtain at least one keyword;

[0033] If the initial information is in voice format, the initial information is converted into a text format, and keywords are extracted from the initial information in text format to obtain at least one keyword.

[0034] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a text generation device, the device comprising:

[0035] An acquisition module is used to acquire the first question text;

[0036] A processing module, configured to match the first question text with a plurality of question texts in a corpus to obtain a first answer identifier that matches the first question text, wherein the corpus includes the plurality of question texts and an answer identifier corresponding to each question text;

[0037] The processing module is further used to obtain, according to the first answer identifier, a first answer corresponding to the first answer identifier from a pre-constructed tree structure, wherein the tree structure includes a root node and multiple layers of child nodes of the root node, each of the child nodes includes an identifier of the child node, an identifier of a parent node of the child node, and text stored in the child node; the root node includes an identifier of the root node, text stored in the root node, and an identifier of the parent node of the root node, and the identifier of the parent node of the root node is a preset identifier;

[0038] The processing module is further used to generate an answer text for the first question text according to the first answer.

[0039] In some embodiments, the processing module is also used to take the node in the tree structure corresponding to the first answer identifier as the initial node, obtain the text of the initial node; determine whether the identifier of the parent node of the initial node is the preset identifier; if the identifier of the parent node of the initial node is not the preset identifier, then take the node corresponding to the identifier of the parent node in the initial node as the initial node, obtain the text of the initial node, and execute the step of determining whether the identifier of the parent node of the initial node is the preset identifier until the identifier of the parent node of the initial node is the preset identifier; and obtain the first answer based on the text of the initial node obtained each time.

[0040] In some embodiments, the processing module is further used to sort the text of the obtained initial node according to the size of the level identifier of the obtained initial node to obtain the initial text; and obtain the first answer according to the initial text.

[0041] In some embodiments, the processing module is further used to obtain a first answer template corresponding to the first question text; and to add each text of the initial text to a corresponding position in the first answer template in sequence according to a hierarchical identification order to obtain the first answer.

[0042] In some embodiments, the processing module is further used to obtain a user identifier of a user who inputs the first question text; and determine a corpus matching the user identifier based on the user identifier.

[0043] In some embodiments, the processing module is further used to obtain initial information input by the user; perform keyword extraction on the initial information to obtain at least one keyword; and obtain the first question text according to the at least one keyword.

[0044] In some embodiments, the processing module is also used to, if the initial information is in text format, perform keyword extraction on the initial information in text format to obtain at least one keyword; if the initial information is in voice format, perform format conversion on the initial information to obtain the initial information in text format, and perform keyword extraction on the initial information in text format to obtain at least one keyword.

[0045] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0046] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0047] The text generation method, text generation device, electronic device and storage medium proposed in the present application obtain a first question text, match the first question text with multiple question texts in a corpus, and obtain a first answer identifier that matches the first question text. The corpus includes multiple question texts and answer identifiers corresponding to each question text. According to the first answer identifier, a first answer corresponding to the first answer identifier is obtained from a pre-constructed tree structure, wherein the tree structure includes a root node and multiple layers of child nodes of the root node, each child node includes an identifier of the child node, an identifier of the parent node of the child node, and a text stored in the child node. The root node includes an identifier of the root node, text stored in the root node, and an identifier of the parent node of the root node, which is represented as a preset identifier. According to the first answer, an answer text for the first question text is generated. The identifier is stored in the corpus, and the answers to the corpus are stored in a tree structure. By obtaining the corresponding answer from the tree structure through the identifier, the storage space occupied by the corpus can be effectively reduced, and the tree structure can improve data query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 is an optional flowchart of the text generation method provided in the embodiment of the present application;

[0049] Figure 2 is a schematic diagram of a corpus provided in an embodiment of the present application;

[0050] Figure 3 is a schematic diagram of a pre-built tree structure provided in an embodiment of the present application;

[0051] Figure 4 yes Figure 1 Flow chart of step S103 in FIG.

[0052] Figure 5 is a schematic diagram of the relationship between the corpus provided in the embodiment of the present application and the pre-built tree structure;

[0053] Figure 6 yes Figure 4 Flow chart of step S404 in FIG.

[0054] Figure 7 yes Figure 6 Flowchart of step S602 in FIG.

[0055] Figure 8 It is a schematic diagram of the relationship between the corpus set provided in the embodiment of the present application and the pre-constructed tree tags;

[0056] Fig. 9 is a structural schematic diagram of a text generation device provided in an embodiment of the present application;

[0057] Fig.10 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0059] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0061] First, some nouns involved in this application are analyzed:

[0062] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0063] Natural language processing (NLP): NLP uses computers to process, understand and apply human languages ​​(such as Chinese, English, etc.). NLP is a branch of artificial intelligence and an interdisciplinary subject between computer science and linguistics. It is often referred to as computational linguistics. Natural language processing includes grammatical analysis, semantic analysis, and text comprehension. Natural language processing is often used in technical fields such as machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information intent recognition, information extraction and filtering, text classification and clustering, public opinion analysis and opinion mining. It involves data mining related to language processing, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computing.

[0064] At present, intelligent question and answer is a trend in which computers and humans communicate in the form of natural language. Users can directly obtain relevant answers by asking questions through the intelligent question and answer system, thereby realizing the dialogue between users and the intelligent question and answer system. For example, in the query scenario of related business, if users want to know the details of a certain business, they can enter the corresponding questions in the human-computer dialogue interface of the intelligent question and answer, and the intelligent question and answer system will feedback the relevant answers.

[0065] The answering ability of the above-mentioned intelligent question-answering system depends on the support of the knowledge base. The current knowledge base includes a large amount of corpus, each of which includes a question and the answer corresponding to the question, and occupies a large storage space. Therefore, how to reduce the space occupied by the corpus of the knowledge base has become a technical problem that needs to be solved urgently.

[0066] Based on this, the embodiments of the present application provide a text generation method, a text generation device, an electronic device and a storage medium, aiming to reduce the storage space occupied by the corpus.

[0067] The text generation method, text generation device, electronic device and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the recommended method in the embodiments of the present application is described.

[0068] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0069] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0070] The text generation method provided in the embodiment of the present application relates to the field of artificial intelligence technology. The text generation method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server side, and can also be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms; the software can be an application that implements the text generation method, etc., but is not limited to the above forms.

[0071] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0072] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0073] Figure 1 is an optional flowchart of the text generation method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S104.

[0074] Step S101, obtaining the first question text.

[0075] In this embodiment, initial information input by the user is obtained. The user can input the initial information by voice input or by text input. The initial information is divided into text format and voice format. The first question text is further obtained based on the initial information.

[0076] Step S102, matching the first question text with a plurality of question texts in a corpus to obtain a first answer identifier that matches the first question text, wherein the corpus includes a plurality of question texts and an answer identifier corresponding to each question text.

[0077] In this embodiment, the corpus includes multiple corpora, each corpus includes multiple question texts and answer identifiers corresponding to each question text. The first question text is matched with the multiple question texts in the corpus, the question text in the corpus that matches the first question text is determined, and the answer identifier corresponding to the matched question text is obtained, that is, the first answer identifier matched by the above-mentioned first question text.

[0078] See also Figure 2 , Figure 2 is a schematic diagram of a corpus provided in an embodiment of the present application, each corpus includes a plurality of question texts and an answer identifier corresponding to each question text, Figure 2 The corpus set shown includes corpus 1, corpus 2, corpus 2 and corpus 4, etc. The answer corresponding to corpus 1 is identified as ID2, the answer corresponding to corpus 2 is identified as ID1, the answer corresponding to corpus 3 is identified as ID3, and the answer corresponding to corpus 4 is identified as IDX.

[0079] Step S103, according to the first answer identifier, obtain the first answer corresponding to the first answer identifier from a pre-constructed tree structure, wherein the tree structure includes a root node and multiple layers of child nodes of the root node, each child node includes the identifier of the child node, the identifier of the parent node of the child node, and the text stored in the child node; the root node includes the identifier of the root node, the text stored in the root node, and the identifier of the parent node of the root node, and the identifier of the parent node of the root node is a preset identifier.

[0080] In this embodiment, a tree structure is pre-built. The tree structure displays hierarchical information through a clear hierarchical structure, which makes it easy to find corresponding nodes and data level by level according to the relationship between data. Figure 3 , Figure 3 is a schematic diagram of a pre-built tree structure provided in an embodiment of the present application. The tree structure is represented by a tree tag. The tree structure includes a root node, which is located at the upper end of the tree structure. The root node includes an identifier of the root node, text stored in the root node, and an identifier of the parent node of the root node. The identifier of the parent node of the root node is a preset identifier. Figure 3 The topmost node is the root node, the root node is identified as ID1, the text stored in the root node is A, the root node's parent node's identifier is a preset identifier, that is, the root node's parent node's identifier = null (empty); the tree structure includes child nodes, and the multi-layer nodes located below the root node in the tree structure are multi-layer child nodes of the root node, and each child node includes the child node's identifier, the child node's parent node identifier, and the child node's stored text. Figure 3 There are three layers of child nodes under the middle root node, and the corresponding child node identifiers include ID2, ID3, and ID4. The parent node identifier corresponding to ID2 is ID1, and the text stored in the child node is B. The parent node identifier corresponding to ID3 is ID2, and the text stored in the child node is C. The parent node identifier corresponding to ID4 is ID3, and the text stored in the child node is D.

[0081] Specifically, according to the first answer identifier, a node identifier matching the first answer identifier is searched from a pre-built tree structure, and the node identifier may be a root node or a child node, and then the corresponding first answer is obtained according to the matching node identifier.

[0082] Step S104: Generate an answer text for the first question text according to the first answer.

[0083] In this embodiment, an answer text of the first question text is generated based on the first answer, and the answer text of the first question text is output to the user, or the answer text is generated and converted into a voice or dialogue program to the user.

[0084] In steps S101 to S106 shown in the embodiment of the present application, a first question text is obtained, the first question text is matched with multiple question texts in a corpus, a first answer identifier matching the first question text is obtained, a first answer corresponding to the first answer identifier is obtained from a pre-built tree structure according to the first answer identifier, an answer text for the first question text is generated according to the first answer, the identifiers are stored in the corpus, and the answers to the corpus are stored in a tree structure. Obtaining corresponding answers from the tree structure through the identifiers can effectively reduce the storage space occupied by the corpus, and the use of a tree structure can improve data query efficiency.

[0085] See also Figure 4 In some embodiments, step S103 may include but is not limited to steps S401 to S404:

[0086] Step S401: Take the node corresponding to the first answer identifier in the tree structure as the initial node, and obtain the text of the initial node.

[0087] In this embodiment, the first question text is matched with multiple question texts in the corpus to obtain a first answer identifier that matches the first question text, and the node corresponding to the first answer identifier in the tree structure is used as the initial node. Figure 5 , the first answer that matches is identified as ID3, the node corresponding to ID3 is taken as the initial node, and the text of the initial node is obtained.

[0088] Step S402: determine whether the identifier of the parent node of the initial node is a preset identifier.

[0089] In this embodiment, it is determined whether the identifier of the parent node of the initial node is a preset identifier, where the preset identifier is empty. By determining whether it is the preset identifier, it can be determined whether the initial node is a root node or a child node. If the identifier of the parent node of the initial node is the preset identifier, it means that the initial node is a root node; if the identifier of the parent node of the initial node is not the preset identifier, it means that the initial node is not a root node but a child node.

[0090] Step S403, if the identifier of the parent node of the initial node is not a preset identifier, then the node corresponding to the identifier of the parent node in the initial node is taken as the initial node, the text of the initial node is obtained, and the step of determining whether the identifier of the parent node of the initial node is a preset identifier is executed until the identifier of the parent node of the initial node is the preset identifier.

[0091] In this embodiment, if the identifier of the parent node of the initial node is not a preset identifier, that is, it is not empty, it means that the initial node is not a root node but a child node. The node corresponding to the identifier of the parent node in the initial node is taken as the initial node, and the text of the initial node is obtained. The step of determining whether the identifier of the parent node of the initial node is a preset identifier is continued until the identifier of the parent node of the initial node is a preset identifier, indicating that the initial node is a root node and has no corresponding parent node.

[0092] See also Figure 5 , Figure 5 It is a schematic diagram of the relationship between the corpus provided in an embodiment of the present application and the pre-constructed tree structure. The first question text is matched with multiple question texts in the corpus to obtain a first answer identifier that matches the first question text. If the first answer identifier is ID3, the node corresponding to ID3 is used as the initial node to obtain the text of the initial node, that is, to obtain text C. It is determined whether the identifier of the parent node of the initial node is a preset identifier, wherein the preset identifier is the identifier of the parent node of the root node, and the identifier of the parent node of the initial node is not a preset identifier, but ID2. The identifier of the parent node in the initial node, that is, the node corresponding to ID2, is used as the initial node to obtain the text of the initial node, that is, to obtain text B. The following steps are continued: determining whether the identifier of the parent node of the initial node is a preset identifier. The identifier of the parent node of the initial node is not a preset identifier, but ID1. The identifier of the parent node in the initial node, that is, the node corresponding to ID1, is used as the initial node to obtain the text of the initial node, that is, to obtain text A. The following steps are continued: determining whether the identifier of the parent node of the initial node is a preset identifier. The identifier of the initial node is a preset identifier, indicating that it is a root node.

[0093] Step S404, obtaining a first answer according to the text of the initial node obtained each time.

[0094] In this embodiment, according to the text of the initial node obtained each time, such as the text C, text B, and text A obtained above, the first answer corresponding to the first answer identifier is obtained according to the obtained text C, text B, and text A.

[0095] See also Figure 6 In some embodiments, each child node further includes a level identifier of the child node; the root node further includes a level identifier of the root node; step S404 may include but is not limited to steps S601 to S602:

[0096] Step S601, sorting the text of the obtained initial node according to the size of the level identifier of the obtained initial node to obtain the initial text;

[0097] Step S602, obtaining a first answer according to the initial text.

[0098] In this embodiment, each sub-node also includes a level identifier of the sub-node, and the level identifier is used to sort the text, such as Figure 5 As shown, the level identifier of the child node of ID2 is 2, the level identifier of the child node of ID3 is 3, the level identifier of the child node of ID4 is 4, and the root node also includes the level identifier of the root node. Figure 5 The level identifier of the root node in is 1. According to the size of the level identifier of the obtained initial node, the text of the obtained initial node is sorted to obtain the initial text. For example, the text obtained above is sorted according to the level identifier size to obtain the initial text. If the preset setting is to sort from small to large, the order in the initial text is A->B->C, or, if the preset setting is to sort from large to small, the order in the initial text is C->B->A, and the first answer is further obtained according to the initial text.

[0099] See also Figure 7 In some implementations, step S602 may include but is not limited to steps S701 to S702:

[0100] Step S701, obtaining a first answer template corresponding to a first question text;

[0101] Step S702: Add each text of the initial text to the corresponding position in the first answer template in sequence according to the hierarchical identification order to obtain the first answer.

[0102] In this embodiment, a corresponding answer template is pre-set for each question text, a first answer template corresponding to the first question text is obtained, the first answer module includes the pre-set text, and each text of the initial text is sequentially added to the corresponding position in the first answer template according to the hierarchical identification order, so as to obtain the first answer. By pre-setting the template and adding text to the template, the configuration is more flexible.

[0103] In some embodiments, before step S102 in some embodiments, the following steps may also be included but are not limited to:

[0104] The user ID of the user who inputs the first question text is obtained; and according to the user ID, a corpus set matching the user ID is determined.

[0105] In this embodiment, different corpora are preconfigured according to different users. If the user is a customer, one corpus corresponds to the user. If the user is an agent, such as an insurance agent, another corpus corresponds to the user. The user ID of the user who inputs the first question text is obtained, and the corpus that matches the user ID is determined according to the user ID. For example, the user ID is matched with the agent ID. If the user ID matches the agent ID, it means that the user is an agent, and the corpus corresponding to the agent is determined as the corpus that matches the user ID. If the user ID does not match all agent IDs, it means that the user is a customer, and the corpus corresponding to the customer is determined as the corpus that matches the user ID. The corpus that can be accurately matched to the user ID is used to distinguish between the customer and the agent corpus, so that different users can get the answers they want.

[0106] In some embodiments, step S101 may include but is not limited to the following steps:

[0107] Initial information input by a user is obtained; keywords are extracted from the initial information to obtain at least one keyword; and a first question text is obtained based on the at least one keyword.

[0108] In this embodiment, the initial information input by the user is obtained, and keywords are extracted from the initial information. Specifically, keywords are preset, and keywords are identified from the initial information based on the preset keywords. The identified keywords are extracted to obtain at least one keyword, and the first question text is obtained based on the at least one keyword. For example, the initial information input by the user is related information about insurance business B in area A, and the preset keywords include area name, business name, etc. Keywords are identified from the initial information as area A and insurance business B, and the first question text is obtained based on area A and insurance business B. By extracting keywords from the initial information, the user's question can be accurately located and the question text can be obtained.

[0109] In some embodiments, extracting keywords from the initial information to obtain at least one keyword may include, but is not limited to, the following steps:

[0110] If the initial information is in text format, keyword extraction is performed on the initial information in text format to obtain at least one keyword; if the initial information is in voice format, format conversion is performed on the initial information to obtain the initial information in text format, and keyword extraction is performed on the initial information in text format to obtain at least one keyword.

[0111] In this embodiment, the initial information is divided into text format and voice format. If the initial information is in text format, no conversion is required. Keyword extraction is performed on the initial information in text format to obtain at least one keyword. If the initial information is in voice format, format conversion is performed first and then keyword extraction is performed. Specifically, the initial information is input into a voice-to-text conversion model to obtain the initial information in text format. Keyword extraction is performed on the initial information in text format to obtain at least one keyword. Applicable to initial information in different formats, users can input by voice or text, so that users can ask questions in different ways.

[0112] In some embodiments, the text generation method may include, but is not limited to, the following steps:

[0113] The latest tree structure and the corpus associated with the latest tree structure are received, and the latest tree structure and the corpus associated with the latest tree structure are stored.

[0114] In this embodiment, as the questions asked by users become more and more extensive and the business is updated, the corpus and tree structure will also be updated accordingly. By receiving the latest tree structure and the corpus associated with the latest tree structure, and storing the latest tree structure and the corpus associated with the latest tree structure, the knowledge base content is enriched and can better meet the needs of users.

[0115] In some embodiments, a first question text is obtained, and the first question text is matched with multiple question texts in a corpus. If the text in the corpus matches the first question text, a first answer identifier that matches the first question text is obtained. If all the texts in the corpus do not match the first question text, it means that the question asked by the user has not yet been set with a corresponding question text, and a prompt message is sent to the terminal. The prompt message includes the initial information input by the user, so that the R&D terminal can add the corresponding question text and the corresponding answer identifier in the corresponding corpus, and add the corresponding child node in the tree structure. The child node includes the identifier of the child node, the identifier of the parent node of the child node, and the text stored in the child node. The terminal feeds back the latest tree structure and the corpus associated with the latest tree structure.

[0116] The following is an example of the text generation method provided in the embodiment of the present application. Figure 8 is a schematic diagram of the relationship between the corpus set provided in the embodiment of the present application and the pre-constructed tree tags, such as Figure 8 As shown, the tree tag (i.e., the pre-built tree tag mentioned above) is associated with the corpus set (i.e., the corpus set mentioned above) in a one-to-one correspondence, wherein the tree tag includes multiple nodes (Node), including a root node (Root Node) and multiple layers of child nodes of the root node, Level represents the level, and Name is the text content.

[0117] Taking FAQ corpus as an example, FAQ (Frequently Asked Questions) is a question-answering system based on artificial intelligence technology, which aims to automatically answer users' questions and solve common problems. The FAQ corpus entity (i.e., the corpus in the above text) only needs to be associated with the lowest node ID of the specified link (i.e., the root node ID or the child node ID in the above text). For example, the tree label is A->B->C->D storage structure as follows Figure 8 As shown, the parentId of the root node corresponding to A is null (i.e., the identifier of the parent node is null), the parentId of the child node corresponding to B is ID1 (i.e., the identifier of the parent node is ID1), the parentId of the child node corresponding to C is ID2 (i.e., the identifier of the parent node is ID2), and the parentId of the child node corresponding to D is ID3 (i.e., the identifier of the parent node is ID3). For example, if Corpus 1 in the Corpus Set is configured with A->B->C, then it is only necessary to record the ID of the bottom-level child node (i.e., the identifier of the child node in the above text) and the identifier ID3 of the child node corresponding to C. For example, if Corpus 2 in the Corpus Set is configured with A->B, then it is only necessary to record the ID of the bottom-level child node (i.e., the identifier of the child node in the above text) and the identifier ID2 of the child node corresponding to B. For example, if Corpus 3 in the Corpus Set is configured with A->B->C->D, then it is only necessary to record the ID of the bottom-level child node (i.e., the identifier of the child node in the above text) and the identifier ID4 of the child node corresponding to D. Reuse can be achieved by reusing this tree label and also recording the ID of the bottom-level child node, and it is easy to use.

[0118] The key post-query method is as follows: 1) First, retrieve all the tree-structured data, and assemble it into a map with the ID as the key and the entire record object as the value, i.e., <ID, node>; 2) After matching Corpus 1, based on the associated ID of the bottommost child node, perform a reverse query of the tree link. The specific query steps are as follows: Step a: Pass the associated node ID to the map (i.e., match the first question text with multiple question texts in the corpus set to obtain the first answer identifier that matches the first question text), and retrieve the node (i.e., use the node in the tree structure that corresponds to the first answer identifier as the initial node). At this time, record the name as the bottommost name of the tree, such as C above (i.e., text C above), and determine whether the parentId of the node is empty (i.e., determine whether the identifier of the parent node of the initial node is the preset identifier). If it is empty, it means that the topmost root node has been reached, and the tree link can be assembled; if it is not empty, take the parentId as the node id and repeat Step a (i.e., perform the step of determining whether the identifier of the parent node of the initial node is the preset identifier) until the identifier of the parent node of the initial node is the preset identifier, and obtain the text of the initial node. At this point, the tree link value of the required corpus can be written back, and according to the text of the initial node obtained each time, the first answer can be obtained. According to the first answer, generate the answer text for the first question text. In the above method, not only is the redundancy between different subject data reduced, but also the association relationship between the subject data and the tree structure is streamlined. Moreover, the tree-structured data is converted into an in-memory map, which improves the data backfill efficiency and makes querying more convenient.

[0119] Please refer to Fig. 9 , the embodiment of the present application further provides a text generation device 90, which can implement the above text generation method. The device 90 includes:

[0120] An acquisition module 901 for acquiring the first question text. A processing module 902 is used to match the first question text with multiple question texts in the corpus set to obtain the first answer identifier that matches the first question text. The corpus set includes multiple question texts and the answer identifiers corresponding to each question text. The processing module 902 is further used to obtain the first answer corresponding to the first answer identifier from the pre-constructed tree structure, where the tree structure includes a root node and multiple layers of child nodes of the root node. Each child node includes the identifier of the child node, the identifier of the parent node of the child node, and the text stored in the child node; the root node includes the identifier of the root node, the text stored in the root node, and the identifier of the parent node of the root node. The identifier of the parent node of the root node is the preset identifier. The processing module 902 is further used to generate the answer text for the first question text according to the first answer.

[0121] In some embodiments, processing module 902 is also used to take the node corresponding to the first answer identifier in the tree structure as the initial node, obtain the text of the initial node; determine whether the identifier of the parent node of the initial node is a preset identifier; if the identifier of the parent node of the initial node is not a preset identifier, then take the node corresponding to the identifier of the parent node in the initial node as the initial node, obtain the text of the initial node, and execute the step of determining whether the identifier of the parent node of the initial node is the preset identifier, until the identifier of the parent node of the initial node is the preset identifier; and obtain the first answer based on the text of the initial node obtained each time.

[0122] In some embodiments, the processing module 902 is further used to sort the text of the obtained initial node according to the size of the level identifier of the obtained initial node to obtain the initial text; and obtain the first answer according to the initial text.

[0123] In some embodiments, the processing module 902 is further used to obtain a first answer template corresponding to the first question text; and to add each text of the initial text to a corresponding position in the first answer template in sequence according to the hierarchical identification order to obtain the first answer.

[0124] In some embodiments, the processing module 902 is further configured to obtain a user identifier of a user who inputs the first question text; and determine, based on the user identifier, a corpus matching the user identifier.

[0125] In some embodiments, the processing module 902 is further used to obtain initial information input by the user; perform keyword extraction on the initial information to obtain at least one keyword; and obtain the first question text according to the at least one keyword.

[0126] In some embodiments, the processing module 902 is also used to, if the initial information is in text format, perform keyword extraction on the initial information in text format to obtain at least one keyword; if the initial information is in voice format, perform format conversion on the initial information to obtain the initial information in text format, and perform keyword extraction on the initial information in text format to obtain at least one keyword.

[0127] The specific implementation of the text generation device is basically the same as the specific implementation of the above-mentioned text generation method, and will not be repeated here.

[0128] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above text generation method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0129] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0130] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0131] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the text generation method of the embodiment of this application;

[0132] Input / output interface 1003, used to implement information input and output;

[0133] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);

[0134] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );

[0135] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .

[0136] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned text generation method is implemented.

[0137] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0138] The present application also provides a computer program product, including a computer program / instruction, which, when executed by one or more processors, implements the steps of the text generation method of any embodiment of the present application.

[0139] The text generation method, text generation device, electronic device and storage medium provided in the embodiments of the present application obtain a first question text, match the first question text with multiple question texts in a corpus, obtain a first answer identifier that matches the first question text, obtain a first answer corresponding to the first answer identifier from a pre-built tree structure according to the first answer identifier, generate an answer text for the first question text according to the first answer, store the identifiers in the corpus, and the answers to the corpus are stored in a tree structure. Obtaining corresponding answers from the tree structure through the identifiers can effectively reduce the storage space occupied by the corpus, and the tree structure can improve data query efficiency.

[0140] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0141] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0142] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0143] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0144] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0145] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0146] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0147] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0148] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0149] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0150] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A text generation method, characterized in that: The method comprises: Get the first question text; Matching the first question text with a plurality of question texts in a corpus to obtain a first answer identifier that matches the first question text, the corpus including the plurality of question texts and an answer identifier corresponding to each question text; According to the first answer identifier, a first answer corresponding to the first answer identifier is obtained from a pre-constructed tree structure, wherein the tree structure includes a root node and multiple layers of child nodes of the root node, each of the child nodes includes the identifier of the child node, the identifier of the parent node of the child node, and the text stored in the child node; the root node includes the identifier of the root node, the text stored in the root node, and the identifier of the parent node of the root node, and the identifier of the parent node of the root node is a preset identifier; An answer text for the first question text is generated according to the first answer.

2. The text generation method according to claim 1, characterized in that: The acquiring, according to the first answer identifier, a first answer corresponding to the first answer identifier from a pre-constructed tree structure includes: Taking the node corresponding to the first answer identifier in the tree structure as an initial node, and obtaining the text of the initial node; Determine whether the identifier of the parent node of the initial node is the preset identifier; If the identifier of the parent node of the initial node is not the preset identifier, taking the node corresponding to the identifier of the parent node in the initial node as the initial node, obtaining the text of the initial node, and executing the step of determining whether the identifier of the parent node of the initial node is the preset identifier, until the identifier of the parent node of the initial node is the preset identifier; A first answer is obtained according to the text of the initial node obtained each time.

3. The text generation method according to claim 2, characterized in that: Each of the sub-nodes further includes a level identifier of the sub-node; the root node further includes a level identifier of the root node; The step of obtaining a first answer according to the text of the initial node obtained each time includes: Sort the text of the initial node obtained according to the size of the level identifier of the initial node obtained to obtain the initial text; The first answer is obtained according to the initial text.

4. The text generation method according to claim 3, characterized in that: The corpus also includes an answer template corresponding to each question text, and the question text corresponds to the answer template one by one; The obtaining the first answer according to the initial text includes: Obtaining a first answer template corresponding to the first question text; Each text of the initial text is added to the corresponding position in the first answer template in sequence according to the order of level identification to obtain the first answer.

5. The text generation method according to claim 1, characterized in that: Before matching the first question text with a plurality of question texts in a corpus to obtain a first answer identifier matching the first question text, the method further includes: Obtaining a user ID of a user who inputs the first question text; According to the user identifier, a corpus set matching the user identifier is determined.

6. The text generation method according to any one of claims 1 to 5, characterized in that: The obtaining of the first question text comprises: Get the initial information entered by the user; Extracting keywords from the initial information to obtain at least one keyword; The first question text is obtained according to the at least one keyword.

7. The text generation method according to claim 6, characterized in that: The extracting keywords from the initial information to obtain at least one keyword includes: If the initial information is in text format, extracting keywords from the initial information in text format to obtain at least one keyword; If the initial information is in voice format, the initial information is converted into a text format to obtain the initial information, and keywords are extracted from the initial information in text format to obtain at least one keyword.

8. A text generation device, characterized in that: The device comprises: An acquisition module is used to acquire the first question text; A processing module, configured to match the first question text with a plurality of question texts in a corpus to obtain a first answer identifier that matches the first question text, wherein the corpus includes the plurality of question texts and an answer identifier corresponding to each question text; The processing module is further used to obtain, according to the first answer identifier, a first answer corresponding to the first answer identifier from a pre-constructed tree structure, wherein the tree structure includes a root node and multiple layers of child nodes of the root node, each of the child nodes includes an identifier of the child node, an identifier of a parent node of the child node, and text stored in the child node; the root node includes an identifier of the root node, text stored in the root node, and an identifier of the parent node of the root node, and the identifier of the parent node of the root node is a preset identifier; The processing module is further used to generate an answer text for the first question text according to the first answer.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the text generation method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text generation method according to any one of claims 1 to 7 is implemented.