Automatic identification method and system for correspondence-related regulations

Through OCR technology and image preprocessing combined with chapter recognition and tree structure, the problem of inefficient identification of correspondence and regulations in the existing technology is solved, and efficient and accurate identification and display of multiple file formats is achieved, which improves the user experience.

CN120388388BActive Publication Date: 2025-08-22NANJING ANXIA ELECTRONIC TECH CO LTD

Patent Information

Application Number
CN202510879287.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-08-22
Estimated Expiration
2045-06-27

AI Technical Summary

Technical Problem

The prior art is inefficient in the identification of correspondence between letters and regulations, and its accuracy is difficult to guarantee. Especially when dealing with diverse formats of legal and regulatory documents, it is impossible to accurately identify the structure and content information of the chapter catalog, resulting in difficulty in extracting and linking information.

Method used

OCR technology is used to combine image preprocessing, chapter recognition and tree structure assembly methods, including file upload, image preprocessing, text recognition, chapter directory structure recognition and content extraction. Characters are segmented through grayscale, noise removal, tilt correction, horizontal and vertical projection methods, and title lines and levels are determined using regular expressions and font features to form a tree structure to display legal information.

Benefits of technology

It realizes compatibility with multiple file formats, improves text recognition and the accuracy of the catalog structure, ensures the reasonable extraction and display of content information, and improves user experience and work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120388388B_ABST
    Figure CN120388388B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of document recognition technology, and discloses a method and system for automatically identifying regulations associated with letters. The method comprises the steps of file uploading, preprocessing, text recognition, chapter recognition, content extraction, tree structure building, and result display. In the image preprocessing, the present invention has accurate grayscale, flexible noise reduction, adaptive binarization, and efficient tilt correction, thereby improving image quality and ensuring the basis for text recognition. The text recognition process is innovative, and line segmentation and character segmentation are reliable and accurate. Character recognition combined with a standard character template library is intelligent and efficient, thereby improving accuracy. Table of contents recognition is judged in multiple dimensions through regular expressions, font features, and numbering structures, and the hierarchy is scientifically and verified, and the content extraction is reasonable. The tree structure is built based on the hierarchy, combined with refined node and content pairs, with clear levels. The modules of the system work together to achieve automated processing, providing users with convenient and intuitive display of regulatory information.
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 system for automatically recognizing regulations associated with correspondence. Background Art

[0002] Existing technologies for identifying the links between correspondence and regulations suffer from numerous deficiencies, resulting in low efficiency and difficulty ensuring accuracy. Traditional legal and regulatory document processing relies heavily on manual review and analysis. This requires staff to sift through mountains of paper or electronic documents, searching word for word for the relevant regulatory clauses. This approach is not only extremely inefficient but also prone to omissions of important information due to negligence. As the number of documents continues to grow, the difficulty of manual processing increases exponentially, making it difficult to meet the ever-increasing workload.

[0003] In terms of digital recognition technology, although OCR technology has been widely used, it still has significant flaws when processing legal and regulatory documents. On the one hand, legal and regulatory documents come from diverse sources and complex formats, including PDFs, images, and scanned copies. Existing OCR systems have poor compatibility with these diverse formats, and recognition errors or even failures to recognize them are common. On the other hand, even if text can be successfully recognized, ordinary OCR technology lacks the ability to effectively recognize and parse the complex chapter and directory structure within the document, making it impossible to accurately sort out the hierarchical relationships within the regulatory content, resulting in difficulties in subsequent information extraction and association.

[0004] When it comes to post-text recognition content analysis, existing technologies lack the intelligent processing capabilities tailored to the specific characteristics of legal and regulatory documents. They are unable to accurately identify the chapter structure within a document, nor can they accurately determine the chapter hierarchy based on key elements such as title prefixes, font characteristics, and numbering structure. This leads to chaotic and disorganized extraction and organization of regulatory content. Furthermore, during the content information extraction and association process, it is difficult to properly match the chapter table of contents with the corresponding text, preventing users from providing a clear and organized presentation of regulatory information. Summary of the Invention

[0005] The purpose of the present invention is to provide a method and system for automatically identifying regulations associated with correspondence, which solves the technical problems raised in the background technology.

[0006] The purpose of the present invention can be achieved through the following technical solutions:

[0007] A method for automatically identifying regulations associated with correspondence, comprising the following steps:

[0008] File upload: Receive legal and regulatory documents uploaded by users;

[0009] Preprocessing: image preprocessing of legal and regulatory documents;

[0010] Text recognition: Use OCR technology to identify text content in legal and regulatory documents;

[0011] Chapter identification: Identify the chapter structure in legal and regulatory documents based on pre-set chapter rules;

[0012] Content extraction: extract the corresponding content information according to the chapter directory structure;

[0013] Tree structure building: building the extracted chapter directory and content information into a tree structure;

[0014] Result display: Display the tree structure to the user.

[0015] As a further solution of the present invention: the legal and regulatory documents uploaded by the user are in any one of the formats of PDF, picture and scanned copy.

[0016] As a further solution of the present invention: the image preprocessing method is as follows:

[0017] Step Y1: Grayscale the image:

[0018] Convert color images to grayscale images;

[0019] Grayscale formula: H=0.299×R+0.587×G+0.114×B;

[0020] Among them, R, G, B are the red, green, and blue components of the pixel respectively, and H is the grayscale value;

[0021] Step Y2: noise removal:

[0022] Use median filtering or mean filtering to remove noise from grayscale images;

[0023] First, for each pixel, take the grayscale values ​​of all pixels in the 3×3 neighborhood around it;

[0024] For median filtering, the grayscale values ​​of all pixels are sorted in ascending order, and the median value is taken as the new value of the pixel;

[0025] For mean filtering, the average grayscale value of all pixels is calculated and used as the new value of the pixel;

[0026] Step Y3: Binarization processing:

[0027] Convert a grayscale image to a black and white binary image as follows:

[0028] First pass: ;

[0029] Calculate the binarization threshold HY;

[0030] Where Hi is the grayscale value of the i-th pixel, i=1, 2, ... n, and n is the total number of pixels in the image;

[0031] Traverse all pixels. If Hi≥HY, adjust the grayscale value of the pixel to 255, that is, white; if Hi<HY, adjust the grayscale value of the pixel to 0, that is, black;

[0032] Step Y4: Tilt correction:

[0033] Detect the tilt angle of the text in the black and white binary image and perform rotation correction on the text in the black and white binary image based on the tilt angle;

[0034] The tilt angle detection method is as follows:

[0035] First, the Canny operator is used to perform edge detection on the binary image;

[0036] Next, Hough transform is used to detect straight lines and obtain the tilt angles of all text lines;

[0037] Finally, the average of the tilt angles of all text lines is taken as the final tilt angle;

[0038] The rotation correction method is as follows:

[0039] Based on the final tilt angle, the rotation matrix is ​​determined, and then the black and white binary image is affine transformed according to the rotation matrix to align the text lines horizontally;

[0040] The rotation matrix is: .

[0041] As a further solution of the present invention: the text content recognition method is as follows:

[0042] Step W1, row segmentation:

[0043] The horizontal projection method is used to horizontally project the black and white binary image, and then the number of black pixels in each row is counted and marked as H(y);

[0044] Among them, y represents the row number variable of the pixel in the black and white binary image;

[0045] Compare the Hy value corresponding to each row with the pre-determined threshold PH:

[0046] When H(y)>PH, the line of the black and white binary image is determined to be a text line;

[0047] When H(y)≤PH, the line spacing of the black and white binary image is determined;

[0048] Then, based on the row number variable, the rows that are continuously determined to be text rows are recorded as the text row area;

[0049] Step W2: character segmentation:

[0050] The vertical projection method is used to perform vertical projection on the text line area in the black and white binary image, and then the number of black pixels in each column is counted and marked as L(x);

[0051] Where x represents the column number variable of the pixel in the text row area;

[0052] Compare the Lx value corresponding to each row with the pre-determined threshold PL:

[0053] When L(x)>PL, the column in the text row area is determined to be a character column;

[0054] When L(x)≤PL, the column in the text row area is determined to be a character gap column;

[0055] Then, based on the column number variable, the columns that are consecutively determined to be text rows are recorded as character areas;

[0056] Step W3: Character recognition:

[0057] Convert each segmented character area into the corresponding text symbol as follows:

[0058] Use common Chinese characters, numbers, and punctuation marks to establish a standard character template library;

[0059] Then the character area to be recognized is scaled, specifically by adjusting the size of the character area to be consistent with the character size in the standard character template library;

[0060] Then pass: ;

[0061] Calculate the similarity SX between the character area to be recognized and each standard character template in the standard character template library:

[0062] Where, E1 r1 is the pixel value of the r1th pixel coordinate of the standard character template, E2 r2 is the pixel value of the r2th pixel coordinate of the character area to be recognized, r1=1, 2, ..., u1, u1 is the total number of pixels of the standard character template, r2=1, 2, ..., u2, u2 is the total number of pixels of the character area to be recognized;

[0063] Then, the standard character template having a similarity SX higher than a preset similarity threshold and the highest similarity SX is selected as the recognition result of the character area to be recognized.

[0064] As a further solution of the present invention: the identification method of the chapter directory structure is as follows:

[0065] Step Z1, matching the title prefix based on the regular expression;

[0066] First, a regular expression library is used to predefine a set of rule patterns;

[0067] Then, the character recognition results of each text line area are matched with each regular pattern in the regular pattern set;

[0068] When the character recognition result of a text line area matches any rule pattern, the text line area is marked as a candidate title line;

[0069] When the character recognition result of a text line area does not match any of the rule patterns, the text line area is marked as a non-title line, also recorded as a body line;

[0070] Step Z2: Verify the title by font features;

[0071] In the text row area corresponding to the candidate title row, a character area is selected, and its maximum pixel height and maximum pixel width are obtained, and they are marked as H1 and W1 respectively;

[0072] At the same time, a character area is selected in the text line area corresponding to the text line, and its maximum pixel height and maximum pixel width are obtained, and they are marked as H2 and W2 respectively;

[0073] Then, the ratio of H1 to H2 and the ratio of W1 to W2 are compared with the preset judgment ratio PB:

[0074] When any one of H1 / H2≥PB and W1 / W2≥PB is true, the text row area corresponding to the candidate title row is determined as the title row;

[0075] When H1 / H2≥PB and W1 / W2≥PB are both not true, the text row area corresponding to the candidate title row is not determined as the title row;

[0076] Step Z3: Determine the level based on the font characteristics and numbering structure;

[0077] Step Z3.1: Determine font feature level

[0078] First, extract all the determined title rows, select a character area from them, and obtain its maximum pixel height and maximum pixel width;

[0079] Then, the maximum pixel height value or the maximum pixel width value of the selected character area corresponding to each title row is sorted in descending order, and the level of the title row is determined according to the sorting result;

[0080] Among them, when any two or more title rows have the same maximum pixel height or maximum pixel width, they are sorted in parallel and are at the same level;

[0081] When the sorting order of a title row by maximum pixel height is different from the sorting order by maximum pixel width, the first-order level is used as the level of the title row;

[0082] Step Z3.2: Determine the numbering structure level

[0083] Extract the preset numbering structure, which is reflected by the number separator;

[0084] Then, the level of the title row is determined according to the number of number separators in the text row area corresponding to the title row;

[0085] Specifically:

[0086] When the text line area corresponding to the title line contains 0 number separators, the title line is recorded as the first-level chapter title;

[0087] When the text line area corresponding to the title line contains a number separator, the title line is recorded as the second-level chapter title;

[0088] Similarly, if the text line area corresponding to the title line contains N-1 number separators, the title line will be recorded as the chapter title of the Nth level.

[0089] As a further solution of the present invention: the maximum pixel width refers to the maximum pixel value occupied by the selected character area in the vertical direction; the maximum pixel height refers to the maximum pixel value occupied by the selected character area in the horizontal direction.

[0090] As a further solution of the present invention: when the font feature level is determined, verification is also performed by reselecting other character areas in each title row.

[0091] As a further solution of the present invention: the numbering structure level is determined by performing a secondary level division on the title lines of the same level based on the font feature level determination.

[0092] As a further solution of the present invention: the content information extraction method is as follows:

[0093] First, all the text lines between two adjacent title lines of the same level are regarded as the text content of the previous title line between the two adjacent title lines of the same level, and they are associated to form a "title-content" pair.

[0094] As a further solution of the present invention: the tree structure is specifically constructed as follows:

[0095] First, based on the font feature hierarchy, tree nodes are constructed for the top-level chapter title rows;

[0096] For each lower-level chapter title under the top-level title, treat it as the direct child node of the corresponding top-level tree node;

[0097] Similarly, continue to set the chapter titles of subsequent levels as subordinate child nodes of the child nodes of the previous level until all chapter title levels are determined in the tree structure;

[0098] Then, according to the numbered structural levels, the remaining hierarchical structure is determined;

[0099] Among the established direct child nodes and subordinate child nodes, further divide them into detailed nodes according to the same child node division rule;

[0100] At the same time, each refined node is combined with its corresponding "title-content" pair to finally form a complete tree structure.

[0101] A system for automatically identifying regulations associated with correspondence, the system being used to implement a method for automatically identifying regulations associated with correspondence, the system comprising:

[0102] File upload module, used for users to upload legal and regulatory documents;

[0103] Preprocessing module, used for image preprocessing of legal and regulatory documents;

[0104] OCR recognition module, used to perform OCR recognition on uploaded files and extract text content;

[0105] Chapter extraction module, used to extract chapter directory and corresponding content information from the text content recognized by OCR;

[0106] A tree structure building module is used to automatically build a tree structure based on the extracted chapter directory and content information;

[0107] The user interface module is used to provide users with an interface for viewing the tree structure.

[0108] Beneficial effects of the present invention:

[0109] Strong file format compatibility: Legal and regulatory documents uploaded by users can be in any of the following formats: PDF, image, and scanned copies. This format can accommodate a variety of common file types, meeting the file storage and uploading habits of different users, and improving the applicability and flexibility of the system.

[0110] Effective image preprocessing: Utilizing a scientific grayscale conversion formula, the system accurately converts color images into grayscale images, paving the way for subsequent processing. It offers both median and mean filtering for noise removal, allowing you to choose the appropriate method based on your specific situation to effectively improve image quality. Grayscale images are binarized by calculating a threshold, converting them into black and white binary images, facilitating text recognition and processing. The Canny operator and Hough transform are used to detect text tilt and perform rotation correction to ensure horizontal alignment of text lines, ensuring accurate text recognition and reducing errors caused by tilted text.

[0111] Accurate and efficient text recognition: A horizontal projection method is used to count the number of black pixels in each row, accurately segmenting text lines and line spacing by comparing against a threshold, and determining the text line area. A vertical projection method is used to process the text line area, accurately segmenting character columns and character spacing columns, and determining the character area. A library of standard character templates is established, and through scaling and similarity calculation, the standard character template with the highest similarity above the threshold is selected as the recognition result, improving character recognition accuracy.

[0112] Accurate chapter and table of contents structure recognition: This feature allows for quick and accurate screening of candidate title lines, improving title recognition efficiency. Verification is performed using the pixel height and width characteristics of the font to further ensure the accuracy of the title line and avoid misjudgments. The hierarchy of the title line is determined comprehensively from both font characteristics and numbering structure, taking into account both differences in font display and the regularity of the numbering structure, making chapter and table of contents structure recognition more accurate. Furthermore, the numbering structure hierarchy is determined by performing a secondary level division based on the font feature level, further refining the hierarchy.

[0113] Reasonable content information extraction: All text lines between two adjacent title lines of the same level are taken as the text content of the previous title line and associated to form a "title-content" pair. This content information extraction method conforms to the structural characteristics of legal and regulatory documents and can accurately extract the content information corresponding to the title.

[0114] Scientific tree structure: The tree structure is gradually built according to the font feature hierarchy and numbering structure hierarchy, organically combining chapter titles and content information to form a complete and clear tree structure, which allows users to intuitively view the structure and content of legal and regulatory documents, and helps users quickly locate and understand the required regulatory information.

[0115] The system has comprehensive functions and good user experience: The automatic identification system for correspondence-related regulations includes multiple modules such as file uploading, preprocessing, OCR recognition, chapter extraction, tree structure building and user interface. These modules work together to realize the automation of the entire process from file uploading to result display, and provide users with an interface for viewing the tree structure, which is easy to operate and improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0116] The present invention will be further described below with reference to the accompanying drawings.

[0117] Figure 1 This is a system block diagram of a method and system for automatically identifying regulations associated with correspondence according to the present invention.

[0118] Figure 2 The present invention is a flowchart of a method and system for automatically identifying regulations associated with correspondence. DETAILED DESCRIPTION

[0119] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0120] Example 1

[0121] See also Figure 1 and Figure 2 As shown, the present invention is a method for automatically identifying regulations associated with correspondence, comprising:

[0122] Step 1: Upload files:

[0123] Receive legal and regulatory documents uploaded by users;

[0124] The legal and regulatory documents uploaded by the user may be in any of the following formats: PDF, image, or scanned copy;

[0125] Step 2: Text Recognition

[0126] Use OCR technology to recognize the text content in the file. The specific method is as follows:

[0127] Step W1, row segmentation:

[0128] The horizontal projection method is used to horizontally project the black and white binary image, and then the number of black pixels in each row is counted and marked as H(y);

[0129] Among them, y represents the row number variable of the pixel in the black and white binary image;

[0130] Compare the Hy value corresponding to each row with the pre-determined threshold PH:

[0131] When H(y)>PH, the line of the black and white binary image is determined to be a text line;

[0132] When H(y)≤PH, the line spacing of the black and white binary image is determined;

[0133] In this embodiment, the determination threshold PH is set to 1%-3% of the width of the black and white binary image;

[0134] Then, based on the row number variable, the rows that are continuously determined to be text rows are recorded as the text row area;

[0135] Step W2: character segmentation:

[0136] The vertical projection method is used to perform vertical projection on the text line area in the black and white binary image, and then the number of black pixels in each column is counted and marked as L(x);

[0137] Where x represents the column number variable of the pixel in the text row area;

[0138] Compare the Lx value corresponding to each row with the pre-determined threshold PL:

[0139] When L(x)>PL, the column in the text row area is determined to be a character column;

[0140] When L(x)≤PL, the column in the text row area is determined to be a character gap column;

[0141] In this embodiment, the determination threshold PH is set at 5%-10% of the height of the text line area;

[0142] Then, based on the column number variable, the columns that are consecutively determined to be text rows are recorded as character areas;

[0143] Step W3: Character recognition:

[0144] Convert each segmented character area into the corresponding text symbol as follows:

[0145] Use common Chinese characters, numbers, and punctuation marks to establish a standard character template library;

[0146] Then the character area to be recognized is scaled, specifically by adjusting the size of the character area to be consistent with the character size in the standard character template library;

[0147] Then pass:

[0148] Calculate the similarity SX between the character area to be recognized and each standard character template in the standard character template library:

[0149] Where, E1 r1 is the pixel value of the r1th pixel coordinate of the standard character template, E2 r2 is the pixel value of the r2th pixel coordinate of the character area to be recognized, r1=1, 2, ..., u1, u1 is the total number of pixels of the standard character template, r2=1, 2, ..., u2, u2 is the total number of pixels of the character area to be recognized;

[0150] Then, the standard character template with the highest similarity SX and a similarity SX higher than the preset similarity threshold is selected as the recognition result of the character area to be recognized;

[0151] Step 3: Chapter Identification

[0152] Identify the chapter structure in legal documents based on pre-defined chapter rules. The specific method is as follows:

[0153] Step Z1, matching the title prefix based on the regular expression;

[0154] First, a regular expression library is used to predefine a set of rule patterns;

[0155] In this embodiment, the rule pattern set includes a rule pattern corresponding to "(i) + chapter / section / article", where i refers to a quantifier, which refers to "1 / 2 / 3 / 4..." and also refers to "one / two / three / four...";

[0156] Then, the character recognition results of each text line area are matched with each regular pattern in the regular pattern set;

[0157] When the character recognition result of a text line area matches any rule pattern, the text line area is marked as a candidate title line;

[0158] When the character recognition result of a text line area does not match any of the rule patterns, the text line area is marked as a non-title line, also recorded as a body line;

[0159] Step Z2: Verify the title by font features;

[0160] In the text row area corresponding to the candidate title row, a character area is selected, and its maximum pixel height and maximum pixel width are obtained, and they are marked as H1 and W1 respectively;

[0161] The maximum pixel width refers to the maximum pixel value occupied by the selected character area in the vertical direction; the maximum pixel height refers to the maximum pixel value occupied by the selected character area in the horizontal direction;

[0162] At the same time, a character area is selected in the text line area corresponding to the text line, and its maximum pixel height and maximum pixel width are obtained, and they are marked as H2 and W2 respectively;

[0163] Then, the ratio of H1 to H2 and the ratio of W1 to W2 are compared with the preset judgment ratio PB:

[0164] When any one of H1 / H2≥PB and W1 / W2≥PB is true, the text row area corresponding to the candidate title row is determined as the title row;

[0165] When H1 / H2≥PB and W1 / W2≥PB are both not true, the text row area corresponding to the candidate title row is not determined as the title row;

[0166] Step Z3: Determine the level based on the font characteristics and numbering structure;

[0167] Step Z3.1: Determine font feature level

[0168] First, extract all the determined title rows, select a character area from them, and obtain its maximum pixel height and maximum pixel width;

[0169] Then, the maximum pixel height value or the maximum pixel width value of the selected character area corresponding to each title row is sorted in descending order, and the level of the title row is determined according to the sorting result;

[0170] Among them, when any two or more title rows have the same maximum pixel height or maximum pixel width, they are sorted in parallel and are at the same level;

[0171] When the sorting order of a title row by maximum pixel height is different from the sorting order by maximum pixel width, the first-order level is used as the level of the title row;

[0172] In this embodiment, verification is also performed by reselecting other character areas in each title row;

[0173] For example:

[0174] Assume there are 5 heading rows (H1, H2, H3, H4, H5), and extract their maximum pixel height and maximum pixel width;

[0175] The details are as follows:

[0176] The maximum pixel height of the title row H1 is 40, and the maximum pixel width is 500;

[0177] The maximum pixel height of the header line H2 is 32, and the maximum pixel width is 450;

[0178] The maximum pixel height of the header line H3 is 32, and the maximum pixel width is 400;

[0179] The maximum pixel height of the H4 header row is 28, and the maximum pixel width is 450;

[0180] The maximum pixel height of the title row H5 is 24, and the maximum pixel width is 380;

[0181] Step 1: Sort by height in descending order

[0182] H1 corresponds to the first level, H2 and H3 correspond to the second level, H4 corresponds to the third level, and H5 corresponds to the fourth level;

[0183] Step 2: Sort by width in descending order

[0184] H1 corresponds to the first level, H2 and H4 correspond to the second level, H3 corresponds to the third level, and H5 corresponds to the fourth level;

[0185] Step 3: Comprehensive comparison to determine the final level

[0186] H1: It is ranked first in both height and width sorting and is ultimately determined to be the first level;

[0187] H2: It is ranked 2nd in height sorting, 2nd in width sorting, and finally ranked 2nd;

[0188] H3: It is the second level in the height sorting and the third level in the width sorting. The higher level is the second level.

[0189] H4: In the height sorting, it is the third level, and in the width sorting, it is the second level. The higher level is the second level.

[0190] H5: It is ranked 4th in both height and width. If there is no 3rd level among H1, H2, H3, and H4, it will eventually be promoted from 4th level to 3rd level.

[0191] Step Z3.2: Determine the numbering structure level

[0192] The numbering structure level is determined by dividing the title lines of the same level into two levels based on the font feature level.

[0193] Extract the preset numbering structure, which is reflected by the number separator;

[0194] In this embodiment, the number separators are such as "." and "-", which shall be determined according to the actual document conventions;

[0195] Then, the level of the title row is determined according to the number of number separators in the text row area corresponding to the title row;

[0196] Specifically:

[0197] When the text line area corresponding to the title line contains 0 number separators, the title line is recorded as the first-level chapter title;

[0198] When the text line area corresponding to the title line contains a number separator, the title line is recorded as the second-level chapter title;

[0199] Similarly, if the text line area corresponding to the title line contains N-1 number separators, then the title line is recorded as the chapter title of the Nth level;

[0200] For example:

[0201] First-level chapter: "Chapter 1" or "Overview", with no separators;

[0202] Second-level chapter: "1.1", which contains the separator ".";

[0203] The third-level chapter: "1.1.1", which contains two separators ".";

[0204] The fourth-level chapter: "1.1.1.1", which contains three separators ".";

[0205] Step 4: Content extraction:

[0206] Extract corresponding content information according to the chapter directory structure;

[0207] The specific steps are as follows:

[0208] First, all the text lines between two adjacent same-level title lines are taken as the text content of the previous title line between the two adjacent same-level title lines, and they are associated to form a "title-content" pair;

[0209] Step 5: Tree structure formation:

[0210] Organize the extracted chapter directory and content information into a tree structure;

[0211] Specifically:

[0212] First, multiple tree nodes are constructed based on the chapter title rows of the first level determined by the font feature hierarchy. Then, the chapter title of the second level in the first level is made the first child node of the corresponding tree node. Similarly, the chapter titles of subsequent levels are made subordinate child nodes of the corresponding first child node until all subsequent levels are determined.

[0213] Then, other levels are determined according to the numbering structure level, and detailed nodes are divided from the corresponding subordinate sub-nodes according to the sub-node division method. At the same time, the corresponding "title-content" pairs of each detailed node are combined to form a tree structure;

[0214] Step 6: Results display:

[0215] Display the tree structure to the user.

[0216] Example 1 provides a method for automatically identifying regulations associated with letters, which has significant advantages in many aspects. The file upload link supports multiple formats such as PDF, pictures and scans, which greatly facilitates the processing of files from different sources. The text recognition stage uses OCR technology to segment lines and characters through horizontal and vertical projection methods, and combines the standard character template library to recognize characters, effectively improving the accuracy and efficiency of text recognition. Chapter recognition is based on regular expressions and font features, and determines the title line and hierarchy from multiple dimensions, making the recognition of the directory structure more reasonable and reliable. Content extraction forms a "title-content" pair based on the directory, and forms a tree structure to clearly display the overall structure and specific content of the file, making it easier for users to access and understand.

[0217] Example 2

[0218] As the second embodiment of the present invention, when the present application is specifically implemented, compared with the first embodiment, the technical solution of this embodiment is different from that of the first embodiment only in that this embodiment further includes the following preprocessing steps:

[0219] This step is used to preprocess the images of legal documents. The image preprocessing method is as follows:

[0220] Step Y1: Grayscale the image:

[0221] Convert color images to grayscale images;

[0222] Grayscale formula: H=0.299×R+0.587×G+0.114×B;

[0223] Among them, R, G, B are the red, green, and blue components of the pixel respectively, and H is the grayscale value;

[0224] Step Y2: noise removal:

[0225] Use median filtering or mean filtering to remove noise from grayscale images;

[0226] First, for each pixel, take the grayscale values ​​of all pixels in the 3×3 neighborhood around it;

[0227] For median filtering, the grayscale values ​​of all pixels are sorted in ascending order, and the median value is taken as the new value of the pixel;

[0228] For mean filtering, the average grayscale value of all pixels is calculated and used as the new value of the pixel;

[0229] Step Y3: Binarization processing:

[0230] Convert a grayscale image to a black and white binary image as follows:

[0231] First pass: ;

[0232] Calculate the binarization threshold HY;

[0233] Where Hi is the grayscale value of the i-th pixel, i=1, 2, ... n, and n is the total number of pixels in the image;

[0234] Traverse all pixels. If Hi≥HY, adjust the grayscale value of the pixel to 255, that is, white; if Hi<HY, adjust the grayscale value of the pixel to 0, that is, black;

[0235] Step Y4: Tilt correction:

[0236] Detect the tilt angle of the text in the black and white binary image and perform rotation correction on the text in the black and white binary image based on the tilt angle;

[0237] The tilt angle detection method is as follows:

[0238] First, the Canny operator is used to perform edge detection on the binary image;

[0239] Next, Hough transform is used to detect straight lines and obtain the tilt angles of all text lines;

[0240] Among them, the basic principle of Hough line detection is to represent and detect the straight line in the image space by converting it into the parameter space. It is an existing technology and will not be described in detail here.

[0241] Finally, the average of the tilt angles of all text lines is taken as the final tilt angle;

[0242] The rotation correction method is as follows:

[0243] Based on the final tilt angle Dp, the rotation matrix is ​​determined, and then the black and white binary image is affine transformed according to the rotation matrix to align the text lines horizontally;

[0244] The rotation matrix is: .

[0245] Example 2 adds a preprocessing step to Example 1, performing image preprocessing on legal and regulatory documents. Grayscale simplifies image information, laying the foundation for subsequent processing. Median or mean filtering removes noise, improving image quality and reducing interference with text recognition. Binarization highlights text information, facilitating segmentation. Skew correction detects and corrects text tilt, aligning text lines horizontally. These preprocessing steps effectively improve image quality, ensuring optimal OCR performance and further enhancing text recognition accuracy.

[0246] Example 3

[0247] As the third embodiment of the present invention, when the present application is specifically implemented, compared with the first and second embodiments, the technical solution of this embodiment is to combine the solutions of the first and second embodiments. The technical solution of this embodiment differs from the first and second embodiments only in that, in this embodiment, the result display also supports the following functions:

[0248] Function 1: Tree expansion / collapse:

[0249] Users can expand or collapse tree nodes to view or hide content;

[0250] Function 2: Content retrieval:

[0251] The user enters keywords and matching content is highlighted.

[0252] Example 3 combines the solutions of Example 1 and Example 2 and adds practical functions to the result display phase. The tree-shaped expand / collapse function allows users to flexibly view or hide content according to their needs, making it easy to quickly locate and browse the sections of interest. The content search function allows users to enter keywords, and the system will highlight matching content, greatly improving the efficiency of users in finding specific information, enhancing the practicality and interactivity of the system, and providing users with a better user experience.

[0253] Example 4

[0254] As the fourth embodiment of the present invention, when this application is specifically implemented, compared with the first, second and third embodiments, the technical solution of this embodiment is to combine and implement the solutions of the above-mentioned first, second and third embodiments.

[0255] Example 4 combines the technical solutions of Examples 1, 2, and 3, leveraging the advantages of each. It combines the advantages of Example 1 in terms of file format compatibility, text recognition, chapter recognition, and content structuring, with the image preprocessing improvements of Example 2, and incorporates the interactive functionality of Example 3. This comprehensive solution provides users with a comprehensive, efficient, and convenient automatic identification service for correspondence-related regulations, meeting their diverse needs and improving overall system performance and user experience.

[0256] The present invention also provides a system for automatically identifying regulations associated with correspondence, the system being used to execute a method for automatically identifying regulations associated with correspondence, the system comprising:

[0257] File upload module, used for users to upload legal and regulatory documents;

[0258] Preprocessing module, used for image preprocessing of legal and regulatory documents;

[0259] OCR recognition module, used to perform OCR recognition on uploaded files and extract text content;

[0260] Chapter extraction module, used to extract chapter directory and corresponding content information from the text content recognized by OCR;

[0261] A tree structure building module is used to automatically build a tree structure based on the extracted chapter directory and content information;

[0262] The user interface module is used to provide users with an interface for viewing the tree structure.

[0263] The above formulas are all dimensionless and numerical calculations. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain the most recent real situation. The preset parameters and thresholds in the formulas are set by technicians in this field according to actual conditions.

[0264] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for automatically identifying regulations associated with correspondence, characterized in that: The following steps are involved: File upload: Receive legal and regulatory documents uploaded by users; Preprocessing: image preprocessing of legal and regulatory documents; Text recognition: Use OCR technology to identify text content in legal and regulatory documents; Chapter identification: Identify the chapter structure in legal and regulatory documents based on pre-set chapter rules; Content extraction: extract the corresponding content information according to the chapter directory structure; Tree structure building: building the extracted chapter directory and content information into a tree structure; Result display: Display the tree structure to the user; The directory structure is identified as follows: Step Z1, matching the title prefix based on the regular expression; First, a regular expression library is used to predefine a set of rule patterns; Then, the character recognition results of each text line area are matched with each regular pattern in the regular pattern set; When the character recognition result of a text line area matches any rule pattern, the text line area is marked as a candidate title line; When the character recognition result of a text line area does not match any of the rule patterns, the text line area is marked as a non-title line, also recorded as a body line; Step Z2: Verify the title by font features; In the text row area corresponding to the candidate title row, a character area is selected, and its maximum pixel height and maximum pixel width are obtained, and they are marked as H1 and W1 respectively; At the same time, a character area is selected in the text line area corresponding to the text line, and its maximum pixel height and maximum pixel width are obtained, and they are marked as H2 and W2 respectively; Then, the ratio of H1 to H2 and the ratio of W1 to W2 are compared with the preset judgment ratio PB: When any one of H1 / H2≥PB and W1 / W2≥PB is true, the text row area corresponding to the candidate title row is determined as the title row; When H1 / H2≥PB and W1 / W2≥PB are both not true, the text row area corresponding to the candidate title row is not determined as the title row; Step Z3: Determine the level based on the font characteristics and numbering structure; Step Z3.1: Determine font feature level First, extract all the determined title rows, select a character area from them, and obtain its maximum pixel height and maximum pixel width; Then, the maximum pixel height value or the maximum pixel width value of the selected character area corresponding to each title row is sorted in descending order, and the level of the title row is determined according to the sorting result; Among them, when any two or more title rows have the same maximum pixel height or maximum pixel width, they are sorted in parallel and are at the same level; When the sorting order of a title row by maximum pixel height is different from the sorting order by maximum pixel width, the first-order level is used as the level of the title row; Step Z3.2: Determine the numbering structure level Extract the preset numbering structure, which is reflected by the number separator; Then, the level of the title row is determined according to the number of number separators in the text row area corresponding to the title row; Specifically: When the text line area corresponding to the title line contains 0 number separators, the title line is recorded as the first-level chapter title; When the text line area corresponding to the title line contains a number separator, the title line is recorded as the second-level chapter title; Similarly, if the text line area corresponding to the title line contains N-1 number separators, the title line will be recorded as the chapter title of the Nth level.

2. The method for automatically identifying regulations associated with correspondence according to claim 1, characterized in that: The image preprocessing method is as follows: Step Y1: Grayscale the image: Convert color images to grayscale images; Step Y2: noise removal: Use median filtering or mean filtering to remove noise from grayscale images; Step Y3: Binarization processing: Convert a grayscale image to a black and white binary image as follows: First, calculate the average grayscale value of all pixels in the grayscale image and determine it as the binarization threshold; Traverse all pixels, if Hi≥HY, adjust the grayscale value of the pixel to 255; if Hi<HY, adjust the grayscale value of the pixel to 0; Where Hi is the grayscale value of the i-th pixel, i=1, 2, ... n, n is the total number of pixels in the image, and HY is the binarization threshold; Step Y4: Tilt correction: Detect the tilt angle of the text in the black and white binary image and perform rotation correction on the text in the black and white binary image based on the tilt angle; The tilt angle detection method is as follows: First, the Canny operator is used to perform edge detection on the binary image; Next, Hough transform is used to detect straight lines and obtain the tilt angles of all text lines; Finally, the average of the tilt angles of all text lines is taken as the final tilt angle; The rotation correction method is as follows: Based on the final tilt angle, the rotation matrix is ​​determined, and then the black and white binary image is affine transformed according to the rotation matrix to align the text lines horizontally.

3. The method for automatically identifying laws and regulations associated with correspondence according to claim 1, characterized in that: The text content recognition method is as follows: Step W1, row segmentation: The horizontal projection method is used to horizontally project the black and white binary image, and then the number of black pixels in each row is counted and marked as H(y); Among them, y represents the row number variable of the pixel in the black and white binary image; Compare the Hy value corresponding to each row with the pre-determined threshold PH: When H(y)>PH, the line of the black and white binary image is determined to be a text line; When H(y)≤PH, the line spacing of the black and white binary image is determined; Then, based on the row number variable, the rows that are continuously determined to be text rows are recorded as the text row area; Step W2: character segmentation: The vertical projection method is used to perform vertical projection on the text line area in the black and white binary image, and then the number of black pixels in each column is counted and marked as L(x); Where x represents the column number variable of the pixel in the text row area; Compare the Lx value corresponding to each row with the pre-determined threshold PL: When L(x)>PL, the column in the text row area is determined to be a character column; When L(x)≤PL, the column in the text row area is determined to be a character gap column; Then, based on the column number variable, the columns that are consecutively determined to be text rows are recorded as character areas; Step W3: Character recognition: Convert each segmented character area into the corresponding text symbol as follows: Use common Chinese characters, numbers, and punctuation marks to establish a standard character template library; Then the character area to be recognized is scaled, specifically by adjusting the size of the character area to be consistent with the character size in the standard character template library; Then pass: ; Calculate the similarity SX between the character area to be recognized and each standard character template in the standard character template library: Where, E1 r1 is the pixel value of the r1th pixel coordinate of the standard character template, E2 r2 is the pixel value of the r2th pixel coordinate of the character area to be recognized, r1=1, 2, ..., u1, u1 is the total number of pixels of the standard character template, r2=1, 2, ..., u2, u2 is the total number of pixels of the standard character template; Then, the standard character template having a similarity SX higher than a preset similarity threshold and the highest similarity SX is selected as the recognition result of the character area to be recognized.

4. The method for automatically identifying laws and regulations associated with correspondence according to claim 1, characterized in that: The maximum pixel width refers to the maximum pixel value occupied by the selected character area in the vertical direction; the maximum pixel height refers to the maximum pixel value occupied by the selected character area in the horizontal direction.

5. The method for automatically identifying laws and regulations associated with correspondence according to claim 4, characterized in that: The numbering structure level is determined by dividing the title lines of the same level into secondary levels based on the font feature level.

6. The method for automatically identifying laws and regulations associated with correspondence according to claim 4, characterized in that: The content information extraction method is as follows: First, treat all the text lines between two adjacent title lines of the same level as the text content of the previous title line between the two adjacent title lines of the same level, and associate them to form a "title-content" pair.

7. The method for automatically identifying laws and regulations associated with correspondence according to claim 6, characterized in that: The tree structure is constructed as follows: First, based on the font feature hierarchy, tree nodes are constructed for the top-level chapter title rows; For each lower-level chapter title under the top-level title, treat it as the direct child node of the corresponding top-level tree node; Similarly, continue to set the chapter titles of subsequent levels as subordinate child nodes of the child nodes of the previous level until all chapter title levels are determined in the tree structure; Then, according to the numbered structural levels, the remaining hierarchical structure is determined; Among the established direct child nodes and subordinate child nodes, further divide them into detailed nodes according to the same child node division rule; At the same time, each refined node is combined with its corresponding "title-content" pair to finally form a complete tree structure.

8. The method for automatically identifying laws and regulations associated with correspondence according to claim 1, characterized in that: The legal and regulatory documents uploaded by users may be in any of the following formats: PDF, image, or scanned copy.

9. A system for automatically identifying regulations associated with correspondence, the system being used to execute the method for automatically identifying regulations associated with correspondence as claimed in any one of claims 1 to 8, characterized in that: The system includes: File upload module, used for users to upload legal and regulatory documents; Preprocessing module, used for image preprocessing of legal and regulatory documents; OCR recognition module, used to perform OCR recognition on uploaded files and extract text content; Chapter extraction module, used to extract chapter directory and corresponding content information from the text content recognized by OCR; A tree structure building module is used to automatically build a tree structure based on the extracted chapter directory and content information; The user interface module is used to provide users with an interface for viewing the tree structure.

Citation Information

Patent Citations

  • Method and device for identifying association laws and regulations of letters

    CN112199466A

  • Automatic identification and import method based on file table

    CN117973334A

Cited By

  • Machine learning-driven intelligent classification method and system for electronic letter attachments

    CN120873875A

  • Machine learning driven electronic mail attachment intelligent classification method and system

    CN120873875B