A method and apparatus for generating an official document
By extracting target text elements and matching official document templates, it automatically converts them to standard formats, and solves the problem of cumbersome formats manually adjusting the formats, achieving convenience and high efficiency of official document generation.
Patent Information
- Application Number
- CN202111272153.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2041-10-29
AI Technical Summary
When writing official documents in the form of electronic documents, users need to manually adjust the font size, font type, line spacing, etc., which leads to cumbersome and inefficient operations. Especially when generating multiple types of official documents, it takes a lot of time and effort.
By receiving a request for the official document generation for the target text, the target text elements are extracted, the matching official document template is determined, and the target text elements are converted into a standard format to generate the corresponding official document.
It realizes automatic extraction of target text elements and matching document templates, and quickly generates official documents, reducing the steps of manual editing by users, improving convenience and generation efficiency.
Smart Images

Figure CN114048712B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of electronic document processing, and particularly to a method and apparatus for generating official documents. Background Art
[0002] In government agencies, official documents are usually required to convey government decrees and policies and handle official business. Official documents (official business documents) are written materials formed and used by legal agencies and organizations in official activities according to specific formats and through certain processing procedures.
[0003] In the related art, when writing official documents in the form of electronic documents, it is usually manually operated by users. Users need to continuously adjust the font size, font type, line spacing, etc. to obtain official documents that meet the format specifications, which makes the operation of users cumbersome and inconvenient. Moreover, the formats corresponding to different types of official documents are also different. If users want to generate multiple types of official documents, they need to edit them separately according to the formats corresponding to each type, which takes a lot of time and effort and has low efficiency. Summary of the Invention
[0004] In view of this, this application provides a method and apparatus for generating official documents.
[0005] Specifically, this application is implemented through the following technical solutions:
[0006] A method for generating an official document, comprising:
[0007] Receiving an official document generation request initiated for a target text;
[0008] Extracting target text elements included in the target text;
[0009] Determining a target official document template matched by the target text based on the target text elements;
[0010] For each of the target text elements, determining a standard format corresponding to a template text element of the same type as the target text element in the target official document template;
[0011] Converting the target text elements into the standard format, and generating a corresponding official document for the target text based on the target text elements converted into the standard format.
[0012] An apparatus for generating an official document, comprising:
[0013] A receiving unit, receiving an official document generation request initiated for a target text;
[0014] An extracting unit, extracting target text elements included in the target text;
[0015] A matching unit that determines a target official document template matched with the target text based on the target text element;
[0016] A determining unit that, for each of the target text elements, determines a standard format corresponding to a template text element of the same type as the target text element in the target official document template;
[0017] A generating unit that converts the target text element into the standard format, and generates a corresponding official document for the target text based on the target text element converted into the standard format.
[0018] As can be seen from the above description, in an embodiment of the present application, after receiving an official document generation request initiated by a user for a target text, several target text elements included in the target text can be extracted, a target official document template matched based on the target text elements is determined, and then for each target text element, a standard format corresponding to a template text element of the same type as the element in the target official document template is determined, the target text element is converted into the standard format, and a corresponding official document is generated for the target text based on the target text element converted into the standard format.
[0019] By using the above method, the target text elements can be automatically extracted according to the target text provided by the user, and the corresponding official document template can be matched, and then an official document can be quickly generated according to the target text elements and the official document template. The entire process does not require the user to manually edit to generate an official document, which improves convenience and the efficiency of official document generation. Description of the Drawings
[0020] Figure 1 is a flowchart showing a method for generating an official document according to an exemplary embodiment of the present application;
[0021] Figure 2 is a flowchart showing another method for generating an official document according to an exemplary embodiment of the present application;
[0022] Figure 3 is a schematic diagram of a page according to an exemplary embodiment of the present application;
[0023] Figure 4 is a schematic diagram of a hardware structure of an electronic device where an official document generation device according to an exemplary embodiment of the present application is located;
[0024] Figure 5 is a block diagram of an official document generation device according to an exemplary embodiment of the present application. Detailed Embodiments
[0025] Exemplary embodiments will be described in detail herein, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0026] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit the present application. The singular forms "a", "the", and "said" used in this application and the appended claims are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0027] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".
[0028] With the continuous development of technology, more and more fields use electronic documents to replace traditional paper documents, which greatly facilitates people's work and life. In government agencies, official documents can be edited through electronic documents to convey government decrees and policies and handle official business based on the official documents. Official documents are materials formed and used by legal organs and organizations in official activities and usually have specific formats, which requires relevant personnel to strictly comply with the format requirements when editing official documents.
[0029] In the related art, official documents are usually manually edited by users. Users need to continuously adjust the font size, font type, line spacing, etc. in the document to obtain official documents that meet the format specifications, which results in cumbersome operations for users and is not convenient enough. Moreover, the formats corresponding to different types of official documents are also different. If users want to edit and obtain multiple types of official documents, they need to edit them separately according to the formats corresponding to each type, which requires a large amount of time and energy and has low efficiency.
[0030] Based on this, the present application provides a method for generating official documents, which can quickly generate corresponding official documents from target texts through a preset official document template, improve the efficiency of generating official documents, and improve the user experience.
[0031] First, some concepts involved in the present application will be described:
[0032] Target text: It refers to the text to be processed and for which an official document needs to be generated, which can be provided by the user after independent compilation. There are no special restrictions on the content and format of the target text.
[0033] Text elements: It refers to several elements obtained by dividing the content of an official document. Text elements can include various types, such as title, body text, attachment description, confidentiality level, etc., and various types of text elements can be preset. For example, if the text element type is "issuing agency", the corresponding text element content can be "Documents of Guangzhou Municipal People's Government".
[0034] Target text elements: Text elements extracted from the target text.
[0035] Template text elements: Text elements included in the official document template.
[0036] Official document template: It refers to a pre-set template for generating official documents. The official document template can include several different types of template text elements and the standard formats corresponding to each type of template text element. Among them, the official document template can only include the types of template text elements, such as "issuing agency", or it can also include the types of template text elements and the corresponding default content, such as "Issuing agency: xx Municipal People's Government", and there are no special restrictions on this. Also, the standard format corresponding to each template text element can be set in the template, and the standard format can include: font, font size, font color, background color, line thickness, line length, etc.
[0037] After clarifying the above content, the following describes an embodiment of a method for generating an official document provided by this application.
[0038] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a method for generating an official document shown in an exemplary embodiment of this application. The method can be applied to an electronic device having a memory and a processor, and an application software for document editing, for example, can be installed on the electronic device.
[0039] The method for generating an official document may include the following steps:
[0040] Step 102, receiving an official document generation request initiated for the target text;
[0041] Step 104, extracting the target text elements included in the target text;
[0042] Step 106, determining the target official document template matched by the target text based on the target text elements;
[0043] Step 108. For each of the target text elements, determine the standard format corresponding to the template text element of the same type as the target text element in the target official document template.
[0044] Step 110. Convert the target text element into the standard format, and generate the corresponding official document based on the target text element converted into the standard format.
[0045] The above steps will be described in detail below.
[0046] In this embodiment, several official document templates can be preset in advance. For example, the templates can be set according to the types of official documents. Common types of official documents such as regulations, provisions, measures, decisions, orders, instructions, replies, notices, letters, reports, meeting minutes, etc. can have corresponding official document templates set for each type of official document. Moreover, the format requirements for different types of official documents are also different, so different official document templates can include different template text elements and different formats of template text elements.
[0047] In this embodiment, the user can initiate an official document generation request for the target text, which can be obtained by the user's independent editing or by other means. The user can initiate the official document generation request by clicking on relevant buttons or controls on the client page.
[0048] After the client receives the official document generation request, it can extract several target text elements from the target text. For example, several types of text elements can be preset in advance. For the header, the following types of text elements can be included: serial number, confidentiality level, confidentiality period, urgency level, issuing agency logo, document number, signatory, etc.; for the main body, the following types of text elements can be included: title, main recipient, body text, annex description, issuing agency signature, date of issue, seal, appendix, annex, etc.; for the footer, the following types of text elements can be included: carbon copy recipient, printing agency, printing date, etc. It can be determined whether the above types of text elements exist in the target official document. If so, the specific content of the text element can be extracted as the target text element.
[0049] Among them, the specific method of extracting text elements from the target official document can refer to related technologies, and this application does not make special restrictions on this. Similarly, text elements can be extracted from the target text based on a semantic analysis algorithm; or they can be extracted based on pre-configured extraction rules, which can be determined based on keywords or positions. For example, if the keyword of a certain text in the target text is recognized as a date and the text is located at a preset position in the target text, it can be determined as a text element related to the date. Another example is that if a certain text in the target text contains the keyword "carbon copy recipient", then this text can be determined as a text element related to the carbon copy recipient.
[0050] After extracting the target text elements, the target official document template matching the target text can be determined based on the target text elements. For example, the target text elements can be matched with the types of template elements included in each official document template, and the target official document template that matches can be determined based on the matching degree. Or the target official document template can also be determined by other means. This will be described in detail in the following embodiments.
[0051] In this embodiment, after determining the target official document template, for each target text element extracted from the target text, the template text element of the same type as the target text element in the target official document template can be determined, and the standard format of the template text element can be determined. Then the target text element is converted into this standard format, and the corresponding official document is generated from the target text according to this standard format. This will be described in detail in the following embodiments.
[0052] As can be seen from the above description, in an embodiment of the present application, several official document templates can be preset in advance. After receiving the official document generation request initiated by the user for the target text, several target text elements included in the target text can be extracted, the target official document template that matches can be determined based on the target text elements, and then for each target text element, the standard format corresponding to the template text element of the same type as the element in the target official document template is determined, the target text element is converted into the said standard format, and the corresponding official document is generated from the target text based on the said standard format.
[0053] By using the above method, the target text elements can be automatically extracted from the target text provided by the user, the corresponding official document template can be matched, and then the official document can be quickly generated according to the target text elements and the official document template. The whole process does not require the user to manually edit to generate the official document, which improves the convenience and the efficiency of official document generation.
[0054] Next, an embodiment of another method for generating an official document provided by the present application will be described. The method described in this embodiment can be applied to text editing application software, such as Microsoft Office, WPS Office, etc.
[0055] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of another method for generating an official document shown in an exemplary embodiment of the present application. The method may include the following steps:
[0056] Step 202, receive the official document generation request initiated for the target text.
[0057] Step 204, extract the target text elements included in the target text.
[0058] In this embodiment, a target document can be specified, and a official document generation request is initiated based on the target document. The text contained in the target document is the target text.
[0059] After the client receives the official document generation request, it can first determine whether the target document is an invalid document, such as whether it is an empty document or a protected document. If so, it is determined to be invalid, and an exception reminder can be output to the user to prompt the user to re-upload the document. If not, it is determined that the document is valid, and the target text elements can be extracted from the target text included in the document. The specific method for extracting the target text elements can refer to the foregoing embodiments and will not be elaborated here.
[0060] Step 206, determine the target official document type to which the target text belongs based on the target text elements.
[0061] In this embodiment, the target official document type to which the target text belongs can be first determined according to the target text elements, and then the corresponding official document template can be found based on the target official document type. This can improve the accuracy of the found official document template and also improve the accuracy of the finally generated official document.
[0062] For example, the title of the target text can be determined from the target text elements, and the target official document type to which the target text belongs is determined based on the title.
[0063] Specifically, the title content of the target text can be extracted, and the target official document type to which the target text belongs is determined according to the title content. For example, the title usually includes some keywords, such as "Notice", "Meeting Minutes", etc., and the target official document type to which the target text belongs can be determined according to these keywords.
[0064] For another example, the element type of the target text elements can also be determined, and then the target official document type to which the target text belongs is determined according to the element type. For example, each official document type can correspond to different types of text elements. The higher the matching degree between the target text elements and the text element type corresponding to a certain official document type, the higher the possibility that the target text belongs to this official document type.
[0065] Of course, the target official document type can also be determined by other means. For example, the body content can be extracted from the target text elements, and the target official document type is determined by performing semantic analysis on the body content. Specifically, it can refer to related technologies, and this application will not elaborate one by one here.
[0066] Step 208, determine the corresponding target official document template based on the target official document type.
[0067] In this embodiment, a mapping relationship between official document templates and official document types can be preset in advance. The target official document type to which the target text belongs can be determined based on the target text elements, and then the official document template corresponding to the target official document type can be determined as the target official document template based on the mapping relationship.
[0068] Among them, one official document type can correspond to only one official document template, or can correspond to multiple official document templates. When the target official document type corresponds to only one official document template, this corresponding official document template can be directly used as the target official document template. When the target official document type corresponds to multiple official document templates, these multiple official document templates can be further screened to determine the target official document template.
[0069] For example, multiple official document templates can be sorted according to their frequency of use in actual application scenarios, and then the official document template with the highest frequency of use can be selected as the target official document template.
[0070] For another example, for each official document template corresponding to the target official document type, the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text can be determined, and the target official document template matched by the target text can be determined based on the matching degree.
[0071] Among them, there can be multiple calculation methods for the matching degree:
[0072] In one example, the text elements of the same type among the template text elements included in the official document template and the target text elements can be determined, and then the matching degree can be determined based on the text elements of the same type.
[0073] For example, it is assumed that the template elements included in official document template 1 are type a, b, c, and the text element types extracted from the target text are a, b, e, f. Then the text elements of the same type are a and b.
[0074] The proportion of the text elements of the same type in the template text elements included in the official document template can be determined, and the matching degree can be determined based on the first proportion. That is, if the first proportion is 2 / 3, the first proportion can be directly used as the matching degree.
[0075] The proportion of the text elements of the same type in the target text elements can also be determined, and the matching degree can be determined based on the second proportion. That is, if the second proportion is 2 / 4 = 1 / 2, the second proportion can be directly used as the matching degree.
[0076] In another example, the matching degree can also be determined based on the first proportion and the second proportion.
[0077] Taking the above example, the first proportion is 2 / 3 and the second proportion is 1 / 2. Further, weights can be assigned to the first proportion and the second proportion, and the weighted sum of the first proportion and the second proportion is calculated as the matching degree. If the weights are both 1, then the matching degree is 2 / 3 + 1 / 2 = 7 / 6.
[0078] Taking the above example, official document template 1 includes 3 template text elements, that is, the first quantity is 3, and the target text includes 4 text elements, that is, the second quantity is 4, then the matching degree can be 3 / 4.
[0079] In this example, when there are multiple official document templates corresponding to the target official document type, the official document template with the highest matching degree can be used as the target official document template.
[0080] Of course, in addition to the above examples, the matching degree can also be determined by other methods. For example, the official document template can also be set with key template element types, and the matching degree is determined based on the matching degree between the target text element type and the key element type.
[0081] For example, assume that the key element type of official document template 1 is "signature", and its feature is a short signature, and the key element type of official document template 2 is "signature", and its feature is a long signature. Then the content of the target text element "signature" in the target text can be determined, and then it is judged whether it belongs to a long signature or a short signature. For example, it can be judged according to the number of characters. If it belongs to a long signature, it is determined that its type matching degree with official document template 2 is higher; if it belongs to a short signature, it is determined that its type matching degree with official document template 1 is higher.
[0082] In addition to the above examples, the matching degree can also be determined by other methods. Or, multiple methods can be combined to determine the matching degree, and this application does not list them one by one here.
[0083] In this embodiment, the target official document template can be automatically determined. For example, the template with the highest matching degree is automatically determined as the template official document template based on the above matching degree method, or the priority of each official document template can be determined based on the matching degree. For example, the higher the matching degree, the higher the priority, and then the candidate official document templates corresponding to the target official document type are displayed in descending order of priority. The user can initiate an official document generation request for any candidate official document template. After receiving the official document generation request initiated for any candidate official document template, the candidate official document template targeted by the official document generation request can be determined as the target official document template, and there is no special limitation on this.
[0084] In this embodiment, if it is impossible to determine the official document type to which the target text belongs, or after determining the official document type, the matching degree between the target text elements and the template text elements included in the official document template corresponding to the official document type is lower than the threshold, then it is impossible to determine a suitable target official document template. In this case, it can be determined that the official document template lacks the template text elements corresponding to the target text elements. Then, an abnormal reminder of text element deficiency can be output to the user to remind the user to supplement the text elements. Of course, it is also possible to select a default official document template as the target official document template corresponding to the target text. This default template can be, for example, the most common and most used template in the actual application scenario, such as the template corresponding to the document type of "notice". And for the situation of text element deficiency, a general format, position, etc. can be used for these missing text elements to generate an official document. That is to say, in this embodiment, compared with the target text elements in the target text, the types or quantities of the template text elements in the target official document template do not necessarily correspond one by one. The method for generating an official document in this embodiment is applicable to this non-one-to-one corresponding situation, and a general format and position can also be used to typeset the missing text elements to solve the problem of inability to typeset due to non-one-to-one correspondence.
[0085] Step 210, for each target text element, determine the standard format corresponding to the template text element of the same type as the target text element in the corresponding template.
[0086] In this embodiment, for each target text element extracted from the target text, a template text element of the same type as the target text element can be determined from the target official document template corresponding to the target text, and the standard format of the template text element can be obtained.
[0087] Among them, when determining the template text element of the same type as the target text element, the following three situations may occur:
[0088] (1) The target official document template includes a template text element of the same type as the target text element.
[0089] In this case, the corresponding standard format can be directly obtained according to the template text element.
[0090] (2) The target official document template does not include a template text element of the same type as the target text element.
[0091] For example, the target text element includes a first text element, while the target official document template does not include a template text element of the same type as the first text element. In this case, the first text element can be converted into a general format. For example, the type of the first text element can be determined, and then the corresponding general national standard format can be found from the national standard, and then the first text element can be converted into the general national standard format. Subsequently, based on the target text element converted into the standard format and the first text element converted into the general format, the corresponding official document can be generated for the target text.
[0092] (3) The template text element included in the target official document template is not of the same type as any of the target text elements.
[0093] In this case, the template text element is ignored or deleted. In the case of setting the standard format of the template text element to extract the target text element, it is ignored in a way that does not extract the template text element; in the case of filling the target text element into the target official document template, the template text element is deleted.
[0094] In this embodiment, the standard format can be font type, font size, line spacing, etc. The conversion of the standard format can be implemented through the API interface of the document editing software, such as the relevant API interface of WPS. Specifically, reference can be made to the relevant technologies, and this application will not elaborate here one by one.
[0095] Of course, in addition to the above format conversion, semantic-level conversion can also be performed on the target text element. There can be multiple specific implementation methods for this.
[0096] For example, for the text element type of the title, it can be stipulated that the standard format is no more than 15 characters, and the title extracted from the target text is 16 characters, exceeding 15 characters. Then, it can be modified to be reduced to within 15 characters while retaining the same semantics.
[0097] For another example, if there are typos, sensitive words, illegal words, etc. in the target text element extracted from the target text, it can also be modified to meet the requirements. Among them, the specific method of format conversion based on semantics can refer to the relevant technologies, and this application does not make special restrictions on this.
[0098] Step 212, generate the corresponding official document for the target text and display it.
[0099] In this embodiment, after obtaining the target text element converted into the standard format, the corresponding official document can be generated based on this standard format.
[0100] In this embodiment, the target position information of the target text element in the official document can also be determined based on the position information of the template text element in the official document. The position information can be preset, and this position information can be fixed or relatively variable. For example, the position information of the text element "title" is "in the first line of the first page", so its position in the official document is usually fixed. Another example is that the position information of the text element "attachment description" is "in the line after the body content", so its position in the official document will change with the change of the body content. If the last line of the body content is the first line of page 2, then the position of "attachment description" is the second line of page 2. If the body content increases and its last line becomes the fifth line of page 2, then the position of "attachment description" becomes the sixth line of page 2.
[0101] In this embodiment, when generating the official document corresponding to the target text based on the target text element, the template text element corresponding to the target text element can be determined. On the one hand, the standard format corresponding to the template text element can be obtained, and the target text element can be converted into the standard format. On the other hand, the position information of the template text element in the official document template can be obtained to determine the target position information of the target text element in the official document. Then, the official document corresponding to the target text can be generated based on the standard format and the target position information. For example, the target text element converted into the standard format can be typeset according to the target position information of the target text element in the official document, and the typesetting result can be used as the official document corresponding to the target text. The specific typesetting method can refer to the related technology.
[0102] The following takes an example to illustrate. Taking the element type of "title" as an example, there can be a preset title in the target official document template, such as "xxx Notice", its standard format is Song typeface, size 5, and its position information is "in the middle of the first page, 2 cm from the top of the page, and in the line above the body content". Then, the title "Notice on Policy Implementation" extracted from the target text can be used to replace "xxx Notice" in the template, convert it into the standard format of Song typeface, size 5, and generate a compliant official document according to the above position information. Of course, this example is only for illustrative purposes and does not limit this application.
[0103] In this embodiment, if the position information corresponding to the target text element cannot be determined, the official document can be generated according to the specified position.
[0104] For example, the specified position can be the position of this type of element in the official document stipulated in the national standard. For example, for the target text element type of confidentiality level, the national standard can stipulate that the serial number is followed by the confidentiality level, and the confidentiality level is followed by the urgency level. Then, the position of the target text element in the official document can be determined according to this regulation.
[0105] For another example, it is also possible to refer to the target text elements adjacent to the target text element in the target text, and then determine the position of the target text element in the target official document template according to the position corresponding to the adjacent target text element in the target official document template, so that the generated official document maintains the unchanged adjacent relationship of these target text elements.
[0106] Of course, the specified position can also be other positions, such as the default position, and this application does not make special restrictions on this.
[0107] It should be noted that here it is based on the official document template for editing to generate an official document, rather than editing the official document template itself.
[0108] In this embodiment, the generated official document can be displayed to the user.
[0109] In one example, only the generated official document can be displayed. The official document includes the target text elements extracted from the target text in standard format, and the positions of the target text elements in the official document match the positions of their corresponding template text elements in the target official document template.
[0110] In another example, in addition to displaying the official document, the target official document template for generating the official document and several candidate official document templates can also be displayed.
[0111] For example, in the aforementioned step 208, there may be multiple official document templates corresponding to the official document type to which the target text belongs. After determining the target official document template and generating an official document based on this, other candidate official document templates can also be displayed. And these candidate official document templates can also be arranged and displayed in descending order of priority. If the user believes that the official document generated based on the target official document template does not meet their requirements, they can also select the template they need from these sorted candidate official document templates to generate an official document.
[0112] Among them, there are various methods to determine the priority of the candidate official document templates. For example, the priority can be determined according to the matching degree between the target text elements and the template text elements determined in the aforementioned step 208. The higher the matching degree, the higher the priority.
[0113] For another example, the priority can also be determined according to the frequency of use of the candidate official document template in the actual scenario. The more frequently it is used, the higher the priority.
[0114] Of course, other methods can also be used to determine the priority, and this application does not list them one by one here.
[0115] Moreover, in addition to displaying a number of candidate document templates in the case where one official document type corresponds to multiple document templates as described above, candidate document templates can also be displayed in other cases. For example, each preset document template can be sorted and displayed according to priority for the user to select.
[0116] Please refer to Figure 3 , Figure 3 which is a page schematic diagram shown in an exemplary embodiment of the present application. Figure 3 Exemplarily, a page for displaying the generated official document to the user is shown. The "Notice (long signature)" marked by the dashed box is the target document template. A preview of the official document generated based on this template can be displayed in the page preview area, and the user can view the generated official document in this area. And, Figure 3 a number of non-target document templates sorted by priority can also be displayed, such as "Reply (end signature)", "Circular", "Communique", etc.
[0117] Step 214, receive a document generation request initiated for any candidate document template.
[0118] In this embodiment, the user can initiate a document generation request for any candidate document template displayed to him / her. After the client receives this request, it can execute the foregoing steps 210-212 to generate an official document for the target text based on the candidate document template specified by the user. The specific generation method refers to the foregoing steps and will not be elaborated here.
[0119] Still taking the Figure 3 example shown as an example, the user can click on the template "Reply (end signature)" to initiate a document generation request. After the client receives this request, it can use this template as the target document template, and then generate an official document for the target text based on this template and display the generated text to the user.
[0120] In this embodiment, after generating the official document, if the user is not satisfied with the format of some text elements in the official document, the user can also perform custom settings on them. For example, the user can click on the Figure 3 "Custom Settings" button at the bottom of the page, and then the user can specify the type of text element to be set and can also set the format of this type of text element. For example, the font size of the title in the target document template is No. 4, and the user can modify it to No. 5 by custom settings to assist the user in obtaining an official document that better meets his / her needs.
[0121] In this embodiment, when the user determines that the official document that meets his / her needs has been obtained, the user can also click on the relevant button to obtain the generated official document. For example, the user can click on the Figure 3 "Open Document" button in the lower right corner.
[0122] As can be seen from the above description, in an embodiment of the present application, a corresponding official document template can be established for each official document type, the type of the target text can be identified, and the corresponding official document template can be found based on this text to generate an official document, so as to obtain a more accurate official document template and finally generate a more accurate official document.
[0123] In addition, several non-target official document templates can also be presented to the user, so that the user can switch between these non-target official document templates, so as to finally obtain an official document that better meets their needs and improve the user experience.
[0124] Corresponding to the embodiment of the method for generating an official document described above, the present application also provides an embodiment of a device for generating an official document.
[0125] The embodiment of the device for generating an official document in the present application can be applied to an electronic device. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by the processor of the electronic device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running. From the hardware level, as Figure 4 shown, it is a hardware structure diagram of the electronic device where the device for generating an official document in the present application is located. In addition to Figure 4 the processor, memory, network interface, and non-volatile memory shown, the electronic device where the device is located in the embodiment usually also includes other hardware according to the actual functions of the electronic device, which will not be elaborated here.
[0126] Please refer to Figure 5 , Figure 5 which is a block diagram of a device for generating an official document shown in an exemplary embodiment of the present application. The device for generating an official document may include: a receiving unit 510, an extracting unit 520, a matching unit 530, a determining unit 540, a generating unit 550, and a displaying unit 560.
[0127] Among them, the receiving unit 510 is configured to receive an official document generation request initiated for the target text;
[0128] The extracting unit 520 is configured to extract the target text elements included in the target text;
[0129] The matching unit 530 is configured to determine the target official document template matched by the target text based on the target text elements;
[0130] The determining unit 540 is configured to determine, for each of the target text elements, the standard format corresponding to the template text elements of the same type as the target text elements in the target official document template;
[0131] A generating unit 550, configured to convert the target text element into the standard format, and generate a corresponding official document for the target text based on the target text element converted into the standard format.
[0132] Optionally, the matching unit 530 is specifically configured to:
[0133] Determine the target official document type to which the target text belongs based on the target text element;
[0134] Determine the official document template corresponding to the target official document type as the target official document template based on a preset mapping relationship.
[0135] Optionally, when the matching unit 530 determines the target official document type to which the target text belongs based on the target text element, it is specifically configured to:
[0136] Determine the title of the target text from the target text element;
[0137] Determine the target official document type to which the target text belongs based on the title.
[0138] Optionally, when the matching unit 530 determines the target official document type to which the target text belongs based on the target text element, it is specifically configured to:
[0139] Determine the target official document type to which the target text belongs based on the element type of the target text element.
[0140] Optionally, when there are multiple official document templates corresponding to the target official document type, the matching unit 530 is further configured to:
[0141] For each official document template corresponding to the target official document type, determine the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text;
[0142] Determine the target official document template matched by the target text based on the matching degree.
[0143] Optionally, when the matching unit 530 determines the target official document template matched by the target text based on the matching degree, it is specifically configured to:
[0144] Determine the text elements of the same type between the template text elements included in the official document template and the target text elements;
[0145] Determine the matching degree based on the text elements of the same type.
[0146] Optionally, when the matching unit 530 determines the target official document template matched by the target text based on the matching degree, it is specifically configured to:
[0147] Based on the matching degree, determine the priorities of each official document template;
[0148] Sort and display the candidate official document templates corresponding to the target official document type in descending order of priority;
[0149] Receive an official document generation request initiated for any candidate official document template;
[0150] Determine the candidate official document template targeted by the official document generation request as the target official document template.
[0151] Optionally, it further includes a display unit 560, and the display unit 560 is specifically configured to:
[0152] When the matching degree between the target text element and the template text element is lower than the matching degree threshold, determine that the official document template lacks the template text element corresponding to the target text element.
[0153] Optionally, the display unit 560 is further configured to:
[0154] Based on the position information of the template text element in the target official document template, determine the target position information of the target text element in the official document;
[0155] The generating unit 550 is specifically configured to: typeset the target text element converted into the standard format according to the target position information;
[0156] Use the typesetting result as the official document corresponding to the target text.
[0157] Optionally, the determining unit 540 is further configured to:
[0158] When the target official document template does not include a template text element of the same type as the first text element in the target text element, convert the first text element into a general format;
[0159] Generate the corresponding official document for the target text based on the target text element converted into the standard format and the first text element converted into the general format.
[0160] For the implementation processes of the functions and roles of each unit in the above device, please refer to the implementation processes of the corresponding steps in the above method for details, which will not be elaborated here.
[0161] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the descriptions of the method embodiments. The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this application. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0162] The systems, devices, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any several of these devices.
[0163] Corresponding to the embodiment of the foregoing official document generation method, this specification also provides an official document generation device, which includes: a processor and a memory for storing machine-executable instructions. Among them, the processor and the memory are usually interconnected by an internal bus. In other possible implementation manners, the device may further include an external interface to be able to communicate with other devices or components.
[0164] In this embodiment, by reading and executing the machine-executable instructions stored in the memory corresponding to the official document generation logic, the processor is caused to:
[0165] Receive an official document generation request initiated for a target text;
[0166] Extract the target text elements included in the target text;
[0167] Determine the target official document template matched by the target text based on the target text elements;
[0168] For each of the target text elements, determine the standard format corresponding to the template text element of the same type as the target text element in the target official document template;
[0169] Convert the target text elements into the standard format, and generate the corresponding official document for the target text based on the target text elements converted into the standard format.
[0170] Optionally, a mapping relationship between official document templates and official document types is preset. When determining the target official document template matched by the target text based on the target text elements, the processor is prompted to:
[0171] Determine the target official document type to which the target text belongs based on the target text elements;
[0172] Based on the mapping relationship, determine the official document template corresponding to the target official document type as the target official document template.
[0173] Optionally, when determining the target official document type to which the target text belongs based on the target text elements, the processor is prompted to:
[0174] Determine the title of the target text from the target text elements;
[0175] Based on the title, determine the target official document type to which the target text belongs.
[0176] Optionally, when determining the target official document type to which the target text belongs based on the target text elements, the processor is prompted to:
[0177] Based on the element type of the target text elements, determine the target official document type to which the target text belongs.
[0178] Optionally, when there are multiple official document templates corresponding to the target official document type, the processor is further prompted to:
[0179] For each official document template corresponding to the target official document type, determine the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text;
[0180] Based on the matching degree, determine the target official document template matched by the target text.
[0181] Optionally, when determining the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text, the processor is prompted to:
[0182] Determine the text elements of the same type between the template text elements included in the official document template and the target text elements;
[0183] Based on the text elements of the same type, determine the matching degree.
[0184] Optionally, when determining the target official document template matched by the target text based on the matching degree, the processor is further prompted to:
[0185] Based on the matching degree, determine the priority of each official document template;
[0186] Display the candidate document templates corresponding to the target document type in descending order of priority;
[0187] Receive a document generation request initiated for any of the candidate document templates;
[0188] Determine the candidate document template targeted by the document generation request as the target document template.
[0189] Optionally, after determining the matching degree between the template text elements included in the document template and the target text elements extracted from the target text for each document template corresponding to the target document type, the processor is further prompted to:
[0190] When the matching degree between the target text elements and the template text elements is lower than the matching degree threshold, determine that the document template lacks the template text elements corresponding to the target text elements.
[0191] Optionally, the processor is further prompted to:
[0192] Based on the position information of the template text elements in the target document template, determine the target position information of the target text elements in the document;
[0193] Generating a corresponding document for the target text based on the standard format includes:
[0194] Typeset the target text elements converted to the standard format according to the target position information;
[0195] Use the typeset result as the document corresponding to the target text.
[0196] Optionally, after determining the standard format corresponding to the template text elements of the same type as the target text elements in the target document template for each of the target text elements, the processor is further prompted to:
[0197] When the target document template does not include template text elements of the same type as the first text element type in the target text elements,
[0198] Convert the first text element to a general format;
[0199] Generate a corresponding document for the target text based on the target text elements converted to the standard format and the first text element converted to the general format.
[0200] Corresponding to the embodiments of the foregoing document generation method, this specification also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented:
[0201] Receive a document generation request initiated for the target text;
[0202] Extract the target text elements included in the target text;
[0203] Determine the target document template matched by the target text based on the target text elements;
[0204] For each of the target text elements, determine the standard format corresponding to the template text element of the same type as the target text element in the target document template;
[0205] Convert the target text elements into the standard format, and generate the corresponding document for the target text based on the target text elements converted into the standard format.
[0206] Optionally, there is a pre - set mapping relationship between the document template and the document type. The determining of the target document template matched by the target text based on the target text elements includes:
[0207] Determine the target document type to which the target text belongs based on the target text elements;
[0208] Determine the document template corresponding to the target document type as the target document template based on the mapping relationship.
[0209] Optionally, the determining of the target document type to which the target text belongs based on the target text elements includes:
[0210] Determine the title of the target text from the target text elements;
[0211] Determine the target document type to which the target text belongs based on the title.
[0212] Optionally, the determining of the target document type to which the target text belongs based on the target text elements includes:
[0213] Determine the target document type to which the target text belongs based on the element type of the target text elements.
[0214] Optionally, when there are multiple document templates corresponding to the target document type, the method further includes:
[0215] For each document template corresponding to the target document type, determine the matching degree between the template text elements included in the document template and the target text elements extracted from the target text;
[0216] Determine the target document template matched by the target text based on the matching degree.
[0217] Optionally, determining the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text includes:
[0218] Determining the template text elements included in the official document template and the text elements of the same type among the target text elements;
[0219] Determining the matching degree based on the text elements of the same type.
[0220] Optionally, determining the target official document template matched by the target text based on the matching degree includes:
[0221] Based on the matching degree, determining the priority of each official document template;
[0222] Displaying the candidate official document templates corresponding to the target official document type in descending order of priority;
[0223] Receiving an official document generation request initiated for any candidate official document template;
[0224] Determining the candidate official document template targeted by the official document generation request as the target official document template.
[0225] Optionally, after determining the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text for each official document template corresponding to the target official document type, it further includes:
[0226] When the matching degree between the target text elements and the template text elements is lower than the matching degree threshold, determining that the official document template lacks the template text elements corresponding to the target text elements.
[0227] Optionally, it further includes:
[0228] Based on the position information of the template text elements in the target official document template, determining the target position information of the target text elements in the official document;
[0229] Generating the corresponding official document for the target text based on the standard format includes:
[0230] Typesetting the target text elements converted into the standard format according to the target position information;
[0231] Taking the typeset result as the official document corresponding to the target text.
[0232] Optionally, after determining the standard format corresponding to the template text elements of the same type as the target text elements in the target official document template for each target text element, it further includes:
[0233] When the target official document template does not include a template text element of the same type as the first text element in the target text elements,
[0234] convert the first text element into a general format;
[0235] Based on the target text elements converted to the standard format and the first text element converted to the general format, generate the corresponding official document for the target text.
[0236] Embodiments of the subject matter and functional operations described in this application can be implemented in the following: digital electronic circuits, tangible computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or a combination of one or more of them. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules in computer program instructions encoded on a tangible non-transitory program carrier to be executed by a data processing device or to control the operation of a data processing device. Alternatively or additionally, the program instructions can be encoded on a manually generated propagated signal, such as a machine-generated electrical, optical, or electromagnetic signal, which is generated to encode and transmit information to a suitable receiver device for execution by a data processing device. A computer storage medium can be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them.
[0237] The processes and logical flows described in this application can be executed by one or more programmable computers executing one or more computer programs to perform corresponding functions by operating on input data and generating output. The processes and logical flows can also be executed by dedicated logic circuits—such as FPGAs (Field Programmable Gate Arrays) or ASICs (Application Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuits.
[0238] Computers suitable for executing computer programs include, for example, general and / or special-purpose microprocessors, or any other type of central processing unit. Generally, the central processing unit will receive instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include one or more mass storage devices for storing data, such as magnetic disks, magneto-optical disks, or optical disks, etc., or the computer will be operatively coupled to such mass storage devices to receive data therefrom or transfer data thereto, or both. However, a computer is not necessarily required to have such devices. In addition, a computer may be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name just a few examples.
[0239] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as including semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD ROM and DVD-ROM disks. The processor and memory may be supplemented by, or incorporated in, special-purpose logic circuitry.
[0240] Although this application contains many specific implementation details, these should not be construed as limiting the scope of any invention or the scope of what is claimed, but rather are mainly used to describe the features of specific embodiments of a particular invention. Certain features described in multiple embodiments in this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may function in certain combinations as described above and are even initially claimed as such, one or more features from a claimed combination may in some cases be removed from that combination, and the claimed combination may be directed to a sub-combination or a variation of a sub-combination.
[0241] Similarly, although operations are depicted in the drawings in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or sequentially, or that all illustrated operations be performed, to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems may generally be integrated together in a single software product, or packaged into multiple software products.
[0242] Accordingly, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the acts recited in the claims can be performed in a different order and still achieve the desired result. In addition, the processes depicted in the figures are not necessarily in the particular order or sequential order shown to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0243] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims can be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0244] The foregoing is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of protection of the present application.
Claims
1. A method for generating an official document, characterized in that, the method includes: receiving an official document generation request initiated for a target text; extracting target text elements included in the target text; determining a target official document template matched with the target text based on the target text elements; for each of the target text elements, determining a standard format corresponding to a template text element of the same type as the target text element in the target official document template; converting the target text elements into the standard format, and generating a corresponding official document for the target text based on the target text elements converted into the standard format; determining target position information of the target text elements in the official document based on position information of the template text elements in the target official document template, wherein the target position information of the target text elements in the official document matches the position information of the corresponding template text elements in the target official document template; the position information is fixed or relatively variable; the generating a corresponding official document for the target text based on the target text elements converted into the standard format includes: typesetting the target text elements converted into the standard format according to the target position information; using the typesetting result as the official document corresponding to the target text.
2. The method according to claim 1, characterized in that, a mapping relationship between an official document template and an official document type is preset, and the determining a target official document template matched with the target text based on the target text elements includes: determining a target official document type to which the target text belongs based on the target text elements; determining the official document template corresponding to the target official document type as the target official document template based on the mapping relationship.
3. The method according to claim 2, characterized in that, the determining a target official document type to which the target text belongs based on the target text elements includes: determining a title of the target text from the target text elements; determining a target official document type to which the target text belongs based on the title.
4. The method according to claim 2, characterized in that, the determining a target official document type to which the target text belongs based on the target text elements includes: determining a target official document type to which the target text belongs based on the element types of the target text elements.
5. The method according to claim 2, characterized in that, when the target official document type corresponds to multiple official document templates, the method further includes: for each official document template corresponding to the target official document type, determining a matching degree between the template text elements included in the official document template and the target text elements extracted from the target text; determining a target official document template matched with the target text based on the matching degree.
6. The method according to claim 5, characterized in that, the determining a matching degree between the template text elements included in the official document template and the target text elements extracted from the target text includes: determining text elements of the same type between the template text elements included in the official document template and the target text elements; determining the matching degree based on the text elements of the same type.
7. The method according to claim 5, wherein, determining the target official document template matched by the target text based on the matching degree includes: determining the priority of each official document template based on the matching degree; displaying the candidate official document templates corresponding to the target official document type in descending order of priority; receiving an official document generation request initiated for any one of the candidate official document templates; determining the candidate official document template targeted by the official document generation request as the target official document template.
8. The method according to claim 5, wherein, after determining the matching degree between the template text elements included in the official document template and the target text elements extracted from the target text for each official document template corresponding to the target official document type, further includes: when the matching degree between the target text elements and the template text elements is lower than the matching degree threshold, determining that the official document template lacks the template text elements corresponding to the target text elements.
9. The method according to claim 1, wherein, after determining the standard format corresponding to the template text elements of the same type as the target text elements in the target official document template for each of the target text elements, further includes: when the target official document template does not include template text elements of the same type as the first text element in the target text elements, converting the first text element into a general format; generating the corresponding official document for the target text based on the target text elements converted into the standard format and the first text element converted into the general format.
10. An apparatus for generating an official document, wherein, the apparatus includes: a receiving unit, configured to receive an official document generation request initiated for a target text; an extracting unit, configured to extract target text elements included in the target text; a matching unit, configured to determine a target official document template matched by the target text based on the target text elements; a determining unit, configured to determine the standard format corresponding to the template text elements of the same type as the target text elements in the target official document template for each of the target text elements; a generating unit, configured to convert the target text elements into the standard format, and generate the corresponding official document for the target text based on the target text elements converted into the standard format; determining the target position information of the target text elements in the official document based on the position information of the template text elements in the target official document template, wherein the target position information of the target text elements in the official document matches the position information of the corresponding template text elements in the target official document template; the position information is fixed or relatively variable; generating the corresponding official document for the target text based on the target text elements converted into the standard format includes: typesetting the target text elements converted into the standard format according to the target position information; using the typesetting result as the official document corresponding to the target text.
11. A computer-readable storage medium, on which a computer program is stored, wherein, the program, when executed by a processor, implements the steps of the method according to any one of claims 1-9.
12. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, when the processor executes the program, the steps of the method according to any one of claims 1-9 are implemented.
Citation Information
Patent Citations
Legal trial business processing method and device
CN108009299A
Document generation method and system
CN111709221A
Automatic typesetting method and system for judgment documents
CN112668299A