Document analysis method and electronic device
By identifying paragraph mark text type tags and style files in DOCX documents, the problems of content extraction and structure preservation in document parsing are solved, improving the document processing efficiency and accuracy of the quality agent.
Patent Information
- Application Number
- CN202611330382.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-06
AI Technical Summary
Existing technologies lack document parsing methods that can extract content from DOCX documents while preserving document structure information, resulting in low efficiency of quality intelligence agents when processing documents in quality management scenarios.
By obtaining the content file of the DOCX document, identifying content blocks using paragraph markup text type tags, matching document page numbers by combining page word count and content block word count, and parsing content block hierarchy information by combining document style files, a multi-dimensional standardized key-value pair structured parsing result is generated.
It achieves accurate matching and structured parsing of document content, improves the data retrieval and analysis efficiency of the quality intelligence agent, and reduces the cost and error of manual processing.
Smart Images

Figure CN123050408A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, specifically to document parsing, and more specifically to a document parsing method and electronic device. Background Technology
[0002] A quality intelligent agent refers to a software system designed for product quality management scenarios. It comprehensively utilizes technologies such as natural language processing, large language models, knowledge retrieval, rule-based judgment, and task orchestration to understand, retrieve, and apply quality documents such as inspection specifications, appearance standards, testing SOPs, risk lists, problem records, and process standards. Based on user questions or quality tasks, the quality intelligent agent can find applicable requirements from relevant DOCX documents, assisting in tasks such as standard Q&A, inspection item verification, defect determination, risk identification, problem tracing, and result referencing. The meaning of information in the documents required by the quality intelligent agent depends not only on the text itself but also on its heading level, order, table rows and columns and their merging relationships, the correspondence between images and descriptive text, content controls such as tables or text boxes, and location information such as file names and page numbers. Currently, there is a lack of document parsing methods that can extract content from DOCX documents while preserving document structure information. Summary of the Invention
[0003] In view of the above problems, embodiments of this application provide a document parsing method and an electronic device.
[0004] According to a first aspect of this application, a document parsing method is provided, comprising: obtaining a content file of a document to be parsed after decompression, the document to be parsed comprising multiple content blocks, the content file comprising paragraph mark text of each content block, the paragraph mark text comprising at least one type tag; obtaining the document content of each content block from each paragraph mark text according to the type tag of each paragraph mark text; obtaining the order information of the multiple content blocks according to the paragraph mark text; the order information representing the order relationship between the multiple content blocks; obtaining the document page number of each content block based on the first word count of each page in the document to be parsed, the second word count of each content block, and the order information of the multiple content blocks; the first word count being obtained by counting the words on each page in a read-only format document, the read-only format document being obtained by format conversion of the document to be parsed, the second word count being the word count of the document content of the content block; and determining the document parsing result for the document to be parsed based on the document content, order information, and document page number of each content block.
[0005] According to an embodiment of this application, the document parsing result includes key-value pair text for each content block. The key-value pair text includes multiple fields and the values of each field. The multiple fields include a content field, a sequence number field, a page number field, a content type field, and a target level field. The values of the content field, the sequence number field, and the page number field are document content, sequence information, and document page number, respectively. The content type value is determined based on the type label of each paragraph mark text.
[0006] According to an embodiment of this application, the multiple fields also include a target level field, and the paragraph mark text includes style identifiers of the content blocks; the method further includes: obtaining a style file of the document to be parsed, the style file including style layout information of the document to be parsed; determining the target level information of each content block from the style layout information according to the style identifiers of each content block; the value of the target level field is the target level information.
[0007] According to embodiments of this application, type tags include at least one of image tags, text tags, table tags, and structured tags; based on the type tags of each paragraph mark text, obtaining the document content of each content block from each paragraph mark text includes at least one of the following: when the type tag of the paragraph mark text is a text tag, extracting the content between the text start tag and the text end tag from the paragraph mark text as the document content; when the type tag of the paragraph mark text is an image tag, determining image information from the paragraph mark text based on the image tag; and determining the target image address from the document dependency file based on the image information as the document content; the document dependency file includes the address of the image in the document to be parsed.
[0008] According to embodiments of this application, obtaining the document content of each content block from each paragraph mark text based on the type tags of each paragraph mark text includes: when the type tag of the paragraph mark text of the content block is a table tag, determining the cell information of multiple cells in the content block sequentially from the paragraph mark text based on the table tag, the cell information including the row number, column number, and cell content of the cell; determining the cell content from the paragraph mark text based on the cell tag; determining the row number range and column number range of multiple merged sub-tables in the content block based on the row number, column number, and cell content of each cell; the merged sub-table contains at least one cell, and the cell content of each cell in the merged sub-table is the same; determining the document content of the content block based on the row number range, column number range, and cell content of each merged sub-table in the content block.
[0009] According to embodiments of this application, obtaining the document content of each content block from each paragraph markup text based on the type tags of each paragraph markup text includes: when the type tag of the paragraph markup text is a structured tag, the content block is taken as the root content block; when the paragraph markup text includes unstructured tags, the first document content of the root content block is determined based on the unstructured tags; the unstructured tags are image tags, text tags, or table tags; when the paragraph markup text also includes M-level structured tags other than type tags, the second document content is determined based on the M-level structured tags, where M is an integer greater than or equal to 1.
[0010] According to an embodiment of this application, determining the content of a second document based on M-level structured tags includes: determining a first-level marked text fragment from paragraph marked text based on structured tags; determining a m-level marked text fragment from (m-1)-level marked text fragments based on the m-th level structured tags in the M-level structured tags; m=2, ..., M; and determining a m-level content fragment in the second document content based on the unstructured tags contained in the m-th level marked text fragment when the m-th level marked text fragment contains unstructured tags.
[0011] According to an embodiment of this application, obtaining the document page number of each content block based on the first word count of each page in the document to be parsed, the second word count of each content block, and the sequence information of multiple content blocks includes: determining the first start index and the first end index of the text on each page based on the first word count of each page in the document to be parsed; determining the sequence number of each content block according to the sequence information; determining the second start index and the second end index of the text in each content block according to the sequence number of each content block and the second word count of the content block; determining the page that first meets the page number matching condition among the multiple pages of the document to be parsed as the target page of the content block, wherein the page number matching condition is that the second start index is less than or equal to the first end index, and the second end index is greater than or equal to the first start index; and using the page number as the document page number of each content block.
[0012] According to embodiments of this application, determining the target hierarchy information of each content block from the style layout information based on the style identifier of each content block includes: determining the style information of multiple style node blocks from the style file based on the style start tag and style end tag; the style information of the style node blocks constitutes the style layout information; matching the style number and hierarchy number of multiple style node blocks from the multiple style information based on the style number tag and hierarchy number tag; matching the content block style number of each content block from the paragraph mark text of each content block based on the content block style tag; determining the target style node block from the multiple style node blocks based on the content block style number of each content block; and using the hierarchy number of the target style node block as the target hierarchy information of each content block.
[0013] According to a second aspect of this application, an electronic device is provided, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0014] The document parsing method provided in this application has at least the following advantages compared with related technologies:
[0015] This application identifies the document content of each content block by using type tags in paragraph markup text, determines the order information of the content blocks based on the paragraph markup text, and accurately matches the document page number corresponding to each content block by combining the page word count and the word count of the content block. Simultaneously, it parses the content block hierarchy information using document style files, ultimately generating a key-value pair structured parsing result containing multi-dimensional standardized fields. This provides a parsable data format suitable for data retrieval, intelligent search, intelligent analysis, and risk prediction by the quality intelligence agent, improving the reuse efficiency of laptop quality document resources and reducing manual processing costs and errors. Attached Figure Description
[0016] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0017] Figure 1 This is an example flowchart of a document parsing method according to an embodiment of this application;
[0018] Figure 2 This is a schematic diagram illustrating the principle of a document parsing method according to an embodiment of this application;
[0019] Figure 3 This is a block diagram of an electronic device to which a document parsing method can be applied, according to an embodiment of this application. Detailed Implementation
[0020] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0021] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0022] Figure 1 This is a flowchart of a document parsing method according to an embodiment of the present disclosure.
[0023] like Figure 1 As shown, the method 100 includes operations S110-S150.
[0024] In operation S110, the content file obtained after decompression of the document to be parsed is obtained. The document to be parsed includes multiple content blocks, and the content file includes paragraph mark text for each content block. The paragraph mark text includes at least one type tag.
[0025] In this embodiment of the disclosure, the document to be parsed is a Word document in DOCX format that conforms to the Office Open XML (OOXML) international standard. This type of document is essentially a collection of files encapsulated using the ZIP compression algorithm, which internally stores multiple sub-files containing information such as document text content, format styles, and media resources.
[0026] The content file is a carrier file extracted from the document to be parsed, used to record all content block markup information and text content. It corresponds to the main document XML file located at / word / document.xml after the DOCX document is decompressed. This file records the format attributes, type identifiers and actual text content of all paragraphs in the document in an XML tree-like tag structure.
[0027] Paragraph markup text is a complete XML node corresponding to a single content block in the content file; for example, a single paragraph markup in the DOCX main document. <w:p>The complete code snippet corresponding to a paragraph node can also be a single element in the main DOCX document. <w:tbl>The complete code snippet corresponding to the table node, or a single one in the DOCX main document. <w:sdt>The complete code snippet corresponding to the structured control node.
[0028] The following is a specific example of a content file:
[0029] <w:body><!-- Document body root node, carrying all content blocks -->
[0030] <w:p><!-- Paragraph node, text-type content block container -->
[0031] <w:ppr> <w:pstyle w:val="Heading1" / > < / w:ppr> <!-- Paragraph attribute, bound to Heading1 heading style -->
[0032] <w:r> <w:t> 1. Technical Overview< / w:t> < / w:r> <!-- Text node, carrying the actual content of the paragraph -->
[0033] < / w:p> <!-- Paragraph node closed -->
[0034] <w:tbl><!-- Table node, container for table-type content blocks -->
[0035] <w:tblpr> <w:tblstyle w:val="TableGrid" / > < / w:tblpr> <!-- Table attribute, bound to the TableGrid grid style -->
[0036] <w:tr> <w:tc> <w:p> <w:r> <w:t> Parameters< / w:t> < / w:r> < / w:p> < / w:tc> < / w:tr> <!-- Table row + cell, carrying text content -->
[0037] < / w:tbl> <!-- Table node closed -->
[0038] <w:sdt><!-- Structured control node, structured content block container -->
[0039] <w:sdtpr> <w:tag w:val="审批栏" / > < / w:sdtpr> <!-- Control attribute, identifying the business type as an approval bar -->
[0040] <w:sdtcontent><!-- Control content container, carrying internal visible content -->
[0041] <w:p> <w:r> <w:t> Approver: ________< / w:t> < / w:r> < / w:p> <!-- Paragraph inside the control, carrying displayed text -->
[0042] < / w:sdtcontent> <!-- Control content node closure -->
[0043] < / w:sdt> <!-- Structured control node closed -->
[0044] < / w:body> <!-- Closing of the root node of the main text -->
[0045] The above content file example includes three content blocks, which respectively correspond to <w:p>Paragraph nodes <w:tbl>Table nodes and <w:sdt>Structured control nodes, so that the paragraph mark text corresponding to each content block corresponds to... <w:p> Tags and< / w:p> Content between tags <w:tbl> Tags and< / w:tbl> The content between tags, and <w:sdt>Tags and <w:sdt>The content between the tags.
[0046] Type tags, on the other hand, determine the content type of a corresponding content block by using specific tags contained in the paragraph markup text. For example... <w:p>If the corresponding content block contains <w:t>If this type of tag exists, then the content block corresponds to the text type. <a:blip>If this type label is specified, then the content block corresponds to the image type type label, and... <w:tbl>and <w:sdt>It itself serves as a type label, indicating that the corresponding content blocks are of the types of tables and structured controls, respectively.
[0047] In operation S120, the document content of each content block is obtained from each paragraph mark text according to the type label of each paragraph mark text.
[0048] In this embodiment of the disclosure, document content refers to the XML text fragment representing the actual content displayed in the Word document, extracted from the complete XML node of the paragraph mark text after removing pure formatting attribute tags. For example, in the above content file example, for <w:t>This type of tag contains the plain text content of the "1 Technical Overview" section enclosed by the tag, which is directly displayed to the user in a Word document; for <w:tbl>The document content of this type of tag is the corresponding table row structure. <w:tr> <w:tc> <w:p> <w:r> <w:t> Parameters< / w:t> < / w:r> < / w:p> < / w:tc> < / w:tr> In the marked fragment, "parameter item" refers to the displayed text within a single cell of the table. This means that the table in the example content file above contains only one cell. When a table contains multiple cells, its document content consists of the displayed text of those multiple cells. For <w:sdt>The document content of this type of tag is the paragraph within the corresponding structured control. <w:p> <w:r> <w:t> Approver: ________< / w:t> < / w:r> < / w:p> The document content in the marked fragment is the visible text "Approver: ________" presented to the user within the control area.
[0049] It is understood that the content of each of the above documents can be obtained through pattern matching, and this application will not elaborate further here.
[0050] In operation S130, the sequence information of multiple content blocks is obtained based on the paragraph mark text; the sequence information indicates the sequential relationship between the various content blocks.
[0051] In this embodiment, the sequence information comes from the natural order of the paragraph mark text in the document body node of the content file, corresponding to the top-to-bottom display order of each content block in the document to be parsed. During the parsing process, the arrangement position of each content block is recorded in the order in which the paragraph mark text appears in the XML tree structure, so as to obtain the sequence information representing the logical relationship between each content block.
[0052] For example, in the content file example above, <w:p>Paragraph nodes <w:tbl>Table nodes and <w:sdt>The structured control nodes are displayed sequentially. Therefore, the order of the three content blocks is paragraph type content block, table type content block, and structured control type content block.
[0053] In operation S140, based on the first word count of each page in the document to be parsed, the second word count of each content block, and the order information of multiple content blocks, the document page number of each content block is obtained; the first word count is obtained by counting the words of each page in the read-only format document, which is obtained by converting the format of the document to be parsed; the second word count is the number of words in the document content of the content block.
[0054] In this embodiment of the disclosure, the first character count is the total number of characters in the text content of each page of the document to be parsed. An exemplary method of obtaining the first character count is to convert the DOCX format document to be parsed into the corresponding read-only format document, such as the corresponding PDF file, and call the built-in character count interface of the PDF to read the first character count of each page. Other methods can also be used to obtain the first character count, such as OCR. This application does not limit this.
[0055] The second character count is the total number of characters in the document content corresponding to a single content block. Combined with the sequential arrangement of content blocks determined by the order information, and by comparing the first character count of each page with the second character count of each content block, the document page number corresponding to each content block in the document to be parsed can be calculated. For example, in the aforementioned content file example, based on the order of the three types of content blocks—paragraphs, tables, and structured controls—and their respective character counts, combined with the first character count of each page in the document, it can be determined that all three content blocks correspond to page 1 of the document. If the total character count of the content blocks preceding subsequent content blocks exceeds the character count range of page 1, then the subsequent content blocks will be deferred to the subsequent page number.
[0056] In operation S150, the document parsing result for the document to be parsed is determined based on the document content, sequence information, and document page number of each content block.
[0057] In this embodiment, the document parsing result is structured data that integrates the document content, sequence information, and corresponding page numbers of each content block. For example, it can be converted into a standardized format such as JSON (JavaScript Object Notation) that can be directly parsed by the intelligent agent, realizing the conversion from unstructured documents to structured data. Taking the above content file example, the final output JSON format parsing result displays the corresponding information of each content block in sequence. The first record corresponds to a paragraph-type content block, including its document content "1 Technical Overview", sequence position 1, and corresponding document page number 1. The second record corresponds to a table-type content block, including its single-cell table content "Parameter Item", sequence position 2, and corresponding document page number 1. The third record corresponds to a structured control-type content block, including its document content "Approver: ________", sequence position 3, and corresponding document page number 1. This allows the downstream intelligent agent to directly read the structured data to complete subsequent document processing operations, reducing manual processing costs.
[0058] In some embodiments, the document parsing result includes key-value pair text for each content block. The key-value pair text includes multiple fields and the values of each field. The multiple fields include a content field, a sequence number field, a page number field, a content type field, and a target level field. The values of the content field, the sequence number field, and the page number field are document content, sequence information, and document page number, respectively. The content type value is determined based on the type label of each paragraph markup text.
[0059] In this embodiment of the disclosure, the parsing result of the above-mentioned JSON format summarizes all content blocks in the form of an array. Each content block corresponds to a set of independent key-value pairs of text, and each field is identified by a fixed key name and the corresponding information is the key value. Taking the above content file example, the generated JSON parsing result contains three array objects arranged in document order, each array object with a fixed key name corresponding to a fixed key value. In the key-value pair corresponding to the first content block, the content field key value is "1 Technical Overview", the sequence number field key value is 1, the page number field key value is 1, and the content type field key value is "Text", which is mapped from the type tag of the corresponding <w:p> node and the internal <w:t> text tag of this content block. In the key-value pair corresponding to the second content block, the content field key value is "Parameter Item", the sequence number field key value is 2, the page number field key value is 1, and the content type field key value is "Table", which is directly mapped from the type tag of the corresponding <w:tbl> node of this content block. In the key-value pair corresponding to the third content block, the content field key value is "Approver:________", the sequence number field key value is 3, the page number field key value is 1, and the content type field key value is "Structured Controls".
[0060] Through the above embodiments, the parsing results are further represented in a more structured key-value pair data format, making it easier for downstream intelligent agents to fully recognize document information.
[0061] In some embodiments, the multiple fields further include a target level field, and the paragraph mark text includes style identifiers of the content blocks; the method further includes: obtaining a style file of the document to be parsed, the style file including style layout information of the document to be parsed; determining the target level information of each content block from the style layout information according to the style identifiers of each content block; the value of the target level field is the target level information.
[0062] In this embodiment, the style file is a style definition file located at / word / styles.xml after the DOCX document has been decompressed, storing a set of style rules for the document to be parsed. The style layout information is a set of format attributes included in each independent style definition in the style file, covering layout and format parameters such as style name, style type, outline level, character format, and paragraph spacing. The style identifier is a unique identifier field used to associate a specified style with each content block in the paragraph mark text, i.e., the w:val attribute value of the <w:pStyle> node within the paragraph mark text, also known as the style ID. This style identifier corresponds one-to-one with the w:styleId attribute of the <w:style> node in the style file, allowing the target level corresponding to the content block to be matched through the style identifier.
[0063] In some embodiments, type tags include at least one of image tags, text tags, table tags, and structured tags; based on the type tags of each paragraph markup text, obtaining the document content of each content block from each paragraph markup text includes at least one of the following: when the type tag of the paragraph markup text is a text tag, extracting the content between the text start tag and the text end tag from the paragraph markup text as the document content; when the type tag of the paragraph markup text is an image tag, determining image information from the paragraph markup text based on the image tag; and determining the target image address from the document dependency file based on the image information as the document content; the document dependency file includes the address of the image in the document to be parsed.
[0064] In this embodiment of the disclosure, the text tags correspond to the XML structure of the DOCX document. <w:p>In the corresponding paragraph content block <w:t>Tags are used to identify nodes representing plain text content; image tags correspond to... <a:blip>Tags are used to identify the reference nodes of the embedded image; table tags correspond to... <w:tbl>Tags are used to identify table-like content block nodes; structured tags correspond to... <w:sdt>a tag, configured to identify a structured control-type content block node
[0065] In the scenario where the type tag of a paragraph markup text is a text tag, by matching the text start tag in the paragraph markup text <w:t> With text end tag< / w:t> , the string content between the two is extracted as the document content of the content block; taking the paragraph content block with the content of "1 Technical Overview" as an example, the paragraph markup text thereof contains <w:t> 1. Technical Overview< / w:t> a node, after identifying that its type tag is a text tag, extracting <w:t> and< / w:t> "1 Technical Overview" between the two, the document content of the content block can be obtained
[0066] In the scenario where the type tag of a paragraph markup text is an image tag, description is given by taking the xml text of the following image-type content block as an example
[0067] <w:p><!-- Paragraph node, a container for inline images -->
[0068] <w:ppr> <w:pstyle w:val="Normal" / > < / w:ppr> <!-- Paragraph attribute, bound to Normal body text style -->
[0069] <w:drawing><!-- Drawing node, the outer container for graphic objects within a paragraph -->
[0070] <wp:inline><!-- Inline graphic node, identifying that the image is embedded in the paragraph in an inline form -->
[0071] <a:graphic><!-- Graphic object node, encapsulating graphic data and type definition -->
[0072] <a:graphicdata uri="http: / / schemas.openxmlformats.org / drawingml / 2006 / picture"><!-- Graphic data node, the uri specifies that the graphic type is an image -->
[0073] <pic:pic><!-- Root node of image object, carrying image filling and attribute information -->
[0074] <pic:blipfill><!-- Image fill node, defining image filling rules -->
[0075] <a:blip r:embed="rIdImage001" / > <!-- Image reference node, associating image files within the document via resource ID -->
[0076] < / pic:blipfill> <!-- Image filling node closed -->
[0077] < / pic:pic> <!-- Image object node closed -->
[0078] < / a:graphicdata> <!-- Graphic data node closure -->
[0079] < / a:graphic> <!-- Graphic object node closure -->
[0080] < / wp:inline> <!-- Inline graphic node closed -->
[0081] < / w:drawing> <!-- Drawing node closed -->
[0082] < / w:p> <!-- Paragraph node closed -->
[0083] First, from the paragraph markup text <a:blip>Extract the value of the r:embed attribute from the image tag as image information, where the value is the unique relationship identifier of the image resource; then read the document dependency file corresponding to the document to be parsed, that is, the .rels file under the word / _rels path after decompression, which stores the mapping relationship between the relationship identifiers of all embedded resources and the actual file storage paths; according to the relationship identifier in the image information, match and obtain the corresponding target image file storage address in the document dependency file, and use this address as the document content of the image content block. For example, in the above paragraph marked text containing an image, the relationship identifier corresponding to the extracted image information is "rIdImage001", and the Target attribute value corresponding to this identifier matched in the document dependency file is "media / image1.png", so that the target image address can be determined as word / media / image1.png, which is used as the document content of this content block.
[0084] Through this embodiment, it is illustrated that when the types of the content blocks are text and image, the information displayed in the Word file is obtained from the XML file, and other irrelevant information is filtered out, so that the downstream quality agent can more accurately grasp the information in the Word file and obtain more accurate input content, thereby reducing the input noise of the quality agent and improving the output accuracy.
[0085] In some embodiments, obtaining the document content of each content block from each paragraph marked text according to the type tag of each paragraph marked text includes: when the type tag of the paragraph marked text of the content block is a table tag, sequentially determine the cell information of a plurality of cells in the content block from the paragraph marked text according to the table tag, where the cell information includes the row number, column number and cell content of the cell; the cell content is determined from the paragraph marked text based on the cell tag; determine the row number interval and column number interval of a plurality of merged sub-tables in the content block according to the row number, column number and cell content of each cell; a merged sub-table includes at least one cell, and the cell content of each cell contained in the merged sub-table is the same; the document content of the content block is determined according to the row number interval, column number interval of each merged sub-table in the content block and the cell content of the cells contained therein.
[0086] In the embodiment of the present disclosure, in the scenario where the type tag of the paragraph marked text is an image tag, the description is given by taking the following XML text of a table type content block as an example:
[0087] <w:tbl><!-- Table root node -->
[0088] <w:tblpr> <w:tblstyle w:val="TableGrid" / > < / w:tblpr> <!-- Table attribute, bound to grid style -->
[0089] <!-- Row 1 -->
[0090] <w:tr><!-- First table row node -->
[0091] <!-- First column: horizontally merged starting cell -->
[0092] <w:tc><!-- Cell at row 1, column 1 -->
[0093] <w:tcpr> <w:hmerge w:val="restart" / > < / w:tcpr> <!-- Cell attribute, marking the start of horizontal merging -->
[0094] <w:p> <w:r> <w:t> A-side appearance inspection< / w:t> < / w:r> < / w:p> <!-- Cell text content -->
[0095] < / w:tc> <!-- Cell closing -->
[0096] <!-- Second column: horizontally merged continuing cell -->
[0097] <w:tc><!-- Cell at row 1, column 2 -->
[0098] <w:tcpr> <w:hmerge w:val="continue" / > < / w:tcpr> <!-- Cell attribute, marking continuation of horizontal merging -->
[0099] <w:p> <w:r> <w:t> A-side appearance inspection< / w:t> < / w:r> < / w:p> <!-- Cell text content -->
[0100] < / w:tc> <!-- Cell closing -->
[0101] <!-- Third column: normal cell -->
[0102] <w:tc><!-- Cell at row 1, column 3 -->
[0103] <w:tcpr / > <!-- Cell attribute, no special format -->
[0104] <w:p> <w:r> <w:t> Judgment criteria< / w:t> < / w:r> < / w:p> <!-- Cell text content -->
[0105] < / w:tc> <!-- Cell closing -->
[0106] < / w:tr> <!-- Table row closed -->
[0107] <!-- Row 2 -->
[0108] <w:tr><!-- Second table row node -->
[0109] <w:tc><!-- Cell at row 2, column 1 -->
[0110] <w:tcpr / > <!-- Cell attribute, no special format -->
[0111] <w:p> <w:r> <w:t> Defect types< / w:t> < / w:r> < / w:p> <!-- Cell text content -->
[0112] < / w:tc> <!-- Cell closure -->
[0113] <w:tc><!-- Cell at row 2, column 2 -->
[0114] <w:tcpr / > <!-- Cell attribute, no special format -->
[0115] <w:p> <w:r> <w:t> Specification< / w:t> < / w:r> < / w:p> <!-- Cell text content -->
[0116] < / w:tc> <!-- Cell closure -->
[0117] <w:tc><!-- Cell at row 2, column 3 -->
[0118] <w:tcpr / > <!-- Cell attribute, no special format -->
[0119] <w:p> <w:r> <w:t> result< / w:t> < / w:r> < / w:p> <!-- Cell text content -->
[0120] < / w:tc> <!-- Cell closure -->
[0121] < / w:tr> <!-- Table row closed -->
[0122] < / w:tbl> <!-- Table root node closed -->
[0123] It is understandable that in the XML text of the table-type content block mentioned above, the text in the first row and first column and the first row and second column are both "A-side appearance inspection", so the cells that need to be merged are the cells in the first row and first column and the first row and second column.
[0124] First, after identifying the paragraph mark text as a table mark, it iterates through the... <w:tbl>All under the node <w:tr>row node and <w:tc>Cell nodes are assigned row numbers for each row and column numbers for each column in traversal order. Simultaneously, each cell's... <w:t>Extracting text from tags as cell content: Taking the XML text of the table-type content block mentioned above as an example, we can obtain complete information for 6 cells: the content of row 1, column 1 is "A-side appearance inspection", the content of row 1, column 2 is "A-side appearance inspection", the content of row 1, column 3 is "judgment criteria", the content of row 2, column 1 is "defect type", the content of row 2, column 2 is "specification", and the content of row 2, column 3 is "result".
[0125] Subsequently, based on the cell merging attributes and content, cells belonging to the same merging group are aggregated into merged sub-tables, and the row numbering range and column numbering range of each merged sub-table are determined. In the example above, the cells in row 1, column 1 and row 1, column 2 belong to the cell group to be merged and can be aggregated into a merged sub-table. The row numbering range of the merged sub-table is [1,1] and the column numbering range is [1,2]. The cell content of each cell in the merged sub-table is "A-side appearance inspection". The remaining 4 cells each correspond to a merged sub-table containing only a single cell, and the row and column numbering ranges are all single values.
[0126] Finally, based on the row numbering range, column numbering range, and cell content of each merged sub-table, the table structure is converted into the required specific format document content.
[0127] In some embodiments, HTML format can be used to convert the table structure to reduce the number of words in the text, reduce the input scale of the downstream quality agent, and improve the output efficiency of the quality agent.
[0128] Given an HTML format, the example XML text based on the table-type content block described above can be converted into the following HTML content: A-side appearance inspection Judgment criteria Defect types Specification result The value "colspan="2" indicates that the cells in the row interval [1,1] and column interval [1,2] are merged to form a merged sub-table.
[0129] In some other embodiments of this application, before extracting the document content of a table-type content block, it is also necessary to constrain the validity of the table. That is, it is necessary to first confirm that the table can be safely and structurally parsed to avoid subsequent calculations of merged cells, crashes during HTML generation, or generation of incorrect structures. Specifically, it is necessary to determine in advance whether the table is valid, including at least: whether the table has at least one row, whether the table has at least one column, and whether the first row and first column cells of the table can be read normally.
[0130] It can be understood that there may also be some structured controls such as text boxes in the word file, and these structured controls are represented in the content file as <w:sdt> …< / w:sdt> , and each structured control can not only contain other types of sub-content blocks, such as text type, image type and table type, but also contain lower-level structured controls. Therefore, when reading the document content corresponding to the structured control, it is necessary to traverse and read the content of other types of sub-content blocks inside each level level by level. The process of extracting the document content of the content block corresponding to the structured tag is further described below.
[0131] In some embodiments, obtaining the document content of each content block from each paragraph marker text according to the type tag of each paragraph marker text includes: when the type tag of the paragraph marker text is a structured tag, taking the content block as the root content block; when the paragraph marker text includes an unstructured tag, determining the first document content of the root content block according to the unstructured tag, where the unstructured tag is an image tag, a text tag or a table tag; when the paragraph marker text further includes M levels of structured tags other than the type tag, determining the second document content according to the M levels of structured tags, where M is an integer greater than or equal to 1; determining the second document content according to the M levels of structured tags includes: determining the first-level marker text segment from the paragraph marker text according to the structured tag; determining the m-th level marker text segment from the (m-1)-th level marker text segment according to the m-th level structured tag in the M levels of structured tags, where m=2, ..., M; when the m-th level marker text segment contains an unstructured tag, determining the m-th level content segment in the second document content from the m-th level marker text segment according to the unstructured tag contained in the m-th level marker text segment.
[0132] In the embodiments of the present disclosure, in the scenario where the type tag of the paragraph marker text is a structured tag, description is made by taking the following xml text with multi-level structured controls as an example.
[0133] <w:sdt><!-- Root structured control node -->
[0134] <w:sdtpr> <w:tag w:val="审批栏" / > < / w:sdtpr> <!-- Control attribute, identifying that the service type is an approval bar -->
[0135] <w:sdtcontent><!-- Root control content container -->
[0136] <w:p> <w:r> <w:t> Approval Main Column< / w:t> < / w:r> < / w:p> <!-- Text content within the root control -->
[0137] <!-- First-level nested structured control -->
[0138] <w:sdt><!-- First-level nested structured control -->
[0139] <w:sdtpr> <w:tag w:val="审批人项" / > < / w:sdtpr> <!-- Control attribute, identified as approver item -->
[0140] <w:sdtcontent><!-- Primary control content container -->
[0141] <w:p> <w:r> <w:t> Approver: ________< / w:t> < / w:r> < / w:p> <!-- Text content inside the primary control -->
[0142] <!-- Second-level nested structured control -->
[0143] <w:sdt><!-- Second-level nested structured control -->
[0144] <w:sdtpr> <w:tag w:val="签字区" / > < / w:sdtpr> <!-- Control attribute, identified as a signature area -->
[0145] <w:sdtcontent><!-- Secondary control content container -->
[0146] <w:p> <w:r> <w:t> signature:< / w:t> < / w:r> < / w:p> <!-- Text content within secondary control -->
[0147] < / w:sdtcontent> <!-- Second-level control content closure -->
[0148] < / w:sdt> <!-- Second-level structured control closing -->
[0149] < / w:sdtcontent> <!-- First-level control content closure -->
[0150] < / w:sdt> <!-- First-level structured control closing -->
[0151] < / w:sdtcontent> <!-- Root control content closure -->
[0152] < / w:sdt> <!-- Root structured control closed -->
[0153] In this example of the xml text with multi-level structured controls, when it is identified that the type tag of the paragraph marker text of the content block is a structured tag, the outermost layer is first <w:sdt>The corresponding content block is used as the root content block, and then the root content block is traversed. <w:sdtcontent>The direct child nodes of a node are filtered out to identify unstructured tags that do not belong to the inner structured controls. In the example, these are the tags directly carried by the root control. <w:t> Approval Main Column< / w:t> The text tag is used to extract the text content "Approval Summary" enclosed in the tag, which is the first document content of the root content block. It can be understood that if this root content block contains other types of content blocks, such as image-type or table-type content blocks, they can be extracted using the methods described above for extracting document content from image-type and table-type content blocks, respectively. This application will not elaborate further on these methods here.
[0154] If the paragraph markup text contains M levels of nested structured tags, the second document content is further extracted layer by layer. For example, in this example of XML text with multi-level structured controls, the total nesting level M=2. The specific execution process is as follows: First, based on the structured tags, locate the first level of nesting from the paragraph markup text of the root content block. <w:sdt>The node retrieves the first-level marked text fragment, which is the structured control XML fragment corresponding to the tag "Approver Item"; then, iterates inwards sequentially, for the m-th level (m=2) structured tag, locating the next level from the (m-1)-th level (first-level) marked text fragment. <w:sdt>The node retrieves the second-level marked text fragment, which is the structured control XML fragment labeled "Signature Area," completing the location of marked text fragments at all levels. After locating the marked text fragments at each level, each level of marked text fragment is processed sequentially. If the fragment contains unstructured tags, the corresponding content is extracted as the m-th level content fragment of the second document content. In the corresponding example, the unstructured text "Approver: ________" in the first-level marked text fragment is the first-level content fragment, and the unstructured text "Signature:" in the second-level marked text fragment is the second-level content fragment. All levels of content fragments together constitute the second document content, and the original nested hierarchical relationship is fully preserved. Finally, the document content of the root content block is composed of the first document content and the second document content carrying hierarchical information, in order to restore the content and hierarchical logic of the nested structured control. It is understood that if other types of content blocks are contained in the content blocks at each level, such as image-type content blocks or table-type content blocks, they can be extracted according to the document content extraction methods for image-type and table-type content blocks described above, and will not be elaborated further in this application.
[0155] In another embodiment of this application, the content blocks at each level mentioned above participate in the sorting of the order relationship between the content blocks mentioned above. That is, each content block at each level in the content block corresponding to the structured control is treated as a new content block according to the order in which it is traversed, and participates in the order sorting with other content blocks to obtain complete order information.
[0156] Through the above embodiments, it is possible to parse the text, tables and other entity content at each level within a multi-layered nested structured control layer by layer, so as to restore the nesting hierarchy of the structured control and ensure that the multi-layered content inside the structured control is extracted without omission and in an orderly manner.
[0157] In some embodiments, obtaining the document page number of each content block based on the first word count of each page in the document to be parsed, the second word count of each content block, and the order information of multiple content blocks includes: determining the first start index and the first end index of the text on each page based on the first word count of each page in the document to be parsed; determining the sequence number of each content block according to the order information; determining the second start index and the second end index of the text in each content block according to the sequence number of each content block and the second word count of the content block; determining the page that first meets the page number matching condition among the multiple pages of the document to be parsed as the target page of the content block, wherein the page number matching condition is that the second start index is less than or equal to the first end index, and the second end index is greater than or equal to the first start index; and using the page number as the document page number of each content block.
[0158] The second character count is the total number of characters in the document content within a single content block. It should be noted that image-type content blocks have no text, so the second character count is uniformly assigned to 0. For nested structured content blocks, the character length of each level of sub-content needs to be counted and accumulated to obtain the second character count of each level of content block. Then, a unique sequence number is assigned to each content block using sequence information, representing the top-to-bottom arrangement order of the content blocks. The index is the continuous character count subscript of the full text, starting from 0 and incrementing.
[0159] The embodiments of this disclosure are illustrated below with examples:
[0160] For example, for any document to be parsed, after converting it to PDF format, if the first character on page 1 is 15, then the page character index range of page 1 includes the first starting index 0 and the first ending index 14. If the first character on page 2 is 16, then the first starting index of page 2 is 15 and the first ending index is 30.
[0161] The document to be parsed contains four content blocks arranged in sequence. Content block 1 is text, with the paragraph text "1 Technical Overview", thus its second character count is 5. Content block 2 is a table, with the total length of all text displayed in the cells being 3, thus its second character count is 3. Content block 3 is a nested structured control; the character count of each level of its internal sub-content needs to be counted and accumulated. The total character count of its two levels of embedded text is 7, therefore the second character count of this structured control content block is 7. Content block 4 is text, with the paragraph text "2 System Architecture Design", thus its second character count is 7. Sequence numbers 1 to 4 are assigned to the content blocks according to their order. The second starting index and second ending index of each content block are calculated sequentially from smallest to largest. The second starting index of content block 1 is 0, and the second ending index is 4; the second starting index of content block 2 is 5, and the second ending index is 7; the second starting index of content block 3 is 8, and the second ending index is 14; the second ending index of content block 4 is... The second starting index is 15, and the second ending index is 21. Then, based on the page number matching condition, a page-by-page matching is performed. That is, if the second starting index of a content block is less than or equal to the first ending index of the page, and the second ending index is greater than or equal to the first starting index of the page, then the content block belongs to the corresponding page. After comparison, the character ranges of content blocks 1, 2, and 3 all overlap with the index range of page 1; therefore, the document page number for all three is page 1. The character range of content block 4 does not overlap with page 1 but matches the index range of page 2; therefore, the document page number for content block 4 is page 2. This completes the determination of the document page numbers for all content blocks, obtaining the page where each content block belongs, thus preserving the document structure information.
[0162] In some embodiments, determining the target hierarchy information of each content block from the style layout information according to the style identifier of each content block includes: determining the style information of a plurality of style node blocks from the style file according to the style start tag and the style end tag; the style information of the style node blocks constitutes the style layout information; matching the style number and hierarchy number of the plurality of style node blocks from the plurality of style information according to the style number tag and the hierarchy number tag; matching the content block style number of each content block from the paragraph mark text of each content block according to the content block style tag; determining a target style node block from the plurality of style node blocks according to the content block style number of each content block; and taking the hierarchy number of the target style node block as the target hierarchy information of each content block.
[0163] In the embodiments of the present disclosure, the manner of obtaining the target hierarchy information is described below by taking an example of a style file corresponding to the above content file:
[0164] <w:styles xmlns:w="http: / / schemas.openxmlformats.org / wordprocessingml / 2006 / main"><!-- Root node of the style file, declaring the Word processing ML namespace -->
[0165] <w:style w:type="paragraph" w:styleid="Heading1"><!-- Paragraph style node, style ID is Heading1 -->
[0166] <w:name w:val="heading 1" / > <!-- Style name, identified as level 1 heading -->
[0167] <w:outlinelvl w:val="1" / > <!-- Outline level, corresponding to document hierarchy level 1 -->
[0168] <w:rpr><!-- Character format attribute container -->
[0169] <w:sz w:val="32" / > <!-- Font size setting -->
[0170] <w:b / > <!-- Character bold setting -->
[0171] < / w:rpr> <!-- Character attribute node closed -->
[0172] < / w:style> <!-- First-level heading style node closed -->
[0173] <w:style w:type="table" w:styleid="TableGrid"><!-- Table style node, style ID is TableGrid -->
[0174] <w:name w:val="Table Grid" / > <!-- Style name, identified as grid table -->
[0175] < / w:style> <!-- Table style node closed -->
[0176] < / w:styles> <!-- Style file root node closed -->
[0177] In this style file example, the style start tag is <w:style> The style closing tag is< / w:style> , and the complete XML node wrapped by each set of start and end tags is an independent style node block, so that two style node blocks can be split from this style file example, which are respectively a paragraph style node block corresponding to the first-level heading style definition and a table style node block corresponding to the table grid style definition, and all attribute information in the two style node blocks jointly constitutes the style layout information of the document.
[0178] And the style number tag is <w:style>The `w:styleId` attribute of a node is used to uniquely identify each style node block; the hierarchy number label is used within the style node block. <w:outlinelvl>The w:val attribute of a node is used to represent the outline hierarchy depth corresponding to the style. For example, in the first paragraph style node block, the style number tag is "Heading1", meaning the style number is "Heading1", and the internal hierarchy number tag is "1", meaning the hierarchy number is 1. The style number of the second table style node block is "TableGrid", and it does not contain a hierarchy number tag, so the default hierarchy number is 9.
[0179] Next, based on the content block style tags, the content block style numbers of each content block are extracted from the paragraph mark text of each content block; the content block style tags differ depending on the content block type, with paragraph-type content blocks corresponding to... <w:ppr>under the node <w:pstyle>The w:val attribute of a node corresponds to the table-type content block. <w:tblpr>under the node <w:tblstyle>The w:val attribute of the node; corresponding to the content file example above, the content block of the paragraph with the content "1 Technical Overview" has the content block style tag value of "Heading1" in the paragraph mark text, that is, the content block style number of this content block is "Heading1"; the content block style tag value of the table content block is the default value 9.
[0180] Finally, based on the content block style number of each content block, a target style node block with the same style number is matched from multiple style node blocks, and the level number corresponding to the target style node block is used as the target level information of the corresponding content block. In the above style file example, the content block with the content "1 Technical Overview" has a content block style number "Heading1" that matches the style number of the first paragraph style node block. The level number of the target style node block is 1, so the target level information of the content block is level 1.
[0181] Through the above embodiments, by matching the style number and level number of the style node block in the style file with the content block style number of the content block itself, the target level information corresponding to each content block can be automatically extracted without manually annotating the document outline level, thus realizing the restoration of the original title level structure of the DOCX document.
[0182] As can be understood, the method of this application has been explained above. The following is a schematic diagram to further illustrate the document parsing method proposed in this application.
[0183] Figure 2 This is a schematic diagram illustrating the principle of an embodiment proposed in this application.
[0184] like Figure 2 As shown, the process first extracts all content blocks from the document to be parsed. Then, it performs content parsing on each block, categorizing them into four types based on their content attributes: text, images, tables, and structured documents. The document content for each block is extracted using processing logic corresponding to its type, including text extraction, image address matching, cell merging and restoration, and layer-by-layer document content extraction. Next, based on the content blocks and document content, it performs page number matching, target level matching, and sequence encoding to determine the page number of each content block, the target level information of the content block, and the sequence number of the content block. Finally, it integrates and summarizes the document content with the page number, level, and sequence attribute information to output a complete structured document parsing result.
[0185] According to embodiments of this disclosure, this disclosure also provides an electronic device.
[0186] Figure 3 A schematic block diagram of an example electronic device 300 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0187] like Figure 3 As shown, device 300 includes a computing unit 301, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 302 or a computer program loaded from storage unit 308 into random access memory (RAM) 303. The RAM 303 may also store various programs and data required for the operation of device 300. The computing unit 301, ROM 302, and RAM 303 are interconnected via bus 304. An input / output (I / O) interface 305 is also connected to bus 304.
[0188] Multiple components in device 300 are connected to I / O interface 305, including: input unit 306, such as keyboard, mouse, etc.; output unit 307, such as various types of monitors, speakers, etc.; storage unit 308, such as disk, optical disk, etc.; and communication unit 309, such as network card, modem, wireless transceiver, etc. Communication unit 309 allows device 300 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0189] The computing unit 301 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 301 performs the various methods and processes described above, such as document parsing methods. For example, in some embodiments, the document parsing method processing can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 308. In some embodiments, part or all of the computer program can be loaded and / or installed on device 300 via ROM 302 and / or communication unit 309. When the computer program is loaded into RAM 303 and executed by the computing unit 301, one or more steps of the document parsing method processing described above can be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform document parsing method processing by any other suitable means (e.g., by means of firmware).
[0190] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard parts (ASSPs), systems-on-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0191] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0192] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.< / w:tblstyle> < / w:tblpr> < / w:pstyle> < / w:ppr> < / w:outlinelvl> < / w:style> < / w:sdt> < / w:sdt> < / w:sdtcontent> < / w:sdt> < / w:t> < / w:tc> < / w:tr> < / w:tbl> < / a:blip> < / w:sdt> < / w:tbl> < / a:blip> < / w:t> < / w:p> < / w:sdt> < / w:tbl> < / w:p> < / w:sdt> < / w:tbl> < / w:t> < / w:sdt> < / w:tbl> < / a:blip> < / w:t> < / w:p> < / w:sdt> < / w:sdt> < / w:sdt> < / w:tbl> < / w:p> < / w:sdt> < / w:tbl> < / w:p>
Claims
1. A document parsing method, characterized in that, The method includes: The compressed file of the document to be parsed is decompressed to obtain a content file. The document to be parsed includes multiple content blocks, and the content file includes paragraph mark text for each content block. The paragraph mark text includes at least one type tag. Based on the type label of each paragraph mark text, obtain the document content of each content block from each paragraph mark text; Based on the paragraph mark text, the order information of multiple content blocks is obtained; the order information indicates the sequential relationship between the various content blocks. Based on the first word count of each page in the document to be parsed, the second word count of each content block, and the order information of multiple content blocks, the document page number of each content block is obtained; the first word count is obtained by counting the words of each page in the read-only format document, which is obtained by converting the format of the document to be parsed; the second word count is the number of words in the document content of the content block. Based on the document content, sequence information, and page numbers of each content block, determine the document parsing result for the document to be parsed.
2. The document parsing method according to claim 1, characterized in that, The document parsing result includes key-value pair text for each content block, and the key-value pair text includes multiple fields and the value of each field; The multiple fields include a content field, a sequence number field, a page number field, a content type field, and a target level field; The values of the content field, sequence number field, and page number field are respectively the document content, sequence information, and document page number; The content type value is determined based on the type label of each paragraph's marked text.
3. The document parsing method according to claim 2, characterized in that, The multiple fields also include target level fields, and the paragraph mark text includes style identifiers for the content block; The method further includes: Obtain the style file of the document to be parsed, wherein the style file includes the style layout information of the document to be parsed; Based on the style identifiers of each content block, the target hierarchy information of each content block is determined from the style layout information; The value of the target level field is the target level information.
4. The document parsing method according to claim 1, characterized in that, The type tags include at least one of image tags, text tags, table tags, and structured tags; The document content obtained from each content block of each paragraph markup text based on the type tag of each paragraph markup text includes at least one of the following: When the type tag of the paragraph mark text is a text tag, the content between the text start tag and the text end tag is extracted from the paragraph mark text and used as the document content; When the type tag of the paragraph markup text is an image tag, image information is determined from the paragraph markup text based on the image tag; based on the image information, the target image address is determined from the document dependency file as the document content; the document dependency file includes the address of the image in the document to be parsed.
5. The document parsing method according to claim 4, characterized in that, The process of obtaining the document content of each content block from each paragraph markup text based on the type tags of each paragraph markup text includes: When the type label of the paragraph mark text in the content block is a table label, the cell information of multiple cells in the content block is determined sequentially from the paragraph mark text according to the table label. The cell information includes the row number, column number, and cell content of the cell. The cell content is determined from the paragraph mark text based on the cell label. Based on the row number, column number, and content of each cell, determine the row number range and column number range of multiple merged sub-tables in the content block; each merged sub-table contains at least one cell, and the cell content of each cell in the merged sub-table is the same; The document content of the content block is determined based on the row numbering range, column numbering range, and cell content of each merged sub-table in the content block.
6. The document parsing method according to claim 3, characterized in that, The process of obtaining the document content of each content block from each paragraph markup text based on the type tags of each paragraph markup text includes: When the type tag of the paragraph mark text is a structured tag, the content block is used as the root content block; If the paragraph markup text includes unstructured tags, the first document content of the root content block is determined based on the unstructured tags; the unstructured tags are image tags, text tags, or table tags. If the paragraph markup text also includes M-level structured tags in addition to the type tags, the second document content is determined based on the M-level structured tags, where M is an integer greater than or equal to 1.
7. The document parsing method according to claim 6, characterized in that, The step of determining the content of the second document based on the M-level structured tags includes: Based on the structured tags, determine the first-level marked text fragments from the paragraph marked text; Based on the m-th level structured tag in the M-th level structured tag, determine the m-th level marked text segment from the (m-1)-th level marked text segment; m=2, ...,M; If the m-th level marked text fragment contains unstructured tags, the m-th level content fragment in the second document content is determined from the m-th level marked text fragment based on the unstructured tags contained in the m-th level marked text fragment.
8. The document parsing method according to claim 1, characterized in that, Based on the first character count of each page, the second character count of each content block, and the order information of multiple content blocks in the document to be parsed, the document page numbers of each content block are obtained as follows: Based on the first character count of each page of the document to be parsed, determine the first starting index and the first ending index of the text on each page; Based on the sequence information, determine the sequence number of each content block; Based on the sequence number of each content block and the second word count of the content block, determine the second start index and the second end index of the text in each content block; The page that first meets the page number matching condition among multiple pages of the document to be parsed is determined as the target page of the content block. The page number matching condition is that the second starting index is less than or equal to the first ending index, and the second ending index is greater than or equal to the first starting index. The page number is used as the document page number for each content block.
9. The document parsing method according to claim 3, characterized in that, The step of determining the target hierarchy information of each content block from the style layout information based on the style identifier of each content block includes: Based on the style start tag and style end tag, the style information of multiple style node blocks is determined from the style file; the style information of the style node blocks constitutes the style layout information. Based on the style number label and the hierarchy number label, match the style number and hierarchy number of multiple style node blocks from multiple style information; Based on the content block style tags, match the content block style number of each content block from the paragraph mark text of each content block; Based on the content block style number of each content block, determine the target style node block from multiple style node blocks; The hierarchical number of the target style node block is used as the target hierarchical information of each content block.
10. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 8.
