A method and system for automatically formatting official documents

Through Bert pre-trained model and language big model, semantic analysis and word segmentation of official document data is performed on official document data, combined with HMM word segmentation model and user historical data, the problem of inaccurate identification and word segmentation of official document elements in the existing technology is solved, and the semantic integrity of official document data is achieved Improvement of sexuality and work efficiency.

CN118690722BActive Publication Date: 2025-02-14SHANDONG GENTLE S&T DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411034130.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2025-02-14
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

The existing automatic formatting system has inaccuracies in the identification of official document elements and word segmentation, resulting in incomplete semantics of elements such as official document titles, affecting work efficiency and smooth government orders.

Method used

The Bert pre-trained model is used to perform semantic analysis and feature recognition on official document data, combine user historical data and open source dictionary to build a training library, use HMM word segmentation model and language big model to perform iterative training, and use semantic complete word segmentation vectors to perform official document paragraph segmentation and typesetting.

Benefits of technology

It realizes the accurate identification and word segmentation of official document elements, ensures the semantic integrity of official document data, and improves work efficiency and smooth government orders.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690722B_ABST
    Figure CN118690722B_ABST
Patent Text Reader

Abstract

The invention discloses an official document automatic formatting method and system, which relates to the field of artificial intelligence technology, and comprises the following steps: inputting an official document for identification and typesetting; preprocessing the input official document data; identifying the elements of the input official document data; preprocessing the data in the training library and inputting it into the word segmentation model of HMM for word segmentation, and outputting the word segmentation label; converting the word segmentation label, character and word of each word segmentation in the training library into vectors and inputting them into a language big model, and iteratively training the vectors; inputting the BERT model output vectors into the language big model to obtain semantically complete word segmentation vectors, and segmenting official document paragraphs of different elements based on the semantically complete word segmentation vectors and appropriate segmentation rules; dividing the segmented official document data into lines according to the upper limit of the number of words in each line, and then obtaining the semantically complete official document typesetting, which is conducive to improving work efficiency and smooth government orders.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an automatic document formatting method and system. Background Art

[0002] The format of official documents is the form of expression of official documents. It is determined by the content of official documents and serves the needs of the content of official documents. This is the basic idea of ​​our understanding of the format of official documents. Its standardization is not only the specific embodiment of the authority, seriousness and binding force of official documents in the form of official documents, but also helps to improve work efficiency and ensure the smooth implementation of government orders.

[0003] However, the current automatic formatting system has inaccurate recognition of official document elements such as titles and issuing agency logos, and generally uses a fixed vocabulary to segment the content of official documents, resulting in the inability to accurately identify and divide emerging words. At the same time, sentences are arbitrarily segmented when wrapping lines, which can easily lead to improper semantic expression of sentences, affecting the semantic integrity of elements such as official document titles, and is not conducive to improving work efficiency and the smooth implementation of government orders. Summary of the invention

[0004] The purpose of the present invention is to solve the shortcomings of the prior art and to propose an automatic document formatting method and system.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions:

[0006] A method for automatically formatting official documents, characterized in that it comprises the following steps:

[0007] Step S10: inputting official documents for recognition and typesetting;

[0008] Step S20: pre-processing the input document data;

[0009] Step S30: inputting the preprocessed official document data into the Bert pre-training model in row order to obtain a two-dimensional vector containing the semantic information of the entire official document, and identifying the elements of the input official document data based on the mapping relationship between the two-dimensional vector and the official document elements;

[0010] Step S40: Collecting historical official document data of the user and building a training library based on an open source data dictionary, pre-processing the data in the training library and inputting it into the HMM word segmentation model for word segmentation, and outputting word segmentation labels;

[0011] Step S50: converting the segmentation label, character and word of each segmentation in the training library into a vector and inputting it into the language model for iterative training;

[0012] Step S60: Input the output vector of the BERT pre-training model into the language model to obtain a semantically complete word segmentation vector, and segment the official document paragraphs of different elements based on the semantically complete word segmentation vector and appropriate segmentation rules;

[0013] Step S70: dividing the segmented official document data into lines according to the upper limit of the number of words in each line, and then obtaining a semantically complete official document layout;

[0014] Preferably, the format of the official document may be .docx, .doc, .Excel or .pdf;

[0015] Preferably, in step S20, the process of preprocessing the input document data includes cleaning and standardizing the document data;

[0016] Preferably, the cleaning and standardization processing specifically include data type verification, data validity check and data storage format unification;

[0017] Preferably, in step S30, the process of identifying the elements of the input official document data includes: firstly, sending the content of the official document data to the Bert pre-training model in row order to obtain a two-dimensional sentence vector containing the semantic information of the entire row, splicing the multiple two-dimensional sentence vectors to obtain a two-dimensional vector that can represent the semantic information of the entire official document data, obtaining a paragraph vector and a position vector according to the content of the official document, combining the two-dimensional sentence vector, paragraph vector and position vector to form an information matrix vector, and identifying the elements of the input official document data based on the mapping relationship between the information matrix vector and the official document elements;

[0018] Preferably, in step S40, the word segmentation tag includes position information of each character in the corresponding word segmentation, namely, the first position, the middle position and the last position;

[0019] Preferably, in step S60, the segmentation rules may include punctuation segmentation rules, syntactic segmentation rules and segmentation rules based on text features. Different segmentation rules may be preset according to different text types and text formats, and the text to be processed may be reasonably segmented by different segmentation rules.

[0020] The present application also provides an automatic document formatting system, which includes an input module, and the input module is used to input document data.

[0021] Preferably, the format of the official document may be .docx, .doc, .Excel or .pdf.

[0022] A preprocessing module is used to clean and standardize the input document data.

[0023] Preferably, the cleaning and standardization processing specifically include data type verification, data validity check and data storage format unification.

[0024] Bert pre-training model module, the Bert pre-training model module is used to input the pre-processed official document data into the Bert pre-training model in row order to obtain a two-dimensional vector containing the semantic information of the entire official document, obtain a paragraph vector and a position vector according to the content of the official document, combine the two-dimensional sentence vector, paragraph vector and position vector to form an information matrix vector, and identify the elements of the input official document data based on the mapping relationship between the information matrix vector and the official document elements.

[0025] The collection module is used to collect users' historical document data and build a training library based on open source data dictionaries.

[0026] The HMM word segmentation model module is used to pre-process the data in the training library and input it into the HMM word segmentation model for word segmentation, and output word segmentation labels.

[0027] Preferably, the word segmentation tag includes position information of each character in the corresponding word segmentation, namely, the first position, the middle position and the last position.

[0028] The vector conversion module is used to convert the segmentation label, character and word of each segmentation in the training library into a vector.

[0029] The language model module is used to input the vectors of the word segmentation labels, characters and word conversions into the language model, perform iterative training on it, and input the output vectors of the BERT pre-trained model into the language model to obtain semantically complete word segmentation vectors.

[0030] The segmentation module is used to segment official document paragraphs of different elements based on the semantically complete word segmentation vector and appropriate segmentation rules.

[0031] The rearrangement module is used to re-line the segmented official document data according to the upper limit of the number of words in each line, and then obtain a semantically complete official document layout.

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

[0033] The present invention can realize accurate and rapid identification of official document elements through the two-dimensional vector that can represent the semantic information of the entire official document output based on the Bert pre-training model and the mapping relationship between the two-dimensional vector and the official document elements; the present invention constructs a training library through the user's historical official document data and an open source data dictionary, and uses the HMM word segmentation model, the large language model, etc. to iteratively train the word segmentation of the training library, which can realize self-learning and real-time updating of the official document vocabulary, so that the word segmentation of the official document data can keep pace with the times, be more accurate and complete, and the semantic expression is more complete; 3. The present invention segments official document paragraphs of different elements based on semantically complete word segmentation vectors and reasonable segmentation rules, and re-lines the segmented official document data according to the upper limit of the number of words in each line, avoiding the problem of incomplete semantics caused by line breaks of official document elements. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 The present invention provides a schematic diagram of the block diagram of an automatic document formatting method.

[0035] Figure 2 The present invention provides a schematic diagram of the block diagram of an automatic document formatting system. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical scheme and advantages of the implementation of this application clearer, the technical scheme in the implementation of this application will be described in more detail in combination with the drawings in the implementation of this application. In the drawings, the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The described implementation is a part of the implementation of this application, not all of the implementations. The implementation described below with reference to the drawings is exemplary and is intended to be used to explain this application, and cannot be understood as a limitation on this application. Based on the implementation in this application, all other implementations obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. The implementation of this application is described in detail below in combination with the drawings.

[0037] Figure 1 It is a flow chart of a preferred embodiment of the method for automatically formatting official documents of the present application.

[0038] The first aspect of the present application provides a method for automatically formatting official documents, comprising:

[0039] Step S10: inputting official documents for recognition and typesetting;

[0040] Step S20: pre-processing the input document data;

[0041] Step S30: inputting the preprocessed official document data into the Bert pre-training model in row order to obtain a two-dimensional vector containing the semantic information of the entire official document, and identifying the elements of the input official document data based on the mapping relationship between the two-dimensional vector and the official document elements;

[0042] Step S40: Collecting historical official document data of the user and building a training library based on an open source data dictionary, pre-processing the data in the training library and inputting it into the HMM word segmentation model for word segmentation, and outputting word segmentation labels;

[0043] Step S50: converting the segmentation label, character and word of each segmentation in the training library into a vector and inputting it into the language model for iterative training;

[0044] Step S60: Input the output vector of the BERT pre-training model into the language model to obtain a semantically complete word segmentation vector, and segment the official document paragraphs of different elements based on the semantically complete word segmentation vector and appropriate segmentation rules;

[0045] Step S70: dividing the segmented official document data into lines according to the upper limit of the number of words in each line, and then obtaining a semantically complete official document layout.

[0046] In this embodiment, the official document is input through a client such as WPS, and the format of the official document can be .docx, .doc, .Excel or .pdf. Then, the input official document data is cleaned and standardized, such as data type proofreading, data validity checking, and data storage format unification.

[0047] In this embodiment, the input official document is identified by the Bert pre-training model, specifically including: inputting the pre-processed official document data into the Bert pre-training model in row order, obtaining a two-dimensional sentence vector containing the semantic information of the entire line of text, so each row corresponds to a two-dimensional sentence vector, splicing these two-dimensional sentence vectors in the order of input, and finally obtaining a two-dimensional vector containing the semantic information of the entire official document, and obtaining a paragraph vector and a position vector according to the content of the official document. Specifically, according to the division of the official document text paragraphs, the full text is divided into three parts, namely, the header, the body and the colophon, and the paragraph vector is formed through numerical mapping. At the same time, since the relative position of the elements is also relatively fixed, the relative position relationship between the paragraphs is converted into a position vector, and the two-dimensional sentence vector, the paragraph vector and the position vector are combined to form an information matrix vector, and each information matrix vector corresponds to a specific official document element. Therefore, the element identification of official document data can be realized through the Bert pre-training model.

[0048] In this embodiment, by collecting historical official document data of users and building a training library based on an open source data dictionary, the data in the training library is preprocessed and then input into the HMM word segmentation model for word segmentation. Through the HMM word segmentation model, the word segmentation label corresponding to each word in the training library is output, and the word segmentation label includes the position information of each character in the corresponding word segmentation. The position information of each character can be expressed as one of B (begin), M (middle), E (end), and S (single), wherein B (begin) represents the starting position of the character in the corresponding word segmentation, that is, the beginning position of the word; M (middle) represents the middle position of the character in the corresponding word segmentation, that is, the middle position of the word; E (end) represents the ending position of the character in the corresponding word segmentation, that is, the end position of the word; S (single) represents that the character itself is a word, that is, a single word. The language model is trained according to the word segmentation label of each word in the training library; specifically, the word segmentation label of each word in the training library can be converted into a label vector, a character vector of each character, and a word vector of each word, which are collectively used as input data and input into the language model for training.

[0049] In this embodiment, the output vector of the BERT model is input into the language model to obtain a semantically complete word segmentation vector; based on the semantically complete word segmentation vector and appropriate segmentation rules, the official document paragraphs of different elements are segmented. The segmentation rules may include punctuation segmentation rules, syntactic segmentation rules, and segmentation rules based on text features. Different segmentation rules may be preset according to different text types and text formats, and the processed text may be reasonably segmented by different segmentation rules. Among them, the punctuation segmentation rule can use the five punctuation marks of comma, period, question mark, exclamation mark and semicolon as punctuation marks, and use the period as the segmentation rule to segment the text information to be processed. In addition, line breaks, paragraph marks, etc. can also be used as higher-level segmentation marks to segment the text information to be processed. In addition to punctuation segmentation rules, syntax segmentation rules and segmentation rules based on text features, punctuation combined with digital restriction segmentation rules can also be included. The specific segmentation process is: according to different official document types, the sentence length threshold of each sentence is set, including the highest value and the lowest value. First, the text to be processed is segmented according to the punctuation segmentation rule to obtain the segmentation unit, and then it is determined whether the segmentation unit exceeds the highest sentence length threshold. For the segmentation unit exceeding the highest sentence length threshold, it can be segmented according to the comma (or semicolon, ellipsis, etc.); for the segmentation unit less than the highest sentence length threshold, the segmentation unit can be spliced ​​with the previous segmentation unit.

[0050] In this embodiment, the segmented official document data is divided into lines according to the upper limit of the number of words in each line, thereby obtaining a semantically complete official document layout.

[0051] like Figure 2 As shown, the present application also provides an automatic document formatting system, including: an input module, wherein the input module is used to input document data.

[0052] In this embodiment, the format of the official document may be .docx, .doc, .Excel or .pdf.

[0053] A preprocessing module is used to clean and standardize the input document data.

[0054] In this embodiment, the cleaning and standardization processing specifically include data type verification, data validity check and data storage format unification.

[0055] Bert pre-training model module, the Bert pre-training model module is used to input the pre-processed official document data into the Bert pre-training model in row order to obtain a two-dimensional vector containing the semantic information of the entire official document, obtain a paragraph vector and a position vector according to the content of the official document, combine the two-dimensional sentence vector, paragraph vector and position vector to form an information matrix vector, and identify the elements of the input official document data based on the mapping relationship between the information matrix vector and the official document elements.

[0056] The collection module is used to collect users' historical document data and build a training library based on open source data dictionaries.

[0057] The HMM word segmentation model module is used to pre-process the data in the training library and input it into the HMM word segmentation model for word segmentation, and output word segmentation labels.

[0058] Preferably, the word segmentation tag includes position information of each character in the corresponding word segmentation, namely, the first position, the middle position and the last position.

[0059] The vector conversion module is used to convert the segmentation label, character and word of each segmentation in the training library into a vector.

[0060] The language model module is used to input the vectors of the word segmentation labels, characters and word conversions into the language model, perform iterative training on it, and input the output vectors of the BERT pre-trained model into the language model to obtain semantically complete word segmentation vectors.

[0061] The segmentation module is used to segment official document paragraphs of different elements based on the semantically complete word segmentation vector and appropriate segmentation rules.

[0062] The rearrangement module is used to re-line the segmented official document data according to the upper limit of the number of words in each line, and then obtain a semantically complete official document layout.

[0063] The modules or units involved in the embodiments described in this application may be implemented by software or hardware. The modules or units described may also be set in a processor, and the names of these modules or units do not constitute limitations on the modules or units themselves in some cases.

[0064] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for automatically formatting official documents, characterized in that: The following steps are involved: step S10: input official documents for recognition and typesetting; Step S20: pre-processing the input document data; Step S30: inputting the preprocessed official document data into the Bert pre-training model in row order to obtain a two-dimensional vector containing the semantic information of the entire official document, and identifying the elements of the input official document data based on the mapping relationship between the two-dimensional vector and the official document elements; In the step S30, the process of identifying the elements of the input official document data includes: firstly, sending the content of the official document data to the Bert pre-training model in row order to obtain a two-dimensional sentence vector containing the semantic information of the entire row, splicing multiple two-dimensional sentence vectors to obtain a two-dimensional vector that can represent the semantic information of the entire official document data, obtaining a paragraph vector and a position vector according to the content of the official document, combining the two-dimensional sentence vector, paragraph vector and position vector to form an information matrix vector, and identifying the elements of the input official document data based on the mapping relationship between the information matrix vector and the official document elements; Step S40: Collecting historical official document data of the user and building a training library based on an open source data dictionary, pre-processing the data in the training library and inputting it into the HMM word segmentation model for word segmentation, and outputting word segmentation labels; In step S40, the word segmentation tag includes the position information of each character in the corresponding word segmentation, that is, the first position, the middle position and the last position; Step S50: converting the segmentation label, character and word of each segmentation in the training library into a vector and inputting it into the language model for iterative training; Step S60: Input the BERT model output vector into the language model to obtain a semantically complete word segmentation vector, and segment the official document paragraphs of different elements based on the semantically complete word segmentation vector and a preset segmentation rule; In step S60, the segmentation rules include punctuation segmentation rules, syntactic segmentation rules, and segmentation rules based on text features. Different segmentation rules are preset according to different text types and text formats, and the text to be processed is reasonably segmented by different segmentation rules. Step S70: dividing the segmented official document data into lines according to the upper limit of the number of words in each line, and then obtaining a semantically complete official document layout.

2. The method for automatic document formatting according to claim 1, characterized in that: The format of the official document is .docx, .doc, .Excel or .pdf.

3. The method for automatic document formatting according to claim 1, characterized in that: In the step S20, the process of preprocessing the input document data includes cleaning and standardizing the document data.

4. The method for automatic document formatting according to claim 3, characterized in that: The cleaning and standardization process specifically includes data type verification, data validity check and data storage format unification.

5. An automatic document formatting system, which uses the method described in any one of claims 1 to 4, characterized in that: The automatic formatting system includes an input module, which is used to input official document data; a preprocessing module, which is used to clean and standardize the input official document data; a Bert pre-training model module, which is used to input the pre-processed official document data into the Bert pre-training model in row order to obtain a two-dimensional vector containing the semantic information of the entire official document, and identify the elements of the input official document data based on the mapping relationship between the two-dimensional vector and the official document elements. The process of identifying the elements of the input official document data includes: first, sending the content of the official document data to the Bert pre-training model in row order to obtain a two-dimensional sentence vector containing the semantic information of the entire row, splicing multiple two-dimensional sentence vectors to obtain a two-dimensional vector that can represent the semantic information of the entire official document data, obtaining a paragraph vector and a position vector according to the content of the official document, combining the two-dimensional sentence vector, paragraph vector and position vector to form an information matrix vector, and identifying the elements of the input official document data based on the mapping relationship between the information matrix vector and the official document elements; The acquisition module is used to collect the user's historical document data and build a training library based on an open source data dictionary; the HMM word segmentation model module is used to pre-process the data in the training library and input it into the HMM word segmentation model for word segmentation, and output the word segmentation label, the word segmentation label includes the position information of each word in the corresponding word segmentation, that is, the first position, the middle position and the last position; the vector conversion module is used to convert the word segmentation label, character and word of each word segmentation in the training library into a vector; the language large model module is used to input the vector converted from the word segmentation label, character and word into the language large model for iterative training; The output vector of the BERT pre-trained model module is input into the language large model module to obtain a semantically complete word segmentation vector; a segmentation module is used to segment official document paragraphs of different elements based on the semantically complete word segmentation vector and segmentation rules, wherein the segmentation rules include punctuation segmentation rules, syntactic segmentation rules, and segmentation rules based on text features. Different segmentation rules are preset according to different text types and text formats, and the processed text is reasonably segmented by different segmentation rules; a rearrangement module is used to re-line the segmented official document data according to the upper limit of the number of words in each line, and then obtain a semantically complete official document layout.

Citation Information

Patent Citations

  • Chinese entity identification method based on BERT and Word2Vec vector fusion

    CN112632997A

  • Text recognition desensitization method and system

    CN114298035A