Document processing method and device, electronic device, and computer-readable storage medium
By performing structured parsing of documents, based on template formats and parsing conditions, the document chapters and table content are identified and processed, solving the problem of low document processing efficiency and achieving efficient automated document parsing and merging.
Patent Information
- Application Number
- CN202111396605.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-11-23
AI Technical Summary
In existing technologies, document processing efficiency is low, especially for Word software, which mainly deals with text data, there is a lack of effective structured parsing methods.
By importing the target document, scanning the document content based on the template format of the preset document template, distinguishing document chapters according to preset parsing conditions, assigning paragraph hierarchical levels using a recursive algorithm, identifying and parsing table objects, and copying and storing text, attachments and image objects, the system achieves the acquisition and storage of structured data.
It improves the efficiency of document processing, enabling automated parsing and merging of structured document data, thereby enhancing the reusability of information assets and the flexibility of document processing.
Smart Images

Figure CN114065719B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data processing technology, and in particular to a document processing method and device thereof, an electronic device, and a computer-readable storage medium. Background Art
[0002] Documents are an important part of enterprise standard management. In the daily affairs of an enterprise, they play a role as a bridge between the flow of affairs and the connection between the upper and lower levels. With the development of computer technology, the electronicization of corporate office documents is becoming more and more common. The storage of simple and convenient electronic documents has become an important way for enterprises to accumulate information assets. As a result, various enterprises have accumulated a huge number of electronic document files. Therefore, how to parse the text, tables and other data in electronic documents, and make the structured data in the documents analyzed by automated programs, as well as merge and export the data with added value, has become the key to research.
[0003] In the related art, conventional office software provides a set of secondary development library interfaces to expand user-defined functions. This set of COM component interfaces allows users to use various programming tools (e.g., C++, C#, JavaScript scripts, etc.) to call. In the related art, most users use this set of development library interfaces to expand the functionality of the spreadsheet tool Excel, but for Word software that mainly uses text data, few users use this set of secondary development libraries to expand the functions of Word, and even fewer users do document processing on these text data, resulting in low document processing efficiency.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a document processing method and device, an electronic device, and a computer-readable storage medium, so as to at least solve the technical problem in the related art that the document is not structured and parsed, thereby reducing the document processing efficiency.
[0006] According to one aspect of an embodiment of the present invention, a document processing method is provided, comprising: importing a target document to be analyzed; scanning the document content of the imported target document based on a template format of a preset document template; and distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data.
[0007] Optionally, the step of scanning the document content of the imported target document based on the template format of the preset document template includes: based on the template format of the preset document template, querying keywords in the target document to obtain the document content of the target document.
[0008] Optionally, the step of distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data includes: using the first sub-parsing condition in the preset parsing conditions to segment each paragraph in the document content; determining the outline level of the outline to which each paragraph belongs; and representing the outline level of the outline to which the paragraph belongs as structured data.
[0009] Optionally, after determining the outline level of the outline to which each paragraph belongs, the method further includes: assigning the paragraph level to the structured data using a preset recursive algorithm based on the outline level of the outline to which the paragraph belongs, so that the hierarchical level of the paragraph is consistent with the target document.
[0010] Optionally, the step of distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data includes: using the second sub-parsing condition in the preset parsing condition to obtain the handles of the table objects and the number of tables in each paragraph in the document content; based on the handles and the number of tables of the table objects in the document content, cyclically calling the table objects to split the paragraphs between every two table objects to obtain the document content of the target document; parsing the table content in the table objects to obtain structured table data.
[0011] Optionally, the step of parsing the table content in the table object to obtain structured table data includes: parsing the field definition table in the table object to obtain voucher format data or report sample; and / or analyzing the business processing flow table in the table object to obtain business field data.
[0012] Optionally, it also includes: using a preset processing control to copy the text object, document attachment or picture object in the document content to a clipboard; calling the preset processing control to save the text object, document attachment or picture object in the clipboard to a specified file in a temporary directory.
[0013] According to another aspect of an embodiment of the present invention, a document processing device is also provided, including: an import unit, used to import a target document to be analyzed; a scanning unit, used to scan the document content of the imported target document based on a template format of a preset document template; and a distinguishing unit, used to distinguish document chapters in the document content according to preset parsing conditions to obtain structured data.
[0014] Optionally, the scanning unit includes: a first query module, configured to query keywords in the target document based on a template format of a preset document template to obtain document content of the target document.
[0015] Optionally, the differentiation unit includes: a first segmentation module, used to adopt a first sub-parsing condition in a preset parsing condition to segment each paragraph in the document content; a first determination module, used to determine the outline level of the outline to which each paragraph belongs; and a first characterization module, used to characterize the outline level of the outline to which the paragraph belongs as structured data.
[0016] Optionally, the first representation module includes: a first assignment submodule, configured to assign a paragraph level to structured data based on the outline level of the outline to which the paragraph belongs, using a preset recursive algorithm, so that the hierarchical level of the paragraph is consistent with that of the target document.
[0017] Optionally, the distinguishing unit includes: a first acquisition module, used to adopt the second sub-parsing condition in the preset parsing condition to obtain the handle of the table object and the number of tables in each paragraph in the document content; a second segmentation module, used to cyclically call the table object based on the handle and the number of tables in the table object in the document content, and segment the paragraphs between every two table objects to obtain the document content of the target document; the first parsing module, used to parse the table content in the table object to obtain structured table data.
[0018] Optionally, the first parsing module includes: a first analysis sub-module, used to parse the field definition table in the table object to obtain voucher format data or report sample; and / or, a second analysis sub-module, used to analyze the business processing flow table in the table object to obtain business field data.
[0019] Optionally, it also includes: a first copy module, used to use a preset processing control to copy the text object, document attachment or picture object in the document content to the clipboard; a first calling module, used to call the preset processing control to save the text object, document attachment or picture object in the clipboard to a specified file in a temporary directory.
[0020] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the document processing methods described above.
[0021] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the document processing methods described above.
[0022] In the present disclosure, by importing a target document to be analyzed, based on a template format of a preset document template, scanning the document content of the imported target document, and distinguishing document chapters in the document content according to preset parsing conditions, structured data is obtained. In the present application, based on the template format of a preset document template, automatic structural analysis is performed on the document content, which can improve the efficiency of document processing, thereby solving the technical problem in the related art that there is no structural analysis of the document, which reduces the document processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0024] Figure 1 is a flowchart of an optional document processing method according to an embodiment of the present invention;
[0025] Figure 2 is a schematic diagram of an optional chapter structure tree diagram according to an embodiment of the present invention;
[0026] Figure 3 is a flowchart of an optional complex object processing method according to an embodiment of the present invention;
[0027] Figure 4 is a schematic diagram of an optional structure for processing a document according to an embodiment of the present invention;
[0028] Figure 5 is a flowchart of an optional method for parsing a document according to an embodiment of the present invention;
[0029] Figure 6 is a schematic diagram of an optional document processing device according to an embodiment of the present invention;
[0030] Figure 7 It is a hardware structure block diagram of an electronic device (or mobile device) for implementing a method for processing service messages according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] The following embodiments of the present invention can be applied to scenarios where various development platforms / systems / applications process documents. Taking the application development lifecycle management platform system (ADLM system) as an example, the present invention can propose a method for automatically parsing and merging electronic documents in software such as Office word or WPS under the Windows platform based on the Microsoft Office development library, thereby building a low-cost and high-efficiency document server processing system.
[0034] Embodiment 1
[0035] According to an embodiment of the present invention, a document processing method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0036] Figure 1 is a flowchart of an optional document processing method according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0037] Step S102: import the target document to be analyzed.
[0038] Step S104: Scan the document content of the imported target document based on the template format of the preset document template.
[0039] Step S106, distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data.
[0040] Through the above steps, the target document to be analyzed can be imported, and based on the template format of the preset document template, the document content of the imported target document can be scanned, and the document chapters in the document content can be distinguished according to the preset parsing conditions to obtain structured data. In the embodiment of the present invention, based on the template format of the preset document template, the document content is automatically structurally analyzed, which can improve the efficiency of document processing, thereby solving the technical problem in the related art that the document is not structurally parsed, which reduces the document processing efficiency.
[0041] The embodiment of the present invention is described in detail below in combination with the above steps.
[0042] Step S102: import the target document to be analyzed.
[0043] In an embodiment of the present invention, the target document may be a document in Word software or a document in other software, for example, a document in WPS software, and the document content includes but is not limited to: text, tables, pictures, attachments, etc.
[0044] Step S104: Scan the document content of the imported target document based on the template format of the preset document template.
[0045] In an embodiment of the present invention, the imported electronic document content (i.e., the document content of the target document) can be scanned according to the template format of a preset document template, and the recognized text content (or table content, etc.) can be distinguished according to the outline level of the document paragraphs, identifiable marks, etc., and a data structure for storing structured data can be formulated so that the structured data can be stored in a database in a discrete manner.
[0046] Optionally, the step of scanning the document content of the imported target document based on the template format of the preset document template includes: based on the template format of the preset document template, querying keywords in the target document to obtain the document content of the target document.
[0047] In an embodiment of the present invention, for content with relatively uniform parsing logic for the text portion, keywords (or key titles) in the text (ie, the target document) can be searched through a VBA interface based on the template format of a preset document template to determine the document content of the target document.
[0048] Step S106, distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data.
[0049] In an embodiment of the present invention, the structured data of the target document can be obtained by analyzing the chapter structure of the target document. In this embodiment, the document chapters in the document content can be distinguished according to three parsing conditions (i.e., preset parsing conditions), and the document chapters can be parsed to obtain structured data.
[0050] Optionally, the step of distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data includes: using the first sub-parsing condition in the preset parsing conditions to segment each paragraph in the document content; determining the outline level of the outline to which each paragraph belongs; and representing the outline level of the outline to which the paragraph belongs as structured data.
[0051] In the embodiment of the present invention, the document does not use carriage returns as the distinction between document paragraphs. There is a chapter level with a parent-child relationship between adjacent paragraphs (i.e., the outline level of the paragraph). When parsing the document content, the outline level can be used as a paragraph distinction condition (i.e., the first parsing condition) to segment each paragraph in the document content. After determining the outline level of each paragraph, the outline level of the paragraph is used as part of the structured data, and the attributes of the structured data are determined by the outline level of the paragraph.
[0052] Optionally, after determining the outline level of the outline to which each paragraph belongs, the method further includes: assigning the paragraph level to the structured data using a preset recursive algorithm based on the outline level of the outline to which the paragraph belongs, so that the hierarchical level of the paragraph is consistent with that of the target document.
[0053] In an embodiment of the present invention, Figure 2 is a schematic diagram of an optional chapter structure tree diagram according to an embodiment of the present invention, such as Figure 2 As shown, including: root paragraph 1.2 Cash Management, first-level leaf paragraph 1.2.1 Project Implementation, second-level leaf paragraph 1.2.1.1 Automatic Deposit Conversion Agreement, second-level leaf paragraph 1.2.1.2 Check Express Agreement, third-level leaf paragraph 1.2.1.1.1 Automatic Deposit Conversion Agreement Entry, third-level leaf paragraph 1.2.1.2.1 Check Express Agreement Entry, third-level leaf paragraph 1.2.1.2.2 Check Express Agreement Review, third-level leaf paragraph 1.2.1.2.3 Check Express Agreement Modification, third-level leaf paragraph 1.2.1.2.4 Check Express Agreement Change, third-level leaf paragraph 1.2.1.2.5 Check Express Agreement Query, Four-level Leaf Paragraph 1.2.1.2.1.1 Check Express Agreement Entry, Four-level Leaf Paragraph 1.2.1.2.2.1 Check Express Agreement Review, Four-level Leaf Paragraph 1.2.1.2.3.1 Check Express Agreement Modification, Four-level Leaf Paragraph 1.2.1.2.4.1 Check Express Agreement Change, Four-level Leaf Paragraph 1.2.1.2.4.2 Check Express Agreement Suspension, Four-level Leaf Paragraph 1.2.1.2.4.3 Check Express Agreement Activation, Four-level Leaf Paragraph 1.2.1.2.4.4 Check Express Agreement Termination. That is, the paragraph levels in the document have both leaf paragraphs of different levels (for example, chapters 1.2.1.1.1.1 and 1.2.1.2.5 are both leaf paragraphs), and the number of leaf paragraphs at the same level is different (for example, Figure 2 For example, there are 2 leaf paragraphs in the second layer and 6 leaf paragraphs in the third layer). In view of the different numbers of leaf paragraphs in different layers and at the same layer, a corresponding recursive algorithm (i.e., a preset recursive algorithm) can be designed based on the outline level of the outline to which the paragraph belongs to assign the paragraph level to the structured data, so that the hierarchical level of each leaf paragraph and title paragraph is consistent with that of the target document to ensure the correctness of the document assets.
[0054] Optionally, the step of distinguishing document chapters in the document content according to preset parsing conditions to obtain structured data includes: using the second sub-parsing condition in the preset parsing condition to obtain the handles of the table objects and the number of tables in each paragraph in the document content; based on the handles and the number of tables of the table objects in the document content, cyclically calling the table objects to split the paragraphs between every two table objects to obtain the document content of the target document; parsing the table content in the table objects to obtain structured table data.
[0055] In the embodiment of the present invention, when parsing the table content in the target document, the table properties can be obtained according to the special mark of the table, and the document content can be parsed with the table as the basic parsing element (i.e., the second parsing condition). The handle of the table object and the number of tables in each paragraph in the document content can be obtained through the relevant interface of the table (e.g., VBA interface). For example, the following procedure can be used to obtain the table object handle and the number of tables in the corresponding paragraph:
[0056] var tables=wordApp.ActiveDocument.Tables;
[0057] var tableCount=tables.Count;
[0058] Based on the handle of the table object and the number of tables in the document content, the table object is called in a loop, and the paragraphs between every two table objects are uniformly treated as text content (that is, the paragraphs between every two table objects are divided to obtain the document content of the target document), and the text content in each table is parsed according to the tags (that is, the table content in the table object is parsed) to obtain structured table data.
[0059] Optionally, the step of parsing the table content in the table object to obtain structured table data includes: parsing the field definition table in the table object to obtain voucher format data or report sample; and / or analyzing the business processing flow table in the table object to obtain business field data.
[0060] In the embodiment of the present invention, the parsing of each paragraph section can be completed in sequence. For example, taking the original IPO document as an example: input screen design, analyze it, and output screen design; input field definition table, analyze it, and output voucher format or report form; input business process flow table, analyze it, and output business field data. That is, the parsing can be completed one by one in sequence and stored in the corresponding cache object.
[0061] Optionally, the document processing method also includes: using a preset processing control to copy text objects, document attachments or image objects in the document content to a clipboard; calling a preset processing control to save the text objects, document attachments or image objects in the clipboard to a specified file in a temporary directory; and for text objects, document attachments and / or image objects, setting a file identifier at a corresponding position in the document content.
[0062] In an embodiment of the present invention, the document content may include complex objects such as pictures, attachments, Ole objects, etc., and the pictures and attachments in the document are not links to independent files, but are directly embedded in binary files (for example, doc files). For the analysis of these complex objects, these objects can be separated from the binary files to make them independent files. A preset processing control (for example, DocServerUtil6 ActiveX control) can be used to copy the text objects, document attachments or picture objects in the document content to the clipboard through the VBA interface, and then the control interface can be called through the VBA program to save the clipboard content as a file in a temporary directory according to additional attributes such as pictures and attachments (that is, the text objects, document attachments or picture objects in the clipboard are saved as a specified file in the temporary directory).
[0063] A file identifier in the form of text is left at the location of the object, picture, etc. in the document (i.e., the file identifier is set at the corresponding location in the document content) to ensure the integrity of the document.
[0064] Figure 3 is a flowchart of an optional complex object processing method according to an embodiment of the present invention. Figure 3 As shown, complex objects in the source document (i.e., the target document) are identified. If it is a simple object, it is directly parsed by the parsing engine. If it is a complex object, the object is copied to the clipboard and saved as a file. A label needs to be set at the location of the complex object to ensure the integrity of the document.
[0065] In this embodiment, after the structured data is obtained, the structured data may be stored in a database.
[0066] In the embodiment of the present invention, the recognized text content can be distinguished according to the outline level of the document paragraph, identifiable marks, etc., and a data structure for storing structured data can be formulated so that the structured data can be stored in a database in a discrete manner.
[0067] In the embodiment of the present invention, the following can be used Figure 4 The schematic diagram of the structure for processing documents shown in the figure can use a host program (e.g., C++, C#, JavaScript script, etc.) based on the VBA automated compilation environment to call the COM interface in Microsoft OfficeInterop Word to perform structural analysis on the Word document. The embodiment of the present invention can obtain the document content based on the above structure and use the following method: Figure 5 The parsing method shown parses the obtained document content, and the specific method is as follows: obtain the document to be parsed, identify the structured paragraphs of the document, if it is an unstructured paragraph, it is processed by the persistence module and stored in the discrete database, if it is a structured paragraph, it is parsed by the parsing engine, and the parsed data is cached in a data file, and after being processed by the persistence module, it is stored in the discrete database.
[0068] The embodiment of the present invention can realize the discretization parsing of the structured data of the document (that is, the text content defined according to a certain template table), that is, it can realize automatic structured parsing and merging of the document based on the office software development library interface. This method can not only greatly improve the efficiency of entering document structured data, but also freely combine structured document data, and export and generate the required document according to the document format required by the user for reading or circulation.
[0069] In the embodiment of the present invention, the above-mentioned parsing method can be used to obtain the following statistical data after statistical analysis in some document processing systems, which is illustrated in Table 1 below:
[0070] Table 1
[0071]
[0072]
[0073] Since the system architecture is designed with high independence between document servers, the operating efficiency of each document server can be simply concluded as follows: it can process about 3,000 pages of merged documents per hour, or can parse document files with 1,000 chapter entries.
[0074] The document processing method based on the office software development library has greatly enriched the parsing method for electronic documents. It can extract new value-added information from a large number of document libraries, and adopt a document merging strategy to reintegrate some originally fragmented information into a set of documents that meet users' new needs according to new templates, thereby improving the reuse rate of these information assets.
[0075] Furthermore, the document processing method in the embodiment of the present invention can be applied to the following functional scenarios:
[0076] (1) The scenario where the document to be parsed has fixed chapter entries and chapter entry outline levels;
[0077] (2) The document to be parsed has a large number of sub-entries, but the structures of the sub-entries are similar (for example, the sub-entries have the same table), that is, the system can abstract the scenario of the sub-entry structure template.
[0078] Embodiment 2
[0079] A document processing device provided in this embodiment includes multiple implementation units, each of which corresponds to each implementation step in the above-mentioned embodiment 1.
[0080] Figure 6 is a schematic diagram of an optional document processing device according to an embodiment of the present invention, such as Figure 6 As shown, the processing device may include: an import unit 60, a scanning unit 62, and a distinguishing unit 64, wherein:
[0081] The importing unit 60 is used to import the target document to be analyzed.
[0082] The scanning unit 62 is used to scan the document content of the imported target document based on the template format of the preset document template.
[0083] The distinguishing unit 64 is used to distinguish document chapters in the document content according to preset parsing conditions to obtain structured data.
[0084] The above processing device can import the target document to be analyzed through the import unit 60, scan the document content of the imported target document based on the template format of the preset document template through the scanning unit 62, and distinguish the document chapters in the document content according to the preset parsing conditions through the distinguishing unit 64 to obtain structured data. In the embodiment of the present invention, based on the template format of the preset document template, the document content is automatically analyzed for structure, which can improve the efficiency of document processing, thereby solving the technical problem in the related art that the document is not structured parsed, which reduces the document processing efficiency.
[0085] Optionally, the scanning unit includes: a first query module, used to query keywords in the target document based on a template format of a preset document template to obtain the document content of the target document.
[0086] Optionally, the distinguishing unit includes: a first segmentation module, used to adopt a first sub-parsing condition in a preset parsing condition to segment each paragraph in the document content; a first determination module, used to determine the outline level of the outline to which each paragraph belongs; and a first characterization module, used to characterize the outline level of the outline to which the paragraph belongs as structured data.
[0087] Optionally, the first representation module includes: a first assignment submodule, which is used to assign the paragraph level to the structured data based on the outline level of the outline to which the paragraph belongs, using a preset recursive algorithm, so that the hierarchical level of the paragraph is consistent with that of the target document.
[0088] Optionally, the distinguishing unit includes: a first acquisition module, used to adopt the second sub-parsing condition in the preset parsing condition to obtain the handle of the table object and the number of tables in each paragraph in the document content; a second segmentation module, used to cyclically call the table object based on the handle of the table object and the number of tables in the document content, and segment the paragraphs between every two table objects to obtain the document content of the target document; the first parsing module, used to parse the table content in the table object to obtain structured table data.
[0089] Optionally, the first parsing module includes: a first analysis sub-module, used to parse the field definition table in the table object to obtain voucher format data or report sample; and / or, a second analysis sub-module, used to analyze the business processing flow table in the table object to obtain business field data.
[0090] Optionally, it also includes: a first copy module, used to use a preset processing control to copy the text object, document attachment or picture object in the document content to the clipboard; a first calling module, used to call the preset processing control to save the text object, document attachment or picture object in the clipboard to a designated file in a temporary directory.
[0091] Optionally, it also includes: a first setting module, which is used to set a file identifier at a corresponding position in the document content for a text object, a document attachment and / or a picture object.
[0092] The above-mentioned processing device may also include a processor and a memory. The above-mentioned import unit 60, scanning unit 62, distinguishing unit 64, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0093] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the structured data can be stored in the database by adjusting the kernel parameters.
[0094] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0095] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: importing a target document to be analyzed, scanning the document content of the imported target document based on a template format of a preset document template, distinguishing document chapters in the document content according to preset parsing conditions, obtaining structured data, and storing the structured data in a database.
[0096] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned service message processing methods.
[0097] Figure 7 1 is a hardware structure block diagram of an electronic device (or mobile device) for implementing a method for processing a service message according to an embodiment of the present invention. Figure 7 As shown, the electronic device may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 4 Different configurations are shown.
[0098] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned document processing methods.
[0099] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0100] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0102] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0103] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0104] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0105] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A document processing method, characterized in that: Applicable to scenarios where the document to be parsed has fixed chapter entries and chapter entry outline levels, including: Importing a target document to be analyzed, wherein the paragraphs in the target document include: leaf paragraphs at different levels and leaf paragraphs at the same level; Scanning the document content of the imported target document based on the template format of the preset document template; According to the preset parsing conditions, the document chapters in the document content are distinguished to obtain structured data, including: Using the first sub-parsing condition in the preset parsing condition, segment each paragraph in the document content; determining the outline level of the outline to which each paragraph belongs; representing the outline level of the outline to which the paragraph belongs as structured data; based on the outline level of the outline to which the paragraph belongs, using a preset recursive algorithm to assign the paragraph level to the structured data, so that the hierarchical level of the paragraph is consistent with the target document; The step of distinguishing document chapters in the document content according to the preset parsing condition to obtain structured data includes: using the second sub-parsing condition in the preset parsing condition to obtain the handle of the table object and the number of tables in each paragraph in the document content; based on the handle and the number of tables of the table object in the document content, cyclically calling the table object to divide the paragraphs between every two table objects to obtain the document content of the target document; parsing the table content in the table object to obtain structured table data; The step of parsing the table content in the table object to obtain structured table data includes: parsing the field definition table in the table object to obtain voucher format data or report sample; and / or analyzing the business processing flow table in the table object to obtain business field data.
2. The processing method according to claim 1, characterized in that: The step of scanning the document content of the imported target document based on the template format of the preset document template includes: Based on the template format of the preset document template, keywords in the target document are queried to obtain the document content of the target document.
3. The processing method according to claim 1, characterized in that: Also includes: Using a preset processing control, copying a text object, a document attachment or a picture object in the document content to a clipboard; The preset processing control is called to save the text object, document attachment or picture object in the clipboard to a designated file in a temporary directory.
4. A document processing device, characterized in that: Applicable to the scenario where the document to be parsed has fixed chapter entries and chapter entry outline levels, the document processing device includes: An importing unit, used for importing a target document to be analyzed, wherein the paragraphs in the target document include: leaf paragraphs at different levels and leaf paragraphs at the same level; A scanning unit, configured to scan the document content of the imported target document based on a template format of a preset document template; A distinguishing unit is used to distinguish document chapters in the document content according to a preset parsing condition to obtain structured data, and the distinguishing unit includes: a first segmentation module, used to adopt a first sub-parsing condition in the preset parsing condition to segment each paragraph in the document content; a first determination module, used to determine the outline level of the outline to which each paragraph belongs; a first characterization module, used to characterize the outline level of the outline to which the paragraph belongs as structured data; the first characterization module includes: a first assignment submodule, used to assign the paragraph level to the structured data based on the outline level of the outline to which the paragraph belongs, using a preset recursive algorithm, so that the hierarchical level of the paragraph is consistent with the target document; The differentiation unit further includes: a first acquisition module, used to adopt the second sub-analysis condition in the preset analysis condition to obtain the handle of the table object and the number of tables in each paragraph in the document content; a second segmentation module, used to cyclically call the table object based on the handle and the number of tables in the document content, segment the paragraphs between every two table objects, and obtain the document content of the target document; the first analysis module, used to parse the table content in the table object to obtain structured table data; The first parsing module includes: a first analysis sub-module, which is used to parse the field definition table in the table object to obtain voucher format data or report sample; and / or, a second analysis sub-module, which is used to analyze the business processing flow table in the table object to obtain business field data.
5. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the document processing method described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the document processing method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Configurable WORD file structured extraction method
CN104199975A
Document analysis method and device, computer equipment and storage medium
CN110377884A