File data processing method and device, equipment and computer storage medium
By typing the file and merging the text blocks, horizontal and vertical texts are generated to identify the differences in the row and column directions of the file, the problem of low file comparison accuracy in the existing technology is solved, and higher file comparison accuracy is achieved .
Patent Information
- Application Number
- CN202411530631.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-18
AI Technical Summary
When identifying and marking file modification differences in the prior art, it is easy to reduce the accuracy of file comparison by merging text information of different columns in the table.
By text recognition of the initial file and the target file, multiple recognized text blocks are obtained and combined based on the position information of these text blocks to generate horizontal text and vertical text to determine the difference in the row and column directions of the files.
Improve the accuracy of file comparison, enables more accurate identification and marking of file modification differences, ensuring file integrity and accuracy.
Smart Images

Figure CN119478979A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a method, device, equipment, computer storage medium and computer program product for processing file data. Background Art
[0002] In modern enterprises, a large number of important official documents are often generated. Employees need to process and save these important official documents through a series of processes. For example, employees review and approve the drafted contract and save it.
[0003] However, during the process of handling important official documents, such as the approval process of a contract, the text of the contract may be modified due to unauthorized or inappropriate expression. Therefore, it is necessary to identify and mark the differences between the documents before and after the modification to ensure the integrity and accuracy of the contract.
[0004] In the related art, files are usually simplified into plain text to identify and mark the differences between files before and after modification. However, in the related art, when files are simplified into plain text, when encountering text containing important layout structure information such as tables and paragraphs, text information from different columns in the table may be merged, resulting in incorrect recognition of text information, which reduces the accuracy of file comparison. Summary of the invention
[0005] The embodiments of the present disclosure provide a method, apparatus, device, computer storage medium and computer program product for processing file data, which can improve the accuracy of file comparison.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for processing file data, the method comprising:
[0007] Performing text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively;
[0008] Based on the position information corresponding to the multiple recognized text blocks, the multiple recognized text blocks located in the same row are merged to obtain the horizontal text corresponding to the initial file and the target file;
[0009] Based on the position information corresponding to the plurality of recognized text blocks, according to a first comparison result between the number of first separators in two adjacent rows of the plurality of recognized text blocks and a preset number threshold, the plurality of recognized text blocks located in the same column are merged to obtain vertical text corresponding to the initial file and the target file, and the first separator is determined according to a second comparison result between the distance between the plurality of recognized text blocks and a preset distance threshold;
[0010] According to the comparison results of the horizontal text similarity between the initial file and the target file, and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds, a horizontal comparison result and a vertical comparison result are obtained;
[0011] The horizontal comparison result and the vertical comparison result are combined to obtain the target comparison result, which corresponds to the different characters.
[0012] In one practicable implementation, before performing text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively, the method further includes:
[0013] Performing image recognition on the initial file to be processed and the target file to be processed to obtain image recognition results corresponding to the initial file to be processed and the target file to be processed;
[0014] According to the image recognition result, determining the target color pixel area in the image recognition result;
[0015] The target color pixel area is filled with the surrounding pixels of the target color pixel area to obtain an initial file and a target file.
[0016] In one practicable implementation, based on the position information corresponding to the multiple recognized text blocks, multiple recognized text blocks located in the same row are merged to obtain horizontal text corresponding to the initial file and the target file, including:
[0017] Based on the position information of the multiple recognized text blocks, the multiple recognized text blocks located in the same line are merged to obtain multiple text lines;
[0018] Merge multiple text lines to obtain horizontal text corresponding to the original and target files.
[0019] In one practicable implementation, based on the position information of the multiple recognized text blocks, the multiple recognized text blocks located in the same line are merged to obtain multiple text lines, including:
[0020] Based on the position information of the plurality of recognized text blocks, the distance between adjacent recognized text blocks located in the same row is compared with a preset distance threshold to obtain a second comparison result;
[0021] When the second comparison result indicates that the distance between adjacent recognized text blocks in the same row is less than a preset distance threshold, merging adjacent recognized text blocks in the same row to obtain a first text row;
[0022] If the second comparison result indicates that the distance between adjacent recognized text blocks located in the same row is greater than or equal to a preset distance threshold, determining a first separator;
[0023] Merge adjacent recognized text blocks and the first separator in the same line to obtain a second text line;
[0024] The first text line and the second text line are merged to obtain multiple text lines.
[0025] In an achievable implementation, based on the position information corresponding to the plurality of recognized text blocks, according to a first comparison result between the number of first separators in two adjacent rows of the plurality of recognized text blocks and a preset number threshold, the plurality of recognized text blocks located in the same column are merged to obtain vertical text corresponding to the initial file and the target file, including:
[0026] Comparing the number of first separators included in any two adjacent lines of the plurality of text lines with a preset number threshold, to obtain a first comparison result;
[0027] If the first comparison result indicates that the number of first separators included in any two adjacent lines of the plurality of text lines is greater than or equal to a preset number threshold, determining a second separator;
[0028] Based on the position information of multiple recognized text blocks, recognized text blocks located in the same column in adjacent text rows whose number of first separators is greater than or equal to a preset number threshold are merged with the second segmentation mark to obtain vertical text corresponding to the initial file and the target file.
[0029] In an achievable implementation, according to the comparison results of the horizontal text similarity between the initial file and the target file and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds, the horizontal comparison result and the vertical comparison result are obtained, including:
[0030] Calculating the similarity of the recognized text blocks with the same position information in the horizontal text of the initial file and the target file to obtain a first similarity;
[0031] When the first similarity is less than the first similarity threshold, a horizontal comparison result is obtained;
[0032] Calculating the similarity of the recognized text blocks with the same position information in the vertical text of the initial file and the target file to obtain a second similarity;
[0033] When the second similarity is less than the second similarity threshold, a vertical comparison result is obtained.
[0034] In one practicable implementation, the horizontal comparison result and the vertical comparison result are combined to obtain a target comparison result, including:
[0035] Combine the horizontal comparison results and the vertical comparison results to obtain the initial comparison results;
[0036] Classifying the initial comparison result according to the character type to obtain a first classification comparison result, where the first classification comparison result corresponds to a text character or a symbol character;
[0037] According to the position information of the recognized text block corresponding to the first classification comparison result, obtaining a first target sentence in the recognized text block corresponding to the first classification comparison result from the target file;
[0038] Inputting the first target sentence into the target model, and using the target model to recognize semantic information of the first target sentence to obtain a semantic recognition result;
[0039] Processing the semantic recognition results to obtain processed sentences;
[0040] Obtain a second target sentence in the recognition text block corresponding to the first classification comparison result in the initial file;
[0041] comparing the similarity of the semantic information of the processed sentence and the second target sentence with a third similarity threshold to obtain a third comparison result;
[0042] If the third comparison result represents that the similarity between the semantic information of the processed sentence and the second target sentence is greater than or equal to a third similarity threshold, the first classification comparison result is determined to be a fourth comparison result;
[0043] The fourth comparison result in the initial comparison result is removed to obtain a target comparison result.
[0044] In an achievable implementation, after combining the horizontal comparison result and the vertical comparison result to obtain the target comparison result, the method further includes:
[0045] According to the position information of the recognition text block corresponding to the target comparison result, the recognition text blocks with adjacent position information corresponding to the target comparison result are merged to obtain the target recognition text block;
[0046] Calculating the similarity between the difference characters corresponding to the target comparison result and the characters of the target recognition text block to obtain a fourth similarity;
[0047] When the fourth similarity is greater than a fourth similarity threshold, determining the character of the target recognition text block as the target character;
[0048] Visually mark the target characters.
[0049] In a second aspect, an embodiment of the present disclosure provides a device for processing file data, the device comprising:
[0050] A recognition module, used for performing text recognition on the initial file and the target file to obtain a plurality of recognition text blocks corresponding to the initial file and the target file respectively;
[0051] A merging module, used for merging multiple recognized text blocks located in the same row based on position information corresponding to the multiple recognized text blocks, to obtain horizontal text corresponding to the initial file and the target file;
[0052] The merging module is further used to merge the multiple recognized text blocks located in the same column based on the position information corresponding to the multiple recognized text blocks and according to a first comparison result of the number of first separators in two adjacent rows of the multiple recognized text blocks and a preset number threshold, so as to obtain vertical text corresponding to the initial file and the target file, wherein the first separator is determined according to a second comparison result of the distance between the multiple recognized text blocks and a preset distance threshold;
[0053] A comparison module, for obtaining a horizontal comparison result and a vertical comparison result according to the comparison results of the horizontal text similarity between the initial file and the target file, and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds;
[0054] The merging module is also used to merge the horizontal comparison results and the vertical comparison results to obtain the target comparison results, and the target comparison results correspond to the different characters.
[0055] In a third aspect, an embodiment of the present disclosure provides a device for processing file data, the device comprising a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement a method for processing file data as described in any one of the first aspects.
[0056] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, a method for processing file data as described in any one of the first aspects is implemented.
[0057] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements a method for processing file data as described in any one of the first aspects.
[0058] The present disclosure provides a method, device, equipment, computer storage medium and computer program product for processing file data. The method performs text recognition on an initial file and a target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively. Based on the position information corresponding to the plurality of recognized text blocks, the plurality of recognized text blocks located in the same row are merged to obtain the horizontal text corresponding to the initial file and the target file. By obtaining the horizontal text, the difference between the initial file and the target file in the row direction can be determined. Based on the position information corresponding to the plurality of recognized text blocks, according to the first comparison result of the number of first separators of two adjacent rows of the plurality of recognized text blocks and a preset number threshold, the plurality of recognized text blocks located in the same column are merged to obtain the vertical text corresponding to the initial file and the target file. According to the similarity of the horizontal texts of the initial file and the target file, and the comparison result of the similarity of the vertical texts of the initial file and the target file with the corresponding similarity threshold, a horizontal comparison result and a vertical comparison result are obtained. By obtaining the vertical text, the difference between the initial file and the target file in the column direction can be determined. The horizontal comparison result and the vertical comparison result are merged to obtain the target comparison result, and the target comparison result corresponds to the characters of the difference. Therefore, the present disclosure can determine the differences between the initial file and the target file in terms of rows and columns by acquiring the horizontal text and the vertical text, thereby improving the accuracy of the file comparison. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the following is a brief introduction to the drawings required for use in the embodiment of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0060] Figure 1 It is a flowchart of a method for processing file data provided by an embodiment of the present disclosure;
[0061] Figure 2 is a flowchart of an image recognition method provided by an embodiment of the present disclosure;
[0062] Figure 3 is a flowchart of a method for obtaining horizontal text provided by an embodiment of the present disclosure;
[0063] Figure 4 is a flowchart of a method for obtaining a text line provided by an embodiment of the present disclosure;
[0064] Figure 5 is a flowchart of a method for obtaining vertical text provided by an embodiment of the present disclosure;
[0065] Figure 6is a flowchart of a method for obtaining horizontal comparison results and vertical comparison results provided by an embodiment of the present disclosure;
[0066] Figure 7 is a flowchart of a method for obtaining a target comparison result provided by an embodiment of the present disclosure;
[0067] Figure 8 is a flow chart of a method for marking a target character provided by an embodiment of the present disclosure;
[0068] Fig. 9 It is a flowchart of another method for processing file data provided by an embodiment of the present disclosure;
[0069] Fig.10 is a structural diagram of a device for processing file data provided by an embodiment of the present disclosure;
[0070] Fig.11 It is a structural diagram of a device for processing file data provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0071] The features and exemplary embodiments of various aspects of the present invention will be described in detail below. In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present invention, rather than to limit the present invention. For those skilled in the art, the present invention can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present invention by illustrating examples of the present invention.
[0072] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0073] It should be noted that the acquisition, storage, use and processing of data in the embodiments of the present application are in compliance with the relevant provisions of national laws and regulations.
[0074] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0075] Before describing the technical solutions provided by the embodiments of the present disclosure, in order to facilitate understanding of the embodiments of the present disclosure, the present disclosure specifically describes the problems existing in the related technologies:
[0076] In modern enterprises, a large number of important official documents are often generated. Employees need to process and save these important official documents through a series of processes. For example, employees review and approve the drafted contract and save it.
[0077] However, during the process of handling important official documents, such as the approval process of a contract, the text of the contract may be modified due to unauthorized or inappropriate expression. Therefore, it is necessary to identify and mark the differences between the documents before and after the modification to ensure the integrity and accuracy of the contract.
[0078] In the related art, files are usually simplified into plain text to identify and mark the differences between files before and after modification. However, the related art uses the method of simplifying files into plain text. When encountering text containing important layout structure information such as tables and paragraphs, the text information of different columns in the table may be merged, thereby incorrectly identifying the text information. For example, the first column of the first row of the table in the initial file is "10", and the second column of the first row is "110". After the initial file is modified, the first column of the first row of the table in the target file is "101", and the second column of the first row is "10". By simplifying the file into plain text to identify the first row of the table in the initial file and the target file, the first row of both texts will be identified as "10110", so that the modified difference information is mistakenly considered to be unmodified, resulting in a decrease in the accuracy of file comparison.
[0079] The embodiments of the present disclosure provide a method, apparatus, device, computer storage medium and computer program product for processing file data, which can solve the above-mentioned technical problems existing in the related technologies.
[0080] The disclosed embodiment performs text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively. Based on the position information corresponding to the plurality of recognized text blocks, the plurality of recognized text blocks located in the same row are merged to obtain the horizontal text corresponding to the initial file and the target file. By obtaining the horizontal text, the difference between the initial file and the target file in the row direction can be determined. Based on the position information corresponding to the plurality of recognized text blocks, according to the first comparison result of the number of first separators in two adjacent rows of the plurality of recognized text blocks and a preset number threshold, the plurality of recognized text blocks located in the same column are merged to obtain the vertical text corresponding to the initial file and the target file. According to the similarity of the horizontal texts of the initial file and the target file, and the comparison result of the similarity of the vertical texts of the initial file and the target file with the corresponding similarity threshold, the horizontal comparison result and the vertical comparison result are obtained. By obtaining the vertical text, the difference between the initial file and the target file in the column direction can be determined. The horizontal comparison result and the vertical comparison result are merged to obtain the target comparison result, and the target comparison result corresponds to the characters of the difference. Therefore, by obtaining the horizontal text and the vertical text, the disclosed embodiment can determine the difference between the initial file and the target file in the row and column, thereby improving the accuracy of the file comparison.
[0081] The following is an introduction to the method for processing file data provided by the embodiment of the present disclosure.
[0082] Figure 1 FIG. 1 is a flow chart showing a method for processing file data provided by an embodiment of the present disclosure. Figure 1 The method may include the following steps S110-S150.
[0083] S110: Perform text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively.
[0084] An initial file and a target file are obtained. Text recognition is performed on the initial file and the target file. A plurality of recognized text blocks corresponding to the initial file and the target file are obtained.
[0085] In one example, text recognition is performed on the initial file and the target file to obtain information such as position information of the recognized text block and recognition confidence information, wherein the recognition confidence information represents the accuracy of the recognition result.
[0086] In one example, optical character recognition (OCR) may be used to perform text recognition on the initial file and the target file.
[0087] In one example, the steps of using optical character recognition to perform text recognition on an initial file and a target file may be: 1. Perform grayscale processing, binarization processing, noise removal processing, and tilt correction processing on the initial file and the target file. 2. Determine the text area of the processed initial file and the target file. 3. Extract the features of the characters in the text area. 4. Compare the features of the extracted characters with the features of the preset characters to obtain a comparison result. 5. Obtain multiple recognized text blocks based on the comparison result.
[0088] S120: Based on the position information corresponding to the multiple recognized text blocks, multiple recognized text blocks located in the same row are merged to obtain horizontal text corresponding to the initial file and the target file.
[0089] After performing text recognition on the initial file and the target file to obtain corresponding multiple recognized text blocks, the recognized text blocks located in the same row are merged according to the corresponding position information of the recognized text blocks to obtain horizontal text corresponding to the initial file and the target file.
[0090] The disclosed embodiment merges multiple recognized text blocks in the same line to obtain horizontal text, which facilitates the subsequent comparison of the differences between the characters of the initial file and the target file in the same line.
[0091] S130: Based on the position information corresponding to the multiple recognized text blocks, and according to the first comparison result of the number of first separators in two adjacent rows of the multiple recognized text blocks and a preset number threshold, the multiple recognized text blocks located in the same column are merged to obtain vertical text corresponding to the initial file and the target file.
[0092] After performing text recognition on the initial file and the target file to obtain a plurality of corresponding recognized text blocks, the number of first separators included in two adjacent rows of the plurality of recognized text blocks is determined according to the corresponding position information of the recognized text blocks. The number of first separators included in the two adjacent rows is compared with a preset number threshold to obtain a first comparison result. According to the first comparison result, the recognized text blocks whose position information is in the same column are merged to obtain vertical text corresponding to the initial file and the target file.
[0093] The first separator is determined according to a second comparison result of the distance between the multiple recognized text blocks and a preset distance threshold.
[0094] In one example, the first separator represents a line separator. For example, if there are two recognized text blocks in the first line of the text file, and the distance between the two recognized text blocks is 5 cm, which is greater than the preset distance threshold of 3 cm, then a line separator is added between the two recognized text blocks.
[0095] S140: Obtaining a horizontal comparison result and a vertical comparison result according to the comparison results of the horizontal text similarity between the initial file and the target file, and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds.
[0096] After obtaining the horizontal text of the initial file and the horizontal text of the target file, the similarity of the horizontal text of the initial file and the target file is calculated and compared with the corresponding similarity threshold to obtain a horizontal comparison result. After obtaining the vertical text of the initial file and the vertical text of the target file, the similarity of the vertical text of the initial file and the target file is calculated and compared with the corresponding similarity threshold to obtain a vertical comparison result.
[0097] S150: Combining the horizontal comparison result and the vertical comparison result to obtain a target comparison result.
[0098] After obtaining the horizontal comparison result and the vertical comparison result, the horizontal comparison result and the vertical comparison result are combined to obtain the target comparison result.
[0099] Among them, the target comparison result corresponds to the different characters.
[0100] In one example, the horizontal comparison result and the vertical comparison result may be combined according to the position information of the text recognition blocks corresponding to the horizontal comparison result and the vertical comparison result to obtain the target comparison result.
[0101] The disclosed embodiment can determine the differences between the initial file and the target file in terms of rows and columns by acquiring the horizontal text and the vertical text, thereby improving the accuracy of the file comparison.
[0102] In one embodiment, Figure 2 As shown, before performing text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively, the method for processing file data further includes steps S160-S180.
[0103] S160: Performing image recognition on the initial file to be processed and the target file to be processed to obtain image recognition results corresponding to the initial file to be processed and the target file to be processed.
[0104] Obtaining an initial file to be processed and a target file to be processed. Performing image recognition on the obtained initial file to be processed and the target file to be processed to identify pixels of the initial file to be processed and the target file to be processed, thereby obtaining image recognition results corresponding to the initial file to be processed and the target file to be processed.
[0105] S170: Determine a target color pixel area in the image recognition result according to the image recognition result.
[0106] After obtaining the image recognition results corresponding to the to-be-processed initial file and the to-be-processed target file, pixels in the image recognition results are compared with target pixels according to the image recognition results to determine the target color pixel area in the image recognition results.
[0107] S180: Fill the target color pixel area with the surrounding pixels of the target color pixel area to obtain an initial file and a target file.
[0108] After determining the target color pixel region, the target color pixel region is filled with the surrounding pixels of the target color pixel region to obtain an initial file and a target file.
[0109] In one example, the target color pixel area may be filled with the surrounding pixels of the target color pixel area using an interpolation method based on surrounding pixels.
[0110] In another example, the target color pixel area may be filled based on the background color of the document.
[0111] In one example, image recognition may be performed on a contract document to identify a red seal area of the contract document, and the red seal area may be filled with white pixels surrounding the red seal area, thereby obtaining a contract document that is displayed more clearly.
[0112] The disclosed embodiment performs image recognition on the initial file to be processed and the target file to be processed, and fills the target color pixel area according to the image recognition result, so as to improve the clarity of the initial file and the target file, thereby improving the accuracy of subsequent text recognition on the initial file and the target file.
[0113] In one embodiment, Figure 3 As shown, based on the position information corresponding to the multiple recognized text blocks, the multiple recognized text blocks located in the same row are merged to obtain the horizontal text corresponding to the initial file and the target file, which may include step S121 and step S122.
[0114] S121: Based on the position information of the multiple recognized text blocks, the multiple recognized text blocks located in the same line are merged to obtain multiple text lines.
[0115] According to the position information of the multiple recognized text blocks, the multiple recognized text blocks located in the same line are merged to obtain multiple text lines.
[0116] In an example, there are 5 lines of content in the file, each line includes two recognized text blocks, and the recognized text blocks in the same line are merged to obtain 5 text lines.
[0117] S122: Merge multiple text lines to obtain horizontal text corresponding to the initial file and the target file.
[0118] Merge multiple text lines to obtain horizontal text corresponding to the original and target files.
[0119] The embodiment of the present disclosure merges multiple recognized text blocks located in the same line to obtain multiple text lines, and then merges the multiple text lines, so that horizontal text can be determined based on the line information of the recognized text blocks.
[0120] In one embodiment, Figure 4 As shown, based on the position information of multiple recognized text blocks, multiple recognized text blocks located in the same line are merged to obtain multiple text lines, which may include steps S1211-S1215.
[0121] S1211: Based on the position information of the plurality of recognized text blocks, the distance between adjacent recognized text blocks in the same row is compared with a preset distance threshold to obtain a second comparison result.
[0122] According to the position information of the plurality of recognized text blocks, the distance between any adjacent recognized text blocks in the same row of recognized text blocks is compared with a preset distance threshold to obtain a second comparison result.
[0123] S1212: When the second comparison result indicates that the distance between adjacent recognized text blocks in the same row is less than a preset distance threshold, merge adjacent recognized text blocks in the same row to obtain a first text row.
[0124] If the distance between adjacent recognized text blocks in the same row is less than a preset distance threshold, the adjacent recognized text blocks in the same row are merged to obtain a first text row.
[0125] S1213: Determine a first separator when the second comparison result indicates that the distance between adjacent recognized text blocks located in the same row is greater than or equal to a preset distance threshold.
[0126] If the distance between adjacent recognized text blocks in the same row is greater than or equal to a preset distance threshold, a first separator is determined.
[0127] The first separator is used to be placed between adjacent recognized text blocks in the same row whose distance is greater than or equal to a preset distance threshold.
[0128] S1214: Merge adjacent recognized text blocks and the first separator in the same line to obtain a second text line.
[0129] After the first separator is determined, adjacent recognized text blocks and the first separator located in the same line are merged to obtain a second text line.
[0130] In one example, if there are two recognized text blocks in the first line of a file and the distance between the two recognized text blocks is greater than a preset distance threshold, a first separator is set between the two recognized text blocks, and the two recognized text blocks and the first separator are merged to obtain a text line containing the first separator.
[0131] S1215: Merge the first text line and the second text line to obtain multiple text lines.
[0132] After obtaining the first text line and the second text line, the first text line and the second text line are merged to obtain a plurality of text lines.
[0133] The embodiment of the present disclosure obtains different text lines according to the distances between adjacent recognized text blocks located in the same line, and can accurately reflect the distance difference information between adjacent recognized text blocks in a text line.
[0134] In one embodiment, Figure 5 As shown, based on the position information corresponding to multiple recognized text blocks, according to the first comparison result of the number of first separators in two adjacent rows of multiple recognized text blocks and a preset number threshold, multiple recognized text blocks located in the same column are merged to obtain vertical text corresponding to the initial file and the target file, which may include steps S131-S133.
[0135] S131: Compare the number of first separators included in any two adjacent lines of a plurality of text lines with a preset number threshold to obtain a first comparison result.
[0136] The number of first separators included in any two adjacent lines of the plurality of text lines is calculated and compared with a preset number threshold to obtain a first comparison result.
[0137] S132: Determine a second separator when the first comparison result indicates that the number of first separators included in any two adjacent lines of the plurality of text lines is greater than or equal to a preset number threshold.
[0138] If the number of first separators included in any two adjacent lines of the plurality of text lines is greater than or equal to a preset number threshold, a second separator is determined.
[0139] The second separator is used to be placed between adjacent recognized text blocks in the same column.
[0140] The disclosed embodiment determines the second separator by comparing the number of first separators with a preset number threshold, which can reflect the existence of structural information such as a table or paragraph between two adjacent rows.
[0141] S133: Based on the position information of the plurality of recognized text blocks, the recognized text blocks in the same column of the adjacent text rows whose number of first delimiters is greater than or equal to a preset number threshold are merged with the second segmentation mark to obtain vertical text corresponding to the initial file and the target file.
[0142] After determining the second separator, based on the position information of multiple recognized text blocks, the recognized text blocks located in the same column in adjacent text rows whose number of first separators is greater than or equal to a preset number threshold are merged with the second segmentation to obtain vertical text corresponding to the initial file and the target file.
[0143] The embodiment of the present disclosure determines the second separator by comparing the number of first separators with a preset number threshold, and merges the recognized text blocks located in the same column in adjacent text rows in which the number of first separators is greater than or equal to the preset number threshold with the second segmentation, thereby being able to determine the vertical text based on the column information of the recognized text blocks.
[0144] In one embodiment, Figure 6 As shown, according to the comparison results of the horizontal text similarity between the initial file and the target file and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds, the horizontal comparison result and the vertical comparison result are obtained, which may include steps S141-S144.
[0145] S141: Calculate the similarity of the recognized text blocks with the same position information in the horizontal text of the initial file and the target file to obtain a first similarity.
[0146] After obtaining the horizontal texts of the initial file and the target file, similarities of recognized text blocks with the same position information in the horizontal texts of the initial file and the target file are calculated to obtain a first similarity.
[0147] S142: When the first similarity is less than a first similarity threshold, obtain a horizontal comparison result.
[0148] If the first similarity is less than the first similarity threshold, a horizontal comparison result is obtained.
[0149] Among them, the horizontal comparison result represents the existence of character differences in the recognized text block.
[0150] S143: Calculate the similarity of the recognized text blocks with the same position information in the vertical text of the initial file and the target file to obtain a second similarity.
[0151] After obtaining the vertical texts of the initial file and the target file, the similarity of the recognized text blocks with the same position information in the vertical texts of the initial file and the target file is calculated to obtain a second similarity.
[0152] S144: When the second similarity is less than the second similarity threshold, obtain a longitudinal comparison result.
[0153] If the second similarity is less than the second similarity threshold, a vertical comparison result is obtained.
[0154] The disclosed embodiment can accurately determine the recognized text blocks where the difference characters appear by comparing the similarities of the horizontal text and the vertical text of the initial file and the target file respectively.
[0155] In one embodiment, Figure 7 As shown, combining the horizontal comparison result and the vertical comparison result to obtain the target comparison result may include steps S151-S159.
[0156] S151: Combine the horizontal comparison result and the vertical comparison result to obtain an initial comparison result.
[0157] After obtaining the horizontal comparison result and the vertical comparison result, the horizontal comparison result and the vertical comparison result are combined to obtain the initial comparison result.
[0158] In one example, the horizontal comparison result and the vertical comparison result may be combined according to the position information of the text recognition blocks corresponding to the horizontal comparison result and the vertical comparison result to obtain an initial comparison result.
[0159] S152: Classify the initial comparison result according to the character type to obtain a first classification comparison result.
[0160] After the initial comparison result is obtained, the characters corresponding to the initial comparison result are determined, and the initial comparison result is classified according to character types based on the characters corresponding to the initial comparison result to obtain a first classification comparison result.
[0161] The first classification comparison result corresponds to a text character or a symbol character, that is, the first classification comparison result indicates that the corresponding characters have a text character difference or a symbol character difference.
[0162] S153: According to the position information of the recognized text block corresponding to the first classification comparison result, a first target sentence in the recognized text block corresponding to the first classification comparison result is obtained from the target file.
[0163] According to the first classification comparison result, the position information of the recognized text block corresponding to the first classification comparison result is determined. Based on the position information, the first target sentence in the recognized text block corresponding to the first classification comparison result is obtained from the target file.
[0164] In one example, the first classification comparison result indicates that a character in the third recognized text block in the second line of the file has a text symbol difference. Then, the first target sentence including the different character in the third recognized text block in the second line of the file is found according to the first classification comparison result.
[0165] S154: Input the first target sentence into the target model, and use the target model to recognize the semantic information of the first target sentence to obtain a semantic recognition result.
[0166] After the first target sentence is acquired, the first target sentence is input into the target model, and the semantic information of the first target sentence is recognized by the target model to obtain a semantic recognition result.
[0167] S155: Process the semantic recognition result to obtain a processed sentence.
[0168] After obtaining the semantic recognition result, the semantic recognition result is processed to obtain a processed sentence.
[0169] In one example, the semantic recognition result of the first target sentence is "The following goods were received today", and the semantic recognition result of the first target sentence is subjected to logic correction processing to obtain the processed sentence "The following goods were received today".
[0170] The disclosed embodiment can reduce the semantic logic error rate of the first target sentence by processing the semantic recognition result.
[0171] S156: Obtain a second target sentence in the recognition text block corresponding to the first classification comparison result in the initial file.
[0172] According to the position information of the recognized text block corresponding to the first classification comparison result, a second target sentence in the recognized text block corresponding to the first classification comparison result in the initial file is obtained.
[0173] There are corresponding difference characters between the second target sentence and the first target sentence.
[0174] S157: Compare the similarity between the processed sentence and the semantic information of the second target sentence with a third similarity threshold to obtain a third comparison result.
[0175] The similarity between the semantic information of the processed sentence and the semantic information of the second target sentence is calculated and compared with a third similarity threshold to obtain a third comparison result.
[0176] S158: When the third comparison result represents that the similarity between the semantic information of the processed sentence and the second target sentence is greater than or equal to a third similarity threshold, the first classification comparison result is determined to be a fourth comparison result.
[0177] If the similarity between the processed sentence and the semantic information of the second target sentence is greater than or equal to the third similarity threshold, the first classification comparison result is determined as the fourth comparison result.
[0178] In one example, if the similarity of semantic information between the processed sentence and the second target sentence is 84%, which is greater than or equal to the third similarity threshold of 70%, the difference characters between the first target sentence and the second target sentence are marked as "suspected to be the same", and the reason for the character difference may be due to an error in optical character recognition.
[0179] S159: Remove the fourth comparison result from the initial comparison result to obtain a target comparison result.
[0180] The fourth comparison result in the initial comparison result is removed to obtain the target comparison result.
[0181] The disclosed embodiment can determine whether the recognized character difference is caused by a recognition error by comparing the similarity of the semantic information of the semantically processed sentence and the second target sentence, thereby improving the accuracy of subsequent comparison between the initial file and the target file.
[0182] In one example, if the similarity of semantic information between the processed sentence and the second target sentence is 20%, which is less than the third similarity threshold of 70%, the difference characters between the first target sentence and the second target sentence are marked as "definitely different".
[0183] In one embodiment, Figure 8 As shown, after the horizontal comparison result and the vertical comparison result are combined to obtain the target comparison result, the method for processing file data further includes steps S210-S240.
[0184] S210: According to the position information of the recognition text block corresponding to the target comparison result, the recognition text blocks with adjacent position information corresponding to the target comparison result are merged to obtain the target recognition text block.
[0185] After obtaining the target comparison result, the recognized text blocks with character differences are determined according to the position information of the recognized text blocks corresponding to the target comparison result. If there are character differences in adjacent recognized text blocks, the recognized text blocks with adjacent position information corresponding to the target comparison result are merged to obtain the target recognized text block.
[0186] S220: Calculate the similarity between the difference characters corresponding to the target comparison result and the characters of the target recognition text block to obtain a fourth similarity.
[0187] Based on the target comparison result, the difference character corresponding to the target comparison result is determined, and the similarity between the difference character and the character of the target recognition text block is calculated to obtain a fourth similarity.
[0188] S230: When the fourth similarity is greater than a fourth similarity threshold, determine the character of the target recognition text block as a target character.
[0189] If the fourth similarity is greater than the fourth similarity threshold, the character of the target recognition text block is determined as the target character, that is, the difference character.
[0190] The present disclosure can accurately determine the specific position information of the difference characters in the target recognition text block, that is, the position information of the target characters, by comparing the similarity between the difference characters and the characters in the target recognition text block.
[0191] S240: Visually mark the target character.
[0192] After the target character is determined, visual markings are made around the target character.
[0193] In one example, the steps for visually marking the target characters can be: 1. Use different colors to distinguish between "definitely different" characters and "suspectedly the same" characters. For example, red can be used to mark "definitely different" and yellow can be used to mark "suspectedly different". 3. Add an indicator arrow or description at each difference to show the specific changes from the initial file to the target file. 3. Overlay the marking information as a separate layer on the initial file so that users can easily switch to view.
[0194] The disclosed embodiment determines the target character by comparing the similarity with the similarity threshold, and visually marks the target character, thereby improving the review efficiency of comparing the initial file with the target file.
[0195] In one example, the steps of processing file data are as follows: Fig. 9As shown, in S901, the initial file and the target file are preprocessed. In S902, the initial file and the target file are subjected to text recognition processing to obtain text recognition results. In S903, the text recognition results of the initial file and the target file are subjected to text structuring processing to obtain structuring processing results. In S904, the structuring processing results of the initial file and the target file are merged in line to obtain a preliminary merging result. In S905, it is determined whether the preliminary merging result has a table structure. If the preliminary merging result has a table structure, S906 is executed to merge the table structure in the preliminary merging result by column to obtain the target merging result. If the preliminary merging result does not have a table structure, S907 is executed to merge the preliminary merging result by page to obtain the target merging result. In S908, it is determined whether there is a difference between the target merging results of the initial file and the target file. If there is a difference, S909 is executed to perform a difference judgment. If the difference judgment is true, S910 is executed to mark the difference as "determined to be different". If the difference is judged to be false, S911 is executed to mark the difference as "suspected to be the same".
[0196] like Fig.10 As shown, the embodiment of the present disclosure further provides a device 1000 for processing file data, and the device 1000 for processing file data includes:
[0197] The recognition module 1001 is used to perform text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively;
[0198] A merging module 1002 is used to merge multiple recognized text blocks located in the same row based on position information corresponding to the multiple recognized text blocks to obtain horizontal text corresponding to the initial file and the target file;
[0199] The merging module 1002 is further used to merge the multiple recognized text blocks located in the same column based on the position information corresponding to the multiple recognized text blocks and according to a first comparison result of the number of first separators in two adjacent rows of the multiple recognized text blocks and a preset number threshold, so as to obtain vertical text corresponding to the initial file and the target file, wherein the first separator is determined according to a second comparison result of the distance between the multiple recognized text blocks and a preset distance threshold;
[0200] A comparison module 1003 is used to obtain a horizontal comparison result and a vertical comparison result according to the comparison results of the horizontal text similarity between the initial file and the target file, and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds respectively;
[0201] The merging module 1002 is further used to merge the horizontal comparison result and the vertical comparison result to obtain a target comparison result, where the target comparison result corresponds to the different characters.
[0202] The present disclosure can determine the differences between the initial file and the target file in terms of rows and columns by acquiring the horizontal text and the vertical text, thereby improving the accuracy of the file comparison.
[0203] In some embodiments, the identification module 1001 is specifically configured to:
[0204] Performing image recognition on the initial file to be processed and the target file to be processed to obtain image recognition results corresponding to the initial file to be processed and the target file to be processed;
[0205] According to the image recognition result, determining the target color pixel area in the image recognition result;
[0206] The target color pixel area is filled with the surrounding pixels of the target color pixel area to obtain an initial file and a target file.
[0207] In some embodiments, the merging module 1002 is specifically configured to:
[0208] Based on the position information of the multiple recognized text blocks, the multiple recognized text blocks located in the same line are merged to obtain multiple text lines;
[0209] Merge multiple text lines to obtain horizontal text corresponding to the original and target files.
[0210] In some embodiments, the comparison module 1003 is specifically configured to:
[0211] Based on the position information of the plurality of recognized text blocks, the distance between adjacent recognized text blocks located in the same row is compared with a preset distance threshold to obtain a second comparison result;
[0212] When the second comparison result indicates that the distance between adjacent recognized text blocks in the same row is less than a preset distance threshold, merging adjacent recognized text blocks in the same row to obtain a first text row;
[0213] If the second comparison result indicates that the distance between adjacent recognized text blocks located in the same row is greater than or equal to a preset distance threshold, determining a first separator;
[0214] Merge adjacent recognized text blocks and the first separator in the same line to obtain a second text line;
[0215] The first text line and the second text line are merged to obtain multiple text lines.
[0216] In some embodiments, the comparison module 1003 is specifically configured to:
[0217] Comparing the number of first separators included in any two adjacent lines of the plurality of text lines with a preset number threshold, to obtain a first comparison result;
[0218] If the first comparison result indicates that the number of first separators included in any two adjacent lines of the plurality of text lines is greater than or equal to a preset number threshold, determining a second separator;
[0219] Based on the position information of multiple recognized text blocks, recognized text blocks located in the same column in adjacent text rows whose number of first delimiters is greater than or equal to a preset number threshold are merged with the second segmentation mark to obtain vertical text corresponding to the initial file and the target file.
[0220] In some embodiments, the device 1000 for processing file data further includes a calculation module, which is used to calculate the similarity of the identified text blocks with the same position information in the horizontal text of the initial file and the target file to obtain a first similarity;
[0221] When the first similarity is less than the first similarity threshold, a horizontal comparison result is obtained;
[0222] Calculating the similarity of the recognized text blocks with the same position information in the vertical text of the initial file and the target file to obtain a second similarity;
[0223] When the second similarity is less than the second similarity threshold, a vertical comparison result is obtained.
[0224] In some embodiments, the merging module 1002 is specifically configured to:
[0225] Combine the horizontal comparison results and the vertical comparison results to obtain the initial comparison results;
[0226] Classifying the initial comparison result according to the character type to obtain a first classification comparison result, where the first classification comparison result corresponds to a text character or a symbol character;
[0227] According to the position information of the recognized text block corresponding to the first classification comparison result, obtaining a first target sentence in the recognized text block corresponding to the first classification comparison result from the target file;
[0228] Inputting the first target sentence into the target model, and using the target model to recognize semantic information of the first target sentence to obtain a semantic recognition result;
[0229] Processing the semantic recognition results to obtain processed sentences;
[0230] Obtain a second target sentence in the recognition text block corresponding to the first classification comparison result in the initial file;
[0231] comparing the similarity of the semantic information of the processed sentence and the second target sentence with a third similarity threshold to obtain a third comparison result;
[0232] If the third comparison result represents that the similarity between the semantic information of the processed sentence and the second target sentence is greater than or equal to a third similarity threshold, the first classification comparison result is determined to be a fourth comparison result;
[0233] The fourth comparison result in the initial comparison result is removed to obtain a target comparison result.
[0234] In some embodiments, the merging module 1002 is specifically configured to:
[0235] According to the position information of the recognition text block corresponding to the target comparison result, the recognition text blocks with adjacent position information corresponding to the target comparison result are merged to obtain the target recognition text block;
[0236] Calculating the similarity between the difference characters corresponding to the target comparison result and the characters of the target recognition text block to obtain a fourth similarity;
[0237] When the fourth similarity is greater than a fourth similarity threshold, determining the character of the target recognition text block as the target character;
[0238] Visually mark the target characters.
[0239] Fig.10 Each module / unit in the device shown has the function of realizing Figures 1 to 8 The functions of each step executed by the application system in the present invention can achieve the corresponding technical effects. For the sake of brevity, they will not be repeated here.
[0240] Fig.11 A schematic diagram of the hardware structure for processing file data provided by an embodiment of the present disclosure is shown.
[0241] The device for processing file data may include a processor 1101 and a memory 1102 storing computer program instructions.
[0242] Specifically, the processor 1101 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0243] The memory 1102 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 1102 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 1102 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 1102 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 1102 is a non-volatile solid-state memory.
[0244] The memory 1102 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of the present disclosure.
[0245] The processor 1101 implements any one of the file data processing methods in the above embodiments by reading and executing computer program instructions stored in the memory 1102 .
[0246] In one example, the device for processing file data may further include a communication interface 1103 and a bus 1104. Fig.11 As shown, the processor 1101, the memory 1102, and the communication interface 1103 are connected via a bus 1104 and communicate with each other.
[0247] The communication interface 1103 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0248] Bus 1104 includes hardware, software or both, and couples the components of online data flow billing equipment to each other. For example, but not limitation, the bus may include Accelerated Graphics Port (AGP) or other graphics bus, Enhanced Industry Standard Architecture (EISA) bus, Front Side Bus (FSB), Hyper Transport (HT) interconnection, Industry Standard Architecture (ISA) bus, InfiniBand interconnection, Low Pin Count (LPC) bus, Memory bus, Micro Channel Architecture (MCA) bus, Peripheral Component Interconnect (PCI) bus, PCI-Express (PCI-X) bus, Serial Advanced Technology Attachment (SATA) bus, Video Electronics Standards Association Local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 1104 may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection. In addition, in conjunction with the method for processing file data in the above embodiment, the present application embodiment also provides a computer storage medium to implement. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the file data processing methods in the above embodiments is implemented.
[0249] An embodiment of the present application also provides a computer program product, including a computer program, which implements any one of the file data processing methods in the above embodiments when the computer program is executed by a processor.
[0250] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0251] The functional blocks shown in the above structural block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), appropriate firmware, plug-in, function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or communication link by a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (Read-Only Memory, ROM), flash memory, erasable read-only memory (Erasable ReadOnly Memory, EROM), floppy disks, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical discs, hard disks, optical fiber media, radio frequency (Radio Frequency, RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0252] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.
[0253] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0254] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be covered within the protection scope of the present invention.
Claims
1. A method for processing file data, characterized in that: include: Performing text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively; Based on the position information corresponding to the multiple recognized text blocks, multiple recognized text blocks located in the same row are merged to obtain horizontal text corresponding to the initial file and the target file; Based on the position information corresponding to the plurality of recognized text blocks, and according to a first comparison result between the number of first separators in two adjacent rows of the plurality of recognized text blocks and a preset number threshold, the plurality of recognized text blocks located in the same column are merged to obtain vertical text corresponding to the initial file and the target file, wherein the first separator is determined according to a second comparison result between the distance between the plurality of recognized text blocks and a preset distance threshold; Obtaining a horizontal comparison result and a vertical comparison result according to the comparison results of the horizontal text similarity between the initial file and the target file, and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds; The horizontal comparison result and the vertical comparison result are combined to obtain a target comparison result, wherein the target comparison result corresponds to the different characters.
2. The method according to claim 1, characterized in that Before performing text recognition on the initial file and the target file to obtain a plurality of recognized text blocks corresponding to the initial file and the target file respectively, the method further includes: Performing image recognition on the initial file to be processed and the target file to be processed to obtain image recognition results corresponding to the initial file to be processed and the target file to be processed; According to the image recognition result, determining a target color pixel area in the image recognition result; The target color pixel area is filled with surrounding pixels of the target color pixel area to obtain the initial file and the target file.
3. The method according to claim 1, characterized in that: The step of merging the multiple recognized text blocks located in the same row based on the position information corresponding to the multiple recognized text blocks to obtain the horizontal text corresponding to the initial file and the target file includes: Based on the position information of the multiple recognized text blocks, multiple recognized text blocks located in the same line are merged to obtain multiple text lines; The multiple text lines are merged to obtain horizontal text corresponding to the initial file and the target file.
4. The method according to claim 3, characterized in that The step of merging the multiple recognized text blocks located in the same row based on the position information of the multiple recognized text blocks to obtain multiple text rows includes: Based on the position information of the plurality of recognized text blocks, comparing the distance between adjacent recognized text blocks located in the same row with the preset distance threshold to obtain the second comparison result; When the second comparison result indicates that the distance between the adjacent recognized text blocks in the same row is less than the preset distance threshold, merging the adjacent recognized text blocks in the same row to obtain a first text row; If the second comparison result indicates that the distance between the adjacent recognized text blocks located in the same row is greater than or equal to the preset distance threshold, determining a first separator; Merging the adjacent recognized text blocks and the first separator in the same row to obtain a second text row; The first text line and the second text line are merged to obtain the multiple text lines.
5. The method according to claim 4, characterized in that The method of merging the multiple recognized text blocks located in the same column based on the position information corresponding to the multiple recognized text blocks and according to a first comparison result between the number of first separators in two adjacent rows of the multiple recognized text blocks and a preset number threshold value to obtain vertical text corresponding to the initial file and the target file includes: Comparing the number of first separators included in any two adjacent lines of the plurality of text lines with a preset number threshold to obtain the first comparison result; If the first comparison result indicates that the number of first separators included in any two adjacent lines of the plurality of text lines is greater than or equal to the preset number threshold, determining a second separator; Based on the position information of the multiple recognized text blocks, the recognized text blocks located in the same column in adjacent text rows whose number of the first separators is greater than or equal to the preset number threshold are merged with the second separator to obtain vertical text corresponding to the initial file and the target file.
6. The method according to claim 1, characterized in that The step of obtaining a horizontal comparison result and a vertical comparison result based on the comparison results of the horizontal text similarity between the initial file and the target file and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds includes: Calculating the similarity of the identified text blocks with the same position information in the horizontal text of the initial file and the target file to obtain a first similarity; When the first similarity is less than a first similarity threshold, obtaining the horizontal comparison result; Calculating the similarity of the identified text blocks with the same position information in the vertical text of the initial file and the target file to obtain a second similarity; When the second similarity is less than a second similarity threshold, the vertical comparison result is obtained.
7. The method according to claim 1, characterized in that The combining the horizontal comparison result and the vertical comparison result to obtain a target comparison result includes: Combining the horizontal comparison result and the vertical comparison result to obtain an initial comparison result; Classifying the initial comparison result according to the character type to obtain a first classification comparison result, wherein the first classification comparison result corresponds to a text character or a symbol character; Acquire, from the target file, a first target sentence in the recognized text block corresponding to the first classified comparison result according to the position information of the recognized text block corresponding to the first classified comparison result; Inputting the first target sentence into a target model, and using the target model to recognize semantic information of the first target sentence to obtain a semantic recognition result; Processing the semantic recognition result to obtain a processed sentence; Obtain a second target sentence in the recognition text block corresponding to the first classification comparison result in the initial file; comparing the similarity of the semantic information of the processed sentence and the second target sentence with a third similarity threshold to obtain a third comparison result; When the third comparison result indicates that the similarity between the semantic information of the processed sentence and the second target sentence is greater than or equal to the third similarity threshold, determining the first classification comparison result as a fourth comparison result; The fourth comparison result in the initial comparison result is removed to obtain the target comparison result.
8. The method according to claim 1, characterized in that After combining the horizontal comparison result and the vertical comparison result to obtain a target comparison result, the method further includes: According to the position information of the recognition text block corresponding to the target comparison result, the recognition text blocks adjacent to the position information corresponding to the target comparison result are merged to obtain the target recognition text block; Calculating the similarity between the difference characters corresponding to the target comparison result and the characters of the target recognition text block to obtain a fourth similarity; In the case where the fourth similarity is greater than a fourth similarity threshold, determining the character of the target recognition text block as the target character; The target character is visually marked.
9. A device for processing file data, characterized in that: The device comprises: A recognition module, the recognition module is used to perform text recognition on the initial file and the target file to obtain a plurality of recognition text blocks corresponding to the initial file and the target file respectively; A merging module, the merging module is used to merge multiple recognized text blocks located in the same row based on the position information corresponding to the multiple recognized text blocks, so as to obtain horizontal text corresponding to the initial file and the target file; The merging module is further used to merge the multiple recognized text blocks located in the same column based on the position information corresponding to the multiple recognized text blocks and according to a first comparison result of the number of first separators in two adjacent rows of the multiple recognized text blocks and a preset number threshold, so as to obtain vertical text corresponding to the initial file and the target file, wherein the first separator is determined according to a second comparison result of the distance between the multiple recognized text blocks and a preset distance threshold; A comparison module, the comparison module is used to obtain a horizontal comparison result and a vertical comparison result according to the comparison results of the horizontal text similarity between the initial file and the target file, and the vertical text similarity between the initial file and the target file with the corresponding similarity thresholds respectively; The merging module is further used to merge the horizontal comparison result and the vertical comparison result to obtain a target comparison result, wherein the target comparison result corresponds to different characters.
10. A device for processing file data, characterized in that: The device comprises: a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the method for processing file data according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method for processing file data according to any one of claims 1 to 8 is implemented.
12. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the method for processing file data according to any one of claims 1 to 8.
Citation Information
Cited By
Contract text comparison detection method and device and electronic equipment
CN119670724A