Document conversion method and device
By analyzing and numbering the title of the document template, the title mapping relationship is generated, and the rapid automatic conversion between document templates is achieved, which solves the problems of inefficient document conversion and high error rate in the existing technology, and realizes efficient batch conversion.
Patent Information
- Application Number
- CN202311575781.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-23
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2043-11-23
AI Technical Summary
The prior art cannot quickly and directly convert written documents from one template to another, resulting in inefficiency and high error rates, and the inability to convert documents between different templates into each other.
By analyzing the source document template and the target document template, extracting and numbering titles at each level, generating a mapping relationship of titles, analyzing the source documents that need to be converted, and converting the source documents into the target document based on the mapping relationship.
It realizes that documents can be easily converted from one template framework to another template framework, keeping the information elements unchanged, improving the efficiency of document conversion, and implementing batch conversion.
Smart Images

Figure CN117709302B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a document conversion method, device, electronic device and computer-readable storage medium. Background Art
[0002] In the process of various engineering construction, a large number of process documents must be generated at each node. These process documents are written based on certain standard templates. When the engineering management system is upgraded or the project encounters other changes, the document standard template will change. At this time, all the original process documents must be converted into documents in the form of new templates.
[0003] For documents with specific content that have already been written, the existing technology cannot quickly and directly convert a document of the original template into a document of another template. This process is usually completed through manual copying and pasting, which is not only inefficient but also has a high error rate.
[0004] Existing document conversion methods are generally aimed at converting between two documents of different formats, such as converting a non-editable PDF document into an editable Word document, or converting a TXT document or XML document into a Word document. The purpose of the conversion is to keep the original document content and structure unchanged, and it is impossible to convert documents of different templates. If there is a need to convert and reorganize existing documents into documents of other structures, it can only be done manually.
[0005] The prior art also uses online editing to achieve document conversion, that is, uploading the existing document to a web page, dragging and adjusting it on the web page, and then downloading it back to the local computer. This method is too dependent on the network and still requires manual conversion, and cannot achieve batch conversion of documents with the same template. Summary of the invention
[0006] In view of the above problems, the present application is proposed to provide a document conversion method, device, electronic device and computer-readable storage medium that overcome the above problems or at least partially solve the above problems.
[0007] The present application embodiment adopts the following technical solutions:
[0008] In a first aspect, an embodiment of the present application provides a document conversion method, comprising:
[0009] Parsing the source document template and the target document template, extracting and numbering the titles of each level of the source document template and the target document template;
[0010] Generate a mapping relationship between the title of the source document template and the title of the target document template based on the number;
[0011] The source document to be converted is parsed, and based on the mapping relationship between the source document template and the title of the target document template, the text content under each title of the source document is written into the target document, thereby converting the source document into the target document.
[0012] Optionally, before parsing the source document to be converted, the method further includes:
[0013] Setting an automatic extension mark at the parent title position of the source document template that needs to be extended;
[0014] In the process of converting the source document into the target document, when the automatic extension mark of the source document template is detected, the number of parallel sections of the source document is obtained, and after the text content of the first section of the source document is written into the target document, the text content of the remaining parallel sections is written into the target document according to the mapping rule of the first section.
[0015] Optionally, the parsing of the source document template and the target document template, extracting and numbering titles of various levels of the source document template and the target document template, includes:
[0016] The file formats of the source document template and the target document template are word. The formats of the source document template and the target document template are converted from word to json, and the titles of the source document template and the target document template are extracted and split, and the extracted titles are numbered.
[0017] Optionally, numbering the extracted titles includes:
[0018] Number the extracted titles according to the following rules:
[0019] The title number of the source document template begins with A, and the title number of the target document template begins with B;
[0020] The first-level titles of the source document template and the target document are expressed as (1 / n), where n represents the first-level title. The numbers of the remaining titles are based on the number of their parent titles, with a set of numbers a / b added in brackets. a refers to the current title level, and b refers to the order of the current title under its parent title.
[0021] Optionally, the generating a mapping relationship between the titles of the source document template and the target document template based on the numbering includes:
[0022] Setting the area in the target document template where the text needs to be written;
[0023] Analyze the title structures of the target document template in the area where the text needs to be written, and use a character similarity matching algorithm to match the titles of the target document template with the titles of the source document template, and generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
[0024] Optionally, the using a character similarity matching algorithm to match titles of various levels of the target document template with titles of the source document template includes:
[0025] For each title of the target document template, a title with the greatest character similarity is found from the source document template as a matching title. When the character similarity between the title in the target document template and the matching title is greater than a preset threshold, the match is successful.
[0026] Optionally, the method further comprises:
[0027] A configuration operation of a user on a mapping relationship between titles of the source document template and the target document template is received.
[0028] In a second aspect, an embodiment of the present application further provides a document conversion device, comprising:
[0029] A title numbering unit, used to parse the source document template and the target document template, extract and number the titles of each level of the source document template and the target document template;
[0030] A mapping relationship generating unit, used for generating a mapping relationship between the title of the source document template and the title of the target document template based on the number;
[0031] The document conversion unit is used to parse the source document to be converted, and write the text content under each title of the source document into the target document based on the mapping relationship between the title of the source document template and the title of the target document template, thereby converting the source document into the target document.
[0032] Optionally, the device further comprises:
[0033] An automatic extension mark setting unit, used for setting an automatic extension mark at the parent title position of the source document template that needs to be extended;
[0034] The document conversion unit is further used to obtain the number of parallel sections of the source document when an automatic extension tag of the source document template is detected during the process of converting the source document into the target document, and after writing the text content of the first section of the source document into the target document, write the text content of the remaining parallel sections into the target document according to the mapping rule of the first section.
[0035] Optionally, the title numbering unit is further used to:
[0036] The file formats of the source document template and the target document template are word. The formats of the source document template and the target document template are converted from word to json, and the titles of the source document template and the target document template are extracted and split, and the extracted titles are numbered.
[0037] Optionally, numbering the extracted titles includes:
[0038] Number the extracted titles according to the following rules:
[0039] The title number of the source document template begins with A, and the title number of the target document template begins with B;
[0040] The first-level titles of the source document template and the target document are expressed as (1 / n), where n represents the first-level title. The numbers of the remaining titles are based on the number of their parent titles, with a set of numbers a / b added in brackets. a refers to the current title level, and b refers to the order of the current title under its parent title.
[0041] Optionally, the mapping relationship generating unit is further used for:
[0042] Setting the area in the target document template where the text needs to be written;
[0043] Analyze the title structures of the target document template in the area where the text needs to be written, and use a character similarity matching algorithm to match the titles of the target document template with the titles of the source document template, and generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
[0044] Optionally, the using a character similarity matching algorithm to match titles of various levels of the target document template with titles of the source document template includes:
[0045] For each title of the target document template, a title with the greatest character similarity is found from the source document template as a matching title. When the character similarity between the title in the target document template and the matching title is greater than a preset threshold, the match is successful.
[0046] Optionally, the device further comprises:
[0047] The configuration operation receiving unit is used to receive a user's configuration operation on the mapping relationship between the title of the source document template and the target document template.
[0048] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0049] Processor; and
[0050] A memory is arranged to store computer executable instructions, which when executed cause the processor to perform the document conversion method described above.
[0051] In a fourth aspect, an embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes the above-mentioned document conversion method.
[0052] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0053] The embodiment of the present application generates a mapping relationship between the titles of a source document template and a target document template based on numbering, and writes the text content under each title of the source document into the target document based on the mapping relationship between the titles of the source document template and the target document template, thereby realizing convenient conversion of a document from one template framework to another template framework. When information elements remain unchanged, the title mapping relationship between the source document template and the target document template is used to realize fast and automatic conversion of the two template documents, thereby improving the efficiency of document conversion and realizing batch conversion.
[0054] In addition, the embodiment of the present application sets an automatic extension mark at the position of the parent title that needs to be expanded in the source document template. In the process of converting the source document into the target document, when the automatic extension mark of the source document template is detected, the number of parallel sections of the source document is obtained. After the main text content of the first section of the source document is written into the target document, the main text content of the remaining parallel sections is written into the target document according to the mapping rule of the first section, thereby realizing automatic conversion of the source document containing parallel sections, which can meet the actual needs of various different source documents.
[0055] In order to further improve the efficiency of document conversion, the embodiment of the present application also proposes to use a character similarity matching algorithm to match the titles of each level of the target document template with the titles of the source document template, and automatically generate a mapping relationship between the titles of the source document template and the target document template based on the numbering. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0057] Figure 1 A flowchart of a document conversion method according to an embodiment of the present application;
[0058] Figure 2A schematic diagram of numbering titles of source document templates according to an embodiment of the present application;
[0059] Figure 3 A schematic diagram of a mapping relationship between titles of a source document template and a target document template generated based on numbering according to an embodiment of the present application;
[0060] Figure 4 A schematic diagram of converting a source document into a target document according to an embodiment of the present application;
[0061] Figure 5A A schematic diagram of converting a source document into a target document when no extended configuration is performed according to an embodiment of the present application;
[0062] Figure 5B A schematic diagram of converting a source document into a target document after extended configuration according to an embodiment of the present application;
[0063] Figure 6 This is a schematic diagram of the structure of a document conversion device according to an embodiment of the present application;
[0064] Figure 7 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0066] It is difficult to convert a standardized word document into a new document under another template framework under the existing technology. When the engineering document template changes and a large number of existing documents need to be converted, they can only be converted one by one by manually copying and pasting, or relying on online tools to assist in comparison and conversion. The process is cumbersome and batch conversion cannot be achieved.
[0067] The embodiments of the present application can realize intelligent conversion of documents from one standard template to another standard template, keeping the original document content unchanged, and can realize intelligent batch conversion of all documents that conform to the template format.
[0068] Figure 1 FIG. 1 is a flowchart of a document conversion method according to an embodiment of the present application. Figure 1 As shown, the method includes:
[0069] S101: parsing a source document template and a target document template, extracting and numbering titles at all levels of the source document template and the target document template;
[0070] It can be understood that the document template in the embodiment of the present application refers to a document with a defined framework structure, such as a word document that defines the position and structure of titles at all levels. The document written based on the template only needs to fill in the main text content under the specified title, or expand some sections with the same structure according to actual conditions.
[0071] The source document template and the target document template have different title positions and structures. The embodiment of the present application extracts and numbers the titles of each level of the source document template and the target document template. By numbering the titles of each level of the parsed source document template and the target document and ensuring the uniqueness of the numbers, it is convenient for subsequent steps to generate a mapping relationship based on the numbers.
[0072] S102: Generate a mapping relationship between the source document template and the target document template title based on the number;
[0073] It can be understood that the mapping relationship between the titles of the source document template and the target document template in the embodiment of the present application refers to which titles of each level in the source document template correspond to which titles in the target document template.
[0074] S103: Parsing the source document to be converted, and writing the text content under each title of the source document into the target document based on the mapping relationship between the source document template and the title of the target document template, thereby converting the source document into the target document.
[0075] In practical applications, the file format of the source document to be converted can be word, and the word document is parsed into a json document. json (Javascript Object Notation) is a lightweight data exchange format that is easy for computers to parse and operate.
[0076] When performing document conversion, based on the mapping relationship, the text content under the specified title of the source document will be written to a specific location of the target document, forming a basic rule for reorganizing the content of the source document template into the target document template.
[0077] The document conversion method of the embodiment of the present application generates a mapping relationship between the titles of the source document template and the target document template based on the numbering, and writes the text content under each title of the source document into the target document based on the mapping relationship between the titles of the source document template and the target document template, so as to realize convenient conversion of the document from one template framework to another template framework. When the information elements remain unchanged, the title mapping relationship between the source document template and the target document template is used to realize fast and automatic conversion of the two template documents, thereby improving the efficiency of document conversion and realizing batch conversion.
[0078] In an optional implementation of the embodiment of the present application, before parsing the source document to be converted, the method further includes:
[0079] Setting an automatic extension mark at the parent title position of the source document template that needs to be extended;
[0080] In the process of converting the source document into the target document, when the automatic extension mark of the source document template is detected, the number of parallel sections of the source document is obtained, and after the text content of the first section of the source document is written into the target document, the text content of the remaining parallel sections is written into the target document according to the mapping rule of the first section.
[0081] It is understandable that in the document template, we can only specify the framework structure of each section of the document, but cannot determine how many parallel sections the source document actually written based on the template contains that conform to this structure. Before converting the document, it is necessary to perform extended configuration at a specific location in the source document template to control the conversion process to intelligently generate a specific number of sections based on the actual source document.
[0082] In an embodiment of the present application, an automatic extension mark is set at the position of the parent title that needs to be expanded in the source document template. During the process of converting the source document into the target document, when the automatic extension mark of the source document template is detected, the number of parallel sections of the source document is obtained. After the main text content of the first section of the source document is written into the target document, the main text content of the remaining parallel sections is written into the target document according to the mapping rule of the first section, thereby realizing automatic conversion of the source document containing parallel sections, which can meet the actual needs of various different source documents.
[0083] Specifically, the parsing of the source document template and the target document template, extracting and numbering the titles of each level of the source document template and the target document template, includes:
[0084] The file formats of the source document template and the target document template are word. The formats of the source document template and the target document template are converted from word to json, and the titles of the source document template and the target document template are extracted and split, and the extracted titles are numbered.
[0085] As mentioned above, JSON is a lightweight data exchange format that is easy for computers to parse and operate. Converting the source document template and the target document template from Word to JSON makes it easier for computers to extract and split titles.
[0086] Specifically, the embodiments of the present application can number the extracted titles according to the following rules:
[0087] The title number of the source document template begins with A, and the title number of the target document template begins with B;
[0088] The first-level titles of the source document template and the target document are expressed as (1 / n), where n represents the first-level title. The numbers of the remaining titles are based on the number of their parent titles, with a set of numbers a / b added in brackets. a refers to the current title level, and b refers to the order of the current title under its parent title.
[0089] Figure 2 This is a schematic diagram of numbering the titles of source document templates according to an embodiment of the present application. Figure 2 As shown in the figure, the numbering format is A(a / b,c / d,e / f……), where "A" represents the source document template and "B" represents the target document template. The brackets contain several groups of numbers, and there are several groups of numbers for each level of title. Each group of numbers is in the form of "(a / b)". The number a in the last group of numbers represents the current level of title, and b represents the number of titles under its parent title.
[0090] Figure 3 The following is a schematic diagram of the mapping relationship between the titles of the source document template and the target document template based on numbering according to an embodiment of the present application. In the target document template, the third-level title B (1 / 1, 2 / 1, 3 / 1) maps to A (1 / 1, 2 / 1, 3 / 1) in the source document template. Then, during the document conversion process, the text content under the title A (1 / 1, 2 / 1, 3 / 1) of the source document will be written to the title B (1 / 1, 2 / 1, 3 / 1) of the target document.
[0091] For a given source document template and target document template, according to the mapping rules, Figure 3 In this example, three number mapping pairs are generated, which are represented as follows:
[0092] A(1 / 1,2 / 1,3 / 1):B(1 / 1,2 / 1,3 / 1);
[0093] A(1 / 1,2 / 2,3 / 1):B(1 / 1,2 / 1,3 / 2);
[0094] A(1 / 2):B(1 / 2).
[0095] According to the above three mapping rules, if the source document provided is Figure 4 As shown on the left, the converted target document is as follows Figure 4 Shown on the right.
[0096] Figure 5A This is a schematic diagram of converting a source document into a target document when no extended configuration is performed according to an embodiment of the present application. Figure 5B A schematic diagram of converting a source document into a target document after extended configuration according to an embodiment of the present application.
[0097] like Figure 5A As shown in the figure, the directory structure of the "Activity Plan" section is defined in the template. However, when a specific document is written based on the template, some documents may have only one activity, while others may have two or more activities. After completing the mapping of the source document template to the target document template title, the target document generated by the conversion is as follows: Figure 5A As shown below, from the generated target document 2, it can be seen that only "Activity 1" is converted. This is because there is only "Activity 1" in the template.
[0098] like Figure 5B As shown, an automatic extension mark is set at the parent title position that needs to be extended in the source document template. When the specific source document is parsed, when the template is parsed to the position where the automatic extension mark is set, the number of parallel sections is automatically detected. If the first section has content that needs to be mapped to the target document, the remaining sections are expanded and converted in the target document in a similar manner according to the mapping rule of the first section.
[0099] In a preferred implementation of the embodiment of the present application, the mapping relationship between the source document template and the target document template title generated based on the number includes:
[0100] Setting the area in the target document template where the text needs to be written;
[0101] Analyze the title structures of the target document template in the area where the text needs to be written, and use a character similarity matching algorithm to match the titles of the target document template with the titles of the source document template, and generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
[0102] Specifically, the adopting of a character similarity matching algorithm to match the titles of each level of the target document template with the titles of the source document template includes:
[0103] For each title of the target document template, a title with the greatest character similarity is found from the source document template as a matching title. When the character similarity between the title in the target document template and the matching title is greater than a preset threshold, the match is successful.
[0104] It is understandable that in order to further improve the efficiency of document conversion, the embodiment of the present application also proposes to use a character similarity matching algorithm to match the titles of each level of the target document template with the titles of the source document template, and automatically generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
[0105] In practical applications, the preset threshold may be 50%-100%. Further, the method further comprises:
[0106] A configuration operation of a user on a mapping relationship between titles of the source document template and the target document template is received.
[0107] Assuming that the preset threshold is 50%, the source document title matched to the template document title B (1 / 1, 2 / 1, 3 / 1) using the character similarity matching algorithm is A (1 / 1, 2 / 1, 3 / 1), and the similarity is 100%, which is greater than the set threshold, and the match is successful. If the similarity between the titles of all source documents and B (1 / 1, 2 / 1, 3 / 1) is less than the threshold of 50% during the attempt to match B (1 / 1, 2 / 1, 3 / 1), the match fails and waits for subsequent manual processing. In the case of multiple similarity values being tied for the largest, such as multiple titles in the source document template that successfully match B (1 / 1, 2 / 1, 3 / 1), the multiple matched contents will be listed under the target title and highlighted for the user to manually select.
[0108] It should be noted that the automatically generated mapping relationship needs to be manually checked and confirmed, and the content left for manual processing by the program should be processed. If not processed, the program will give a default selection.
[0109] In an embodiment of the present application, the mapping relationship between the titles of the source document template and the target document template can be manually configured by the user. In order to reduce the workload of manual operations, when the structures of the source document template and the target document template are regular and organized, the above-mentioned character similarity matching algorithm can be used to achieve fully automatic batch completion.
[0110] Figure 6 FIG. 1 is a schematic diagram of the structure of a document conversion device according to an embodiment of the present application. Figure 6 As shown, the device comprises:
[0111] The title numbering unit 601 is used to parse the source document template and the target document template, extract and number the titles of each level of the source document template and the target document template;
[0112] A mapping relationship generating unit 602, configured to generate a mapping relationship between the source document template and the title of the target document template based on the number;
[0113] The document conversion unit 603 is used to parse the source document to be converted, and write the text content under each title of the source document into the target document based on the mapping relationship between the source document template and the title of the target document template, thereby converting the source document into the target document.
[0114] The document conversion device of the embodiment of the present application generates a mapping relationship between the titles of the source document template and the target document template based on the numbering, and writes the text content under each title of the source document into the target document based on the mapping relationship between the titles of the source document template and the target document template, so as to realize convenient conversion of the document from one template framework to another template framework. When the information elements remain unchanged, the title mapping relationship between the source document template and the target document template is used to realize fast and automatic conversion of the two template documents, thereby improving the efficiency of document conversion and realizing batch conversion.
[0115] Optionally, the device further comprises:
[0116] An automatic extension mark setting unit, used for setting an automatic extension mark at the parent title position of the source document template that needs to be extended;
[0117] The document conversion unit is further used to obtain the number of parallel sections of the source document when an automatic extension tag of the source document template is detected during the process of converting the source document into the target document, and after writing the text content of the first section of the source document into the target document, write the text content of the remaining parallel sections into the target document according to the mapping rule of the first section.
[0118] Optionally, the title numbering unit is further used to:
[0119] The file formats of the source document template and the target document template are word. The formats of the source document template and the target document template are converted from word to json, and the titles of the source document template and the target document template are extracted and split, and the extracted titles are numbered.
[0120] Optionally, numbering the extracted titles includes:
[0121] Number the extracted titles according to the following rules:
[0122] The title number of the source document template begins with A, and the title number of the target document template begins with B;
[0123] The first-level titles of the source document template and the target document are expressed as (1 / n), where n represents the first-level title. The numbers of the remaining titles are based on the number of their parent titles, with a set of numbers a / b added in brackets. a refers to the current title level, and b refers to the order of the current title under its parent title.
[0124] Optionally, the mapping relationship generating unit is further used for:
[0125] Setting the area in the target document template where the text needs to be written;
[0126] Analyze the title structures of the target document template in the area where the text needs to be written, and use a character similarity matching algorithm to match the titles of the target document template with the titles of the source document template, and generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
[0127] Optionally, the using a character similarity matching algorithm to match titles of various levels of the target document template with titles of the source document template includes:
[0128] For each title of the target document template, a title with the greatest character similarity is found from the source document template as a matching title. When the character similarity between the title in the target document template and the matching title is greater than a preset threshold, the match is successful.
[0129] Optionally, the device further comprises:
[0130] The configuration operation receiving unit is used to receive a user's configuration operation on the mapping relationship between the title of the source document template and the target document template.
[0131] It is understandable that the above-mentioned document conversion device can implement each step of the method provided in the above-mentioned embodiment, and the relevant explanations about the method are applicable to the device and will not be repeated here.
[0132] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 7At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0133] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0134] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0135] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a document conversion device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0136] Parsing the source document template and the target document template, extracting and numbering the titles of each level of the source document template and the target document template;
[0137] Generate a mapping relationship between the title of the source document template and the title of the target document template based on the number;
[0138] The source document to be converted is parsed, and based on the mapping relationship between the source document template and the title of the target document template, the text content under each title of the source document is written into the target document, thereby converting the source document into the target document.
[0139] The above application Figure 1The method disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0140] The electronic device may also perform Figure 1 The method in this application will not be described in detail here.
[0141] The present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute Figure 1 The method in the embodiment shown is specifically used to perform:
[0142] Parsing the source document template and the target document template, extracting and numbering the titles of each level of the source document template and the target document template;
[0143] Generate a mapping relationship between the title of the source document template and the title of the target document template based on the number;
[0144] The source document to be converted is parsed, and based on the mapping relationship between the source document template and the title of the target document template, the text content under each title of the source document is written into the target document, thereby converting the source document into the target document.
[0145] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0146] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0147] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0149] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0150] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0151] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0152] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0153] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0154] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A document conversion method, characterized in that: include: Parsing the source document template and the target document template, extracting and numbering the titles of each level of the source document template and the target document template; Generate a mapping relationship between the title of the source document template and the title of the target document template based on the number; Parsing a source document to be converted, and writing the text content under each title of the source document into the target document based on the mapping relationship between the source document template and the title of the target document template, thereby converting the source document into the target document; The generating a mapping relationship between the title of the source document template and the title of the target document template based on the numbering includes: Setting the area in the target document template where the text needs to be written; Analyze the title structures of the target document template in the area where the text needs to be written, and use a character similarity matching algorithm to match the titles of the target document template with the titles of the source document template, and generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
2. The method according to claim 1, characterized in that Before parsing the source document to be converted, the method further includes: Setting an automatic extension mark at the parent title position of the source document template that needs to be extended; In the process of converting the source document into the target document, when the automatic extension mark of the source document template is detected, the number of parallel sections of the source document is obtained, and after the text content of the first section of the source document is written into the target document, the text content of the remaining parallel sections is written into the target document according to the mapping rule of the first section.
3. The method according to claim 1, characterized in that The parsing of the source document template and the target document template, extracting and numbering the titles of each level of the source document template and the target document template, includes: The file formats of the source document template and the target document template are word. The formats of the source document template and the target document template are converted from word to json, and the titles of the source document template and the target document template are extracted and split, and the extracted titles are numbered.
4. The method according to claim 3, characterized in that The step of numbering each extracted title includes: Number the extracted titles according to the following rules: The title number of the source document template begins with A, and the title number of the target document template begins with B; The first-level titles of the source document template and the target document are expressed as (1 / n), where n represents the first-level title. The numbers of the remaining titles are based on the number of their parent titles, with a set of numbers a / b added in brackets. a refers to the current title level, and b refers to the order of the current title under its parent title.
5. The method according to claim 1, characterized in that The adopting of a character similarity matching algorithm to match the titles of the source document template with the titles of each level of the target document template includes: For each title of the target document template, a title with the greatest character similarity is found from the source document template as a matching title. When the character similarity between the title in the target document template and the matching title is greater than a preset threshold, the match is successful.
6. The method according to claim 5, characterized in that The method further comprises: A configuration operation of a user on a mapping relationship between titles of the source document template and the target document template is received.
7. A document conversion device, characterized in that: include: A title numbering unit, used to parse the source document template and the target document template, extract and number the titles of each level of the source document template and the target document template; A mapping relationship generating unit, used for generating a mapping relationship between the title of the source document template and the title of the target document template based on the number; A document conversion unit, configured to parse a source document to be converted, and write the text content under each title of the source document into the target document based on the mapping relationship between the source document template and the title of the target document template, thereby converting the source document into the target document; The mapping relationship generating unit is further used for: Setting the area in the target document template where the text needs to be written; Analyze the title structures of the target document template in the area where the text needs to be written, and use a character similarity matching algorithm to match the titles of the target document template with the titles of the source document template, and generate a mapping relationship between the titles of the source document template and the target document template based on the numbering.
8. An electronic device, characterized in that: include: processor; as well as A memory arranged to store computer executable instructions, which when executed cause the processor to perform the method of any one of claims 1 to 6.
9. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, causes the electronic device to execute any one of the methods of claims 1 to 6.
Citation Information
Patent Citations
Document conversion method and device
CN101751461A