OFD format document paragraph recognition method and device
Through clustering operations and semantic models, the problem of high error rate in the extraction of paragraphs in the layout document is solved, and a more accurate and generalized paragraph recognition effect is achieved.
Patent Information
- Application Number
- CN202210038042.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-13
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-01-13
AI Technical Summary
The prior art often experiences paragraph confusion in text paragraphs in extracting layout documents, resulting in high error rates and lack of effective paragraph recognition methods.
The clustering operation model and semantic model are used to segment and identify text blocks in layout documents. The text blocks are generated through image segmentation, feature attributes are extracted, clustered and evaluated, and the location information and semantic features of the text blocks are combined to identify paragraph blocks. , and update the paragraph logo in the layout document.
It improves the accuracy and universality of pattern document paragraph recognition, ensures that the extracted text paragraphs can be restored to streaming format, and reduces the error rate of paragraph recognition.
Smart Images

Figure CN114359943B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of digital text editing technology, and in particular to a method and device for identifying paragraphs in an OFD format document. Background Art
[0002] A layout document is an electronic file with a fixed layout. Its presentation is device-independent, ensuring consistent viewing across all devices, whether read, printed, or printed. Unlike a flow document, a layout document format has a fixed layout. It uses an absolute description method, clearly identifying the display position, size, and style of every element on each page. Each line of content is defined using coordinates, without the typesetting features of a flow document, such as paragraphs, headings, and tables.
[0003] In the process of implementing the prior art, the inventors found that:
[0004] Because layout documents do not have the so-called paragraphs, titles, tables and other layout features of flow documents, when it is necessary to extract the text content in the layout document, the extracted text often has disordered paragraphs.
[0005] Therefore, it is necessary to provide an OFD layout document paragraph recognition solution to solve the technical problem of high error rate in text paragraph extraction from layout documents. Summary of the Invention
[0006] The embodiment of the present application provides an OFD layout document paragraph recognition solution to solve the technical problem of high error rate in text paragraph extraction from layout documents.
[0007] Specifically, a method for identifying paragraphs in an OFD format document includes the following steps:
[0008] Get the layout document;
[0009] Parsing the layout document to generate a layout image;
[0010] Performing image segmentation on the layout image to generate at least a plurality of text blocks;
[0011] extracting characteristic attributes of the plurality of text blocks;
[0012] Using a clustering operation model, clustering operation is performed on the characteristic attributes of the text block to generate a clustering result of the text block;
[0013] Using a clustering evaluation model, the clustering results of the text blocks are classified to generate a plurality of clustered text block sets whose elements are text blocks;
[0014] Using a semantic model to calculate the relevance between the first clustered text block set and the second clustered text block set;
[0015] Performing paragraph recognition on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set to generate paragraph block information;
[0016] The paragraph mark in the layout document is updated according to the paragraph block information.
[0017] Furthermore, a clustering operation model is used to perform clustering operation on the text block information to generate a clustering result of the text block, specifically including:
[0018] Let the vector of the text block be X={x1,x2,...,x n};
[0019] use
[0020]
[0021] Calculate the clustering results of text blocks;
[0022] Where F is the clustering result of the text block, n is the number of text blocks to be classified, c is the number of cluster categories, v i (i=1,2,…,c) is the cluster center of category i, m and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i For the membership degree of category j, k and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i The probability of class j, d(x j ,v i ) is the text block information x j To cluster center v i The Euclidean distance of Represents the cluster center of the entire text information block, is the cluster center v i To the cluster center The Euclidean distance, v p ,v q is the cluster center of category p and category q, d(v p ,v q ) is the cluster center v p To cluster center v q The Euclidean distance.
[0023] Furthermore, a clustering evaluation model is used to classify the clustering results of the text blocks, and a plurality of clustered text block sets whose elements are text blocks are generated, specifically including:
[0024] Using a clustering evaluation function Q to score the clustering results of the text blocks;
[0025] Let n be the total number of text blocks to be classified, c is the number of clustering categories, k is the weighted index, and k>1, v i represents the cluster center of category i, v s represents the cluster center of category s, and the cluster evaluation function Q is:
[0026]
[0027] Where A and B are coefficients, and A+B=1;
[0028] The text blocks with scores within the tolerance coefficient are classified into the same type of text blocks, and a clustered text block set consisting of several text blocks of the same type is generated.
[0029] Furthermore, paragraph recognition is performed on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set to generate paragraph block information, specifically including:
[0030] determining whether the last character block in the first clustered character block set is in the same row as the previous character block based on the position of the last character block in the first clustered character block set and the position of the previous character block;
[0031] When the last character block in the first clustered character block set is in a different row from the previous character block, identifying whether the last character block in the first clustered character block set is a preset character block;
[0032] When the last character block in the first clustered character block set is a preset character block, the first clustered character block set is defined as a paragraph block.
[0033] Furthermore, paragraph recognition is performed on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set to generate paragraph block information, which specifically includes:
[0034] When the last character block in the first clustered character block set is not a preset character block, obtaining the first character block in the second clustered character block set adjacent to the first clustered character block set;
[0035] Identify whether the first character block in the second clustered character block set is a preset character block;
[0036] When the first character block in the second clustered character block set is a preset character block, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set;
[0037] Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
[0038] Furthermore, paragraph recognition is performed on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set to generate paragraph block information, which specifically includes:
[0039] When the first character block in the second clustered character block set is not a preset character block, determining whether the correlation between the first clustered character block set and the second clustered character block set meets a paragraph determination threshold;
[0040] When the correlation between the first clustered character block set and the second clustered character block set meets the paragraph judgment threshold, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set;
[0041] Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
[0042] Furthermore, paragraph recognition is performed on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set to generate paragraph block information, which specifically includes:
[0043] When the correlation between the first clustered character block set and the second clustered character block set does not meet the paragraph judgment threshold, the first clustered character block set is defined as a paragraph block.
[0044] Furthermore, the method further comprises:
[0045] Performing image segmentation on the layout image to generate at least a plurality of table blocks;
[0046] Extracting characteristic attributes of the plurality of table blocks;
[0047] defining a table area according to characteristic attributes of the table block;
[0048] Extracting characteristic attributes of text blocks in the table area;
[0049] Performing paragraph recognition on the text blocks in the table area to generate paragraph block information;
[0050] The paragraph mark in the table area is updated according to the paragraph block information.
[0051] An embodiment of the present application also provides an OFD format document paragraph recognition device.
[0052] Specifically, an OFD format document paragraph recognition device includes:
[0053] Acquisition module, used to obtain layout documents;
[0054] An imaging model, used for parsing the layout document and generating a layout image;
[0055] a segmentation module, configured to segment the layout image to generate at least a plurality of text blocks;
[0056] The paragraph recognition module is used to extract the characteristic attributes of the multiple text blocks; it is also used to use a clustering operation model to perform clustering operations on the characteristic attributes of the text blocks to generate clustering results of the text blocks; it is also used to use a clustering evaluation model to classify the clustering results of the text blocks to generate multiple clustered text block sets whose elements are text blocks; it is also used to use a semantic model to calculate the association between the first clustered text block set and the second clustered text block set; it is also used to perform paragraph recognition on the multiple clustered text block sets based on the characteristic attributes of the text blocks in the first clustered text block set or the association between the first clustered text block set and the second clustered text block set to generate paragraph block information; it is also used to update the paragraph identifier in the layout document based on the paragraph block information.
[0057] Furthermore, the segmentation module is further used to perform image segmentation on the layout image to generate at least a number of table blocks;
[0058] The paragraph recognition module is further configured to:
[0059] Extracting characteristic attributes of the plurality of table blocks;
[0060] defining a table area according to characteristic attributes of the table block;
[0061] Extracting characteristic attributes of text blocks in the table area;
[0062] Performing paragraph recognition on the text blocks in the table area to generate paragraph block information;
[0063] The paragraph mark in the table area is updated according to the paragraph block information.
[0064] The technical solutions provided in the embodiments of the present application have at least the following beneficial effects:
[0065] This application segments layout images and clusters similar layouts, thereby proposing a method for identifying text paragraphs based on the spatial position of text blocks. Furthermore, by calculating the semantic continuity of text blocks, the accuracy of text paragraph recognition is improved. Furthermore, a new text extraction method for OFD layout document tables is proposed, improving the versatility of text extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0067] Figure 1 A flowchart of a method for identifying paragraphs in an OFD format document provided in an embodiment of the present application.
[0068] Figure 2 A flowchart of the detailed steps for performing paragraph recognition in a text area provided in an embodiment of the present application.
[0069] Figure 3 A flowchart of the detailed steps for performing paragraph recognition in a table area provided in an embodiment of the present application.
[0070] Figure 4 A schematic structural diagram of an OFD format document paragraph recognition device provided in an embodiment of the present application.
[0071] 100 OFD format document paragraph recognition device
[0072] 11 Get Module
[0073] 12 Imaging Model
[0074] 13 Split Module
[0075] 14 Paragraph Recognition Module DETAILED DESCRIPTION
[0076] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0077] Please refer to Figure 1 , the present application provides a method for identifying paragraphs in an OFD format document, comprising the following steps:
[0078] S110: Obtaining a layout document.
[0079] It is understood that a layout document is an electronic file with a fixed layout. The characteristics of a layout document are fixed layout and fixed presentation. That is, during the use of the layout document, the presentation effect will not change due to changes in the software and hardware environment or the operator. The layout, layout, font, font size, etc. will always remain completely consistent.
[0080] The file format of the layout document is independent. In actual application scenarios, the layout document has multiple file formats, such as OFD (Open Fixed-layout Documents) document format, PDF (Portable Document Format) document format, CAJ (China Academic Journals) document format, etc.
[0081] It should be noted that the layout document described in this application is preferably an OFD layout document. The OFD layout document is an electronic file with highly accurate layout rendering effect, which is independently developed and compiled by my country.
[0082] Specifically, the OFD layout document uses a different file description method than the commonly used PDF layout document. The OFD layout document is a container file, while the PDF layout document is a single file. In other words, the OFD layout document can be understood as a compressed package containing multiple files. The PDF layout document, on the other hand, is a single file and cannot be split.
[0083] In addition, the OFD format document uses Extensible Markup Language (XML) to describe data and structure, while the PDF format document uses a data dictionary (Dictionary) to describe data and structure.
[0084] The OFD and PDF documents describe states in two different ways. The PDF document's description of state is fragmented, requiring tracing back to the beginning of the document to determine the current state's attributes. The OFD document's description of state is self-contained, allowing state attributes to be determined solely from the current XML node. This makes analyzing the state of the PDF document more challenging.
[0085] Since the OFD layout document was released recently, it is still in the initial promotion and popularization stage. In addition, the file description method used by the OFD layout document is different from that of the commonly used PDF layout document. Therefore, there are few editing methods for the OFD layout document on the market.
[0086] According to the specific practice of the OFD layout document, the layout document annotation method provided by this application can be specifically used in the following scenario where text extraction is required for the OFD layout document: In the prior art, if the text in the OFD layout document is extracted, the extracted text often has disordered paragraphs. For example, when the operator wants to extract text divided into paragraphs, but in the scenario of text extraction for the OFD layout document, the actual extracted text is divided into lines. This is because the OFD layout document does not have the so-called paragraph, title, table and other layout features in the streaming document, so it is impossible to identify and extract the complete paragraph consisting of text.
[0087] S120: Parse the layout document to generate a layout image.
[0088] The layout document is parsed to generate a layout image, which is specifically performed as follows:
[0089] Parsing the OFD format document using Extensible Markup Language (XML) to determine graphic primitive objects;
[0090] The graphic primitive object is converted into a layout image using a two-dimensional vector imaging model.
[0091] Considering that the OFD layout document uses extensible markup language XML to describe data and structure, the present invention also uses extensible markup language XML to parse the OFD layout document, so as to determine the XML node where the graphic object is located, and then determine the graphic object of the OFD layout document.
[0092] Through the two-dimensional vector imaging model, the program segment corresponding to the primitive object can be converted into a layout image. Specifically, the layout image can be understood as the document content presented by graphics, images or text in a fixed layout relationship, which can be intuitively read by users.
[0093] S130: performing image segmentation on the layout image to generate at least a plurality of text blocks.
[0094] S140: Extracting characteristic attributes of the plurality of text blocks.
[0095] S150: using a clustering operation model to perform clustering operation on the characteristic attributes of the text block to generate a clustering result of the text block.
[0096] S160: using a clustering evaluation model to classify the clustering results of the text blocks, and generating a plurality of clustered text block sets whose elements are text blocks.
[0097] It should be noted that, in conjunction with the prior art parsing process of the layout document, in a specific application scenario, by parsing the OFD layout document, the position information of the image on the layout image can be directly obtained, but the text or graphics on the layout image cannot be accurately segmented. In order to accurately extract the text on the layout image, the present application performs image segmentation on the layout image in step S130 to generate at least a number of text blocks. The specific performance of step S130 is as follows:
[0098] According to the characteristic attributes of graphics, images or texts, an image segmentation algorithm is used to first segment the layout image to obtain graphic areas, image areas or text areas, and then segment the text areas to generate at least a number of text blocks.
[0099] It is understood that the text area is composed of a plurality of text blocks. The text blocks can be understood as at least one of characters selected from the group consisting of words, numbers, letters, and symbols. Furthermore, the text blocks have characteristic attributes, such as coordinates, font, typeface, font size, and color.
[0100] Of course, the plurality of text blocks may have different characteristic attributes. Furthermore, the text area may be clustered and segmented based on the characteristic attributes of the text blocks, and text blocks whose characteristic attributes meet a preset threshold are classified into the same type of text blocks, thereby generating a plurality of clustered text block sets whose elements are text blocks.
[0101] For example, the text area can be clustered and segmented by using the coordinate information and font size information of the text blocks to divide the area into title, body, table, header, footer, etc. In this application scenario, the title, body, table, header, footer, etc. area is a clustered text block set whose elements are text blocks.
[0102] In a specific embodiment provided in this application, step S140 extracts characteristic attributes of the plurality of text blocks, which are as follows:
[0103] Parse the content.xml of each page in the OFD layout document to obtain a textObejct object;
[0104] Analyze the textObejct object to obtain characteristic attributes such as the starting coordinates of the text block, the width and height of the text block, whether the text block contains punctuation marks, whether the text block ends with punctuation marks, the font size of the text block, and the font type of the text block;
[0105] By extracting the width, height, font shape, font size and other characteristic attributes of the text block, a feature vector group corresponding to the text block is formed.
[0106] Furthermore, the text area is clustered and segmented based on the characteristic attributes of the text blocks, and text blocks whose characteristic attributes meet a preset threshold are classified into the same type of text blocks, thereby generating a plurality of clustered text block sets whose elements are text blocks. In a specific application scenario, this is manifested as follows:
[0107] Step S150: using a clustering operation model to perform clustering operation on the characteristic attributes of the text block to generate a clustering result of the text block.
[0108] Step S160: using a clustering evaluation model to classify the clustering results of the text blocks, and generating a plurality of clustered text block sets whose elements are text blocks.
[0109] Step S150 specifically includes:
[0110] Let the vector of the text block be X={x1,x2,...,x n};
[0111] use
[0112]
[0113] Calculate the clustering results of text blocks;
[0114] Where F is the clustering result of the text block, n is the number of text blocks to be classified, c is the number of cluster categories, v i (i=1,2,…,c) is the cluster center of category i, m and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i For the membership degree of category j, k and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i The probability of class j, d(x j ,v i ) is the text block information x j To cluster center v i The Euclidean distance of Represents the cluster center of the entire text information block, is the cluster center v i To cluster center The Euclidean distance, v p ,v q is the cluster center of category p and category q, d(v p ,v q ) is the cluster center v p To cluster center v q The Euclidean distance.
[0115] Step S160 specifically includes:
[0116] Using a clustering evaluation function Q to score the clustering results of the text blocks;
[0117] Let n be the total number of text blocks to be classified, c is the number of clustering categories, k is the weighted index, and k>1, v i represents the cluster center of category i, v s represents the cluster center of category s, and the cluster evaluation function Q is:
[0118]
[0119] Where A and B are coefficients, and A+B=1;
[0120] The text blocks with scores within the tolerance coefficient are classified into the same type of text blocks, and a clustered text block set consisting of several text blocks of the same type is generated.
[0121] S170: Calculate the correlation between the first clustered text block set and the second clustered text block set using a semantic model.
[0122] S180: Perform paragraph recognition on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set to generate paragraph block information.
[0123] S190: updating the paragraph mark in the layout document according to the paragraph block information.
[0124] Paragraph recognition can be performed on the clustered text blocks based on the positional information of the text blocks on the layout image. For example, text blocks with unchanged vertical coordinates but varying horizontal coordinates are defined as belonging to the same line of text. Whether two lines of text are segmented can be determined by checking whether a preset number of spaces exist between them.
[0125] Of course, considering that the above paragraph recognition method has limitations in specific applications due to the unclear characteristics of some text paragraphs, for example, in some documents with special text layout, there is no space between the end of the previous paragraph and the end of the next paragraph.
[0126] In order to solve the technical problem of inaccurate paragraph recognition, this application performs paragraph recognition by combining the position information of text blocks on the layout image and semantic recognition technology based on natural language, thereby improving the accuracy of paragraph recognition.
[0127] The natural language-based semantic recognition technology is as follows:
[0128] The content.xml file of the OFD layout document is parsed to obtain the characteristic attributes of the text blocks. The text blocks are then annotated with semantic features using an NLP tokenizer. The characteristic attributes and labels of the text blocks are then converted into computer-readable vector information. A semantic model is used to calculate the correlation between the first clustered text blocks and the second clustered text blocks.
[0129] Furthermore, paragraph recognition is performed on the clustered text block set in combination with the position information and semantics of the text blocks, which can be specifically performed as follows:
[0130] determining whether the last character block in the first clustered character block set is in the same row as the previous character block based on the position of the last character block in the first clustered character block set and the position of the previous character block;
[0131] When the last character block in the first clustered character block set is in a different row from the previous character block, identifying whether the last character block in the first clustered character block set is a preset character block;
[0132] When the last character block in the first clustered character block set is a preset character block, the first clustered character block set is defined as a paragraph block.
[0133] When the last character block in the first clustered character block set is not a preset character block, obtaining the first character block in the second clustered character block set adjacent to the first clustered character block set;
[0134] Identify whether the first character block in the second clustered character block set is a preset character block;
[0135] When the first character block in the second clustered character block set is a preset character block, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set;
[0136] Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
[0137] When the first character block in the second clustered character block set is not a preset character block, determining whether the correlation between the first clustered character block set and the second clustered character block set meets a paragraph determination threshold;
[0138] When the correlation between the first clustered character block set and the second clustered character block set meets the paragraph judgment threshold, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set;
[0139] Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
[0140] When the correlation between the first clustered character block set and the second clustered character block set does not meet the paragraph judgment threshold, the first clustered character block set is defined as a paragraph block.
[0141] It is understandable that the preset text block can be understood as a punctuation mark with ending semantics, such as a period, question mark, exclamation mark, double quotation mark, etc.
[0142] Please refer to Figure 2 In a specific embodiment provided in the present application, step S180 performs paragraph recognition on the plurality of clustered character block sets based on the characteristic attributes of the character blocks in the first clustered character block set or the association between the first clustered character block set and the second clustered character block set, and generates paragraph block information, which is expressed as follows:
[0143] Obtain n text blocks block1 to blockn from the clustered text block set. Extract at least the character content and position information corresponding to the text blocks from the characteristic attributes of the n text blocks. Then calculate the left and right boundaries of the clustered text block set, that is, calculate the left and right boundaries of the current text area.
[0144] According to the arrangement order of the characteristic attributes of the n text blocks, calculate the distance x1 of the left boundary relative to the upper left corner of the current text area, the distance x2 of the right boundary relative to the upper left corner of the current text area, the distance y1 of the upper boundary relative to the upper left corner of the current text area, and the distance y2 of the lower boundary relative to the upper left corner of the current text area for two adjacent text blocks blockn-1 and blockn (n starts from 2).
[0145] It is determined whether the values of y1 and y2 of two adjacent text blocks blockn-1 and blockn are equal, or whether the difference between y1 and y2 meets a preset distance threshold.
[0146] If the above condition is met, the two adjacent text blocks blockn-1 and blockn are considered to belong to the same row, and the row attribute of the two adjacent text blocks is set to line=m (m is the row number, starting from 1). Repeat the above steps until the row attribute setting of the current text area is completed.
[0147] If the above condition is not met, it means that the two adjacent text blocks blockn-1 and blockn are in different lines, and it is necessary to determine whether they belong to the same paragraph.
[0148] Specifically, the spatial distances between two adjacent text blocks and the current text area are calculated, and the following four situations are judged:
[0149] The position of blockn is right relative to the horizontal center of the current text area, indicating that blockn is a right-aligned structure;
[0150] The x1 of blockn is far away from the left baseline of the current text area, indicating that blockn is the beginning of a paragraph;
[0151] The x2 of blockn-1 is far away from the right baseline of the current text area, indicating that blockn-1 is the end of the paragraph;
[0152] The x1 values of the two adjacent text blocks blockn and blockn-1 are different and the value is larger, indicating that blockn is the beginning of a paragraph.
[0153] If any of the above four situations is met, it means that the two adjacent text blocks blockn-1 and blockn belong to the same paragraph, and the paragraph attributes of the two adjacent text blocks are set to para=k (k is the paragraph number, starting from 1).
[0154] If none of the above four conditions are met, it means that the spatial distance between two adjacent text blocks is not obvious. It is necessary to identify the paragraphs based on natural language processing and judge the following two situations:
[0155] Whether the text of blockn-1 ends with a punctuation mark;
[0156] Whether the text of blockn begins with a terminal punctuation.
[0157] If either of the above two situations is met, it means that the contents of the two adjacent text blocks in the order of arrangement are semantically incoherent and do not belong to the same paragraph. Set the paragraph attribute of blockn-1 to para=k, and the paragraph attribute of blockn to para=k+1.
[0158] If neither of the above two situations is met, it means that the contents of the two adjacent text blocks are semantically coherent. The current text area can be defined as a paragraph and a paragraph tag can be added.
[0159] Afterwards, the above steps are repeated for the text blocks of the next clustered text block set until the paragraph identifiers of the entire OFD layout document are updated.
[0160] The paragraph recognition method for OFD layout documents provided in this application improves paragraph recognition accuracy by combining the positional information of text blocks on the layout image with natural language-based semantic recognition technology. Furthermore, by updating the paragraph identifiers for the entire OFD layout document, the operator can obtain a string in a restored streaming format when extracting text paragraphs.
[0161] The present application also provides a method for extracting text from a table in an OFD format document. Specifically, the OFD format document paragraph recognition method further includes:
[0162] Performing image segmentation on the layout image to generate at least a plurality of table blocks;
[0163] Extracting characteristic attributes of the plurality of table blocks;
[0164] defining a table area according to characteristic attributes of the table block;
[0165] Extracting characteristic attributes of text blocks in the table area;
[0166] Performing paragraph recognition on the text blocks in the table area to generate paragraph block information;
[0167] The paragraph mark in the table area is updated according to the paragraph block information.
[0168] It is understood that performing image segmentation on the layout image to generate at least a plurality of table blocks can be performed by first performing image segmentation on the layout image using an image segmentation algorithm to obtain a region where the graphic is a table, and then segmenting the table region to generate at least a plurality of table blocks.
[0169] Furthermore, the graphics of several table blocks can constitute a graphic area. When the graphic area is represented as a table area, the graphics of the table blocks are represented as table lines. Moreover, the graphics of the table blocks have characteristic attributes, such as coordinates, shape, color, etc.
[0170] The table area is defined according to the characteristic attributes of the table block, specifically as follows:
[0171] Filter out several table blocks whose graphics are table lines;
[0172] The table area is restored according to the graphic features of the plurality of table blocks and the positional relationship of the plurality of table blocks.
[0173] Usually, the grids in the table area contain text content, but in specific application scenarios, the positions of text blocks and table blocks are mixed, so extracting text paragraphs from the grids in the table area is much more complicated than extracting text paragraphs from the text area.
[0174] Therefore, the present application first identifies the table block to define the table area; and then performs paragraph marking on the text block in the table area to improve the accuracy of text paragraph recognition in complex areas.
[0175] Furthermore, after the table area is determined, paragraph recognition can be performed using the above-mentioned method based on the position information of the text block, or using the above-mentioned method based on the position information and semantics of the text block, which will not be described in detail here.
[0176] It should be noted that, considering that the text content in the table area is relatively simple in actual application scenarios, in order to improve the efficiency of paragraph recognition, in a preferred embodiment provided by this application, paragraph recognition is performed on the text blocks in the table area to generate paragraph block information, which can be expressed as follows:
[0177] Identifying a plurality of text blocks in a single cell of the table area;
[0178] defining a plurality of text blocks in a single cell of the table area as paragraphs;
[0179] Deleting spaces and paragraph marks between text blocks in a single cell of the table area;
[0180] Adding a paragraph mark to the last text block in the arrangement order of a single cell in the table area;
[0181] Update the paragraph mark in the single cell of the table area.
[0182] For details, please refer to Figure 3 , the identification of several text blocks in a single cell of the table area is performed as follows:
[0183] Traverse the table rows tr in the table structure in turn to determine whether the table row tr spans rows.
[0184] If the table row tr spans rows and spans rowspan, then the current table row tr is taken as the first row and the process goes back to the rowspanth row and stops.
[0185] Traverse the table column td in the table row tr, wherein the table column td includes the location information location.
[0186] Search the text block's attribute for the characters contained within location and populate them in the table column td. The characters found here will have their attribute visited set to true, and characters with visited set to true will be skipped during the search.
[0187] The table column td under each table row tr in the table structure is traversed in sequence to determine a number of text blocks in a single cell in the table area.
[0188] Several text blocks between two table rows tr are separated by line breaks, and several text blocks between two table columns td under a table row tr are separated by spaces, thereby updating the paragraph mark in the single cell of the table area.
[0189] Please refer to Figure 4 To support the OFD format document paragraph recognition method, the present application further provides an OFD format document paragraph recognition device 100, comprising:
[0190] An acquisition module 11 is used to acquire a layout document;
[0191] An imaging model 12, configured to parse the layout document and generate a layout image;
[0192] A segmentation module 13 is used to segment the layout image to generate at least a plurality of text blocks;
[0193] The paragraph recognition module 14 is used to extract the characteristic attributes of the multiple text blocks; it is also used to use a clustering operation model to perform clustering operations on the characteristic attributes of the text blocks to generate clustering results of the text blocks; it is also used to use a clustering evaluation model to classify the clustering results of the text blocks to generate multiple clustered text block sets whose elements are text blocks; it is also used to use a semantic model to calculate the association between the first clustered text block set and the second clustered text block set; it is also used to perform paragraph recognition on the multiple clustered text block sets based on the characteristic attributes of the text blocks in the first clustered text block set or the association between the first clustered text block set and the second clustered text block set to generate paragraph block information; it is also used to update the paragraph identifier in the layout document based on the paragraph block information.
[0194] The imaging model 12 parses the layout document to generate a layout image, which is specifically performed as follows:
[0195] The imaging model 12 uses the Extensible Markup Language (XML) to parse the OFD format document and determine the graphic primitive objects.
[0196] The imaging model 12 uses a two-dimensional vector imaging model to convert the graphic primitive object into a layout image.
[0197] Considering that the OFD layout document uses extensible markup language XML to describe data and structure, the imaging model 12 also uses extensible markup language XML to parse the OFD layout document, thereby determining the XML node where the graphic object is located, and then determining the graphic object of the OFD layout document.
[0198] The imaging model 12 can convert the program segments corresponding to the graphic primitive objects into layout images through a two-dimensional vector imaging model. Specifically, the layout image can be understood as document content presented by graphics, images, or text in a fixed layout relationship, which can be intuitively read by users.
[0199] It should be noted that, in conjunction with the prior art parsing process for layout documents, in specific application scenarios, the imaging model 12 can directly obtain the position information of images on the layout image by parsing the OFD layout document, but cannot accurately segment text or graphics on the layout image. To accurately extract text from the layout image, the present application uses the segmentation module 13 to segment the layout image, generating at least a number of text blocks.
[0200] Specifically, the segmentation module 13 uses an image segmentation algorithm to segment the layout image according to the characteristic attributes of the graphics, images or texts to obtain graphic areas, image areas or text areas, and then segments the text areas to generate at least a plurality of text blocks.
[0201] It is understood that the text area is composed of a plurality of text blocks. The text blocks can be understood as at least one of characters selected from the group consisting of words, numbers, letters, and symbols. Furthermore, the text blocks have characteristic attributes, such as coordinates, font, typeface, font size, and color.
[0202] Of course, the plurality of text blocks may have different characteristic attributes. The segmentation module 13 may then cluster and segment the text area based on the characteristic attributes of the text blocks, classifying the text blocks whose characteristic attributes meet a preset threshold as the same type of text blocks, and generating a plurality of clustered text block sets whose elements are text blocks.
[0203] For example, the segmentation module 13 can cluster and segment the text area based on the coordinate information and font size information of the text blocks, and divide the text area into regions such as title, body, table, header, and footer. In this application scenario, the regions such as title, body, table, header, and footer are clustered text blocks whose elements are text blocks.
[0204] In a specific embodiment provided in the present application, the paragraph recognition module 14 extracts characteristic attributes of a block, which are expressed as follows:
[0205] The paragraph recognition module 14 parses the content.xml of each page in the OFD format document to obtain a textObejct object;
[0206] The paragraph recognition module 14 analyzes the textObject object to obtain characteristic attributes such as the starting coordinates of the text block, the width and height of the text block, whether the text block contains punctuation marks, whether the text block ends with punctuation marks, the font size of the text block, and the font type of the text block;
[0207] The paragraph recognition module 14 extracts characteristic attributes of the text block, such as width, height, font shape and size, to form a feature vector group corresponding to the text block.
[0208] Furthermore, the paragraph recognition module 14 clusters and segments the text area based on the characteristic attributes of the text blocks, classifies the text blocks whose characteristic attributes meet a preset threshold into the same type of text blocks, and generates a plurality of clustered text block sets whose elements are text blocks. In a specific application scenario, this is manifested as follows:
[0209] The paragraph recognition module 14 uses a clustering operation model to perform clustering operations on the characteristic attributes of the text blocks to generate clustering results of the text blocks.
[0210] The paragraph recognition module 14 uses a clustering evaluation model to classify the clustering results of the text blocks and generates a plurality of clustered text block sets whose elements are text blocks.
[0211] The paragraph recognition module 14 uses a clustering operation model to perform clustering operations on the characteristic attributes of the text blocks to generate clustering results of the text blocks, specifically including:
[0212] Let the vector of the text block be X={x1,x2,...,x n};
[0213] use
[0214]
[0215] Calculate the clustering results of text blocks;
[0216] Where F is the clustering result of the text block, n is the number of text blocks to be classified, c is the number of cluster categories, v i (i=1,2,…,c) is the cluster center of category i, m and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i For the membership degree of category j, k and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i The probability of class j, d(x j ,v i ) is the text block information x j To cluster center v i The Euclidean distance of Represents the cluster center of the entire text information block, is the cluster center v i To the cluster center The Euclidean distance, v p ,v q is the cluster center of category p and category q, d(v p ,v q ) is the cluster center v p To cluster center v q The Euclidean distance.
[0217] The paragraph recognition module 14 uses a clustering evaluation model to classify the clustering results of the text blocks and generates a plurality of clustered text block sets whose elements are text blocks, specifically including:
[0218] Using a clustering evaluation function Q to score the clustering results of the text blocks;
[0219] Let n be the total number of text blocks to be classified, c is the number of clustering categories, k is the weighted index, and k>1, v i represents the cluster center of category i, v s represents the cluster center of category s, and the cluster evaluation function Q is:
[0220]
[0221] Where A and B are coefficients, and A+B=1;
[0222] The text blocks with scores within the tolerance coefficient are classified into the same type of text blocks, and a clustered text block set consisting of several text blocks of the same type is generated.
[0223] Furthermore, the paragraph recognition module 14 performs paragraph recognition on the clustered text blocks, and paragraph recognition can be performed based on the positional information of the text blocks on the layout image. For example, the paragraph recognition module 14 defines text blocks with unchanged vertical coordinates but varying horizontal coordinates as belonging to the same line of text. The paragraph recognition module 14 determines whether two lines of text are segmented by checking whether there is a preset number of spaces between the two lines of text.
[0224] Of course, considering that the above paragraph recognition method has limitations in specific applications due to the unclear characteristics of some text paragraphs, for example, in some documents with special text layout, there is no space between the end of the previous paragraph and the end of the next paragraph.
[0225] To solve the technical problem of inaccurate paragraph recognition, the paragraph recognition module 14 performs paragraph recognition by combining the position information of the text blocks on the layout image and the semantic recognition technology based on natural language, thereby improving the accuracy of paragraph recognition.
[0226] The natural language-based semantic recognition technology is as follows:
[0227] The content.xml file of the OFD layout document is parsed to obtain the characteristic attributes of the text blocks. The text blocks are then annotated with semantic features using an NLP tokenizer. The characteristic attributes and labels of the text blocks are then converted into computer-readable vector information. A semantic model is used to calculate the correlation between the first clustered text blocks and the second clustered text blocks.
[0228] Furthermore, the paragraph recognition module 14 performs paragraph recognition on the clustered text block set based on the position information and semantics of the text blocks, which can be specifically performed as follows:
[0229] determining whether the last character block in the first clustered character block set is in the same row as the previous character block based on the position of the last character block in the first clustered character block set and the position of the previous character block;
[0230] When the last character block in the first clustered character block set is in a different row from the previous character block, identifying whether the last character block in the first clustered character block set is a preset character block;
[0231] When the last character block in the first clustered character block set is a preset character block, the first clustered character block set is defined as a paragraph block.
[0232] When the last character block in the first clustered character block set is not a preset character block, obtaining the first character block in the second clustered character block set adjacent to the first clustered character block set;
[0233] Identify whether the first character block in the second clustered character block set is a preset character block;
[0234] When the first character block in the second clustered character block set is a preset character block, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set;
[0235] Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
[0236] When the first character block in the second clustered character block set is not a preset character block, determining whether the correlation between the first clustered character block set and the second clustered character block set meets a paragraph determination threshold;
[0237] When the correlation between the first clustered character block set and the second clustered character block set meets the paragraph judgment threshold, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set;
[0238] Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
[0239] When the correlation between the first clustered character block set and the second clustered character block set does not meet the paragraph judgment threshold, the first clustered character block set is defined as a paragraph block.
[0240] It is understandable that the preset text block can be understood as a punctuation mark with ending semantics, such as a period, question mark, exclamation mark, double quotation mark, etc.
[0241] In a specific embodiment provided by the present application, the paragraph recognition module 14 performs paragraph recognition on the plurality of clustered character block sets based on characteristic attributes of the character blocks in the first clustered character block set or the association between the first clustered character block set and the second clustered character block set, and generates paragraph block information, which is expressed as follows:
[0242] Obtain n text blocks block1 to blockn from the clustered text block set. Extract at least the character content and position information corresponding to the text blocks from the characteristic attributes of the n text blocks. Then calculate the left and right boundaries of the clustered text block set, that is, calculate the left and right boundaries of the current text area.
[0243] According to the arrangement order of the characteristic attributes of the n text blocks, calculate the distance x1 of the left boundary relative to the upper left corner of the current text area, the distance x2 of the right boundary relative to the upper left corner of the current text area, the distance y1 of the upper boundary relative to the upper left corner of the current text area, and the distance y2 of the lower boundary relative to the upper left corner of the current text area for two adjacent text blocks blockn-1 and blockn (n starts from 2).
[0244] It is determined whether the values of y1 and y2 of two adjacent text blocks blockn-1 and blockn are equal, or whether the difference between y1 and y2 meets a preset distance threshold.
[0245] If the above condition is met, the two adjacent text blocks blockn-1 and blockn are determined to belong to the same line, and the paragraph recognition module 14 sets the line attribute of the two adjacent text blocks to line=m (m is the line number, starting from 1). The above steps are repeated until the line attribute setting of the current text area is completed.
[0246] If the above condition is not met, it means that the two adjacent text blocks blockn-1 and blockn are in different lines, and it is necessary to determine whether they belong to the same paragraph.
[0247] Specifically, the paragraph recognition module 14 calculates the spatial distances between two adjacent text blocks and the current text area, and determines the following four situations:
[0248] The position of blockn is right relative to the horizontal center of the current text area, indicating that blockn is a right-aligned structure;
[0249] The x1 of blockn is far away from the left baseline of the current text area, indicating that blockn is the beginning of a paragraph;
[0250] The x2 of blockn-1 is far away from the right baseline of the current text area, indicating that blockn-1 is the end of the paragraph;
[0251] The x1 values of the two adjacent text blocks blockn and blockn-1 are different and the value is larger, indicating that blockn is the beginning of a paragraph.
[0252] If any of the above four situations is met, it means that the two adjacent text blocks blockn-1 and blockn belong to the same paragraph. The paragraph recognition module 14 sets the paragraph attributes of the two adjacent text blocks to para=k (k is the paragraph number, starting from 1).
[0253] If none of the above four conditions are met, it means that the spatial distance between two adjacent text blocks is not obvious. It is necessary to identify the paragraphs based on natural language processing and judge the following two situations:
[0254] Whether the text of blockn-1 ends with a punctuation mark;
[0255] Whether the text of blockn begins with a terminal punctuation.
[0256] If either of the above two situations is met, it means that the two adjacent text blocks are semantically incoherent and do not belong to the same paragraph. The paragraph identification module 14 sets the paragraph attribute of blockn-1 to para=k and the paragraph attribute of blockn to para=k+1.
[0257] If neither of the above two situations is met, it means that the contents of the two adjacent text blocks are semantically coherent. The current text area can be defined as a paragraph and a paragraph tag can be added.
[0258] Afterwards, the paragraph identification module 14 repeats the above steps for the text blocks in the next clustered text block set until the paragraph identification of the entire OFD format document is updated.
[0259] The OFD layout document paragraph recognition device 100 provided herein improves paragraph recognition accuracy by combining the positional information of text blocks on a layout image with natural language-based semantic recognition technology. Furthermore, by updating the paragraph identifiers for the entire OFD layout document, the operator can retrieve a string in a restored streaming format when extracting a text paragraph.
[0260] The present application also provides a solution for extracting text from a table in an OFD layout document. Specifically, the segmentation module 13 is further configured to segment the layout image to generate at least a plurality of table blocks.
[0261] The paragraph identification module 14 is further configured to:
[0262] Extracting characteristic attributes of the plurality of table blocks;
[0263] defining a table area according to characteristic attributes of the table block;
[0264] Extracting characteristic attributes of text blocks in the table area;
[0265] Performing paragraph recognition on the text blocks in the table area to generate paragraph block information;
[0266] The paragraph mark in the table area is updated according to the paragraph block information.
[0267] It is understood that the table block is first segmented by the segmentation module 13 using an image segmentation algorithm to obtain an area where the graphic is a table. The table area is then segmented to generate at least a plurality of table blocks. Furthermore, the graphics of the plurality of table blocks can constitute a graphic area. When the graphic area is represented as a table area, the graphics of the table block are represented as table lines. In addition, the graphics of the table block have characteristic attributes, such as coordinates, shape, color, etc.
[0268] The paragraph recognition module 14 defines the table area according to the characteristic attributes of the table block, which is specifically manifested as follows:
[0269] Filter out several table blocks whose graphics are table lines;
[0270] The table area is restored according to the graphic features of the plurality of table blocks and the positional relationship of the plurality of table blocks.
[0271] Usually, the grids in the table area contain text content, but in specific application scenarios, the positions of text blocks and table blocks are mixed, so extracting text paragraphs from the grids in the table area is much more complicated than extracting text paragraphs from the text area.
[0272] Therefore, the paragraph recognition module 14 first identifies the table block to define the table area, and then performs paragraph marking on the text block in the table area to improve the accuracy of text paragraph recognition in the complex area.
[0273] Furthermore, after the table area is determined, the paragraph recognition module 14 may perform paragraph recognition based on the above-mentioned position information of the text block, or may perform paragraph recognition based on the above-mentioned position information and semantics of the text block, which will not be described in detail here.
[0274] It should be noted that, considering that the text content in the table area is relatively simple in actual application scenarios, in order to improve the efficiency of paragraph recognition, in a preferred embodiment provided by the present application, the paragraph recognition module 14 performs paragraph recognition on the text blocks in the table area and generates paragraph block information, which can be expressed as follows:
[0275] Identifying a plurality of text blocks in a single cell of the table area;
[0276] defining a plurality of text blocks in a single cell of the table area as paragraphs;
[0277] Deleting spaces and paragraph marks between text blocks in a single cell of the table area;
[0278] Adding a paragraph mark to the last text block in the arrangement order of a single cell in the table area;
[0279] Update the paragraph mark in the single cell of the table area.
[0280] Specifically, the paragraph recognition module 14 recognizes that several text blocks in a single cell in the table area are represented as follows:
[0281] Traverse the table rows tr in the table structure in turn to determine whether the table row tr spans rows.
[0282] If the table row tr spans rows and spans rowspan, then the current table row tr is taken as the first row and the process goes back to the rowspanth row and stops.
[0283] Traverse the table column td in the table row tr, wherein the table column td includes the location information location.
[0284] Search the text block for characters within the location and populate them in the table column td. The characters found here will have their attribute visited set to true, and characters with visited set to true will be skipped during the search.
[0285] The table column td under each table row tr in the table structure is traversed in sequence to determine a number of text blocks in a single cell in the table area.
[0286] Several text blocks between two table rows tr are separated by line breaks, and several text blocks between two table columns td under a table row tr are separated by spaces, thereby updating the paragraph mark in the single cell of the table area.
[0287] It should be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, product, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, product, or apparatus. In the absence of further limitations, the phrase "comprises a..." to define an element does not preclude the presence of other identical elements in the process, method, product, or apparatus that includes the element.
[0288] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0289] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
Claims
1. A paragraph recognition method for OFD format documents, It is characterized in that The following steps are involved: Get the layout document; Parsing the layout document to generate a layout image; Performing image segmentation on the layout image to generate at least a plurality of text blocks; Extracting characteristic attributes of the plurality of text blocks; Using a clustering operation model, clustering operation is performed on the characteristic attributes of the text block to generate a clustering result of the text block; Using a clustering evaluation model, classifying the clustering results of the text blocks, and generating a plurality of clustered text block sets whose elements are text blocks; The semantic model is used to calculate the correlation between the first clustered text block set and the second clustered text block set; According to the characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set, paragraph recognition is performed on the plurality of clustered character block sets to generate paragraph block information; The paragraph mark in the layout document is updated according to the paragraph block information.
2. The OFD format document paragraph recognition method as claimed in claim 1, It is characterized in that A clustering operation model is used to perform clustering operation on the text block information to generate a clustering result of the text block, specifically including: Suppose the vector of the text block is X={x 1 , x 2 , ..., x n }; use Calculate the clustering results of the text blocks; Where F is the clustering result of the text block, n is the number of text blocks to be classified, c is the number of clustering categories, and v i (i=1, 2, ..., c) is the cluster center of category i, m and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i For the membership of category j, k and u, i, j are the weighted index and text block vector x defined by the algorithm respectively. i The probability of class j, d(x j , v i ) is the text block information x j To cluster center v i The Euclidean distance of Represents the cluster center of the entire text information block, is the cluster center v i To cluster center The Euclidean distance, v p , v q is the cluster center of category p and category q, d(v p , v q ) is the cluster center v p To cluster center v q The Euclidean distance.
3. The OFD format document paragraph recognition method as claimed in claim 1, It is characterized in that The clustering evaluation model is used to classify the clustering results of the text blocks, and a plurality of clustered text block sets whose elements are text blocks are generated, specifically including: Using a clustering evaluation function Q to score the clustering result of the text block; Let n be the total number of text blocks to be classified, c be the number of clustering categories, k be the weighted index, and k>1, v i represents the cluster center of category i, v s represents the cluster center of category s, and the cluster evaluation function Q is: Where A and B are coefficients, and A+B=1; The text blocks with scores within the tolerance coefficient are classified into the same type of text blocks, and a clustered text block set consisting of several text blocks of the same type is generated.
4. The OFD format document paragraph recognition method as claimed in claim 1, It is characterized in that According to the characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set, paragraph recognition is performed on the plurality of clustered character block sets to generate paragraph block information, specifically including: According to the position of the last character block in the first cluster character block set and the position of the previous character block, determining whether the last character block in the first cluster character block set is in the same row as the previous character block; When the last character block in the first clustered character block set is in a different row from the previous character block, identifying whether the last character block in the first clustered character block set is a preset character block; When the last character block in the first clustered character block set is a preset character block, the first clustered character block set is defined as a paragraph block.
5. The OFD format document paragraph recognition method as claimed in claim 4, It is characterized in that According to the characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set, paragraph recognition is performed on the plurality of clustered character block sets to generate paragraph block information, which specifically includes: When the last character block in the first clustered character block set is not a preset character block, obtaining the first character block in the second clustered character block set adjacent to the first clustered character block set; Identify whether the first character block in the second clustered character block set is a preset character block; When the frontmost character block in the second clustered character block set is a preset character block, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set; Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
6. The OFD format document paragraph recognition method as claimed in claim 5, It is characterized in that According to the characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set, paragraph recognition is performed on the plurality of clustered character block sets to generate paragraph block information, which specifically includes: When the first character block in the second clustered character block set is not a preset character block, determining whether the correlation between the first clustered character block set and the second clustered character block set meets a paragraph determination threshold; When the correlation between the first clustered character block set and the second clustered character block set meets the paragraph judgment threshold, the first clustered character block set and the second clustered character block set are merged into a new clustered character block set; Repeatedly identify whether the last text block in the new clustered text block set is a preset text block, until the new clustered text block set is defined as a paragraph block.
7. The OFD format document paragraph recognition method as claimed in claim 6, It is characterized in that According to the characteristic attributes of the character blocks in the first clustered character block set or the correlation between the first clustered character block set and the second clustered character block set, paragraph recognition is performed on the plurality of clustered character block sets to generate paragraph block information, which specifically includes: When the correlation between the first clustered character block set and the second clustered character block set does not meet the paragraph judgment threshold, the first clustered character block set is defined as a paragraph block.
8. The OFD format document paragraph recognition method as claimed in claim 1, It is characterized in that The method further comprises: Performing image segmentation on the layout image to generate at least a plurality of table blocks; Extracting characteristic attributes of the plurality of table blocks; Defining a table area according to characteristic attributes of the table block; Extracting characteristic attributes of text blocks in the table area; Performing paragraph recognition on the text blocks in the table area to generate paragraph block information; The paragraph mark in the table area is updated according to the paragraph block information.
9. An OFD format document paragraph recognition device, It is characterized in that include: Acquisition module, used to obtain layout documents; An imaging model, used for parsing the layout document and generating a layout image; A segmentation module, used for performing image segmentation on the layout image to generate at least a plurality of text blocks; The paragraph recognition module is used to extract the characteristic attributes of the plurality of text blocks; it is also used to adopt a clustering operation model to perform clustering operation on the characteristic attributes of the text blocks to generate clustering results of the text blocks; it is also used to adopt a clustering evaluation model to classify the clustering results of the text blocks to generate a plurality of clustered text block sets whose elements are text blocks; it is also used to adopt a semantic model to calculate the association between the first clustered text block set and the second clustered text block set; it is also used to perform paragraph recognition on the plurality of clustered text block sets based on the characteristic attributes of the text blocks in the first clustered text block set or the association between the first clustered text block set and the second clustered text block set to generate paragraph block information; it is also used to update the paragraph identification in the layout document based on the paragraph block information.
10. The OFD format document paragraph recognition device as claimed in claim 9, It is characterized in that The segmentation module is also used to perform image segmentation on the layout image to generate at least a number of table blocks; The paragraph recognition module is also used for: Extracting characteristic attributes of the plurality of table blocks; Defining a table area according to characteristic attributes of the table block; Extracting characteristic attributes of text blocks in the table area; Performing paragraph recognition on the text blocks in the table area to generate paragraph block information; The paragraph mark in the table area is updated according to the paragraph block information.
