Method and device for identifying directory in document

By identifying the color, space interval and text line correlation of the area to be identified in the document, the problem of difficult to identify document directories in the prior art is solved, and accurate identification of directories in the document and row-level positioning are achieved.

CN119540982APending Publication Date: 2025-02-28ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311095600.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

It is difficult for the prior art to accurately identify directories in documents, especially in personalized reading methods, and links from directories to document text need to be realized based on the identification of directories.

Method used

By determining the area to be identified in the target document, identifying the color range and external rectangle of each text line, and determining the alignment characteristics; identifying the gap interval and layout style, and determining the directory association characteristics; performing text line association detection, determining the continuity characteristics, and combining these results to determine whether it is a directory.

Benefits of technology

It realizes accurate identification of all directory areas in the document, and identifies the corresponding number of rows in each directory area. The positioning granularity is more detailed, supports single page processing, does not rely on the full document format, and is suitable for directory recognition in non-standard protocols.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540982A_ABST
    Figure CN119540982A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for recognizing a directory in a document, and relates to the technical field of document recognized.The method for recognizing the directory in the document comprises the steps that a to-be-recognized area in a target document is determined, and the to-be-recognized area comprises at least one connected text line; identifying the color range of the text object in each text line and the bounding rectangle of each text line, and determining whether the to-be-identified area has a first identification result of an alignment feature; identifying a gap interval and an arrangement style of the text object in each text line, and determining whether the to-be-identified area has a second identification result of a directory association feature; performing text line association detection on each text line to obtain a detection result that whether the to-be-recognized region has a continuity feature; and according to the first identification result, the second identification result and the detection result, determining whether the to-be-identified area in the target document is a directory. According to the method and the device, a plurality of directories existing in each page of the document can be quickly and accurately identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of document recognition, and in particular to a method and device for recognizing a directory in a document. Background Art

[0002] The table of contents in a document can improve the reading speed of readers and facilitate content retrieval. The table of contents in a document is equivalent to a reference to the entire document, indexing the main content of the entire document. In addition, if a personalized reading method is implemented, such as establishing a link from the table of contents to the document body, it needs to be implemented on the basis of identifying the table of contents. Therefore, how to identify the table of contents in a document is a problem that needs to be solved urgently. Summary of the invention

[0003] In view of the problems existing in the prior art, an embodiment of the present invention provides a method and device for identifying a directory in a document.

[0004] The present invention provides a method for identifying a directory in a document, comprising:

[0005] Determine a region to be identified in a target document, wherein the region to be identified includes at least one connected text line;

[0006] Identify the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines to determine whether the area to be identified has a first identification result of an alignment feature;

[0007] Identify the space interval and arrangement style of the text objects in each of the text lines to determine whether the area to be identified has a second identification result of a catalog-related feature;

[0008] Performing text line association detection on each of the text lines to obtain a detection result of whether the to-be-identified area has a continuity feature, wherein the continuity feature represents feature continuity between the text lines;

[0009] According to the first recognition result, the second recognition result and the detection result, it is determined whether the to-be-recognized area in the target document is a directory.

[0010] According to a method for identifying a directory in a document provided by the present invention, the alignment feature includes a color alignment feature and a text line alignment feature, and the first recognition result includes a color alignment recognition result and a text line alignment recognition result;

[0011] Accordingly, the step of identifying the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines to determine the alignment features of the area to be identified includes:

[0012] For each of the text lines, identify the color corresponding to each text object in the text line under the target color mode, and obtain the color range corresponding to each text object in the text line; determine whether the area to be identified has the color alignment recognition result of the color alignment feature according to the color range;

[0013] For each of the text lines, the boundary coordinates of the circumscribed rectangle of the text line are identified; and according to the boundary coordinates, it is determined whether the area to be identified has the text line alignment recognition result of the text line alignment feature.

[0014] According to a method for identifying a directory in a document provided by the present invention, the color alignment identification result of determining whether the area to be identified has the color alignment feature according to the color range includes:

[0015] Determining whether each text line pair is a target text line pair, wherein the text line pair is two connected text lines in each of the text lines, and the color ranges corresponding to the two text lines in the target text line pair overlap;

[0016] If so, determining that the color alignment recognition result is that the area to be recognized has the color alignment feature;

[0017] If not, it is determined that the color alignment recognition result is that the to-be-recognized area does not have the color alignment feature.

[0018] According to a method for identifying a directory in a document provided by the present invention, the boundary coordinates include a first coordinate corresponding to the front end and a second coordinate corresponding to the rear end of the circumscribed rectangle in the writing direction;

[0019] Accordingly, before determining the text line alignment recognition result of whether the to-be-recognized area has the text line alignment feature according to the boundary coordinates, the method further includes:

[0020] Obtaining the line height of each of the text lines, and determining a reference line height according to each of the line heights;

[0021] Correspondingly, the text line alignment recognition result of determining whether the to-be-recognized area has the text line alignment feature according to the boundary coordinates includes:

[0022] Calculate a first coordinate average value according to each of the first coordinates, and calculate a second coordinate average value according to each of the second coordinates;

[0023] Determine whether a first difference between each of the first coordinates and an average value of the first coordinates, and a second difference between each of the second coordinates and an average value of the second coordinates are both less than or equal to the reference row height;

[0024] If so, determining that the text line alignment recognition result is that the area to be recognized has the text line alignment feature;

[0025] If not, it is determined that the text line alignment recognition result is that the area to be recognized does not have the text line alignment feature.

[0026] According to a method for identifying a directory in a document provided by the present invention, the directory association feature includes a space interval feature and a directory style feature, and the second recognition result includes a space interval recognition result and a directory style recognition result;

[0027] Accordingly, the identifying of the space intervals and arrangement styles of the text objects in each of the text lines to determine the directory-related features of the area to be identified includes:

[0028] For each of the text lines, identifying the gap intervals between the text objects in the text line; determining the gap interval recognition result of whether the to-be-recognized area has the gap interval feature according to the number of target gap intervals in each of the gap intervals, wherein the target space interval is a gap interval greater than a first set spacing;

[0029] For each of the text lines, the arrangement style of the text line is identified to determine the end text type and the mid-line text type of the text line; based on the end text type and the mid-line text type, determine whether the area to be identified has the directory style characteristics of the directory style recognition result.

[0030] According to a method for identifying a directory in a document provided by the present invention, before determining the gap interval identification result of whether the to-be-identified area has the gap interval feature according to the number of target gap intervals in each of the gap intervals, the method further includes:

[0031] Determine an average font size of each of the text lines, and use a specified multiple of the average font size as a first set spacing;

[0032] For each text line, determining a gap interval in the text line that is larger than a first set spacing as a target gap interval, and counting the number of the target gap intervals in the text line;

[0033] Correspondingly, the interstitial interval recognition result of determining whether the to-be-recognized area has the interstitial interval feature according to the number of target interstitial intervals in each of the interstitial intervals includes:

[0034] Determining whether the number of the target gap intervals in each of the text lines is less than the set number of intervals;

[0035] If so, determining that the gap interval recognition result is that the to-be-recognized area does not have the gap interval feature;

[0036] If not, it is determined that the gap interval recognition result is a gap interval feature that the to-be-recognized area does not have.

[0037] According to a method for identifying a directory in a document provided by the present invention, the directory style recognition result of determining whether the area to be identified has the directory style feature according to the end-of-line text type and the line-in text type includes:

[0038] Determine whether each of the text lines meets the directory style recognition condition, the directory style recognition is that the end text type of the text line is a numeric type, and the middle text type of the text line is a directory connection type;

[0039] If so, determining that the catalog style recognition result is that the to-be-recognized area has the catalog style feature;

[0040] If not, it is determined that the directory style recognition result is that the to-be-recognized area does not have the directory style feature.

[0041] According to a method for identifying a directory in a document provided by the present invention, the directory connection type is that the continuous number of directory separators is greater than a quantity threshold, or the gap interval between the end text object and the specified text object in the text line is greater than a second set spacing, and the specified text object is a non-directory separator text object above the end text object in the text line.

[0042] According to a method for identifying a directory in a document provided by the present invention, the text line association detection includes content type detection and text line type detection, the continuity feature includes content type feature and text line type feature, and the content type detection result includes a blank line detection result and a picture line detection result;

[0043] Correspondingly, the performing text line association detection on each of the text lines to obtain a detection result of whether the to-be-recognized area has a continuity feature includes:

[0044] Performing content type detection on each of the text lines to obtain the content type detection result of whether the area to be identified has the content type feature;

[0045] A text line type detection is performed on each of the text lines to obtain the text line type detection result of whether the area to be identified has the text line type feature.

[0046] According to a method for identifying a directory in a document provided by the present invention, determining whether the to-be-identified area in the target document is a directory according to the first recognition result, the second recognition result and the detection result includes:

[0047] Compare the first recognition result, the second recognition result and the detection result with set directory recognition conditions respectively;

[0048] When the comparison result is that both are consistent, it is determined that the area to be identified in the target document is a directory.

[0049] According to a method for identifying a directory in a document provided by the present invention, after comparing the first recognition result, the second recognition result and the detection result with the set directory recognition condition respectively, the method further includes:

[0050] If the comparison result shows that there is a mismatch, determining that the area to be identified in the target document is not a directory, and obtaining the number of text lines included in the area to be identified;

[0051] comparing the alignment feature, the directory association feature and the continuity feature with set directory recognition conditions respectively;

[0052] When the number of rows is not equal to the first preset value, subtract the second preset value from the number of rows to obtain an updated number of rows;

[0053] Determine each target sub-region in the to-be-recognized region, wherein the target sub-region contains the updated number of connected text lines;

[0054] The target sub-regions are respectively used as updated regions to be identified, and the step of identifying the color range of the text object in each text line and the circumscribed rectangle of each text line is continued.

[0055] The present invention also provides a device for identifying a directory in a document, comprising:

[0056] A first determination module is configured to determine a region to be identified in a target document, wherein the region to be identified includes at least one connected text line;

[0057] A first recognition module is configured to recognize a color range of a text object in each of the text lines and a circumscribed rectangle of each of the text lines, and determine a first recognition result of whether the area to be recognized has an alignment feature;

[0058] A second recognition module is configured to recognize the space interval and arrangement style of the text objects in each of the text lines, and determine whether the area to be recognized has a second recognition result of a catalog-related feature;

[0059] A detection module is configured to perform text line association detection on each of the text lines to obtain a detection result of whether the to-be-identified area has a continuity feature, wherein the continuity feature represents feature continuity between the text lines;

[0060] The second determination module is configured to determine whether the to-be-recognized area in the target document is a directory according to the first recognition result, the second recognition result and the detection result.

[0061] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for identifying a directory in a document as described in any one of the above methods is implemented.

[0062] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for identifying a directory in a document as described in any one of the above is implemented.

[0063] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for identifying a directory in a document as described in any one of the above is implemented.

[0064] The method and device for identifying a directory in a document provided by the present invention are as follows: determining an area to be identified in a target document, wherein the area to be identified includes at least one connected text line; identifying the color range of text objects in each of the text lines and the circumscribed rectangle of each of the text lines, and determining a first recognition result of whether the area to be identified has an alignment feature; identifying the space intervals and arrangement styles of text objects in each of the text lines, and determining a second recognition result of whether the area to be identified has a directory association feature; performing text line association detection on each of the text lines, and obtaining a detection result of whether the area to be identified has a continuity feature, wherein the continuity feature represents the feature continuity between the text lines; and determining whether the area to be identified in the target document is a directory based on the first recognition result, the second recognition result, and the detection result. The present invention can accurately identify all directory areas in a document, and identify the specific number of lines corresponding to each directory area, with more detailed positioning granularity, and realize line-level directory recognition; it only needs to parse the current page, and does not require the entire directory structure, that is, it supports single-page processing and is independent of the entire document; if multiple directories appear in a single page, they can be separated; the recognition process does not rely on the directory format in the standard protocol, supports the recognition of directories of non-standard protocols, and supports the recognition of directory variants; it is convenient for the reader to operate when displaying the document, convenient for streaming documents to automatically generate outlines, and convenient for improving the effect when converting or rearranging layout documents. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0066] Figure 1 It is a flowchart of a method for identifying a directory in a document provided by the present invention;

[0067] Figure 2 It is a schematic diagram of the effect of the method for identifying directories in a document provided by the present invention;

[0068] Figure 3 It is a schematic diagram of the structure of the device for identifying directories in a document provided by the present invention;

[0069] Figure 4 It is a schematic diagram of the structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0071] First, the terms involved in the present invention are explained.

[0072] Streaming documents refer to documents that can be freely edited, mainly including Word documents and TXT documents, etc. Layout documents refer to non-editable documents, that is, documents with fixed layouts, mainly including PDF (Portable Document Format) documents and OFD (Open Fixed-layout Document) documents, etc.

[0073] A table of contents is an index or navigation tool that lists chapters, titles or topics in a certain order in a document such as a book, document or report, and provides corresponding page numbers or links so that readers can quickly locate and find specific content.

[0074] The text object is the basic element in the document. For layout documents, such as PDF, it refers to TextObject, and for streaming documents, such as Word documents, it refers to TextContainer. The text object contains the character code (CharCode) of the text content in the font, the font (Font), the character external coordinate box (CBox), and the unified character encoding Unicode.

[0075] A font is a set of visual representations of characters, including their appearance, style, and arrangement. A font is made up of glyphs, which define how characters are drawn, including information such as the character's outline, curves, and strokes. By combining glyphs, specific text can be formed. Each glyph represents a character in the font. There are many properties of a font that can be adjusted and set, including but not limited to the font family or cluster, font style, font size, font weight, letter spacing, line height, and fixed-pitch.

[0076] A font family or cluster is a category or classification of fonts that specifies that text should use a certain font or font sequence, such as Songti, Arial, Times New Roman, and Kaiti. Font styles include Regular, Italic, and Bold. Font size determines the display size of characters. Font weight specifies the thickness of characters. Character spacing refers to the horizontal spacing adjustment between characters. Line height refers to the vertical spacing adjustment between lines, etc. Fixed width means that the characters in a font have the same fixed width, regardless of the actual width of the characters.

[0077] Writing Mode is used to describe the direction of text layout, mainly including LrTb, RlTb and TbRl. Among them, LrTb means that the line direction is from left to right and the paragraph direction is from top to bottom. The writing direction of most documents is LrTb; RlTb means that the line direction is from right to left and the paragraph direction is from top to bottom, which is usually Arabic or Hebrew, that is, it is generally used in writing systems such as Arabic and Hebrew; TbRl means that the line direction is from top to bottom and the paragraph direction is from right to left, which is often used in writing systems such as Chinese (classical), Japanese and Mongolian. In addition, although the writing direction used for Mongolian is TbLr, there are only three types of LrTb, RlTb and TbRl in the PDF standard, so the writing direction of Mongolian is regarded as TbRl in PDF.

[0078] The paragraph direction refers to the direction in which the next line should be typeset after the current line is typeset. For example, in the common LrTb writing direction, the paragraph direction is from top to bottom and the line direction is from left to right.

[0079] In order to facilitate a clearer understanding of the embodiments of the present invention, some relevant background knowledge is first introduced as follows.

[0080] The table of contents in a document can improve the reader's reading speed and facilitate content retrieval. The table of contents in a document is equivalent to a reference to the entire document, indexing the main content of the entire document. In addition, if you want to achieve a personalized reading method, such as establishing a link from the table of contents to the document body, you need to do it based on the recognition of the table of contents.

[0081] In the prior art, there are four commonly used methods for identifying directories. Method 1 is to find special characters in the directory page based on rules and find the directory at the page level; Method 2 is to parse the cross-index table of PDF and identify the directory in the standard protocol; Method 3 is to preset the feature pattern of the standard directory, use the matched features to score, and find the directory page; Method 4 is to obtain the paragraph features in each page, and analyze the possible directory area after parsing all of them.

[0082] However, the above method 1 is page-level directory recognition, which cannot recognize directories at a finer level, and has low accuracy and high granularity; method 2 can only recognize standard directories (standard directories corresponding to the directory structure, which can achieve jumps), and cannot recognize non-standard directories (such as manually typed texts with directory structures that cannot achieve page jumps); method 3 can also only recognize page-level directory recognition, and the feature pattern is relatively rough, with low accuracy and high granularity; method 4 relies on the full text and is page-level directory recognition.

[0083] Therefore, the present invention provides a method and device for identifying directories in a document to solve the above-mentioned problem.

[0084] Combine the following Figure 1-Figure 2 The method of identifying a directory in a document according to the present invention is described.

[0085] Figure 1 is a flow chart of the method for identifying directories in a document provided by the present invention, see Figure 1 As shown, it includes steps 101 to 105, wherein:

[0086] Step 101: Determine a region to be recognized in a target document, wherein the region to be recognized includes at least one connected text line.

[0087] First of all, it should be noted that the execution subject of the present invention can be any electronic device for object recognition in a document, for example, a smart phone, a smart watch, a desktop computer, a laptop computer, etc. Secondly, the method for identifying a directory in a document provided by the present invention can be applied to scenarios such as layout document conversion, layout document rearrangement, layout document editing, and streaming document display.

[0088] Specifically, the target document refers to a document that needs to be identified whether a directory exists, which can be a layout document, a streaming document, a presentation document such as a slide document, or a picture document, and the present invention does not impose any limitation on this. The area to be identified refers to the area in the target document where a directory exists, which can be the entire display area of ​​the target document, that is, all display areas, a specified partial area in the target document, or an area corresponding to the currently displayed page in the target document, and the present invention does not impose any limitation on this. A text line refers to a line in a document used to display content.

[0089] In practical applications, before determining the area to be identified in the target document, the target document must be acquired first. There are many methods for acquiring the target document, and the present invention does not limit this.

[0090] Exemplarily, a user uploads a target document through a document upload page, and accordingly, the execution subject obtains the target document.

[0091] Exemplarily, the execution subject receives a document acquisition instruction or a directory identification instruction, and accordingly, the execution subject acquires the target document from the storage area pointed to by the document acquisition instruction or the directory identification instruction.

[0092] On the basis of acquiring the target document, further, the area to be identified in the target document is determined: the entire display area of ​​the target document can be used as the area to be identified; when a selection instruction is received, the area of ​​the target document mapped with the selection instruction is used as the area to be identified.

[0093] It should be noted that before determining the area to be identified in the target document, it also includes: identifying the document type of the target document. If the document type is a layout document, such as PDF, then the text line and writing direction of the text object are identified according to the position of the text object in the target document, that is, a judgment is made, for example, using a line identifier to identify the text line and writing direction of the text object; or the document type of the layout document is converted into a streaming document. If it is a streaming document or a presentation document, the step of determining the area to be identified in the target document is executed. If it is a picture document, the optical character recognition (OCR) technology is used to extract the text content in the picture document, and a target document of the streaming document type is generated according to the text content. In this way, the document recognition directory of different document types can be guaranteed, the scope of application of directory recognition is improved, and the flexibility of directory recognition is improved.

[0094] Step 102: Identify the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines to determine whether the area to be identified has a first identification result of an alignment feature.

[0095] Specifically, the color range refers to the range of color values, which can be the color range in the ARGB color mode or the RGB color mode. The bounding rectangle (BBox) is the rectangular box corresponding to each text line, which contains the position information of the bounding rectangle, that is, the BBox represents the coordinate values ​​of each side of the bounding rectangle. The alignment feature characterizes that the color dimension and the position dimension of the bounding rectangle of the area to be identified are relatively consistent. The first recognition result refers to the result of color range and bounding rectangle recognition, that is, the result of whether the area to be identified has the alignment feature.

[0096] In actual applications, after the area to be identified is determined, the color range of the text objects in each text line and the bounding rectangle of each text line can be identified. For example, a line identifier can be used to identify the color range of the text objects in each text line and the bounding rectangle of each text line, so as to determine whether the area to be identified has alignment features, that is, to determine the first recognition result.

[0097] Step 103: Identify the space intervals and arrangement styles of the text objects in each of the text lines to determine whether the area to be identified has a second identification result of a directory-related feature.

[0098] Specifically, the spacing, or spacing, refers to the distance between two adjacent text objects in the same text line. The arrangement style refers to the characteristics of the distribution and arrangement of text objects in a text line. The directory association feature characterizes that the text object in the area to be identified is associated with the directory. The second recognition result refers to the result of the spacing and arrangement style recognition, that is, whether the area to be identified has the directory association feature.

[0099] In actual applications, after determining the area to be identified, the spacing and arrangement style of the text objects in each text line can be identified. For example, a line identifier can be used to identify the spacing of the text objects in each text line, and the arrangement style of the text objects in each text line, so as to determine whether the area to be identified has directory-related features, that is, to determine the second recognition result.

[0100] Step 104: Perform text line association detection on each of the text lines to obtain a detection result of whether the to-be-identified area has a continuity feature, where the continuity feature represents feature continuity between the text lines.

[0101] Specifically, text line association detection refers to the detection of whether the text lines in the area to be identified are associated, that is, the detection of whether the text lines in the area to be identified are continuous. The continuity feature characterizes the continuity of the features between the text lines. The detection result refers to the result of the text line association detection, that is, the result of whether the area to be identified has the continuity feature.

[0102] In practical applications, after the area to be identified is determined, text line association detection is performed on each text line in the area to be identified. For example, a line identifier can be used to perform text line association detection to obtain the detection result of the area to be identified, that is, to determine whether the area to be identified has continuity features.

[0103] It should be noted that the processes corresponding to step 102 to step 104 can be executed synchronously or in a set order, and the present invention does not limit this. For ease of understanding, the present invention takes the order of step 102 to step 104 as an example for explanation.

[0104] Step 105: Determine whether the to-be-recognized area in the target document is a directory based on the first recognition result, the second recognition result, and the detection result.

[0105] Specifically, the catalog refers to the table of contents before the main text of a book, which is a tool for revealing and reporting books.

[0106] In practical applications, after the first recognition result, the second recognition result, and the detection result are determined, it can be determined whether the area to be recognized is a directory based on the first recognition result, the second recognition result, and the detection result.

[0107] Exemplarily, the first recognition result, the second recognition result and the detection result are respectively compared with their corresponding set results or conditions. If they are the same, it is determined that the area to be recognized in the target document is a directory. If there are differences, it is determined that the area to be recognized in the target document is not a directory.

[0108] The method for identifying a directory in a document provided by the present invention is as follows: determining an area to be identified in a target document, wherein the area to be identified includes at least one connected text line; identifying the color range of text objects in each of the text lines and the circumscribed rectangle of each of the text lines, and determining a first recognition result of whether the area to be identified has an alignment feature; identifying the space intervals and arrangement styles of text objects in each of the text lines, and determining a second recognition result of whether the area to be identified has a directory association feature; performing text line association detection on each of the text lines, and obtaining a detection result of whether the area to be identified has a continuity feature, wherein the continuity feature represents the feature continuity between the text lines; and determining whether the area to be identified in the target document is a directory based on the first recognition result, the second recognition result, and the detection result. The present invention can accurately identify all directory areas in a document, and identify the specific number of lines corresponding to each directory area, with more detailed positioning granularity, and realize line-level directory recognition; it only needs to parse the current page, and does not require the entire directory structure, that is, it supports single-page processing and is independent of the entire document; if multiple directories appear in a single page, they can be separated; the recognition process does not rely on the directory format in the standard protocol, supports the recognition of directories of non-standard protocols, and supports the recognition of directory variants; it is convenient for the reader to operate when displaying the document, convenient for streaming documents to automatically generate outlines, and convenient for improving the effect when converting or rearranging layout documents.

[0109] In one or more optional embodiments of the present invention, the alignment feature includes a color alignment feature and a text line alignment feature, and the first recognition result includes a color alignment recognition result and a text line alignment recognition result; accordingly, the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines are recognized to determine whether the area to be recognized has the first recognition result of the alignment feature, and the specific implementation process can be as follows:

[0110] For each of the text lines, identify the color corresponding to each text object in the text line under the target color mode, and obtain the color range corresponding to each text object in the text line; determine whether the area to be identified has the color alignment recognition result of the color alignment feature according to the color range;

[0111] For each of the text lines, the boundary coordinates of the circumscribed rectangle of the text line are identified; and according to the boundary coordinates, it is determined whether the area to be identified has the text line alignment recognition result of the text line alignment feature.

[0112] Specifically, the color mode is a way to represent colors in the digital world. In the digital world, in order to represent various colors, colors are usually divided into several components. The color modes include RGB color mode, CMYK color mode, HSB color mode, LAB color mode and ARGB color mode, etc. Different color modes correspond to different colors, and accordingly, the color ranges are also different. The target color mode is a pre-set color mode. The color alignment feature, that is, the color consistency feature (ColorConsistent), characterizes that the text lines in the area to be identified are consistent in the color dimension. The boundary coordinates refer to the coordinates of the boundary of the circumscribed rectangle, such as the coordinates of the upper boundary of the circumscribed rectangle, the coordinates of the left boundary, etc. The text line alignment feature, also known as the alignment feature (Aligned), characterizes that the text lines in the area to be identified are relatively consistent in the position dimension. The color alignment recognition result refers to the result of whether the area to be identified has the color alignment feature. The text line alignment recognition result refers to the result of whether the area to be identified has the text line alignment feature.

[0113] In practical applications, for each text line in the area to be identified, the color corresponding to each text object in the text line under the target color mode is identified, that is, the color range corresponding to each text object in the text line is obtained; then the color range corresponding to each text object in each text line is used to determine whether the area to be identified has color alignment features, that is, to determine the color alignment recognition result. At the same time, for each text line in the area to be identified, the boundary coordinates of the circumscribed rectangle of the text line are identified; then, based on the boundary coordinates corresponding to each text line, it is determined whether the area to be identified has text line alignment features, that is, to determine the text line alignment recognition result. In this way, the first recognition result is determined in a more fine-grained manner from the two dimensions of color alignment features and text line alignment features, thereby improving the accuracy and reliability of the first recognition result.

[0114] Optionally, the color alignment recognition result of determining whether the area to be recognized has the color alignment feature based on the color range can be: judging whether the color ranges of each text line are the same, or judging whether the color ranges of each text line are within a preset range; if so, determining that the color alignment recognition result is that the area to be recognized has the color alignment feature; if not, determining that the color alignment recognition result is that the area to be recognized does not have all the color alignment features. In this way, by judging whether each color range is the same or within a preset range, the process of determining the color alignment recognition result can be simplified, and the efficiency of determining the color alignment recognition result can be improved.

[0115] Optionally, the color alignment recognition result of determining whether the to-be-recognized area has the color alignment feature according to the color range may be specifically implemented as follows:

[0116] Determining whether each text line pair is a target text line pair, wherein the text line pair is two connected text lines in each of the text lines, and the color ranges corresponding to the two text lines in the target text line pair overlap;

[0117] If so, determining that the color alignment recognition result is that the area to be recognized has the color alignment feature;

[0118] If not, it is determined that the color alignment recognition result is that the to-be-recognized area does not have the color alignment feature.

[0119] In practical applications, for each text line pair (two connected text lines), if there are any two consecutive text lines (text line pairs) whose corresponding color ranges have no intersection or overlap in value, the color alignment recognition result is that the area to be recognized does not have color alignment features, otherwise the color alignment recognition result is that the area to be recognized has color alignment features. In this way, by determining whether there is overlap in the color range, the color alignment recognition result can be determined, which can avoid some subtle differences in color between text lines in the directory, resulting in recognition failure, thereby improving the efficiency and accuracy of directory recognition while ensuring the accuracy of the color alignment recognition result.

[0120] In an achievable embodiment of the present invention, the color mode is a CMYK color mode; accordingly, the color corresponding to each text object in the text line under the target color mode is identified to obtain a color range corresponding to each text object in the text line. The specific implementation process may be as follows: identify the cyan, magenta, yellow and black colors corresponding to each text object in the text line under the CMYK color mode, and obtain the cyan color range, magenta color range, yellow color range and black color range corresponding to each text object in the text line.

[0121] It should be noted that CMYK is generated based on the principle of reflection, and four colors are formed by mixing and superimposing three primary colors, namely cyan (Cyan, C), magenta (Magenta, M), yellow (Yellow, Y), and black (blank, K). In this way, the color range can be determined more finely from multiple colors, which can improve the accuracy of the color range.

[0122] In another achievable embodiment of the present invention, the color mode is an ARGB color mode; accordingly, the color corresponding to each text object in the text line under the target color mode is identified to obtain the color range corresponding to each text object in the text line. The specific implementation process may be as follows:

[0123] Identify the transparency, red, green and blue corresponding to each text object in the text line in the ARGB color mode, and obtain the transparency color range, red color range, green color range and blue color range corresponding to each text object in the text line.

[0124] In actual applications, the ARGB color mode is set according to the principle of color luminescence, and has four channels: transparency (Alpha, A), red (Red, R), green (Green, G), and blue (Blue, B), each channel corresponding to a color. Therefore, in the ARGB color mode, for each text line, the transparency color range, red color range, green color range, and blue color range corresponding to each text object in the text line are obtained. In this way, the color range can be determined more finely from multiple colors, which can improve the accuracy of the color range.

[0125] In an achievable embodiment of the present invention, when the color mode is the ARGB color mode, to determine whether each text line pair is a target text line pair, the following can be done: for each text line pair, determine whether the transparency color ranges of the two text lines in the text line pair overlap, whether the red color ranges overlap, whether the green color ranges overlap, or whether the blue color ranges overlap. That is, it is sufficient to determine whether there is overlap in the transparency color range, the red color range, the green color range, and the blue color range. As long as one of them overlaps, there is no need to determine the remaining undetermined ones. In this way, the amount of data processing can be reduced to a certain extent, and the determination efficiency can be improved.

[0126] In another achievable embodiment of the present invention, when the color mode is the ARGB color mode, the transparency color range, the red color range, the green color range, and the blue color range corresponding to the two text lines in the target text line pair all overlap; accordingly, the specific implementation process of determining whether each text line pair is a target text line pair is as follows:

[0127] For each text line pair, determine whether the transparency color ranges of the two text lines in the text line pair overlap, whether the red color ranges overlap, whether the green color ranges overlap, and whether the blue color ranges overlap.

[0128] In practical applications, for each text line pair, when the transparency color range, red color range, green color range, and blue color range of the two text lines in the text line pair overlap, the text line pair is identified as a target text line pair. Furthermore, when all text line pairs are target text line pairs, the color alignment recognition result is determined to be that the area to be recognized has color alignment features, and when all text line pairs are not target text line pairs, the color alignment recognition result is determined to be that the area to be recognized does not have color alignment features. In this way, by more finely granularly determining the target text line pairs and the color alignment recognition results based on multiple color ranges, the accuracy of the target text line pairs and the color alignment recognition results can be improved.

[0129] Exemplarily, the value ranges of the four ARGB channels of all TextObjects in each given row (all text rows in the area to be identified) are counted (color ranges, including transparency color range, red color range, green color range and blue color range), such as respectively counting the value ranges of R, G, B, and A in this row to obtain the transparency color range, red color range, green color range and blue color range. For example, the minimum value of R in the first row is 50 and the maximum value is 100. If there are any two consecutive rows (front and back rows or up and down rows) in which the color range values ​​of any channel (color) do not intersect (do not overlap), taking the R channel as an example, the previous row is R1 (50, 60) and the next row is R2 (55, 65), then there is an intersection; then the color alignment recognition result isColorConsistent (color alignment feature) = False (does not have color alignment feature), otherwise the color alignment recognition result is True (has color alignment feature).

[0130] Optionally, the boundary coordinates include a first coordinate corresponding to the front end and a second coordinate corresponding to the rear end of the circumscribed rectangle in the writing direction; accordingly, before the text line alignment recognition result of determining whether the area to be recognized has the text line alignment feature according to the boundary coordinates, the method further includes:

[0131] Obtaining the line height of each text line, and determining a reference line height according to each of the line heights;

[0132] Correspondingly, the text line alignment recognition result of determining whether the to-be-recognized area has the text line alignment feature according to the boundary coordinates may be specifically implemented as follows:

[0133] Calculate a first coordinate average value according to each of the first coordinates, and calculate a second coordinate average value according to each of the second coordinates;

[0134] Determine whether a first difference between each of the first coordinates and an average value of the first coordinates, and a second difference between each of the second coordinates and an average value of the second coordinates are both less than or equal to the reference row height;

[0135] If so, determining that the text line alignment recognition result is that the area to be recognized has the text line alignment feature;

[0136] If not, it is determined that the text line alignment recognition result is that the area to be recognized does not have the text line alignment feature.

[0137] Specifically, the reference line height refers to a pre-set line height for reference, which can be the mode of the line heights of each text line (mode line height), the average of the line heights of each text line (average line height), or the median of the line heights of each text line (median line height). The present invention does not impose any limitation on this. The front end is the starting end of the circumscribed rectangle in the writing direction, and the rear end is the ending end of the circumscribed rectangle in the writing direction. If the writing direction is from left to right, the front end is the leftmost end or left side of the circumscribed rectangle, and the rear end is the rightmost end or right side of the circumscribed rectangle.

[0138] In practical applications, the line height of each text line can be obtained first, and then the reference line height can be determined according to the set reference line height determination strategy. Then, the first coordinates corresponding to each text line are averaged to obtain the first coordinate average value, and the second coordinates corresponding to each text line are averaged to obtain the second coordinate average value. Further, the first difference between each first coordinate and the first coordinate average value, and the second difference between each second coordinate and the second coordinate average value are calculated. Then, it is determined whether each first difference and each second difference are less than or equal to the reference line height. If so, it is determined that the text line alignment recognition result is that the area to be identified has the text line alignment feature; if not, it is determined that the text line alignment recognition result is that the area to be identified does not have the text line alignment feature. Since the alignment method of the directory is generally two-end alignment, the discreteness of the coordinates at the front and rear ends relative to the coordinate average value is less than the reference line spacing, which can ensure the alignment of the text lines in the writing direction to a certain extent, thereby improving the accuracy of the text line alignment recognition result.

[0139] Exemplarily, the writing direction is from left to right. If, in all given lines (all text lines in the area to be identified), the left coordinate (first coordinate) of the circumscribed rectangle of each line and the average value of the first coordinate do not exceed the average line height, and the right coordinate (second coordinate) of the circumscribed rectangle of each line and the average value of the second coordinate do not exceed the average line height, then the text line alignment recognition result isAligned (text line alignment feature) = True (having text line alignment feature), otherwise it is False (not having text line alignment feature).

[0140] Optionally, the boundary coordinates include the first coordinates corresponding to the front end and the second coordinates corresponding to the rear end of the circumscribed rectangle in the writing direction; accordingly, the text line alignment recognition result of determining whether the area to be identified has the text line alignment feature based on the boundary coordinates includes: calculating the third difference between the first coordinates of the two text lines in each text line pair and the fourth difference between the second coordinates; judging whether each of the third differences and each of the fourth differences is less than or equal to a preset difference; if so, determining that the text line alignment recognition result is that the area to be identified has the text line alignment feature; if not, determining that the text line alignment recognition result is that the area to be identified does not have the text line alignment feature. In this way, the alignment of the two ends of the text line in the writing direction can be guaranteed to a certain extent, thereby improving the accuracy of the text line alignment recognition result.

[0141] In one or more optional embodiments of the present invention, the catalog association features include gap spacing features and catalog style features; accordingly, the gap spacing and arrangement style of the text objects in each of the text lines are identified, and the second recognition result includes a gap spacing recognition result and a catalog style recognition result. The specific implementation process can be as follows:

[0142] For each of the text lines, identifying the gap intervals between the text objects in the text line; determining the gap interval recognition result of whether the to-be-recognized area has the gap interval feature according to the number of target gap intervals in each of the gap intervals, wherein the target space interval is a gap interval greater than a first set spacing;

[0143] For each of the text lines, the arrangement style of the text line is identified to determine the end text type and the mid-line text type of the text line; based on the end text type and the mid-line text type, determine whether the area to be identified has the directory style characteristics of the directory style recognition result.

[0144] Specifically, the gap spacing feature, that is, more than one gap (MoreThanOneGap), characterizes that the gap spacing corresponding to the area to be identified is relatively consistent. The first set spacing refers to a pre-set reference spacing. The first set spacing can be N times the average font size, such as 4 times, and can be M times the average line spacing, such as 2 times. The gap spacing recognition result refers to the result of whether the area to be identified has the gap spacing feature. The end-of-line text type refers to the type of text object at the end of the text line, such as picture type, data type, and Chinese character type, etc. The in-line text type refers to the type of text object between the beginning and end of the text line. The directory style feature, that is, the directory feature (Table of Contents, TOC), characterizes that the text object in the area to be identified has some of the same properties as the directory, such as the attribute of implementing the index and the attribute of containing page numbers. The directory style recognition result refers to the result of whether the area to be identified has the directory style feature.

[0145] In practical applications, for each text line, the gap intervals between the text objects in the text line can be identified, and then the number of target gap intervals greater than the first set spacing in all the gap intervals of the text line is counted, and then based on the number of target gap intervals, it is determined whether the area to be identified has gap interval characteristics, that is, the gap interval recognition result is determined. At the same time, for each text line, the layout style of the text line is identified, mainly the text objects at the end of the text line and in the line are identified, and the text type at the end of the line and the text type in the line are obtained. Then, according to the text type at the end of the line and the text type in the line, it is determined whether the area to be identified has directory style characteristics, that is, the directory style recognition result is determined. In this way, the second recognition result is determined in a more fine-grained manner from the two dimensions of gap interval characteristics and directory style characteristics, thereby improving the accuracy and reliability of the second recognition result.

[0146] Optionally, before determining the gap interval recognition result of whether the to-be-recognized area has the gap interval feature according to the number of target gap intervals in each of the gap intervals, the method further includes:

[0147] Determine an average font size of each of the text lines, and use a specified multiple of the average font size as a first set spacing;

[0148] For each text line, determining a gap interval in the text line that is larger than a first set spacing as a target gap interval, and counting the number of the target gap intervals in the text line;

[0149] Correspondingly, the gap interval recognition result of determining whether the to-be-recognized area has the gap interval feature according to the number of target gap intervals in each of the gap intervals may be specifically implemented as follows:

[0150] Determining whether the number of the target gap intervals in each of the text lines is less than the set number of intervals;

[0151] If so, determining that the gap interval recognition result is that the to-be-recognized area does not have the gap interval feature;

[0152] If not, it is determined that the gap interval recognition result is a gap interval feature that the to-be-recognized area does not have.

[0153] Specifically, the average font size refers to the average font size of all text objects in a text line. The specified multiple refers to a preset multiple. The set number of intervals refers to a preset number of intervals for reference; since a directory generally has a target gap interval (one gap may be a directory feature), preferably, the number of intervals is set to 2.

[0154] In practical applications, for each text line, the font size of each text object in the text line is counted, and based on the font size of each text object in the text line, the average font size is calculated; then the average font size is multiplied by a specified multiple to obtain the first set spacing corresponding to the text line. Each text line is traversed to obtain the first set spacing corresponding to each text line.

[0155] Furthermore, for each text line, each gap interval in the text line is compared with the first preset spacing corresponding to the text line, the gap interval in the text line that is larger than the first set spacing is determined as the target gap interval, and the number of target gap intervals in the text line is counted. Each text line is traversed to obtain the number of target gap intervals in each text line. Then, it is determined whether the number of target gap intervals in each text line is less than the set number of intervals; if so, the gap interval recognition result is determined to be that the area to be recognized does not have a gap interval feature; if not, the gap interval recognition result is determined to be that the area to be recognized has a gap interval feature. In this way, by setting the number of intervals and the first set spacing, the gap interval recognition result is determined to be, which can improve the accuracy of the gap interval recognition result.

[0156] Exemplarily, the average font size of each line in all given lines (all text lines in the area to be identified) is counted. If there is any line with at least 2 (set number of intervals) target gap intervals (the target gap interval is calculated as: the distance between text objects is greater than 4 times the average font size), the gap interval recognition result hasMoreThanOneGap (gap interval feature) = True (has gap interval feature), otherwise it is False (does not have gap interval feature).

[0157] Optionally, the gap interval recognition result of determining whether the area to be recognized has the gap interval feature according to the number of target gap intervals in each of the gap intervals may be specifically implemented as follows: calculating the average of the number of target gap intervals in each of the gap intervals; judging whether the fifth difference between the number of target gap intervals in each of the text lines and the average is less than a set difference; if so, determining that the gap interval recognition result is that the area to be recognized does not have the gap interval feature; if not, determining that the gap interval recognition result is that the area to be recognized has the gap interval feature. In this way, the process of determining the gap interval recognition result can be simplified, and the efficiency of determining the gap interval recognition result can be improved.

[0158] Optionally, the directory style recognition result of determining whether the to-be-recognized area has the directory style feature according to the end-of-line text type and the in-line text type may be specifically implemented as follows:

[0159] Determine whether each of the text lines meets the directory style recognition condition, the directory style recognition is that the end text type of the text line is a numeric type, and the middle text type of the text line is a directory connection type;

[0160] If so, determining that the catalog style recognition result is that the to-be-recognized area has the catalog style feature;

[0161] If not, it is determined that the directory style recognition result is that the to-be-recognized area does not have the directory style feature.

[0162] Specifically, the number type refers to text that represents numbers, such as Roman numerals, Chinese numerals, Arabic numerals, etc. The directory connection type refers to the content used to connect the title and page number in the directory.

[0163] In practical applications, after determining the text type at the end of each text line and the text type in the line, it is determined whether each text line meets the directory style recognition conditions, that is, whether the text type at the end of each text line is a digital type, and whether the text type in each text line is a directory connection type. If so, the directory style recognition result is determined to be that the area to be recognized has the directory style characteristics; if not, the directory style recognition result is determined to be that the area to be recognized does not have the directory style characteristics. In this way, the efficiency of determining the directory style recognition result can be improved through the digital type and directory connection type.

[0164] In addition, the directory connection type is that the consecutive number of directory separators is greater than the number threshold, or the gap interval between the end text object and the specified text object in the text line is greater than the second set spacing, and the specified text object is a non-directory separator text object above the end text object in the text line.

[0165] Specifically, the directory separator refers to the symbol that separates the title and the page number, such as the hyphen "-", the spacer ".", the ellipsis "..." and the underscore "_". The continuous number refers to the number of directory separators that are connected together (connected). Preferably, the continuous number refers to the number of target separators that are connected together (connected) and are the same. The second set spacing refers to a preset reference spacing, which may be the same as the first set spacing or different, such as N times the average font size, such as 4 times. The end-of-line text object refers to the text object at the end of a text line. The designated text object refers to the non-directory separator text object that is closest to the end-of-line text object in the text line.

[0166] In actual applications, the text type in a line where the number of consecutive directory separators is greater than the quantity threshold can be used as the directory connection type, or the text type in a line where the gap between the end text object and the specified text object in the text line is greater than the second set spacing can be used as the directory connection type.

[0167] Exemplarily, the directory style features of each line in all given lines (all text lines in the area to be identified) are calculated. If the last character at the end of the line (the character with the rightmost coordinates in the text line) is a number, including Roman numerals, Chinese numerals, Arabic numerals, etc., that is, the text type at the end of the line is a number type, then it is considered that there is an end-of-line page number in the current line. If there are continuous, identical characters (directory separators) in the line that exist in the directory separator set, and the number of directory separators is greater than the threshold of 8 (quantity threshold), or when traversing from the end-of-line page number (end-of-line text object) in the reverse direction (opposite to the writing direction) to the first character (specified text object) in the non-directory separator set, there is a significant gap, that is, the gap between the end-of-line text object and the specified text object is greater than the second set spacing, then it is considered that there is a directory connector in the current line, that is, it meets the directory connection type. If there is any line without a page number at the end of the line (the text type at the end of the line is not a numeric type) or without a directory connector (the Chinese text type is not a directory connection type), then the directory style recognition result isTOC (directory style feature) = False (does not have a directory style feature), otherwise it is True (has a directory style feature).

[0168] It should be noted that if the directory separator is "...", then this directory separator is counted as 3 dots and 3 characters when calculating the threshold.

[0169] In one or more optional embodiments of the present invention, the text line association detection includes content type detection and text line type detection, the continuity feature includes content type feature and text line type feature, and the content type detection result includes a blank line detection result and a picture line detection result; accordingly, the text line association detection is performed on each of the text lines to obtain a detection result of whether the area to be identified has a continuity feature, including:

[0170] Performing content type detection on each of the text lines to obtain the content type detection result of whether the area to be identified has the content type feature;

[0171] A text line type detection is performed on each of the text lines to obtain the text line type detection result of whether the area to be identified has the text line type feature.

[0172] Specifically, content type detection refers to the detection of the content in the text line. Content type features refer to the relatively consistent types of content in the text line, wherein the types of content include picture types and blank line types, etc., the picture type indicates that the content is a picture, and the blank line type indicates that there is no substantial content. The content type detection result refers to the result of content type detection on the text line, that is, the result of whether the area to be identified has content type features. Text line type detection refers to the detection of the relationship between text lines or text line types, wherein the relationship between text lines includes whether the writing methods between text lines are the same, whether there are intersections, whether the font styles are the same, and whether the line spacing meets the line spacing requirements; text line type refers to the type of text line whose content is text, including writing direction type, line intersection type, font style type and line spacing type. Text line type features indicate that the types between text lines are relatively consistent. Text line type detection results refer to the result of text line type detection on text lines, that is, the result of whether the area to be identified has text line type features.

[0173] In practical applications, the line identifier can be used to detect the content type of the text line, and determine whether the area to be identified has content type features based on the content type detection results, that is, determine the content type detection results; at the same time, the line identifier can be used to detect the text line type of each text line, and determine whether the area to be identified has text line type features based on the text line type detection results, that is, determine the text line type detection results. In this way, the text line type detection results are determined more finely from the two dimensions of content type features and text line type features, thereby improving the accuracy and reliability of the text line type detection results.

[0174] Optionally, the content type detection includes blank line detection and picture line detection, the content type feature includes a blank line feature and a picture line feature, and the content type detection result includes a blank line detection result and a picture line detection result; accordingly, performing content type detection on each of the text lines to obtain the content type detection result of whether the area to be identified has the content type feature includes:

[0175] Obtaining the blank line detection result of whether the to-be-identified area has the blank line feature by performing blank line detection on each of the text lines;

[0176] By performing picture line detection on each of the text lines, the picture line detection result is obtained to determine whether the area to be identified has the picture line feature.

[0177] Specifically, an empty line refers to a text line without text content, such as a line without any characters, a line with only spaces, and a line with only lines. An image line refers to a text line with text content but no text type elements, that is, a text line with a picture as the text content. The empty line feature, i.e., content empty line (ContentEmptyLine), indicates that the area to be identified contains an empty line. The image line feature (FigureLine) indicates that the area to be identified contains an image line.

[0178] In practical applications, for each text line, a blank line detection can be performed on the text line according to the content or characters in the text line, that is, whether the text line is a blank line can be identified. For example, if there are only underlines or spaces modified by underlines in the current text line, then there is no specific text content, and the text line is a blank line. Thus, a blank line detection result is obtained to determine whether the area to be identified has blank line features. At the same time, for each text line, a picture line detection is performed on the text line, that is, whether the text line is a picture line is identified, thereby obtaining a picture line detection result to determine whether the area to be identified has picture line features. In this way, the content type detection result is determined in a more fine-grained manner from the two dimensions of blank line features and picture line features, thereby improving the accuracy and reliability of the content type detection result.

[0179] In one or more optional embodiments of the present invention, the blank line detection is performed on each of the text lines to obtain the blank line detection result of whether the area to be identified has the blank line feature. The specific implementation process may be as follows:

[0180] Performing blank line detection on each of the text lines to determine whether each of the text lines is a blank line without text content;

[0181] In the case where there is a blank line in each of the text lines, determining the blank line detection result as that the to-be-identified area has the blank line feature;

[0182] In the case that there is no blank line in each of the text lines, the blank line detection result is determined as the area to be identified does not have the blank line feature.

[0183] In practical applications, each text line can be simultaneously tested for blank lines to determine whether each text line is a blank line. If there is a blank line in each text line, the blank line detection result is determined to be that the area to be identified has blank line features. If there is no blank line in each text line, the blank line detection result is determined to be that the area to be identified does not have blank line features. In this way, the efficiency and accuracy of determining the blank line detection result can be improved.

[0184] Exemplarily, if there is no text content in any line of all given lines (all text lines in the area to be identified), the empty line detection result hasContentEmptyLine (empty line feature) = True (has empty line feature), otherwise it is False (does not have empty line feature).

[0185] In addition, each text line can be detected as blank line in a certain order. When the current text line is detected as a blank line, the blank line detection result can be determined as the area to be identified has blank line features. In this way, blank line detection can be avoided for all text lines, which reduces the amount of data processing to a certain extent and improves the efficiency of determining the blank line detection result.

[0186] In one or more optional embodiments of the present invention, the step of performing picture line detection on each of the text lines to obtain the picture line detection result of whether the area to be identified has the picture line feature includes:

[0187] Performing picture line detection on each of the text lines to determine whether each of the text lines is a picture line;

[0188] In the case where there is a picture line in each of the text lines, determining the picture line detection result as that the area to be identified has the picture line feature;

[0189] In the case that there is no picture row in each of the text rows, it is determined that the picture row detection result is that the to-be-identified area does not have the picture row feature.

[0190] In practical applications, each text line can be simultaneously subjected to image line detection to determine whether each text line is an image line. If an image line exists in each text line, the image line detection result is determined to be that the area to be identified has image line features. If an image line does not exist in each text line, the image line detection result is determined to be that the area to be identified does not have image line features. In this way, the efficiency and accuracy of determining the image line detection result can be improved.

[0191] Exemplarily, if there is any line in all given lines (all text lines in the area to be identified) that has text content but no text type elements, then there may be a picture as the text content of the current line, that is, the picture line detection result hasFigureLine (picture line feature) = True (has picture line feature), otherwise the picture line detection result is False (does not have picture line feature).

[0192] In addition, image line detection can be performed on each text line in a certain order. When the current text line is detected as an image line, the image line detection result can be determined as the area to be identified having image line features. In this way, image line detection can be avoided for all text lines, which reduces the amount of data processing to a certain extent and improves the efficiency of determining the image line detection result.

[0193] Optionally, the text line type detection includes writing direction detection, line intersection detection, font style detection and line spacing detection, the text line type features include writing direction features, line intersection features, font style features and line spacing features, and the text line type detection result includes writing direction detection results, line intersection detection results, font style detection results and line spacing detection results; accordingly, performing text line type detection on each of the text lines to obtain the text line type detection result of whether the area to be identified has the text line type features includes:

[0194] Performing writing direction detection on each of the text lines to obtain the writing direction detection result of whether the area to be identified has the writing direction feature;

[0195] Performing a line intersection detection on each of the text lines to obtain the line intersection detection result of whether the area to be identified has the line intersection feature;

[0196] Performing font style detection on each of the text lines to obtain the font style detection result of whether the area to be identified has the font style feature;

[0197] Perform line spacing detection on each of the text lines to obtain the line spacing detection result of whether the area to be identified has the line spacing feature.

[0198] Specifically, the line intersection refers to the overlapping part of the projection of two adjacent text lines in the line direction. The line spacing refers to the distance between two adjacent text lines. The writing direction feature, that is, the writing mode is consistent (writingModeConsistent), which indicates that the writing directions corresponding to the text lines in the area to be identified are the same. The writing direction detection result refers to the result of writing direction detection on each text line, that is, the result of whether the area to be identified has the writing direction feature. The line intersection feature, that is, the intersection block feature (IntersectInBlockDir), indicates that there is a line intersection between the text lines in the area to be identified. The line intersection detection result refers to the result of line intersection detection on each text line, that is, the result of whether the area to be identified has the line intersection feature. The font style feature, that is, font style consistency (isFontStyleConsistent), indicates that the font styles corresponding to the area to be identified are consistent. The font style detection result refers to the result of font style detection on each text line, that is, the result of whether the area to be identified has the font style feature. The line spacing feature, that is, line spacing consistency (LineSpacingConsistent), indicates that the line spacing corresponding to the area to be identified is relatively consistent. The line spacing detection result refers to the result of line spacing detection for each text line, that is, the result of whether the area to be identified has a line spacing feature.

[0199] In practical applications, for each text line, a line identifier can be used to detect the writing direction of the text line, that is, to identify the writing direction of the text line; then, according to the sub-writing direction detection results corresponding to each text line, determine whether the area to be identified has the writing direction feature, that is, the writing direction detection result. Line intersection detection is performed for each two adjacent text lines, and then, according to the sub-line intersection detection results corresponding to each text line, the line intersection detection result of whether the area to be identified has the line intersection feature is determined. Font style detection is performed for each two adjacent text lines, and then, according to the sub-font style detection results corresponding to each text line, the font style detection result of whether the area to be identified has the font style feature is determined. Line spacing detection is performed for each two adjacent text lines, and then, according to the sub-line spacing detection results corresponding to each text line, the line spacing detection result of whether the area to be identified has the line spacing feature is determined. In this way, the text line type detection result is determined more finely from the four dimensions of writing direction feature, line intersection feature, font style feature and line spacing feature, thereby improving the accuracy and reliability of the text line type detection result.

[0200] Optionally, the writing direction detection is performed on each of the text lines to obtain the writing direction detection result of whether the area to be identified has the writing direction feature. The specific implementation process may be as follows:

[0201] Performing writing direction detection on each of the text lines to determine the writing direction of each of the text lines;

[0202] In the case where all the writing directions are the same, determining the writing direction detection result as that the area to be identified has the writing direction feature;

[0203] In the case that different writing directions exist among the writing directions, it is determined that the writing direction detection result is that the area to be identified does not have a writing direction feature.

[0204] In practical applications, the existing or future achievable writing direction detection method can be used to simultaneously detect the writing direction of each text line, thereby determining the writing direction of each text line. It is determined whether the writing directions of each text line are the same; if so, the writing direction detection result is determined to be that the area to be identified has writing direction characteristics; if not, the writing direction detection result is determined to be that the area to be identified does not have writing direction characteristics. In this way, the efficiency and accuracy of determining the writing direction detection result can be improved.

[0205] Exemplarily, according to a method for quickly identifying the writing direction of text content in a PDF, the writing direction of each line in all text lines in the area to be identified is determined. If the writing direction of each line in all given lines (all text lines in the area to be identified) is the same, then the writing direction detection result writingModeConsistent (writing direction feature) = True (having the writing direction feature), otherwise the writing direction detection result is False (not having the writing direction feature).

[0206] In addition, the writing direction of each text line can be detected in a certain order. When the writing direction of the current text line is detected to be different from the writing direction that has been detected, it can be determined that the area with the writing direction feature is not the area with the writing direction feature. In this way, it is possible to avoid writing direction detection for all text lines, reduce the amount of data processing to a certain extent, and improve the efficiency of determining the area with the writing direction feature.

[0207] Optionally, the performing of line intersection detection on each of the text lines to obtain the line intersection detection result of whether the to-be-identified area has the line intersection feature may be specifically implemented as follows:

[0208] Performing line intersection detection on each text line pair to determine whether projections of the text lines in each text line pair in the line direction have an intersection, wherein the text line pair is two connected text lines in each text line;

[0209] If not, it is determined that the row intersection detection result is that the to-be-identified area does not have the row intersection feature.

[0210] Specifically, the row direction refers to the arrangement direction of the text line, which is perpendicular to the writing direction of the text line. For example, if the writing direction is from left to right, that is, horizontally, the row direction is vertically.

[0211] In practical applications, for each text line pair, the two text lines in the text line pair are projected in the line direction. If there is no corresponding intersection for each text line pair, the line intersection detection result is determined to be that the area to be identified does not have a line intersection feature. In this way, the efficiency and accuracy of determining the line intersection detection result can be improved.

[0212] Optionally, the font style detection is performed on each of the text lines to obtain the font style detection result of whether the area to be identified has the font style feature. The specific implementation process may be as follows:

[0213] Performing font style detection on each of the text line pairs to determine whether each of the text line pairs meets a font style feature condition, wherein the font style feature condition is that the font thickness ranges between the text lines in the text line pairs overlap, and the italic attributes between the text lines are the same;

[0214] If so, determining that the font style detection result is that the area to be identified has the font style feature;

[0215] If not, it is determined that the font style detection result shows that the to-be-identified area does not have the font style feature.

[0216] Specifically, the row direction refers to the arrangement direction of the text line, which is perpendicular to the writing direction of the text line. If the writing direction is from left to right, that is, horizontal, the row direction is vertical. The italic attribute includes italic and non-italic.

[0217] In practical applications, for each text line pair, the fonts of each text line in the text line pair are identified, and the font thickness range and italic attribute corresponding to each text line in the text line pair are obtained accordingly. Then, it is determined whether each text line pair meets the font style feature conditions, that is, it is determined whether there is an intersection in the font thickness range corresponding to each text line in each text line pair, and whether the italic attributes corresponding to each text line in each text line pair are the same. If so, it is determined that the font style detection result is that the area to be identified has the font style feature. If not, it is determined that the font style detection result is that the area to be identified does not have the font style feature. In this way, the efficiency and accuracy of determining the font style detection result can be improved.

[0218] There are many ways to identify the font of each text line in the text line pair. For each text line, the fonts of the text contents in the text line can be counted, and the font with the largest number can be determined as the font of the text line, and the font thickness range and italic attributes corresponding to the font with the largest number can be determined as the font thickness range and italic attributes corresponding to the text line; it can also be other ways, which are not limited to the present invention.

[0219] Preferably, in order to reduce the amount of data processing, font style detection is performed on each of the text line pairs to determine whether there is an intersection in the font thickness ranges between the text lines in each of the text line pairs, and whether the italic attributes between the text lines are the same, including: font style detection is performed on the first text object pair in each of the text lines to obtain the font thickness range and italic attribute between the text lines in each of the text line pairs. The font of the first text object in the text line is used to represent the font of this line. Because multiple text objects may be written in a text line, different text objects have different fonts.

[0220] Exemplarily, if within all given lines (all text lines in the area to be identified), there are any two consecutive lines, and there is no intersection between the Font and Font Weight given in the first TextObject in the line (the font thickness range is a range. For example, the previous line is given [400, 600], and the next line is given [500, 800], then the intersection is [500, 600]) or the Italic (both are italic or neither is italic) attributes are not equal, then the font style detection result isFontStyleConsistent (font style feature) = False (does not have font style features), otherwise the font style detection result is True (has font style features).

[0221] Optionally, the line spacing detection is performed on each of the text lines to obtain the line spacing detection result of whether the area to be identified has the line spacing feature. The specific implementation process may be as follows:

[0222] Performing line spacing detection on each of the text line pairs to determine the line spacing between the text lines in each of the text line pairs;

[0223] According to each of the line distances, it is determined whether the area to be identified has the line distance detection result of the line distance feature.

[0224] In practical applications, the line spacing between the two text lines in each text line pair can be detected to determine the line spacing between the two text lines in each text line pair. Then, based on each line spacing, the line spacing detection result is determined, that is, whether the area to be identified has a line spacing feature. In this way, the accuracy of determining the line spacing detection result can be improved.

[0225] In an optional embodiment of the present invention, the line spacing detection result of determining whether the area to be identified has the line spacing feature according to each line spacing includes: judging whether each line spacing is less than a set line spacing, if so, determining that the line spacing detection result is that the area to be identified has the line spacing feature; if not, determining that the line spacing detection result is that the area to be identified does not have the line spacing feature. In this way, by setting the line spacing to determine the line spacing detection result, the process of determining the line spacing detection result can be simplified, and the efficiency of determining the line spacing detection result can be improved.

[0226] In another optional embodiment of the present invention, the line spacing detection result of determining whether the to-be-identified area has the line spacing feature according to each line spacing may be specifically implemented as follows:

[0227] Determine an average line spacing of each of the line spacings, and calculate a second average font size of all text objects in each of the text lines;

[0228] Determine whether all the line spacings are target line spacings, the target line spacing is less than or equal to a first set multiple of the second average font size, and the absolute difference between the target line spacing and the average line spacing is less than or equal to a second set multiple of the second average font size, and the first set multiple is greater than the second set multiple;

[0229] If so, determining that the line spacing detection result is that the area to be identified has the line spacing feature;

[0230] If not, it is determined that the line spacing detection result is that the area to be identified does not have the line spacing feature.

[0231] In practical applications, the average line spacing is obtained by adding up the line spacing and dividing it by the number of line spacings. The font sizes of all text objects in the area to be identified are counted and the average is calculated, which is the second average font size. Then, it is determined whether each line spacing is the target line spacing, that is, whether each line spacing is less than or equal to the product of the second average font size and the first set multiple, and the absolute difference with the average line spacing is less than or equal to the product of the second average font size and the second set multiple. If so, it is determined that the line spacing detection result is that the area to be identified has line spacing characteristics; if not, it is determined that the line spacing detection result is that the area to be identified does not have line spacing characteristics. In this way, the accuracy and credibility of the line spacing detection results can be improved.

[0232] Exemplarily, the distance between every two consecutive lines in all given lines (all text lines in the area to be identified) is counted, and the average line spacing is obtained. The average font size (second average font size) of all text objects in all given lines is counted. If the line spacing (line spacing) between any two consecutive lines is greater than 1.3 times the average font size (first set multiple), or the absolute difference between the average line spacing and the average font size is greater than 0.2 times the average font (second set multiple), then the line spacing detection result isLineSpacingConsistent (line spacing feature) = False (no line spacing feature), otherwise the line spacing detection result is True (with line spacing feature).

[0233] It should be noted that if the projections of the text lines in each text line pair in the line direction have corresponding intersections, it is necessary to further determine the line intersection features, that is, after performing line intersection detection on each text line pair and determining whether the projections of the text lines in each text line pair in the line direction have intersections, the method further includes:

[0234] If so, determine whether there is a target intersection in each of the intersections, the length of the target intersection is greater than or equal to a third set multiple of the projection length of the target text line, and the target text line is any text line corresponding to the target intersection;

[0235] If so, determining the row intersection detection result is that the to-be-identified area has the row intersection feature;

[0236] If not, it is determined that the row intersection detection result is that the to-be-identified area does not have the row intersection feature.

[0237] In practical applications, if the projections of the text lines in each text line pair in the row direction intersect, it is necessary to determine whether there is a target intersection in each intersection whose length is greater than or equal to the third set multiple of the projection length of the target text line, where the target text line is any text line corresponding to the target intersection. If it exists, the row intersection detection result is determined to be that the area to be identified has a row intersection feature; if it does not exist, the row intersection detection result is determined to be that the area to be identified does not have a row intersection feature. In this way, by doubly determining the row intersection detection result based on whether there is an intersection and whether there is a target intersection, the credibility and accuracy of the row intersection detection result can be improved.

[0238] Exemplarily, if within all given rows (all text rows in the area to be identified), there are any two consecutive rows (i.e., the two rows are in a vertical / horizontal layout relationship, or a left / right / vertical layout relationship) or their corresponding circumscribed rectangles (BBoxes), and the projections of the rows in the row direction (usually LrTb, then its projection axis is the Y axis) have an intersection, and the length of the intersecting interval is greater than or equal to 0.7 (the third set multiple) of the projection length of any one of the two rows in the row direction, then the row intersection detection result hasIntersectInBlockDir (row intersection feature) = True (has row intersection feature), otherwise the row intersection detection result is False (does not have row intersection feature).

[0239] In one or more optional embodiments of the present invention, determining whether the to-be-recognized area in the target document is a directory according to the first recognition result, the second recognition result, and the detection result includes:

[0240] Compare the first recognition result, the second recognition result and the detection result with set directory recognition conditions respectively;

[0241] When the comparison result is that both are consistent, it is determined that the area to be identified in the target document is a directory.

[0242] In actual applications, the first recognition result, the second recognition result, and the detection result are respectively compared with the set directory recognition conditions. The first recognition result can be compared with the set directory recognition conditions, the second recognition result can be compared with the set directory recognition conditions, and the detection result can be compared with the set directory recognition conditions to obtain three comparison results. It is judged whether each comparison result is in compliance. If so, it is determined that the area to be recognized in the target document is a directory; if not, it is determined that the area to be recognized in the target document is not a directory. The first recognition result, the second recognition result, and the detection result can be constructed into a matrix to judge whether the matrix meets the set directory recognition conditions. If so, it is determined that the area to be recognized in the target document is a directory; if not, it is determined that the area to be recognized in the target document is not a directory. In this way, by setting the directory recognition conditions, it is possible to quickly and accurately determine whether the area to be recognized is a directory.

[0243] For example, assume that the Nth line is currently recognized. Then, a two-dimensional matrix matrix[m][n] can be constructed, and each element in it is initialized to False, where matrix[m][n] indicates whether all lines from the mth line to the nth line can form a table of contents, with 1 ≤ m < n ≤ N. According to the first recognition result, the second recognition result, and the detection result, each element in matrix[m][n] is updated. If all elements of matrix[m][n] meet the set table of contents recognition conditions, then matrix[m][n] = True, that is, the to-be-recognized area in the target document is the table of contents.

[0244] It should be noted that when determining whether all elements of matrix[m][n] meet the set table of contents recognition conditions, it can be determined one by one. If any one element does not meet the conditions, there is no need to determine the remaining elements. At this time, it can be determined that the to-be-recognized area in the target document is not the table of contents, that is, matrix[m][n] = False.

[0245] Preferably, the set table of contents recognition conditions include: hasContentEmptyLine (empty line feature) = False (does not have the empty line feature), writingModeConsistent (writing direction feature) = True (has the writing direction feature), hasFigureLine (picture line feature) = False (does not have the picture line feature), hasIntersectInBlockDir (line intersection feature) = False (does not have the line intersection feature), isFontStyleConsistent (font style feature) = True (has the font style feature), isLineSpacingConsistent (line spacing feature) = True (has the line spacing feature), isColorConsistent (color alignment feature) = True (has the color alignment feature), hasMoreThanOneGap (gap interval feature) = False (does not have the gap interval feature), isTOC (table of contents style feature) = True (has the table of contents style feature), and isAligned (text line alignment feature) = True (has the text line alignment feature).

[0246] Optionally, after comparing the first recognition result, the second recognition result, and the detection result with the set table of contents recognition conditions respectively, it further includes:

[0247] In the case where the comparison result shows non-compliance, it is determined that the to-be-recognized area in the target document is not the table of contents, and the number of text lines included in the to-be-recognized area is obtained;

[0248] comparing the alignment feature, the directory association feature and the continuity feature with set directory recognition conditions respectively;

[0249] When the number of rows is not the first preset value, subtract the first preset value from the number of rows to obtain an updated number of rows;

[0250] Determine each target sub-region in the to-be-recognized region, wherein the target sub-region contains the updated number of connected text lines;

[0251] The target sub-regions are respectively used as updated regions to be identified, and the step of identifying the color range of the text object in each text line and the circumscribed rectangle of each text line is continued.

[0252] Specifically, the first preset value and the second preset value are both pre-set values, which are used to adjust the accuracy of identifying a directory, or to identify a directory of a set length. The first preset value and the second preset value may be the same or different. Preferably, in order to improve the accuracy, the first preset value and the second preset value are both one.

[0253] In practical applications, the determination order should be in the order of the number of lines from long to short, that is, first determine the interval with the longest number of lines (the area to be recognized), and then determine the sub-interval (each target sub-area in the area to be recognized) based on the result. In this way, it is possible to avoid splitting a directory that occupies multiple text lines into multiple directories, thereby improving the accuracy and completeness of the recognized directory.

[0254] Optionally, the target sub-regions are respectively used as updated regions to be identified, and the step of identifying the color range of the text objects in each text line and the bounding rectangle of each text line is continued. The specific implementation process may be as follows:

[0255] The first target sub-regions are respectively used as updated regions to be identified, and the step of identifying the color range of the text objects in each of the text lines and the circumscribed rectangle of each of the text lines is continued, wherein the first target sub-region is any target sub-region;

[0256] If the first target sub-region is a directory, it is determined that the second target sub-region is not a directory, wherein a combination of the second target sub-region and the first target sub-region is any designated area to be identified before updating, and the designated area to be identified is not a directory.

[0257] In practical applications, each target sub-region can be used as an updated area to be identified, and directory identification can be continued for each area to be identified. If the first target sub-region is a directory, it can be directly determined that the second target sub-region is not a directory. In this way, directory identification can be performed on the second target sub-region, which greatly reduces the amount of data processing and improves the efficiency of directory identification while ensuring the accuracy of directory identification.

[0258] Continuing with the above example, if matrix[i][j] = True, and (i,j) contains (k,l), then there is no need to determine matrix[k][l]. For example, assuming there are 10 rows in total, then matrix[1]

[10] should be determined first. Next, matrix[1][9] and matrix[2]

[10] , which have 9 rows, should be determined. Then matrix[1][8], matrix[2][8], and matrix[3]

[10] should be determined, and so on. If matrix[1][9] is False and matrix[1][8] is True, since the union of matrix[2][9] and matrix[1][8] is matrix[1][9], there is no need to judge matrix[2][9] based on the above process, and matrix[2][9] can be directly determined to be False. Similarly, if the union of matrix[1][8] and matrix[3]

[10] is matrix[1]

[10] , there is no need to judge matrix[3]

[10] based on the above process, and matrix[2][9] can be directly determined to be False. That is, when matrix[1][9] is False and matrix[1][8] is True, since both matrix[2][9] and matrix[3]

[10] have an intersection with matrix[1][9], there is no need to judge either of them, and only the result of matrix[9]

[10] needs to be judged. That is, if matrix[1][9] is False and matrix[1][8] is True, matrix[2][9] must be False, because if both are True, then matrix[1][9] should be True, which is a contradiction. Therefore, the present invention does not need to worry about missing the optimal result and can accurately identify each directory.

[0259] Exemplarily, a method for identifying a directory in a document is as follows:

[0260] 1. Precondition: Line Identifier. If it is a layout document, it needs to be determined based on the position of the TextObject in the document. If it is a flow document, no special identification is required.

[0261] The basic determination method is as follows, where (1)-(10) are independent of each other. It should be noted that the following solution for the average value in each line is based on a single Glyph. For example, there may be two TextObjects in a line. The first TextObject has 3 words and a font size of 10, and the second TextObject has 2 words and a font size of 20. Then the average font size is (3*10+2*20) / (3+2)=14.

[0262] (1) If there is no text content in any of the given lines (all text lines in the area to be identified), the empty line detection result hasContentEmptyLine (empty line feature) = True (has empty line feature), otherwise it is False (does not have empty line feature).

[0263] (2) According to a method for quickly identifying the writing direction of text content in PDF, the writing direction of each line in all text lines in the area to be identified is determined. If the writing direction of each line in all given lines (all text lines in the area to be identified) is the same, then the writing direction detection result writingModeConsistent (writing direction feature) = True (having the writing direction feature), otherwise it is False (not having the writing direction feature).

[0264] (3) If there is any line in all the given lines (all the text lines in the area to be identified) that has text content but no text type element, then there may be a picture as the text content of the current line, that is, the picture line detection result hasFigureLine (picture line feature) = True (has picture line feature), otherwise it is False (does not have picture line feature).

[0265] (4) If, within all given lines (all text lines in the area to be identified), there exist any two consecutive lines (text line pairs) or their corresponding bounding rectangles (BBoxes), the projections of the lines in the row direction have an intersection, and the length of the intersecting interval is greater than or equal to 0.7 times (the third set multiple) of the projection length of any of the two lines in the row direction, then the row intersection detection result hasIntersectInBlockDir (row intersection feature) = True (having row intersection feature), otherwise it is False (not having row intersection feature).

[0266] (5) If there are any two consecutive lines in all given lines (all text lines in the area to be identified), there is no intersection between the Font Weights given in the first TextObject in the line, or the Italic attributes are not equal, then the font style detection result isFontStyleConsistent (font style feature) = False (does not have font style features), otherwise it is True (has font style features).

[0267] (6) Count the distance between every two consecutive lines in all given lines (all text lines in the area to be identified) and obtain the average line spacing. Count the average font size (second average font size) of all text objects in all given lines. If the line spacing (line spacing) between any two consecutive lines is greater than 1.3 times the average font size (first set multiple), or the absolute difference between the line spacing and the average line spacing is greater than 0.2 times the average font size (second set multiple), then the line spacing detection result isLineSpacingConsistent (line spacing feature) = False (no line spacing feature), otherwise it is True (with line spacing feature).

[0268] (7) Count the value ranges of the four ARGB channels of all TextObjects in each given row (all text rows in the area to be identified), and count the value ranges of R, G, B, and A in this row respectively, to obtain the transparency color range, red color range, green color range, and blue color range. If there are any two consecutive rows (previous and next rows or up and down rows) where the color range values ​​of any channel (color) do not intersect (do not overlap), then the color alignment recognition result isColorConsistent (color alignment feature) = False (does not have color alignment feature), otherwise it is True (has color alignment feature).

[0269] (8) Count the average font size of each given line (all text lines in the area to be identified). If there is any line with at least two target gaps (the target gap is calculated as: the distance between text objects is greater than 4 times the average font size), the gap recognition result hasMoreThanOneGap (gap feature) = True (has gap feature), otherwise it is False (does not have gap feature).

[0270] (9) Calculate the catalog-style features of each line among all the given lines (all text lines in the area to be recognized). If the last character at the end of a line is a number, it is considered that there is a page number at the end of the current line. If there are consecutive, identical characters (catalog delimiters) in a line that exist in the catalog delimiter set, and the number of catalog delimiters is greater than the threshold of 8 (quantity threshold), or when traversing backward (in the opposite direction of the writing direction) from the page number at the end of the line (the text object at the end of the line) to the first character not in the catalog delimiter set (the specified text object), there is a significant gap, that is, the gap between the text object at the end of the line and the specified text object is greater than the second set spacing, then it is considered that there is a catalog connector in the current line, that is, it conforms to the catalog connection type. If there is any line without a page number at the end of the line (the text type at the end of the line is not a numeric type) or without a catalog connector (the text type is not of the catalog connection type), then the catalog style recognition result isTOC (catalog style feature) = False (does not have the catalog style feature), otherwise it is True (has the catalog style feature).

[0271] (10) Taking the writing direction from left to right as an example, if for each line among all the given lines (all text lines in the area to be recognized), the left coordinate (the first coordinate) of the circumscribed rectangle of each line does not exceed the average line height compared with the average value of the first coordinates, and the right coordinate (the second coordinate) of the circumscribed rectangle of each line does not exceed the average line height compared with the average value of the second coordinates, then the text line alignment recognition result isAligned (text line alignment feature) = True (has the text line alignment feature), otherwise it is False (does not have the text line alignment feature).

[0272] 2. According to the line recognizer, obtain all the line information in the current document page, that is, the respective features corresponding to the above (1)-(10). Assume that a total of N lines are recognized currently, then a two-dimensional matrix matrix[m][n] can be constructed, and each element in it is initialized to False, where matrix[m][n] represents whether all the lines from the m-th line to the n-th line can form a catalog, 1 ≤ m < n ≤ N. Update each element in matrix[m][n] according to the blank line detection result, writing direction detection result, picture line detection result, line intersection detection result, font style detection result, line spacing detection result, color alignment recognition result, gap interval recognition result, catalog style recognition result, and text line alignment recognition result. If all the elements of matrix[m][n] meet the set catalog recognition conditions, then matrix[m][n] = True, that is, the area to be recognized in the target document is a catalog, that is, then if all the lines from the m-th line to the n-th line meet the following set catalog recognition conditions, then matrix[m][n] = True.

[0273] The judgment order should be from the longest to the shortest number of rows, that is, the interval with the longest number of rows (the area to be identified) should be judged first. If matrix[i][j] = True, and (i,j) contains (k,l), then matrix[k][l] does not need to be judged. For example, assuming there are 10 rows in total, then matrix[1]

[10] should be judged first. Next, matrix[1][9] and matrix[2]

[10] with 9 rows should be judged. Then matrix[1][8], matrix[2][8] and matrix[3]

[10] should be judged, and so on. If matrix[1][9] is False and matrix[1][8] is True, since matrix[2][9] and matrix[3]

[10] both have intersections with matrix[1][9], they do not need to be judged, and only the result of matrix[9]

[10] needs to be judged. That is, if matrix[1][9] is False and matrix[1][8] is True, matrix[2][9] must be False, because if both are True, then matrix[1][9] should be True. Therefore, the present invention does not need to worry about missing the optimal result and can accurately identify each directory.

[0274] Setting directory recognition conditions includes: hasContentEmptyLine (empty line feature) = False (does not have empty line feature), writingModeConsistent (writing direction feature) = True (has writing direction feature), hasFigureLine (picture line feature) = False (does not have picture line feature), hasIntersectInBlockDir (line intersection feature) = False (does not have line intersection feature), isFontStyleConsistent (font style feature) = True (has font style feature), isLineSpacingConsistent (line spacing feature) = True (has line spacing feature), isColorConsistent (color alignment feature) = True (has color alignment feature), hasMoreThanOneGap (gap spacing feature) = False (does not have gap spacing feature), isTOC (table of contents style feature) = True (has table of contents style feature) and isAligned (text line alignment feature) = True (has text line alignment feature).

[0275] 3. Get the specific row number and area of ​​the directory based on the result of the matrix.

[0276] (10) First, obtain the number of rows that are True in the long interval segment, and obtain the intervals corresponding to several directories (areas to be identified);

[0277] (11) Then obtain the area (area to be identified) that does not intersect with the above interval but has a matrix result of True, and obtain several directories;

[0278] (12) Repeat the above operations (10) and (11) until all rows are traversed, and each directory interval (area to be identified) is labeled with a corresponding label to obtain the final recognition result.

[0279] See also Figure 2 , Figure 2 It is a schematic diagram of the effect of the method for identifying directories in a document provided by the present invention: through the method for identifying directories in a document provided by the present invention, not only two unconnected directories, such as directory 1 and directory 2, can be identified, but also two connected directories, such as directory 3 and directory 4, can be identified, thereby avoiding identifying two connected directories as one directory, thereby improving the accuracy of directory identification.

[0280] The method for identifying directories in a document provided by the present invention determines each text line interval that may be a directory, that is, whether any m to n lines are a directory, based on the features between text lines. A reasonable merging operation is performed on the text line interval that may be a directory. For example, if lines 1-3 are identified as directories and lines 1-5 are directories, then lines 1-5 should be merged with lines 1-3. If lines 1-3 and 4-5 are directories, but lines 1-5 are not directories, they are not merged. All directories in a document can be accurately identified, and the specific number of lines corresponding to each directory can be identified. It is convenient to implement special processing (code highlighting, no re-arrangement of codes in layout documents, etc.) in subsequent document display, and it is also convenient to perform automatic indentation functions when editing documents, such as the reader can highlight key elements for the directory area; the directory can be treated as a whole in the PDF re-arranged version; it can be converted into a text style suitable for reading and editing in HTML-based documents such as Docx. In addition, the method for identifying directories in a document provided by the present invention is applicable to layout documents (such as PDF) and streaming documents.

[0281] In addition, the present invention can accurately identify all directory areas in the document and identify the specific number of lines corresponding to each directory area. It only needs to parse the current page, and does not require the entire directory structure. It supports the identification of directories of non-standard protocols and supports the identification of directory variants. It is convenient for the reader to operate when displaying the document, convenient for the automatic generation of outlines for streaming documents, and convenient for improving the effect when converting or rearranging layout documents.

[0282] The following is a description of the device for identifying a directory in a document provided by the present invention. The device for identifying a directory in a document described below and the method for identifying a directory in a document described above can be referred to each other.

[0283] Figure 3 is a schematic diagram of the structure of the device for identifying directories in a document provided by the present invention, such as Figure 3 As shown, the device 300 for identifying a directory in a document includes: a first determination module 301, a first identification module 302, a second identification module 303, a detection module 304 and a second determination module 305, wherein:

[0284] A first determination module 301 is configured to determine a region to be identified in a target document, wherein the region to be identified includes at least one connected text line;

[0285] A first recognition module 302 is configured to recognize the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines, and determine whether the area to be recognized has a first recognition result of an alignment feature;

[0286] The second recognition module 303 is configured to recognize the space interval and arrangement style of the text objects in each of the text lines, and determine whether the area to be recognized has a second recognition result of a catalog-related feature;

[0287] The detection module 304 is configured to perform text line association detection on each of the text lines to obtain a detection result of whether the to-be-identified area has a continuity feature, wherein the continuity feature represents the feature continuity between the text lines;

[0288] The second determination module 305 is configured to determine whether the to-be-recognized area in the target document is a directory according to the first recognition result, the second recognition result and the detection result.

[0289] The device for identifying a directory in a document provided by the present invention determines an area to be identified in a target document, wherein the area to be identified includes at least one connected text line; identifies the color range of text objects in each of the text lines and the circumscribed rectangle of each of the text lines, and determines a first recognition result of whether the area to be identified has an alignment feature; identifies the space intervals and arrangement styles of text objects in each of the text lines, and determines a second recognition result of whether the area to be identified has a directory association feature; performs text line association detection on each of the text lines, and obtains a detection result of whether the area to be identified has a continuity feature, wherein the continuity feature represents feature continuity between the text lines; and determines whether the area to be identified in the target document is a directory based on the first recognition result, the second recognition result, and the detection result. It can accurately identify all directory areas in the document and the specific number of lines corresponding to each directory area, with finer positioning granularity to achieve row-level directory recognition. It only needs to parse the current page and does not require the entire directory structure, that is, it supports single-page processing and is independent of the entire document. If multiple directories appear on a single page, they can be separated. The recognition process does not rely on the directory format in the standard protocol, supports the recognition of directories of non-standard protocols, and supports the recognition of directory variants. It is convenient for the reader to operate when displaying the document, facilitates the automatic generation of outlines for streaming documents, and facilitates the conversion or rearrangement of layout documents to improve the effect.

[0290] Optionally, the alignment feature includes a color alignment feature and a text line alignment feature, and the first recognition result includes a color alignment recognition result and a text line alignment recognition result;

[0291] Correspondingly, the first recognition module 302 is further configured to, for each of the text lines, identify the colors corresponding to each text object in the text line under the target color mode, and obtain the color range corresponding to each text object in the text line; determine, based on the color range, whether the area to be recognized has the color alignment feature of the color alignment recognition result; for each of the text lines, identify the boundary coordinates of the circumscribed rectangle of the text line; and determine, based on the boundary coordinates, whether the area to be recognized has the text line alignment feature of the text line alignment recognition result.

[0292] Optionally, the first recognition module 302 is further configured to determine whether each text line pair is a target text line pair, wherein the text line pair is two connected text lines in each of the text lines, and the color ranges corresponding to the two text lines in the target text line pair overlap; if so, determine that the color alignment recognition result is that the area to be recognized has the color alignment feature; if not, determine that the color alignment recognition result is that the area to be recognized does not have the color alignment feature.

[0293] Optionally, the boundary coordinates include a first coordinate corresponding to the front end and a second coordinate corresponding to the rear end of the circumscribed rectangle in the writing direction;

[0294] Accordingly, the device further comprises an acquisition module configured to acquire the line height of each of the text lines, and determine a reference line height according to each of the line heights;

[0295] Correspondingly, the first recognition module 302 is further configured to calculate the first coordinate average value based on each of the first coordinates, and to calculate the second coordinate average value based on each of the second coordinates; to determine whether the first difference between each of the first coordinates and the first coordinate average value, and the second difference between each of the second coordinates and the second coordinate average value are both less than or equal to the reference line height; if so, to determine that the text line alignment recognition result is that the area to be recognized has the text line alignment feature; if not, to determine that the text line alignment recognition result is that the area to be recognized does not have the text line alignment feature.

[0296] Optionally, the directory association feature includes a space interval feature and a directory style feature, and the second recognition result includes a space interval recognition result and a directory style recognition result;

[0297] Correspondingly, the second recognition module 303 is further configured to, for each of the text lines, identify the gap intervals between the text objects in the text line; determine the gap interval recognition result of whether the area to be recognized has the gap interval feature according to the number of target gap intervals in each of the gap intervals, and the target space interval is a gap interval greater than a first set spacing; for each of the text lines, identify the arrangement style of the text line to determine the end text type and the mid-line text type of the text line; determine the directory style recognition result of whether the area to be recognized has the directory style feature according to the end text type and the mid-line text type.

[0298] Optionally, the device further comprises a statistical module configured to determine an average font size of each of the text lines, and use a specified multiple of the average font size as a first set spacing; for each text line, determine a gap spacing in the text line that is larger than the first set spacing as a target gap spacing, and count the number of the target gap spacing in the text line;

[0299] Correspondingly, the second recognition module 303 is further configured to determine whether the number of the target gap intervals in each of the text lines is less than the set number of intervals; if so, determine that the gap interval recognition result is that the area to be recognized does not have the gap interval feature; if not, determine that the gap interval recognition result is the gap interval feature that the area to be recognized does not have.

[0300] Optionally, the second recognition module 303 is further configured to determine whether each of the text lines meets the directory style recognition conditions, and the directory style recognition is that the end text type of the text line is a digital type, and the mid-line text type of the text line is a directory connection type; if so, determine that the directory style recognition result is that the area to be recognized has the directory style characteristics; if not, determine that the directory style recognition result is that the area to be recognized does not have the directory style characteristics.

[0301] Optionally, the directory connection type is that the consecutive number of directory separators is greater than a quantity threshold, or the gap interval between the end text object and the specified text object in the text line is greater than a second set spacing, and the specified text object is a non-directory separator text object above the end text object in the text line.

[0302] Optionally, the text line association detection includes content type detection and text line type detection, the continuity feature includes content type feature and text line type feature, and the content type detection result includes blank line detection result and picture line detection result;

[0303] Accordingly, the detection module 304 includes a content type detection module and a text line type detection module;

[0304] The content type detection module is configured to perform content type detection on each of the text lines to obtain the content type detection result of whether the area to be identified has the content type feature;

[0305] The text line type detection module is configured to perform text line type detection on each of the text lines to obtain the text line type detection result of whether the area to be identified has the text line type feature.

[0306] Optionally, the second determination module 305 is further configured to compare the first recognition result, the second recognition result and the detection result with set directory recognition conditions respectively; when the comparison results are all in compliance, determine that the area to be recognized in the target document is a directory.

[0307] Optionally, the second determination module 305 is further configured to, when the comparison result is a mismatch, determine that the area to be identified in the target document is not a directory, and obtain the number of text lines contained in the area to be identified; compare the alignment feature, the directory association feature and the continuity feature with the set directory recognition conditions respectively; when the number of lines is not the first preset value, subtract the second preset value from the number of lines to obtain an updated number of lines; determine each target sub-area in the area to be identified, the target sub-area containing the updated number of connected text lines; use each target sub-area as an updated area to be identified, and continue to execute the step of identifying the color range of the text objects in each of the text lines and the circumscribed rectangle of each of the text lines.

[0308] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute a method for identifying a directory in a document, the method comprising: determining a region to be identified in a target document, the region to be identified comprising at least one connected text line; identifying the color range of the text objects in each of the text lines and the circumscribed rectangle of each of the text lines, and determining a first recognition result of whether the region to be identified has an alignment feature; identifying the gap interval and arrangement style of the text objects in each of the text lines, and determining a second recognition result of whether the region to be identified has a directory association feature; performing a text line association detection on each of the text lines, and obtaining a detection result of whether the region to be identified has a continuity feature, the continuity feature characterizing the continuity of features between the text lines; determining whether the region to be identified in the target document is a directory according to the first recognition result, the second recognition result and the detection result.

[0309] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0310] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the method for identifying a directory in a document provided by the above methods, the method including: determining an area to be identified in a target document, the area to be identified includes at least one connected text line; identifying the color range of text objects in each of the text lines and the circumscribed rectangle of each of the text lines, and determining a first recognition result of whether the area to be identified has an alignment feature; identifying the gap spacing and arrangement style of the text objects in each of the text lines, and determining a second recognition result of whether the area to be identified has a directory association feature; performing text line association detection on each of the text lines to obtain a detection result of whether the area to be identified has a continuity feature, the continuity feature characterizing the feature continuity between the text lines; determining whether the area to be identified in the target document is a directory based on the first recognition result, the second recognition result and the detection result.

[0311] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the method for identifying a directory in a document provided by the above-mentioned methods, the method comprising: determining an area to be identified in a target document, the area to be identified comprising at least one connected text line; identifying the color range of text objects in each of the text lines and the circumscribed rectangle of each of the text lines, and determining a first recognition result of whether the area to be identified has an alignment feature; identifying the space intervals and arrangement styles of text objects in each of the text lines, and determining a second recognition result of whether the area to be identified has a directory association feature; performing text line association detection on each of the text lines, and obtaining a detection result of whether the area to be identified has a continuity feature, the continuity feature characterizing the feature continuity between the text lines; and determining whether the area to be identified in the target document is a directory based on the first recognition result, the second recognition result and the detection result.

[0312] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0313] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0314] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for identifying a directory in a document, characterized in that: include: Determine a region to be identified in a target document, wherein the region to be identified includes at least one connected text line; Identify the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines to determine whether the area to be identified has a first identification result of an alignment feature; Identify the space interval and arrangement style of the text objects in each of the text lines to determine whether the area to be identified has a second identification result of a catalog-related feature; Performing text line association detection on each of the text lines to obtain a detection result of whether the to-be-identified area has a continuity feature, wherein the continuity feature represents feature continuity between the text lines; According to the first recognition result, the second recognition result and the detection result, it is determined whether the to-be-recognized area in the target document is a directory.

2. The method for identifying a directory in a document according to claim 1, characterized in that: The alignment feature includes a color alignment feature and a text line alignment feature, and the first recognition result includes a color alignment recognition result and a text line alignment recognition result; Accordingly, the step of identifying the color range of the text object in each of the text lines and the circumscribed rectangle of each of the text lines to determine whether the to-be-identified area has a first identification result of the alignment feature includes: For each of the text lines, identify the color corresponding to each text object in the text line under the target color mode, and obtain the color range corresponding to each text object in the text line; determine whether the area to be identified has the color alignment recognition result of the color alignment feature according to the color range; For each of the text lines, the boundary coordinates of the circumscribed rectangle of the text line are identified; and according to the boundary coordinates, it is determined whether the area to be identified has the text line alignment recognition result of the text line alignment feature.

3. The method for identifying a directory in a document according to claim 2, characterized in that: The color alignment recognition result of determining whether the to-be-recognized area has the color alignment feature according to the color range includes: Determining whether each text line pair is a target text line pair, wherein the text line pair is two connected text lines in each of the text lines, and the color ranges corresponding to the two text lines in the target text line pair overlap; If so, determining that the color alignment recognition result is that the area to be recognized has the color alignment feature; If not, it is determined that the color alignment recognition result is that the to-be-recognized area does not have the color alignment feature.

4. The method for identifying a directory in a document according to claim 2, characterized in that: The boundary coordinates include a first coordinate corresponding to the front end of the circumscribed rectangle in the writing direction and a second coordinate corresponding to the rear end; Accordingly, before determining the text line alignment recognition result of whether the to-be-recognized area has the text line alignment feature according to the boundary coordinates, the method further includes: Obtaining the line height of each of the text lines, and determining a reference line height according to each of the line heights; Correspondingly, the text line alignment recognition result of determining whether the to-be-recognized area has the text line alignment feature according to the boundary coordinates includes: Calculate a first coordinate average value according to each of the first coordinates, and calculate a second coordinate average value according to each of the second coordinates; Determine whether a first difference between each of the first coordinates and an average value of the first coordinates, and a second difference between each of the second coordinates and an average value of the second coordinates are both less than or equal to the reference row height; If so, determining that the text line alignment recognition result is that the area to be recognized has the text line alignment feature; If not, it is determined that the text line alignment recognition result is that the area to be recognized does not have the text line alignment feature.

5. The method for identifying a directory in a document according to claim 1, characterized in that: The directory association feature includes a space interval feature and a directory style feature, and the second recognition result includes a space interval recognition result and a directory style recognition result; Accordingly, the second recognition result of identifying the space interval and arrangement style of the text objects in each of the text lines to determine whether the area to be recognized has a directory-related feature includes: For each of the text lines, identifying the gap intervals between the text objects in the text line; determining the gap interval recognition result of whether the to-be-recognized area has the gap interval feature according to the number of target gap intervals in each of the gap intervals, wherein the target space interval is a gap interval greater than a first set spacing; For each of the text lines, the arrangement style of the text line is identified to determine the end text type and the mid-line text type of the text line; based on the end text type and the mid-line text type, determine whether the area to be identified has the directory style characteristics of the directory style recognition result.

6. The method for identifying a directory in a document according to claim 5, characterized in that: Before determining the gap interval recognition result of whether the to-be-recognized area has the gap interval feature according to the number of target gap intervals in each of the gap intervals, the method further includes: Determine an average font size of each of the text lines, and use a specified multiple of the average font size as a first set spacing; For each text line, determining a gap interval in the text line that is larger than a first set spacing as a target gap interval, and counting the number of the target gap intervals in the text line; Correspondingly, the interstitial interval recognition result of determining whether the to-be-recognized area has the interstitial interval feature according to the number of target interstitial intervals in each of the interstitial intervals includes: Determining whether the number of the target gap intervals in each of the text lines is less than the set number of intervals; If so, determining that the gap interval recognition result is that the to-be-recognized area does not have the gap interval feature; If not, it is determined that the gap interval recognition result is a gap interval feature that the to-be-recognized area does not have.

7. The method for identifying a directory in a document according to claim 5, characterized in that: The directory style recognition result of determining whether the to-be-recognized area has the directory style feature according to the end-of-line text type and the mid-line text type includes: Determine whether each of the text lines meets the directory style recognition condition, the directory style recognition is that the end text type of the text line is a numeric type, and the middle text type of the text line is a directory connection type; If so, determining that the catalog style recognition result is that the to-be-recognized area has the catalog style feature; If not, it is determined that the directory style recognition result is that the to-be-recognized area does not have the directory style feature.

8. The method for identifying a directory in a document according to claim 7, characterized in that: The directory connection type is that the continuous number of directory separators is greater than the number threshold, or the gap between the end text object and the specified text object in the text line is greater than the second set spacing, and the specified text object is a non-directory separator text object above the end text object in the text line.

9. The method for identifying a directory in a document according to claim 1, characterized in that: The text line association detection includes content type detection and text line type detection, the continuity feature includes content type feature and text line type feature, and the content type detection result includes blank line detection result and picture line detection result; Correspondingly, the performing text line association detection on each of the text lines to obtain a detection result of whether the to-be-recognized area has a continuity feature includes: Performing content type detection on each of the text lines to obtain the content type detection result of whether the area to be identified has the content type feature; A text line type detection is performed on each of the text lines to obtain the text line type detection result of whether the area to be identified has the text line type feature.

10. The method for identifying a directory in a document according to claim 1, characterized in that: The determining, according to the first recognition result, the second recognition result and the detection result, whether the to-be-recognized area in the target document is a directory includes: Compare the first recognition result, the second recognition result and the detection result with set directory recognition conditions respectively; When the comparison result is that both are consistent, it is determined that the area to be identified in the target document is a directory.

11. The method for identifying a directory in a document according to claim 10, characterized in that: After comparing the first recognition result, the second recognition result and the detection result with the set directory recognition condition respectively, the method further includes: If the comparison result shows that there is a mismatch, determining that the area to be identified in the target document is not a directory, and obtaining the number of text lines included in the area to be identified; comparing the alignment feature, the directory association feature and the continuity feature with set directory recognition conditions respectively; When the number of rows is not equal to the first preset value, subtract the second preset value from the number of rows to obtain an updated number of rows; Determine each target sub-region in the to-be-recognized region, wherein the target sub-region contains the updated number of connected text lines; The target sub-regions are respectively used as updated regions to be identified, and the step of identifying the color range of the text object in each text line and the circumscribed rectangle of each text line is continued.

12. A device for identifying a directory in a document, characterized in that: include: A first determination module is configured to determine a region to be identified in a target document, wherein the region to be identified includes at least one connected text line; A first recognition module is configured to recognize a color range of a text object in each of the text lines and a circumscribed rectangle of each of the text lines, and determine a first recognition result of whether the area to be recognized has an alignment feature; A second recognition module is configured to recognize the space interval and arrangement style of the text objects in each of the text lines, and determine whether the area to be recognized has a second recognition result of a catalog-related feature; A detection module is configured to perform text line association detection on each of the text lines to obtain a detection result of whether the to-be-identified area has a continuity feature, wherein the continuity feature represents the feature continuity between the text lines; The second determination module is configured to determine whether the to-be-recognized area in the target document is a directory according to the first recognition result, the second recognition result and the detection result.