Document generation method and device, storage medium and electronic equipment
By using semantic similarity analysis and intelligent matching technology, the document generation process is automated, solving the problems of low efficiency and insufficient accuracy in traditional methods, and achieving efficient and accurate automatic document generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- YGSOFT INC
- Filing Date
- 2024-11-28
- Publication Date
- 2026-08-04
AI Technical Summary
Traditional methods for automatically generating documents are inefficient and inaccurate, especially when dealing with complex data sources, where inconsistencies and errors in human operation can easily occur, leading to misaligned or missing information.
By acquiring target templates, table data, and topics, and utilizing semantic similarity analysis and intelligent matching technology, the system automatically determines the directory titles and matches the table data with relevant text content to the corresponding directories, generating accurate target documents.
It improves the efficiency and accuracy of automatic document generation, reduces human intervention, and ensures the professionalism and consistency of document content.
Smart Images

Figure CN119670714B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more specifically, to a method, apparatus, storage medium, and electronic device for generating documents. Background Technology
[0002] In today's information age, document automatic generation technology has become a key tool for improving work efficiency and reducing human error, especially in fields such as law, finance, scientific research, and education, where there is a high demand for the rapid generation of large numbers of reports and documents. However, when faced with complex and diverse data sources, the limitations of traditional automatic generation methods are becoming increasingly apparent, mainly in terms of efficiency and accuracy.
[0003] The inefficiency stems from the over-reliance on manual operations in traditional methods. Parsing document templates and filling in content, constructing tables of contents, and extracting key information from tables all require manual intervention. This is not only time-consuming, but also significantly increases the inconsistency and error risk of manual operations when processing large-scale data. Especially when processing tables, complex formatting such as merged cells, blank values, and negative numbers becomes a formidable obstacle, greatly impacting the accuracy and efficiency of data extraction.
[0004] The lack of accuracy is attributed to the deficiencies of existing technologies in integrating and matching structured data with document content. In traditional methods, the association between data and text relies mainly on manual judgment. This often leads to information misalignment or omissions when processing documents with complex structures and high information density, seriously affecting the integrity and professionalism of the documents.
[0005] There is currently no effective solution to the above problems. Summary of the Invention
[0006] This application provides a document generation method, apparatus, storage medium, and electronic device to at least solve the technical problems of low efficiency and low accuracy in conventional methods when automatically generating documents.
[0007] According to one aspect of this application, a method for generating a document is provided, comprising: obtaining a target template, table data, and a target topic input by a target user; determining a target directory title associated with the target topic based on the target template; calculating the semantic similarity between the table data, target content, and the target directory title, wherein the target content is text content associated with the target topic and the target directory title obtained from a target library, wherein the target library is a database including data and documents related to various businesses; and matching the table data and the target content to the corresponding target directory title based on the semantic similarity to obtain a target document corresponding to the target topic.
[0008] Optionally, determining the target directory title associated with the target topic based on the target template includes: parsing the target template to obtain the directory structure, directory title, and corresponding text content of the directory title; generating a target directory title that matches the target topic based on the directory structure and directory title of the target template, wherein the target directory title has the same format as the directory title.
[0009] Optionally, calculating the semantic similarity between the table data, the target content, and the target directory title includes: cleaning the table data to obtain the target table data, wherein the data cleaning is used to handle merged cells, empty values, and negative numbers in the table; converting the data in the target table data into tuple form to obtain a set of tuples corresponding to the target table data, wherein each tuple in the set of tuples represents a row of data in the target table data; constructing M first indices based on the set of tuples, wherein M is an integer greater than or equal to 1, the key of the first index is used to represent any data feature in the set of tuples, and the value of the first index is used to represent the tuples in the set of tuples that include the data feature; constructing N second indices based on the target content, wherein N is an integer greater than or equal to 1, the key of the second index is used to represent any data feature in the target content, and the value of the second index is used to represent the text content in the target content that includes the data feature; and determining the semantic similarity between the table data, the target content, and the target directory title based on the M first indices and the N second indices.
[0010] Optionally, determining the semantic similarity between the table data, the target content, and the target directory title based on M first indices and N second indices includes: extracting title features from S titles in the target directory title to obtain S title features, where S is an integer greater than or equal to 1; retrieving tuples associated with the i-th title feature from the M first indices based on the i-th title feature among the S title features, and calculating the first semantic similarity between the tuple and the i-th title feature, where i is a positive integer less than or equal to S; and retrieving text content associated with the i-th title feature from the N second indices based on the i-th title feature among the S title features, and calculating the second semantic similarity between the text content and the i-th title feature.
[0011] Optionally, matching the tabular data with the target content based on semantic similarity to the corresponding target directory title yields the target document corresponding to the target topic. This includes: if the first semantic similarity between the tuple and the i-th title feature is greater than a first preset threshold, using the tuple as the first tuple; if the second semantic similarity between the text content and the i-th title feature is greater than a second preset threshold, using the text content as the first text content; associating the first tuple, the first text content, and the title corresponding to the i-th title feature, and converting them into a dictionary to obtain the dictionary corresponding to the i-th title feature; and obtaining the target document corresponding to the target topic based on the S dictionaries corresponding to the S title features.
[0012] Optionally, based on the S dictionaries corresponding to the S title features, a target document corresponding to the target topic is obtained, including: expanding and integrating the text content of the S dictionaries, the target topic, and the target template according to the large language model to generate the target document.
[0013] Optionally, after matching the table data with the target content to the corresponding target directory title based on semantic similarity to obtain the target document corresponding to the target topic, the document generation method further includes: performing format validation on the target document based on the target template to obtain the format-validated target document.
[0014] According to another aspect of this application, a document generation apparatus is also provided, comprising: an acquisition unit for acquiring a target template, table data, and a target topic input by a target user; a determination unit for determining a target directory title associated with the target topic based on the target template; a calculation unit for calculating the semantic similarity between the table data, target content, and the target directory title, wherein the target content is text content associated with the target topic and the target directory title obtained from a target library, wherein the target library is a database including data and documents associated with various businesses; and a matching unit for matching the table data and the target content to the corresponding target directory title based on the semantic similarity, thereby obtaining a target document corresponding to the target topic.
[0015] According to another aspect of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed, the device on which the computer-readable storage medium is located performs the above-described document generation method.
[0016] According to another aspect of this application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the document generation method described above.
[0017] In this application, the target template, table data, and target topic input by the target user are first obtained. Then, the target directory title associated with the target topic is determined based on the target template. Next, the semantic similarity between the table data, target content, and target directory title is calculated to evaluate their relevance and matching degree. The target content is the text content associated with the target topic and target directory title obtained from the target library, which is a database containing data and documents related to various businesses. Finally, the table data and target content are matched to the corresponding target directory title based on semantic similarity to obtain the target document corresponding to the target topic. That is, through semantic similarity analysis and intelligent matching, the goal of highly customized and accurate matching of document content is achieved, thereby improving the efficiency and accuracy of automatic document generation and solving the technical problems of low efficiency and low accuracy of traditional methods in automatic document generation. Attached Figure Description
[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0019] Figure 1 This is a flowchart of an optional document generation method according to an embodiment of this application;
[0020] Figure 2 This is a schematic diagram of an optional document generation method according to an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of an optional document generation apparatus according to an embodiment of this application. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0024] It should also be noted that the information and data collected in this application are authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with the relevant laws, regulations, and standards of the relevant regions, and necessary confidentiality measures have been taken. This does not violate public order and good morals, and corresponding access points are provided for users to choose to authorize or refuse. For example, this system has interfaces with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface, and the relevant information is obtained only after receiving consent from the aforementioned user or organization.
[0025] According to an embodiment of this application, an embodiment of a document generation method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0026] It should be noted that a document generation system is used as the execution subject of the document generation method in this application embodiment. It is understood that the document generation method provided in this application embodiment can also be executed by other systems or devices, and this application embodiment does not specifically limit this.
[0027] Figure 1 This is a flowchart of an optional document generation method according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0028] Step S101: Obtain the target template, table data, and target theme input by the target user.
[0029] Optionally, the target template is a pre-set document template by the user, including document structure, title and some fixed content, used to guide the automatic generation of the document; the target topic is the core topic or business requirement around which the document to be generated by the user revolves.
[0030] Optionally, the document generation system receives the target template, tabular data, and specific target topic input by the user.
[0031] Step S102: Determine the target directory title associated with the target topic based on the target template.
[0032] Optionally, the document generation system determines the table of contents related to the user-input topic based on the target template and target topic.
[0033] Step S103: Calculate the semantic similarity between the table data, the target content, and the target directory title.
[0034] In step S103, the target content is the text content obtained from the target library that is associated with the target topic and the target directory title.
[0035] In step S103, the target library is a database that includes data and documents related to various business operations.
[0036] Optionally, the target repository is a knowledge base, which is a database containing information from multiple domains. This information is organized and categorized, covering everything from basic data, technical terms, and industry standards to complex theoretical knowledge and practical experience. The data in the knowledge base may come from multiple sources, including but not limited to publicly available literature and resources, professional databases, historically produced documents, user input, and feedback.
[0037] Optionally, the document generation system calculates the semantic similarity between the table data, the target content, and the target directory title to measure the degree of similarity between two or more texts or data in meaning, and to determine the relevance between the table data and the target content and the target directory title.
[0038] Step S104: Match the table data with the target content according to semantic similarity and place them under the corresponding target directory title to obtain the target document corresponding to the target topic.
[0039] Optionally, the document generation system matches the table data with the target content based on semantic similarity and assigns them to the corresponding target directory headings. The final generated document meets the user's needs, including precisely matched table data and target content, and is a document that perfectly matches the target topic.
[0040] As can be seen from steps S101 to S104, in this application, the target template, table data, and target topic input by the target user are first obtained. Then, the target directory title associated with the target topic is determined based on the target template. Next, the semantic similarity between the table data, target content, and target directory title is calculated to evaluate their relevance and matching degree. The target content is the text content associated with the target topic and target directory title obtained from the target library. The target library is a database that includes data and documents related to various businesses. Finally, the table data and target content are matched to the corresponding target directory title based on the semantic similarity to obtain the target document corresponding to the target topic. That is, through semantic similarity analysis and intelligent matching, the purpose of highly customized and accurate matching of document content is achieved, thereby improving the efficiency and accuracy of automatic document generation and solving the technical problems of low efficiency and low accuracy of traditional methods in processing automatic document generation.
[0041] In one optional embodiment, the document generation system first parses the target template to obtain the target template's directory structure, directory titles, and corresponding text content. Then, it generates a target directory title that matches the target topic based on the target template's directory structure and directory titles, wherein the target directory title has the same format as the directory title.
[0042] Optionally, the document generation system can intelligently predict and populate table of contents titles based on the user-input topic and the structure of existing templates, maintaining overall formatting consistency.
[0043] Optionally, the document generation system employs regular expressions and natural language processing technologies to perform deep analysis of the target template uploaded by the target user. Through these technologies, the system can accurately identify the directory structure, directory titles, and corresponding content in the template. Then, the system segments these identified directory titles and content and stores them as independent text files. This processing method not only ensures the clarity of the document structure and facilitates the subsequent management and retrieval of the directory and content by the system, but also maintains the traceability of the content. Then, based on the parsed directory structure and directory titles, the document generation system automatically generates a set of new directory titles that closely match the target topic input by the user through a large language model and knowledge base, while maintaining the same format as the original template directory titles.
[0044] As described above, the document generation system, through regular expressions and natural language processing technology, can identify and parse the directory structure of the target template, extract the directory titles and related text content, greatly simplifying the initial preparation steps for document generation and improving overall efficiency. Furthermore, based on the target theme provided by the user, it can intelligently generate a new directory title set that is consistent with the format of the original template's directory titles. The generated target directory titles have the same format as the original template's directory titles, but the content is more closely aligned with the target theme, achieving standardization of document format and personalized customization of content. This meets the specific requirements for document format and content in different business scenarios. Simultaneously, through automated parsing and intelligent generation of directory titles, the system significantly reduces manual intervention in the document generation process, lowers the risk of errors caused by manual operation, and improves the accuracy and reliability of document generation.
[0045] In one optional embodiment, the document generation system first cleans the table data to obtain target table data. The data cleaning process handles merged cells, null values, and negative numbers in the table. Next, the data in the target table data is converted into tuples, resulting in a set of tuples corresponding to the target table data. Each tuple in the set represents a row of data in the target table data. Then, M first indices are constructed based on the tuple set, where M is an integer greater than or equal to 1. The key of the first index represents any data feature in the tuple set, and the value of the first index represents the tuples in the set that include the data feature. Following this, N second indices are constructed based on the target content, where N is an integer greater than or equal to 1. The key of the second index represents any data feature in the target content, and the value of the second index represents the text content in the target content that includes the data feature. Finally, the semantic similarity between the table data, the target content, and the target directory title is determined based on the M first indices and the N second indices.
[0046] Optionally, the document generation system receives a target template, table data with complex formatting, and a target topic provided by the user. First, it cleans the table data to handle special formats such as merged cells, empty values, and negative numbers, ensuring data integrity and consistency. Next, it converts the cleaned table data into a structured set of tuples (e.g., extracting key numerical information from the table data and converting it into a tuple structure), where each tuple corresponds to a row or column of records in the table, facilitating subsequent data processing and index construction. Then, the document generation system constructs M first indexes, where M is an integer greater than or equal to 1. The key value of each first index corresponds to a specific data feature in the tuple set, such as date, amount, or name, while the index value contains all tuples containing that feature. This facilitates rapid retrieval and matching of specific data. Subsequently, the system retrieves text content related to the target topic and target directory title from the knowledge base (target database) and constructs N second indexes, where N is also an integer greater than or equal to 1. The key value of each second index corresponds to a data feature in the text, and the index value contains all text fragments containing that feature. This ensures that content highly relevant to the target topic can be accurately identified. Finally, based on the constructed first and second indexes, the system calculates the semantic similarity between the table data and the target content under different directory titles to determine their matching relationship. Through semantic similarity analysis and intelligent matching, the system associates the key information in the table data with the most relevant text content and integrates it under the target directory title to generate a complete and accurate target document.
[0047] As described above, the document generation system automates the handling of merged cells, empty values, and negative numbers, reducing manual intervention, accelerating data preparation, and ensuring data quality and consistency in subsequent processing. It converts tabular data into a set of tuples, facilitating rapid retrieval and efficient processing, and improving the flexibility and speed of matching data with document content. By constructing first and second indexes, it enables rapid location of data features and instant retrieval of relevant text content, significantly reducing search time and improving matching efficiency. Through semantic similarity calculation, the system intelligently matches tabular data with the most relevant text content and integrates it under the target directory heading, ensuring the accuracy and professionalism of document generation and avoiding incorrect matching and information omissions.
[0048] In one optional embodiment, the document generation system extracts title features from S titles in the target directory title to obtain S title features, where S is an integer greater than or equal to 1. Then, based on the i-th title feature among the S title features, it retrieves the tuple associated with the i-th title feature from M first indices and calculates the first semantic similarity between the tuple and the i-th title feature, where i is a positive integer less than or equal to S. Finally, based on the i-th title feature among the S title features, it retrieves the text content associated with the i-th title feature from N second indices and calculates the second semantic similarity between the text content and the i-th title feature.
[0049] Optionally, the document generation system first extracts S title features from the target directory titles. These features can be keywords, phrases, or other descriptive elements. Then, for each extracted title feature, i.e., the i-th title feature (where i is a positive integer less than or equal to S), the system retrieves all tuples closely related to that feature from the previously constructed M first indices and calculates the first semantic similarity between these tuples and the i-th title feature. Through this index retrieval mechanism, the system can quickly locate tabular data related to the directory title features, avoiding full table scans and significantly improving data matching efficiency. Next, the system continues to use N second indices to retrieve associated text content based on the same set of title features, i.e., the i-th title feature, and calculates the second semantic similarity between this text content and that feature. This step of calculating the second semantic similarity further enhances the system's intelligent matching capability for document content, ensuring that the generated document content is highly relevant to the target topic and directory titles.
[0050] As can be seen from the above, the document generation system utilizes the constructed first and second indexes to achieve rapid retrieval and matching, avoiding a full-scale scan of the entire database, greatly improving the speed and efficiency of data processing. By calculating the first semantic similarity between tuples and title features, and the second semantic similarity between text content and title features, the system can intelligently filter out the data and content most relevant to the table of contents title features, ensuring the accuracy and professionalism of document generation, reducing manual intervention, and lowering the error rate.
[0051] In one optional embodiment, the document generation system uses a tuple as the first tuple if the first semantic similarity between the tuple and the i-th title feature is greater than a first preset threshold, and uses the text content as the first text content if the second semantic similarity between the text content and the i-th title feature is greater than a second preset threshold. Then, the first tuple, the first text content, and the title corresponding to the i-th title feature are associated and converted into a dictionary to obtain the dictionary corresponding to the i-th title feature. Finally, based on the S dictionaries corresponding to the S title features, the target document corresponding to the target topic is obtained.
[0052] Optionally, the keys of the dictionary represent the various headings in the target directory headings. These headings form the skeleton of the document structure and are stored in the form of keys for easy subsequent location and content filling. The values are the table data and text content that match the heading. The combination of values ensures a close relationship between the table data and the text content, making it easy for the system to automatically fill in the corresponding content based on the directory headings.
[0053] Optionally, the document generation system introduces two preset thresholds when matching tuples with text content to ensure that the matching degree between data and content reaches a certain standard. When the first semantic similarity between a tuple and the i-th title feature exceeds the first preset threshold, the tuple is considered a "first tuple," meaning it is sufficiently relevant to the specific title feature and can be used as part of the matching data. Similarly, when the second semantic similarity between the text content and the i-th title feature exceeds the second preset threshold, the text content is marked as "first text content," indicating that its relevance and matching degree with the title feature also meet the requirements. The system then associates this set of first tuples and first text content with the corresponding i-th title feature and converts them into dictionary form, creating a dictionary corresponding to the i-th title feature. The keys and values in the dictionary represent title features, matching table data, and text content, respectively, forming a structured data set that facilitates subsequent document generation operations. Ultimately, the system constructs corresponding dictionaries based on the extracted S title features, and then integrates these S dictionaries to generate a document structure and content that perfectly matches the target topic. This method ensures that every step in the document generation process is based on highly matched data, improving the accuracy and professionalism of the generated documents.
[0054] As can be seen from the above, the document generation system incorporates highly matched data and content into the document, significantly improving the professionalism and relevance of the generated document. This better meets the specific needs of users, not only improving the professionalism and accuracy of the document but also significantly enhancing the efficiency and quality of document generation. Furthermore, the adoption of a dictionary structure enables the system to quickly retrieve and integrate information, greatly accelerating the document generation speed and improving work efficiency.
[0055] In one optional embodiment, the document generation system expands and integrates the text content of S dictionaries, target topics, and target templates based on a large language model to generate a target document.
[0056] Optionally, the document generation system utilizes a large language model to deeply expand and integrate the S pre-built dictionaries, the user-input target topic, and the original text content in the target template to generate the final target document. The S dictionaries contain tabular data and text content related to different title features. These dictionaries, as input to the large model, provide the specific information and data foundation required for document generation. Through the processing of the large model, the system can understand the information in these dictionaries and, combined with the target topic, generate more in-depth and comprehensive content. Simultaneously, it integrates with the original content in the target template, ensuring that the generated document includes automatically processed data while maintaining the style and framework of the user-generated template.
[0057] Optionally, the document generation system obtains the document content from the decomposed target template, creates a corresponding index for the document content, and compares the target title with the document content using the same method as calculating the similarity between tuples and target titles. The semantic similarity is calculated, aiming to identify the content fragment most relevant to each target title, ensuring that every part of the new document closely adheres to the theme requirements. When the calculated similarity between the content and the title exceeds a set threshold, the system adds these content fragments to the corresponding title in the newly generated document, thus ensuring the relevance and accuracy of the document content. This process not only improves the intrinsic quality of the document but also ensures that the new document maintains consistency with the target template in structure and content, while incorporating more in-depth information related to the theme, enhancing the document's professionalism and readability.
[0058] Optionally, Figure 2 This is a schematic diagram of an optional document generation method according to an embodiment of this application, such as... Figure 2As shown, the user inputs a text template, a table, and a topic. The document generation system segments the text template into a text template directory and content, storing the directory in one file and the titles and their corresponding content in another. This segmentation facilitates separate processing of the directory and content. Next, based on the text template directory and the user-input topic, a new directory title is generated. Then, the user-input table data is extracted and processed, and Natural Language Processing (NLP) is used to convert the processed table data into tuples. Subsequently, based on similarity matching, the table data and the generated text content (topic-related content generated from a knowledge base) are inserted into the most similar directory. This involves generating a dictionary structure corresponding to the directory titles, table data, and text content. Finally, a large language model is used to generate the chapters of a new document based on the matched dictionary, the new directory titles, and the text template content. These are then combined to form the target document. Additionally, it should be noted that users can also input relevant keywords for the system to generate and match content.
[0059] As can be seen from the above, the document generation system, through its large-scale model content generation capabilities, not only expands the document content but also adds in-depth analysis and professional knowledge, enhancing the professionalism and information content of the documents. This significantly accelerates the content expansion and integration process, reduces manual intervention, saves labor costs, and improves the efficiency of document generation.
[0060] In one optional embodiment, the document generation system performs format validation on the target document based on the target template to obtain the format-validated target document.
[0061] Optionally, after generating the target document, the document generation system initiates a format verification process. This step ensures that the generated document conforms to the format requirements of the target template, including but not limited to font type, font size, paragraph spacing, heading levels, and figure / table positions. Through format verification, the system can automatically check whether the target document fully follows the style and layout specifications of the target template, effectively avoiding visual confusion and a decrease in professionalism caused by inconsistent formatting.
[0062] For example, regarding the organization of scientific research literature, users upload relevant research topics and related literature database information through the system. The system uses natural language processing technology to extract literature abstracts, keywords, and main research results, automatically arranges the literature review according to the specified format, and provides citation formatting functions. For market research reports, users upload survey questionnaire data and statistical results through the system. The system automatically generates market research reports containing charts, data analysis, and conclusions according to the preset report structure, supporting multiple chart types and data visualization options. For the automated generation service of legal documents, users input the basic facts of the case and legal clauses. The system automatically matches the corresponding legal document templates based on this information, generates legal documents such as contracts and complaints, and automatically performs format verification and clause review. For the creation of courseware in the education industry, users provide course outlines and knowledge points. The system combines educational resource libraries to automatically generate courseware containing teaching objectives, content summaries, exercises, and answers, supporting the integration of multiple teaching media resources. For the organization of medical records, the system extracts patient medical records, examination results, and treatment records from the hospital information system, automatically generates structured medical reports and discharge summaries, ensuring the standardization and accuracy of medical documents. As can be seen from the above, document generation systems, by combining technologies such as natural language processing, data analysis, template matching, and content generation, can achieve automated document generation in various fields, significantly improving the speed and quality of document processing, while also reducing error rates and enhancing the consistency and professionalism of information.
[0063] As can be seen from the above, format verification ensures that the target document generated by the system is completely consistent with the target template in terms of format, improving the professional appearance and overall quality of the document. This automated verification process reduces the need for manual inspection, avoids format errors caused by human negligence or omission, improves the efficiency and reliability of document generation, and, based on the target template, enables the system to generate documents that conform to specific styles and standards, meet the format requirements of different industries and scenarios, and enhance the flexibility and applicability of the service.
[0064] According to another aspect of the embodiments of this application, a schematic diagram of a document generation apparatus is also provided. Figure 3 This is a schematic diagram of an optional document generation apparatus according to an embodiment of this application, such as... Figure 3 As shown, the document generation device includes: an acquisition unit 301, a determination unit 302, a calculation unit 303, and a matching unit 304.
[0065] Optionally, the acquisition unit 301 is used to acquire the target template, table data, and target topic input by the target user; the determination unit 302 is used to determine the target directory title associated with the target topic based on the target template; the calculation unit 303 is used to calculate the semantic similarity between the table data, target content, and target directory title, wherein the target content is text content associated with the target topic and target directory title obtained from the target library, wherein the target library is a database including data and documents associated with various businesses; and the matching unit 304 is used to match the table data and target content to the corresponding target directory title based on the semantic similarity to obtain the target document corresponding to the target topic.
[0066] Optionally, the determining unit 302 includes: a first parsing subunit and a first generating subunit. The first parsing subunit is used to parse the target template to obtain the target template's directory structure, directory titles, and corresponding text content. The first generating subunit is used to generate a target directory title that matches the target topic based on the target template's directory structure and directory titles, wherein the target directory title has the same format as the directory title.
[0067] Optionally, the calculation unit 303 includes: a first processing subunit, a first transformation subunit, a first construction subunit, a second construction subunit, and a first determination subunit. The system comprises the following subunits: a first processing subunit for cleaning the table data to obtain target table data, wherein data cleaning is performed to handle merged cells, empty values, and negative numbers in the table; a first transformation subunit for converting the data in the target table data into tuple form to obtain a set of tuples corresponding to the target table data, wherein each tuple in the set of tuples represents a row of data in the target table data; a first construction subunit for constructing M first indices based on the set of tuples, wherein M is an integer greater than or equal to 1, the key of the first index is used to represent any data feature in the set of tuples, and the value of the first index is used to represent the tuples in the set of tuples that include the data feature; a second construction subunit for constructing N second indices based on the target content, wherein N is an integer greater than or equal to 1, the key of the second index is used to represent any data feature in the target content, and the value of the second index is used to represent the text content in the target content that includes the data feature; and a first determination subunit for determining the semantic similarity between the table data, the target content, and the target directory title based on the M first indices and the N second indices.
[0068] Optionally, the first determining subunit includes: a first extraction module, a first calculation module, and a second calculation module. The first extraction module is used to extract title features from S titles in the target directory titles, resulting in S title features, where S is an integer greater than or equal to 1; the first calculation module is used to retrieve tuples associated with the i-th title feature from M first indices based on the i-th title feature among the S title features, and calculate a first semantic similarity between the tuple and the i-th title feature, where i is a positive integer less than or equal to S; the second calculation module is used to retrieve text content associated with the i-th title feature from N second indices based on the i-th title feature among the S title features, and calculate a second semantic similarity between the text content and the i-th title feature.
[0069] Optionally, the matching unit 304 includes: a second determining subunit, a third determining subunit, a second processing subunit, and a fourth determining subunit. The second determining subunit is used to classify a tuple as a first tuple if the first semantic similarity between the tuple and the i-th title feature is greater than a first preset threshold; the third determining subunit is used to classify the text content as first text content if the second semantic similarity between the text content and the i-th title feature is greater than a second preset threshold; the second processing subunit is used to associate the first tuple, the first text content, and the title corresponding to the i-th title feature, and convert them into a dictionary to obtain the dictionary corresponding to the i-th title feature; the fourth determining subunit is used to obtain the target document corresponding to the target topic based on the S dictionaries corresponding to the S title features.
[0070] Optionally, the fourth determining subunit includes: a first generation module, used to expand and integrate the text content of S dictionaries, target topics, and target templates according to the large language model, and generate a target document.
[0071] Optionally, the document generation apparatus further includes a verification unit, used to perform format verification on the target document according to the target template, to obtain the format-verified target document.
[0072] According to another aspect of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed, the device on which the computer-readable storage medium is located performs the above-described document generation method.
[0073] According to another aspect of this application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the above-described document generation method.
[0074] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0075] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0076] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0077] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0078] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0079] If the integrated unit is implemented as 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 this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0080] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method of generating a document, characterized by, include: Obtain the target template, table data, and target theme input by the target user; Determine the target directory titles associated with the target topic based on the target template; Calculate the semantic similarity between the table data, the target content, and the target directory title, wherein the target content is text content obtained from the target library that is associated with the target topic and the target directory title, and wherein the target library is a database that includes data and documents associated with various businesses; Based on the semantic similarity, the table data and the target content are matched to the corresponding target directory title to obtain the target document corresponding to the target topic; Determine the target directory titles associated with the target topic based on the target template, including: The target template is parsed to obtain the directory structure, directory titles, and text content corresponding to the directory titles. Based on the directory structure and directory titles of the target template, a target directory title matching the target topic is generated using a large language model and knowledge base, wherein the target directory title has the same format as the directory title.
2. The document generation method according to claim 1, characterized in that, Calculating the semantic similarity between the table data, the target content, and the target directory title includes: The table data is cleaned to obtain the target table data, wherein the data cleaning is used to process merged cells, blank values and negative numbers in the table; The data in the target table data is converted into tuples to obtain a set of tuples corresponding to the target table data, wherein each tuple in the set of tuples represents a row of data in the target table data; M first indices are constructed based on the tuple set, where M is an integer greater than or equal to 1. The key of the first index is used to characterize any data feature of the tuple set, and the value of the first index is used to characterize the tuple in the tuple set that includes the data feature. N second indices are constructed based on the target content, where N is an integer greater than or equal to 1. The key of the second index is used to represent any data feature in the target content, and the value of the second index is used to represent the text content in the target content that includes the data feature. The semantic similarity between the table data, the target content, and the target directory title is determined based on M first indices and N second indices.
3. The document generation method according to claim 2, characterized in that, Determining the semantic similarity between the table data, the target content, and the target directory title based on M first indices and N second indices includes: Extract the title features of S titles from the target directory titles to obtain S title features, where S is an integer greater than or equal to 1; Based on the i-th title feature among the S title features, retrieve the tuple associated with the i-th title feature from the M first indices, and calculate the first semantic similarity between the tuple and the i-th title feature, where i is a positive integer less than or equal to S; Based on the i-th title feature among the S title features, retrieve the text content associated with the i-th title feature from the N second indices, and calculate the second semantic similarity between the text content and the i-th title feature.
4. The document generation method according to claim 3, characterized in that, Based on the semantic similarity, the table data is matched with the target content and placed under the corresponding target directory title to obtain the target document corresponding to the target topic, including: If the semantic similarity between the tuple and the i-th title feature is greater than a first preset threshold, the tuple is taken as the first tuple; If the second semantic similarity between the text content and the i-th title feature is greater than a second preset threshold, the text content is used as the first text content; Associate the first tuple, the first text content, and the title corresponding to the i-th title feature, and convert them into dictionary form to obtain the dictionary corresponding to the i-th title feature; Based on the S dictionaries corresponding to the S title features, the target document corresponding to the target topic is obtained.
5. The document generation method according to claim 4, characterized in that, Based on the S dictionaries corresponding to the S title features, a target document corresponding to the target topic is obtained, including: The target document is generated by expanding and integrating the text content of the S dictionaries, the target topic, and the target template based on the large language model.
6. The document generation method according to claim 1, characterized in that, After matching the table data with the target content according to the semantic similarity to the corresponding target directory title to obtain the target document corresponding to the target topic, the document generation method further includes: The target document is format-validated based on the target template to obtain the format-validated target document.
7. A document generation apparatus, characterized in that, include: The acquisition unit retrieves the target template, table data, and target theme input by the target user. The determining unit determines the target directory title associated with the target topic based on the target template; The calculation unit calculates the semantic similarity between the table data, the target content, and the target directory title, wherein the target content is text content obtained from the target library that is associated with the target topic and the target directory title, and the target library is a database that includes data and documents associated with various businesses; The matching unit matches the table data with the target content according to the semantic similarity and assigns them to the corresponding target directory title to obtain the target document corresponding to the target topic; it also determines the target directory title associated with the target topic according to the target template, including: The target template is parsed to obtain the directory structure, directory titles, and text content corresponding to the directory titles. Based on the directory structure and directory titles of the target template, a target directory title matching the target topic is generated using a large language model and knowledge base, wherein the target directory title has the same format as the directory title.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed, the device on which the computer-readable storage medium is located performs the document generation method according to any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to perform the document generation method according to any one of claims 1 to 6.