A method and system for automatically generating documents

Through the combination of deep learning and regular expressions, document templates are automatically generated, which solves the problems of cumbersome and time-consuming templates in traditional document generation methods, and improves the efficiency of document generation.

CN112560419BActive Publication Date: 2024-09-10NO 15 INST OF CHINA ELECTRONICS TECH GRP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011442492.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-08
Publication Date
2024-09-10
Estimated Expiration
2040-12-08

AI Technical Summary

Technical Problem

The traditional document generation method based on template fill-in-the-blank requires the production of a large number of different types of templates. The process is cumbersome, time-consuming and labor-intensive, resulting in document compilation being time-consuming and inefficient.

Method used

The deep learning method is used to identify named entities in the text of historical documents, and regular expressions are used to match the head and tail, and merged into document templates. The BERT and BLSTM-CRF models are used to extract document element information and automatically generate document templates. Simplify the operation process.

Benefits of technology

It effectively avoids the problems of traditional templates being difficult to enumerate and static and inflexible templates, simplifying the document compilation process and significantly improving the efficiency of document generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112560419B
    Figure CN112560419B
Patent Text Reader

Abstract

The present invention discloses a method and system for automatically generating documents. The method comprises: obtaining historical documents, using a deep learning method to perform named entity recognition on the body of the historical documents to obtain a document body template; using regular expressions to match the head and tail of the historical documents to obtain a document head and tail template; merging the document body template and the document head and tail template into a document template, and filling the document element information to be filled into the document body template and the document head and tail template to generate the document. The method and system of the present invention are used to generate document templates based on deep learning combined with rules, so that the machine learns the element rules of the template and automatically generates the document template, which can effectively avoid the problems of traditional templates being difficult to enumerate and templates being static and inflexible, simplify the operation process, reduce the time consumption of document compilation, and effectively improve the efficiency of document generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of document generation, and in particular to a method and system for automatically generating a document. Background Art

[0002] The existing method of generating documents is: according to the type of document to be generated, the corresponding template is matched from the template library, and various element information of the document to be generated is filled into the extracted document template, so as to generate a target document that meets the requirements.

[0003] However, the traditional document generation method based on template filling has the following disadvantages: the way to obtain templates requires the production of a large number of different types of templates, which is cumbersome, time-consuming and labor-intensive. Therefore, how to simplify the operation process, reduce the time consumption of document compilation, and improve the efficiency of document generation is an urgent problem to be solved. Summary of the invention

[0004] The purpose of the present invention is to provide a method and system for automatically generating documents, which can improve the efficiency of document generation.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] A method for automatically generating a document, comprising:

[0007] Acquisition of historical documents;

[0008] Using a deep learning method to perform named entity recognition on the body of the historical document to obtain a document body template;

[0009] The head and tail of the historical document are matched using regular expressions to obtain the head and tail templates of the document;

[0010] The document body template and the document header and tail template are combined into a document template; the document template is used to generate a document.

[0011] Optionally, after merging the document body template and the document header and footer template into a document template, the method further includes:

[0012] Fill the document element information to be filled into the document body template and the document header and footer template accordingly to generate the document.

[0013] Optionally, the method of performing named entity recognition on the body of the historical document using a deep learning method to obtain a document body template specifically includes:

[0014] Input the text of the historical document into the BERT model to obtain an output vector;

[0015] The output vector is input into the trained BLSTM-CRF model to obtain a label; the label is used to determine the named entity.

[0016] Optionally, the training process of the trained BLSTM-CRF model specifically includes:

[0017] Obtain the text of the document to be trained;

[0018] Input the document text to be trained into the BERT model to obtain a vector to be trained;

[0019] The BLSTM-CRF model is trained with the vector to be trained as input and the label corresponding to the document text to be trained as output to obtain a trained BLSTM-CRF model.

[0020] Optionally, the step of inputting the document text to be trained into a BERT model to obtain a vector to be trained specifically includes:

[0021] Performing word segmentation processing on the document body to be trained to obtain a word segmented text;

[0022] Adding marking information at the beginning and end of each sentence in the document to be trained to obtain a plurality of sentences with marking information;

[0023] The text after the word segmentation processing and the sentence with the tag information are processed by using Transformer encoding to obtain the vector to be trained.

[0024] Optionally, the document element information specifically includes:

[0025] The information of the beginning and end elements of the document and the main body of the document;

[0026] The document head and tail element information includes: the document title, document number, issuing unit, issuer, grade, and category;

[0027] The document body element information includes: key persons in the document body, key time in the document body, and key locations in the document body.

[0028] The present invention also provides a document automatic generation system, comprising:

[0029] A historical document acquisition module is used to acquire historical documents;

[0030] A document body template generation module, used to perform named entity recognition on the body of the historical document using a deep learning method to obtain a document body template;

[0031] A document header and footer template generation module is used to match the header and footer of the historical document using regular expressions to obtain the document header and footer templates;

[0032] A document template generation module is used to merge the document body template and the document header and footer template into a document template; the document template is used to generate a document.

[0033] Optionally, the document body template generation module specifically includes:

[0034] A first input submodule, used to input the text of the historical document into the BERT model to obtain an output vector;

[0035] The second input submodule is used to input the output vector into the trained BLSTM-CRF model to obtain a label; the label is used to determine the named entity.

[0036] Optionally, the second input submodule specifically includes:

[0037] A training unit is used to obtain the document text to be trained; input the document text to be trained into the BERT model to obtain the vector to be trained; train the BLSTM-CRF model with the vector to be trained as input and the label corresponding to the document text to be trained as output to obtain a trained BLSTM-CRF model.

[0038] Optionally, the training unit specifically includes:

[0039] A word segmentation processing subunit is used to perform word segmentation processing on the document body to be trained to obtain a text after word segmentation processing;

[0040] A marking subunit, used for adding marking information at the beginning and end of each sentence of the document body to be trained, so as to obtain a plurality of sentences with marking information;

[0041] The training subunit is used to process the text after the word segmentation processing and the sentence with the tag information by using Transformer encoding to obtain the vector to be trained.

[0042] Compared with the prior art, the present invention has the following beneficial effects:

[0043] The present invention proposes a method and system for automatically generating documents, which obtains historical documents, uses a deep learning method to perform named entity recognition on the body of the historical documents, and obtains a document body template; uses regular expressions to match the head and tail of the historical documents to obtain the head and tail templates of the document; merges the document body template and the head and tail templates into a document template, and the document template is used to generate the document. The present invention generates document templates based on deep learning combined with rules, and allows machines to learn the element rules of templates and automatically generate document templates, which can effectively avoid the problems of traditional templates being difficult to enumerate and templates being static and inflexible, simplify the operation process, reduce the time consumption of document compilation, and effectively improve the efficiency of document generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0045] Figure 1 This is a flow chart of a method for automatically generating a document in an embodiment of the present invention;

[0046] Figure 2 A schematic diagram of a neural network generating an official document text template in an embodiment of the present invention;

[0047] Figure 3 A flow chart for generating a specific document template in an embodiment of the present invention;

[0048] Figure 4 A flowchart for generating official documents in an embodiment of the present invention;

[0049] Figure 5 This is a schematic diagram of automatic extraction of document templates in an embodiment of the present invention;

[0050] Figure 6 A schematic diagram of document generation based on templates and elements in an embodiment of the present invention. DETAILED DESCRIPTION

[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0052] The purpose of the present invention is to provide a method and system for automatically generating documents, which can improve the efficiency of document generation.

[0053] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0054] Example

[0055] Figure 1 Flow chart of the method for automatically generating a document in an embodiment of the present invention. Figure 1 As shown, a method for automatically generating a document includes:

[0056] Step 101: Obtain historical documents.

[0057] Step 102: Use deep learning methods to perform named entity recognition on the main body of the historical document to obtain a document main body template.

[0058] Step 103: Use regular expressions to match the head and tail of the historical document to obtain the head and tail templates of the document.

[0059] Step 104: The document body template and the document header and footer template are combined into a document template; the document template is used to generate the document.

[0060] Step 105: Fill the document element information to be filled into the document body template and the document header and footer template to generate the document.

[0061] Document element information specifically includes: document head and tail element information and document body element information. Document head and tail element information includes: document title, document number, issuing unit, issuer, level, and category; document body element information includes: key figures in the document body, key time in the document body, and key location in the document body.

[0062] Step 102 specifically includes:

[0063] Input the main text of the historical document into the BERT model and obtain the output vector;

[0064] The output vector is input into the trained BLSTM-CRF model to obtain the label; the element, namely the named entity, is obtained through the label.

[0065] Among them, the training process of the trained BLSTM-CRF model specifically includes:

[0066] Obtain the text of the document to be trained;

[0067] Input the document text to be trained into the BERT model to obtain the vector to be trained;

[0068] The BLSTM-CRF model is trained with the vector to be trained as input and the label corresponding to the document text to be trained as output to obtain a trained BLSTM-CRF model.

[0069] Specifically, the document to be trained is input into the BERT model to obtain the vector to be trained, which includes:

[0070] Perform word segmentation processing on the text of the document to be trained to obtain a word segmented text;

[0071] Adding marking information at the beginning and end of each sentence in the document to be trained to obtain multiple sentences with marking information;

[0072] Transformer encoding is used to process the text after word segmentation and the sentences with labeled information to obtain the vectors to be trained.

[0073] The present invention also provides a document automatic generation system, comprising:

[0074] The historical document acquisition module is used to acquire historical documents.

[0075] The document body template generation module is used to perform named entity recognition on the body of historical documents using deep learning methods to obtain the document body template.

[0076] The document header and tail template generation module is used to match the header and tail of historical documents using regular expressions to obtain the document header and tail templates.

[0077] The document template generation module is used to merge the document body template and the document header and footer template into a document template; the document template is used to generate the document.

[0078] The document generation module is used to fill the document element information to be filled into the document body template and the document header and footer template to generate the document.

[0079] The document body template generation module includes:

[0080] The first input submodule is used to input the text of the historical document into the BERT model to obtain the output vector;

[0081] The second input submodule is used to input the output vector into the trained BLSTM-CRF model to obtain a label; the element, namely the named entity, is obtained through the label.

[0082] The second input submodule specifically includes:

[0083] The training unit is used to obtain the document text to be trained; input the document text to be trained into the BERT model to obtain the vector to be trained; train the BLSTM-CRF model with the vector to be trained as input and the label corresponding to the document text to be trained as output to obtain a trained BLSTM-CRF model.

[0084] Specifically, the training unit includes:

[0085] The word segmentation processing subunit is used to perform word segmentation processing on the document body to be trained to obtain a text after word segmentation processing;

[0086] A marking subunit is used to add marking information at the beginning and end of each sentence of the document body to be trained, so as to obtain a plurality of sentences with marking information;

[0087] The training subunit is used to process the text after word segmentation and the sentence with tag information using Transformer encoding to obtain the vector to be trained.

[0088] As for the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method part.

[0089] The automatic document generation method of the present invention is further described below:

[0090] Step 1:

[0091] In a narrow sense, official documents refer to formally prescribed types of documents, which are mainly divided into: reports, meeting minutes, decisions, requests for instructions, instructions, plans, notices, etc.

[0092] For some official documents with fixed formats and standardized wording, such as reports, meeting minutes, decisions, requests, instructions, plans, notifications, etc., the elements are marked. The information elements include the document title, document number, issuing unit, issuer, level, category, key persons in the body of the document, key time in the body of the document, key location in the body of the document, etc.

[0093] Use labeled data to train the model and perform named entity recognition to obtain entities in official document texts.

[0094] The main body of official documents is recognized by a method based on deep learning models, and the header and footer of official documents are recognized by a rule-based method.

[0095] Step 2:

[0096] The annotated text above is used as the training set for the named entity recognition training model BLSTM-CRF.

[0097] A deep learning-based method is used to perform named entity recognition on the content of official documents. The deep learning-based method is mainly based on sequence labeling.

[0098] Official documents mainly include the issuing unit, issuer, document number, level, category, document body and organizing unit. The BERT (Bidirectional Encoder Representation from Transformers) model is used to convert the official document text into a set of vectors.

[0099] Specifically,

[0100] The training data of official document text is defined as K = (K1, K2, ..., K n ), the maximum length of the training text data is MAX len . First, the training text data is processed by word segmentation. A special marker ([CLS]) is added to the beginning of each sentence in the text, and a special marker ([SEP]) is inserted at the end of each sentence in the text to distinguish different sentences. Each word is converted into a corresponding index using a word dictionary, which is constructed using the WordPiece algorithm. The word index, sentence segmentation encoding, and position information encoding correspond to token embeddings, segmentation embeddings, and position embeddings, respectively. The corresponding word vector, sentence vector, and position vector are added together to generate the final vector, denoted by T. T is input into the bidirectional Transformer encoding structure to obtain the final vector representation of the official document text, denoted by E.

[0101] The input of the BLSTM-CRF model is the vector E corresponding to the Chinese character sequence, and the output is the label corresponding to each Chinese character (BIO, B represents the beginning of the entity, I represents the part after the entity, and O represents the rest of the entity). The basic idea of ​​BLSTM-CRF is to convert the traditional named entity recognition problem into a sequence labeling task.

[0102] BiLSTM (Bi-directional Long Short-Term-Memory)-CRF stands for Bidirectional Long Short-Term Memory Network, which consists of forward LSTM and backward LSTM. In order to solve the problem that long-distance dependencies in sentences are difficult to capture, the traditional LSTM network was proposed, which can learn what information to remember and what information to forget during the training process. However, the LSTM modeling method often still has some problems, such as the inability to encode the relationship from back to front. In order to optimize this problem, the bidirectional LSTM was proposed. On the premise of being able to remember the previous information, the reverse LSTM is added so that it can also learn the semantic relationship with the following text. This forward and backward combination of encoding can better model the text. Figure 2 Schematic diagram for the neural network generation of official document text templates.

[0103] Combined with the official document text generated based on deep learning, a rule-based method is added to the annotated text data for named entity recognition.

[0104] For the header and tail of official documents, a rule-based named entity recognition method is used to obtain named entities. The header of an official document mainly includes the issuing unit, issuer, document number, level, and category; the tail mainly includes the undertaking unit.

[0105] By maintaining a professional vocabulary dictionary for official documents, the document number and date are matched using regular expressions, the level and category are matched by the maintained professional vocabulary dictionary, and the issuing unit, the hosting unit and the issuer are determined according to the document category. The fixed format of the issuing unit and the hosting unit of different document categories is XX ministry, and the fixed format of the issuer is XX cadre.

[0106] The above deep learning-based and rule-based named entity recognition methods are used to generate specific document templates, such as Figure 3 shown.

[0107] Step 3: After the document template is generated, the user can manually fill in the elements and fill in the slots in the template to generate the required document. Figure 4 shown.

[0108] In order to obtain a document template, we can use the historical document as input, use the trained neural network to perform named entity recognition, and obtain the character positions of the time, place, person and other element information in the document. According to the results of the neural network recognition, the input historical document is segmented, and the position of the element information is used as the empty space to be filled, and the corresponding information content is used to fill in, so as to obtain the document template. Figure 5 shown.

[0109] Based on the instructions, according to the type of document to be generated, the corresponding template is matched from the automatically extracted template library, and the document element information of the user is filled into the extracted document template, so as to generate the target document that meets the requirements. The schematic diagram of document generation based on templates and elements is shown in the figure below. Figure 6 shown.

[0110] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only used to help understand the method and core ideas of the present invention. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for automatically generating a document, characterized in that: include: Acquisition of historical documents; Using deep learning methods to perform named entity recognition on the body of the historical document to obtain a document body template; The head and tail of the historical document are matched using regular expressions to obtain the head and tail templates of the document; Merging the document body template and the document beginning and end template into a document template; The document template is used to generate a document; The body part of the historical document is subjected to named entity recognition using a deep learning method to obtain a document body template, which specifically includes: Input the main text of the historical document into the BERT model to obtain an output vector; Input the output vector into the trained BLSTM-CRF model to obtain a label; the label is used to determine the named entity; The training process of the trained BLSTM-CRF model specifically includes: Obtain the text of the document to be trained; Input the document text to be trained into the BERT model to obtain a vector to be trained; The BLSTM-CRF model is trained by taking the vector to be trained as input and the label corresponding to the document text to be trained as output to obtain a trained BLSTM-CRF model; The step of inputting the document text to be trained into the BERT model to obtain the vector to be trained specifically includes: The document body to be trained is processed by word segmentation to obtain a text after word segmentation, specifically, each word is converted into a corresponding index using a word dictionary, and the word dictionary is constructed using a WordPiece algorithm; Adding marking information at the beginning and end of each sentence in the document to be trained to obtain a plurality of sentences with marking information; The text after the word segmentation processing and the sentence with the tag information are processed by using Transformer encoding to obtain the vector to be trained.

2. The method for automatically generating documents according to claim 1, characterized in that: After merging the document body template and the document head and tail template into a document template, the method further includes: Fill the document element information to be filled into the document body template and the document header and footer template accordingly to generate the document.

3. The method for automatically generating a document according to claim 2, characterized in that: The document element information specifically includes: The information of the beginning and end elements of the document and the main body of the document; The document head and tail element information includes: the document title, document number, issuing unit, issuer, grade, and category; The document body element information includes: key persons in the document body, key time in the document body, and key locations in the document body.

4. A document automatic generation system, characterized in that: include: A historical document acquisition module is used to acquire historical documents; A document body template generation module, used to perform named entity recognition on the body of the historical document using a deep learning method to obtain a document body template; A document header and footer template generation module is used to match the header and footer of the historical document using regular expressions to obtain the document header and footer templates; A document template generation module, used for merging the document body template and the document head and tail template into a document template; The document template is used to generate a document; The document body template generation module specifically includes: A first input submodule, used to input the text of the historical document into the BERT model to obtain an output vector; The second input submodule is used to input the output vector into the trained BLSTM-CRF model to obtain a label; the label is used to determine the named entity; The second input submodule specifically includes: A training unit is used to obtain a document text to be trained; input the document text to be trained into a BERT model to obtain a vector to be trained; train the BLSTM-CRF model with the vector to be trained as input and a label corresponding to the document text to be trained as output to obtain a trained BLSTM-CRF model; The training unit specifically includes: A word segmentation processing subunit is used to perform word segmentation processing on the document body to be trained to obtain a text after word segmentation processing, specifically, using a word dictionary to convert each word into a corresponding index, and the word dictionary is constructed using a WordPiece algorithm; A marking subunit, used for adding marking information at the beginning and end of each sentence of the document body to be trained, so as to obtain a plurality of sentences with marking information; The training subunit is used to process the text after the word segmentation processing and the sentence with the tag information by using Transformer encoding to obtain the vector to be trained.

Citation Information

Patent Citations

  • Dispute case entity identification method and device, computer equipment and storage medium

    CN111062834A