A method, device, computer storage medium and terminal for realizing character recognition

By combining multi-character recognition technology and OCR technology, the problems of missed and incorrect character detection in PDF documents have been solved, achieving accurate character positioning and recognition in PDF documents and improving the accuracy of character recognition.

CN115393883BActive Publication Date: 2026-06-02ZHUHAI KINGSOFT OFFICE SOFTWARE +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHUHAI KINGSOFT OFFICE SOFTWARE
Filing Date
2021-05-25
Publication Date
2026-06-02

Smart Images

  • Figure CN115393883B_ABST
    Figure CN115393883B_ABST
Patent Text Reader

Abstract

A method, device, computer storage medium and terminal for realizing character recognition, the embodiment of the present application acquires a character image containing a preset number of characters based on a PDF document, and performs multi-word recognition on the character image; in the case that the result of multi-word recognition contains a preset number of characters, the final recognition result of the characters contained in the PDF document is determined according to the result of multi-word recognition. The embodiment of the present application can read and render the characters in the PDF file, can determine which character in the PDF the character image corresponds to, in the case that the result of multi-word recognition contains a preset number of characters, the quick confirmation of missed detection or multiple detection is realized, and the accuracy of character recognition is improved according to the result of multi-word recognition; the recognized result is converted into a uniform code (Unicode) and attached to the corresponding character of the PDF, and the accurate recognition of the characters contained in the PDF document is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to, but is not limited to, automated office application technologies, and in particular to a method, device, computer storage medium, and terminal for character recognition. Background Technology

[0002] In portable document format (PDF) documents, if the Unicode information for characters is missing, garbled characters will appear when copying and pasting text content. To eliminate garbled characters, related technologies use optical character recognition (OCR) technology to recognize the text and obtain Unicode information, and then use the obtained Unicode information to repair the garbled characters.

[0003] The aforementioned OCR recognition technology may experience character omissions or errors when repairing garbled text if the PDF document is not properly positioned, the scanned image is skewed, the scanning resolution is low (e.g., less than 300 dots per inch (dpi)), or the PDF document has background shading. This is especially true for punctuation marks and special characters, where the probability of omissions or errors is even higher, thus reducing the effectiveness of garbled text repair. Summary of the Invention

[0004] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.

[0005] This invention provides a method, apparatus, computer storage medium, and terminal for character recognition, which can improve the effect of repairing garbled characters in PDFs.

[0006] This invention provides a method for character recognition, comprising:

[0007] Obtain character images containing a preset number of characters from PDF documents, and perform multi-character recognition on the character images;

[0008] If the result of the multi-character recognition includes a preset number of characters, the final recognition result of the characters contained in the PDF document is determined based on the result of the multi-character recognition.

[0009] On the other hand, embodiments of the present invention also provide a computer storage medium storing a computer program, which, when executed by a processor, implements the above-described method for character recognition.

[0010] Furthermore, embodiments of the present invention also provide a terminal, comprising: a memory and a processor, wherein the memory stores a computer program; wherein,

[0011] The processor is configured to execute computer programs in memory;

[0012] When the computer program is executed by the processor, it implements the character recognition method as described above.

[0013] Furthermore, embodiments of the present invention also provide an apparatus for implementing character recognition, comprising: a multi-character recognition unit and a determination unit; wherein,

[0014] The multi-character recognition unit is configured to: acquire a character image containing a preset number of characters based on a PDF document, and perform multi-character recognition on the character image;

[0015] The determination unit is set as follows: when the result of multi-character recognition contains a preset number of characters, the final recognition result of the characters contained in the PDF document is determined based on the result of multi-character recognition.

[0016] This invention provides an embodiment of the invention that acquires character images containing a preset number of characters from a PDF document and performs multi-character recognition on these images. If the multi-character recognition result contains the preset number of characters, the final recognition result for the characters contained in the PDF document is determined based on the multi-character recognition result. This invention reads and renders characters in a PDF file, determining which specific character the character image corresponds to in the PDF. When the multi-character recognition result contains the preset number of characters, it achieves rapid confirmation of missed or over-detection and improves the accuracy of character recognition based on the multi-character recognition result. Subsequently, the Unicode encoding of the recognition result is appended to the corresponding character in the PDF, achieving accurate recognition of the characters contained in the PDF document.

[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings. Attached Figure Description

[0018] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of the present invention and do not constitute a limitation on the technical solutions of the present invention.

[0019] Figure 1 This is a flowchart illustrating the method for character recognition according to an embodiment of the present invention;

[0020] Figure 2 This is a structural block diagram of a device for character recognition according to an embodiment of the present invention;

[0021] Figure 3 This is a schematic diagram of a character image spliced ​​as an application example of the present invention;

[0022] Figure 4 This is a schematic diagram of another spliced ​​character image as an application example of the present invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

[0024] The steps illustrated in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases the steps shown or described may be performed in a different order than that presented here.

[0025] Figure 1 The flowchart below shows the method for character recognition implemented in an embodiment of the present invention. Figure 1 As shown, it includes:

[0026] Step 101: Obtain a character image containing a preset number of characters based on a Portable Document Format (PDF) document, and perform multi-character recognition on the character image;

[0027] It should be noted that when copying text from a PDF, garbled characters often occur. The generation of a PDF is essentially a process of "virtual printing". "Virtual printing" indicates that this process is not a character recognition process. Its working principle is to arrange the specified text on the paper in accordance with the shapes recorded by coordinates and fonts; the entire process is completely unrelated to questions such as "what character is this". Similarly, the process of a PDF drawing text is simply to extract the characters (glyphs) at specific code positions from the font resource file and place them at a certain coordinate position. Characters in a computer are distinguished and called through encoding. Currently, the most common and widespread encoding scheme is Unicode. On the other hand, in the font files embedded within a PDF, each character also has an encoding; when drawing text, the Tj / TJ command can request the required character from the font file through this encoding; these two sets of encodings can be (and often are in non-English environments) different, and the "bridge" between them is the ToUnicode property attached to the font; the value of ToUnicode is a mapping table (referred to as a charactermap / CMap), which gives the correspondence between the characters at each code position in the font file and the Unicode encoding. In operations such as copying and searching, a PDF relies on this CMap table to know what character each character actually is. If this table is lost, damaged, or maliciously tampered with, for example, for a PDF file that only contains the character "鹿" (deer), when opening the PDF file with a text editor, you can see <ba6f>The statement `Tj` draws the character encoded as 0xBA6F from the font file. Based on the cross-references of the PDF object (explained later), we find CMap, whose key part is: `1beginbfrange / `. <ba6f> <ba6f><2fc5> / endbfrange; This CMap tells the reader that the character encoded as 0x6ABF in the font file corresponds to U+2FC5 in Unicode; Looking up the Unicode code table, we can see that U+2FC5 is exactly the Chinese character '鹿'. If we change 2FC5 in the above code to 9A6C and then reopen the PDF file. Apparently, there seems to be no change in the file; but if you try to copy this character, you will find that the result is '马'; The reason for the above change is that '马' is exactly U+9A6C in Unicode. The above example shows that what you see in a PDF may not be what you get. As long as the content of / ToUnicode (or the / Encoding attribute for older or English PDFs) is missing or incorrect, the text copy will be garbled. At the same time, the display of the PDF will not be affected at all (because the text drawing is controlled by statements that are completely independent of the encoding). On the contrary, using the principle of the garbled fault, it is also possible to deliberately damage or modify the CMap, thus creating a file that appears normal but cannot be copied or searched at all, indirectly achieving the effect of encrypting the PDF.

[0028] That is to say, there are two character encodings stored in the PDF file. One is for rendering (the encoding corresponding to the font file), and the other is for copying (Unicode), and there is a mapping relationship between them. After subsequent character recognition including OCR, what actually needs to be determined is the Unicode encoding corresponding to the character. The embodiment of the present invention realizes the correction of the mapping relationship between the two character encodings through the result of subsequent OCR recognition. In addition, when reading characters in the embodiment of the present invention, the position of the read character in the PDF document can be recorded. There is a text object set on the PDF document, and this text object is aligned one by one with the character positions in the PDF document. After obtaining the Unicode encoding corresponding to the character through recognition, the Unicode encoding is placed at the position corresponding to the character, so that when the user copies the character, what is copied is the Unicode encoding corresponding to the character.

[0029] Step 102, when the result of multi-character recognition contains a preset number of characters, determine the final recognition result of the characters included in the PDF document according to the result of multi-character recognition.

[0030] In the embodiments of the present invention, multi-character recognition adopts the technology of optical character recognition (OCR). OCR refers to the process in which an electronic device (such as a scanner or a digital camera) examines the characters printed on paper, determines their shapes by detecting dark and bright patterns, and then translates the shapes into computer text using character recognition methods. That is, for printed characters, an optical method is used to convert the text in a paper document into an image file of black and white dot matrices, and the text in the image is converted into a text format by an identification software for further editing and processing by a word processing software. How to debug or use auxiliary information to improve the recognition accuracy is the most important topic of OCR, and the term ICR (Intelligent Character Recognition) thus emerges. The main indicators for measuring the performance of an OCR system include: rejection rate, misrecognition rate, recognition speed, friendliness of the user interface, stability of the product, ease of use, and feasibility, etc.

[0031] OCR recognition includes single-character recognition and multi-character recognition. For multi-character recognition, the characters in an image containing multiple characters need to be cut first, and after being cut into single characters, single-character recognition is performed. Among them, due to the limitations of the shooting conditions, character adhesion and broken strokes often occur, thus limiting the performance of the recognition system. Generally, a character recognition software is required to have a character cutting function.

[0032] Character recognition includes template matching and feature extraction. Among them, due to reasons such as the displacement of the text, the thickness, broken strokes, adhesion, and rotation of the strokes, it is more difficult to extract features. When there are problems with the quality of character cutting, situations of over-detection or missed detection are likely to occur. For example, cutting "饭糊了” into "饭米胡了” results in over-detection, and cutting "文武双全” into "斌双全” results in missed detection. In addition, there are also situations where the number of cut characters is the same but the cutting is incorrect, such as cutting "明月清风” into "日朋清风”. Generally, in multi-character recognition, the single characters obtained by cutting can be recognized in parallel to improve the efficiency of multi-character recognition. That is to say, when recognizing 10 characters, multi-character recognition can recognize 10 characters simultaneously, while single-character recognition needs to recognize 10 characters sequentially. However, the accuracy of single-character recognition is higher than that of multi-character recognition.

[0033] In this embodiment, when the result of multi-character recognition contains a preset number of characters, it can be preliminarily determined that there is no situation of missed detection or over-detection, and further, the final recognition result of the characters contained in the PDF document can be determined according to the result of multi-character recognition.

[0034] This invention provides an embodiment of the method for obtaining character images containing a preset number of characters from a PDF document and performing multi-character recognition on these images. If the multi-character recognition result contains the preset number of characters, the final recognition result for the characters contained in the PDF document is determined based on the multi-character recognition result. This invention reads and renders characters in a PDF file, determining which specific character the character image corresponds to in the PDF. When the multi-character recognition result contains the preset number of characters, it achieves rapid confirmation of missed or over-detection and improves the accuracy of character recognition based on the multi-character recognition result. Subsequently, the Unicode encoding of the recognition result is appended to the corresponding character in the PDF, achieving accurate recognition of the characters contained in the PDF document.

[0035] In one exemplary instance, embodiments of the present invention acquire a character image containing a preset number of characters from a PDF document, and perform multi-character recognition on the character image, including:

[0036] Read characters from a PDF document and render each character as a character image;

[0037] A preset number of character images are stitched together, and multi-character recognition is performed on the stitched character images.

[0038] In one exemplary embodiment, the character image of this invention may include an image of a preset size. In another exemplary embodiment, characters read from a PDF document can be rendered to the same size, for example, rendered as 50 pixels * 50 pixels. Rendering the read characters to the same size facilitates the determination of the number of characters included in the stitched character image later. Furthermore, it results in a well-formed stitched character image, which is beneficial for accurate character segmentation and classification when using Optical Character Recognition (OCR) for multi-character recognition, thus improving the accuracy of multi-character recognition. Specifically, this embodiment of the invention reads the characters first and then stitches them together, resulting in a more regular stitched image. Unlike methods that acquire an entire PDF image and then perform OCR recognition, this approach avoids the problems that can arise from different character formats within the PDF, leading to difficulties in character segmentation and affecting recognition efficiency, or difficulty in determining the position of the recognized character within the PDF.

[0039] In one exemplary embodiment, during the character reading process of this invention, the font, size, and other formats of the character can be determined. Based on the font, size, and other formats of the character, the format of the identified Unicode encoding can be adjusted to be consistent with the font, size, and other formats of the character, so that the position of the character in the PDF corresponds one-to-one.

[0040] In one exemplary embodiment, the character image splicing of this invention can refer to related technologies. The character images are spliced ​​according to the order of the characters in the PDF document. The length of the spliced ​​character image can be set by those skilled in the art based on the size of the character image, the computational performance of group recognition, or the number of characters in each line of text in the PDF. The splicing method can include: splicing more than one line of characters; or splicing more than one column of characters. Other splicing methods can be used in this embodiment, and are not limited here. For example, when the rendered character image is 50 pixels * 50 pixels, the computational performance of group recognition can be considered... Figure 3 The method shown involves stitching together a character image of 10 characters per line. Multi-character recognition includes existing recognition methods in related technologies, such as line recognition, for example, OCR recognition of the stitched image; embodiments of the present invention can also employ existing algorithms in related technologies to perform character recognition on the stitched character image. In an exemplary instance, before determining the final recognition result of the characters contained in the PDF document based on the multi-character recognition result, the method of this embodiment of the present invention further includes:

[0041] Determine the dimensions of the spliced ​​character images;

[0042] Based on the determined size of the spliced ​​character image, determine the number of characters contained in the spliced ​​character image;

[0043] The number of characters contained in the determined spliced ​​character image is a preset number.

[0044] In this embodiment of the invention, after setting the size of the character image, the number of characters can be counted simply and efficiently by determining the size of the spliced ​​character image. For example, if the preset size of the character image is 50 pixels * 50 pixels, then after splicing 10 character images, the spliced ​​character image is 500 * 50 pixels, and the number of characters contained in the spliced ​​character image is determined to be 10.

[0045] In one exemplary instance, when splicing a preset number of character images, the method of this embodiment of the invention further includes:

[0046] Record the number of character images that are spliced, which is a preset number.

[0047] This invention provides a convenient way to determine whether the number of characters obtained from multi-character recognition is the preset number by recording the number of spliced ​​character images and comparing it with a preset number.

[0048] In one exemplary instance, embodiments of the present invention read characters from a PDF document and render each character as a character image, including:

[0049] Determine if the character being read is a whitespace character;

[0050] The selected blank character is rendered as a blank image, and the blank image is the character image.

[0051] In one exemplary instance, according to an embodiment of the present invention, whitespace characters include characters that occupy space but are not displayed. Whitespace characters may include spaces and / or tabs, and may also include placeholders.

[0052] In one exemplary instance, when the characters read in this embodiment of the invention contain blank characters, during the process of counting whether the result of multi-character recognition contains a preset number of characters, each blank image is recorded as one character.

[0053] In one exemplary instance, if it is determined that the read character is a blank character before concatenating the character image, this embodiment of the invention records the position (index) of the blank character so that the character image can be concatenated according to the recorded position of the blank character during the character image concatenation process. See also Figure 3 Before splicing the character image, this embodiment of the invention determines that the fourth character read is a blank character. This embodiment of the invention records the blank character in the fourth position and splices the character image according to the recorded position of the blank character.

[0054] In one exemplary instance, before determining the final recognition result of the characters contained in the PDF document based on the multi-character recognition result, the method of this embodiment of the invention further includes:

[0055] If it is determined that the read characters contain whitespace characters, the results of multi-character recognition are corrected.

[0056] In one exemplary instance, embodiments of the present invention correct the result of multi-character recognition when it is determined that the read characters contain whitespace characters, including:

[0057] If it is determined that the read characters contain whitespace characters, whitespace characters are inserted into the multi-character recognition results according to the sorting position of the whitespace characters, and the confidence level of the whitespace characters is set to a preset value.

[0058] In certain text types (such as Chinese), OCR recognition cannot recognize whitespace characters. (See also...) Figure 3 For example, if the presence of whitespace characters is uncertain, the result obtained through multi-character recognition will inevitably omit the composition of whitespace characters, resulting in fewer than 10 characters being recognized, and leading to a direct determination of a missed detection. In this embodiment, when it is determined that the read characters contain whitespace characters, whitespace characters are inserted into the multi-character recognition result according to their sorting position. This avoids the error of directly determining the result as a missed detection, ensuring that whitespace characters are accurately represented in the multi-character recognition result, thus improving the accuracy of character recognition.

[0059] In addition, embodiments of the present invention can set the confidence level of blank characters. In one exemplary instance, the preset value can be set by those skilled in the art based on experience; for example, a value greater than 0.9 can be set.

[0060] In this embodiment of the invention, the confidence level refers to the probabilistic information used to evaluate the reliability of the OCR recognition result. The character confidence level information can be obtained through the following processing: inputting the character image of the PDF document into the OCR algorithm, extracting features from the network results in the OCR algorithm, and then using a softmax (a logistic regression model generalized to multi-classification problems) after each time slice of the Long Short-Term Memory (LSTM) network in the OCR algorithm. Each softmax outputs a probability value for a character, which is the confidence level value of the character.

[0061] In one exemplary instance, when the result of multi-character recognition includes a preset number of characters, this embodiment of the invention determines the final recognition result of the characters contained in a PDF document based on the result of multi-character recognition, including:

[0062] If the result of multi-character recognition contains a preset number of characters, the final recognition result is determined based on the confidence information of each character in the multi-character recognition result.

[0063] In this embodiment of the invention, the final recognition result is determined by confidence information for both the corrected multi-character recognition results that do not contain whitespace characters and those that do contain whitespace characters.

[0064] In one exemplary instance, embodiments of the present invention determine the final recognition result based on the confidence information of each character in the multi-character recognition result, including:

[0065] If the result of multi-character recognition contains characters with confidence information less than the confidence threshold, then perform single-character recognition on the characters with confidence information less than the confidence threshold.

[0066] The single-character recognition results of characters with confidence information less than the confidence threshold are overwritten with the results obtained when recognizing multiple characters to obtain the final recognition result.

[0067] In this embodiment of the invention, the confidence threshold can be set and adjusted by technicians based on experience. Based on the set confidence threshold, characters that may be incorrectly identified in the multi-character recognition results can be corrected through single-character recognition, thereby improving the accuracy of character recognition in PDF documents. The confidence threshold can be set by those skilled in the art based on experience; for example, it can be set to a value greater than 0.9 but less than 1. The specific value can be set by technicians based on the accuracy and processing speed of character recognition. Higher accuracy requirements allow for a larger confidence threshold. A higher confidence threshold means a relatively larger number of characters needing single-character recognition, resulting in more subsequent processing and thus a relatively higher processing speed. Assuming a confidence threshold of 0.9 is set, this embodiment of the invention performs single-character recognition on characters with a confidence level less than 0.9. Taking the multi-character recognition results shown in Table 2 as an example, this embodiment of the invention performs single-character recognition on the two characters with sorting numbers 5 and 9; the single-character recognition result overwrites the result obtained during multi-character recognition to obtain the final recognition result.

[0068] The single-character recognition method in this embodiment of the invention may include: performing character recognition on each character image based on an image classification algorithm; this embodiment of the invention may also use existing algorithms in related technologies to perform character recognition on character images.

[0069] In one exemplary instance, embodiments of the present invention determine the final recognition result based on the confidence information of each character in the multi-character recognition result, including:

[0070] If the confidence level of each character in the multi-character recognition result is greater than the preset confidence threshold, the multi-character recognition result is determined as the final recognition result.

[0071] For example, if the confidence threshold is set to 0.65, and the confidence of all characters in the multi-character recognition result is greater than 0.65, then the content in the multi-character recognition result will be used as the final recognition result.

[0072] In the multi-character recognition results of this invention, if the confidence information of each character is greater than the preset confidence threshold, the final recognition result can be efficiently determined by multi-character recognition alone, without the need for additional, time-consuming single-character recognition.

[0073] In one exemplary instance, the method of this embodiment of the invention further includes:

[0074] If the result of multi-character recognition is not the preset number of characters, it is determined that there is a recognition error in the multi-character recognition result.

[0075] In an exemplary example, the situation where the result of multi-character recognition in an embodiment of the present invention is not a preset number of characters may include: recognition errors such as missed detection or over-detection in multi-character recognition. Taking Figure 4 the spliced character image shown as an example, in the process of multi-character recognition, due to a recognition error, during the recognition of the character images at sorting serial numbers 2 and k at sorting serial number 3, an extra character 'e' is recognized, thus resulting in an over-detection error; if during the multi-character recognition process, two characters are recognized as one character, a missed detection problem will occur. For example, if the characters 'wen' and 'wu' are recognized as the character 'bin', the number of characters in the multi-character recognition result will be reduced.

[0076] In an exemplary example, when it is determined that there is a recognition error in the result of multi-character recognition, the method in an embodiment of the present invention further includes: performing single-character recognition on each character image in the spliced character image; determining the final recognition result according to the result of single-character recognition and the result of multi-character recognition. That is to say, in this embodiment, when there are missed detections, over-detections or low confidence in the recognition result in multi-character recognition, the single-character recognition method can be further used to correct the multi-character recognition to obtain a more accurate and reliable final recognition result.

[0077] In an exemplary example, the present invention embodiment determines the final recognition result according to the result of single-character recognition and the result of multi-character recognition, including:

[0078] Taking the difference in the number of characters between the result of single-character recognition and the result of multi-character recognition as the first quantity;

[0079] Editing the characters in the result of multi-character recognition according to a preset strategy and the first quantity to obtain multiple combinations of editing results, where each editing result contains a preset number of characters;

[0080] Determining the final recognition result according to the editing result and the result of single-character recognition.

[0081] It should be noted that for the situation including blank characters in an embodiment of the present invention, blank characters are also counted in the statistics of the number of characters included in the editing result of the present invention embodiment.

[0082] In addition, the multiple combinations of editing results in an embodiment of the present invention are determined according to the number of permutations and combinations that the characters of the first quantity can achieve in the result of multi-character recognition. For example, if the number of spliced character images is 5 and the number of characters obtained by multi-character recognition is 3, the number of permutations and combinations is the number of permutations and combinations of inserting 2 characters among 3 characters, that is

[0083] In one exemplary instance, embodiments of the present invention edit the characters in the multi-character recognition result according to a preset strategy and a first quantity, obtaining various combinations of edited results, including:

[0084] If the first quantity is greater than zero, determine multiple insertion combinations of inserting the first quantity of caret into the result of multi-character recognition, and obtain the editing result of multiple insertion combinations. The insertion combination includes the insertion position of the determined character and the number of characters inserted at the insertion position.

[0085] If the first number is less than zero, determine multiple deletion combinations of deleting the first number of characters from the multi-character recognition result, and obtain multiple insertion combinations for editing results. The deletion combination includes the characters to be deleted from the multi-character recognition result. For example, if the number of concatenated character images is 3 and the number of characters obtained from multi-character recognition is 5, then the number of permutations and combinations is the number of permutations and combinations for selecting 2 characters to delete from the 5 characters.

[0086] In one exemplary instance, the caret in this embodiment of the invention can be any pre-defined character. The insertion of the caret is solely for adjusting the position of characters in the multi-character recognition result, facilitating comparison between the multi-character recognition result and the single-character recognition result to determine the specific location where a missed or over-detection occurred. In one insertion combination, one or more target positions are selected before or after different characters, and one or more caret characters are inserted at the selected target positions, with the total number of caret characters inserted at all target positions being a first quantity.

[0087] In one exemplary instance, embodiments of the present invention determine the final recognition result based on the editing result and the single-character recognition result, including:

[0088] Each edit result is compared with the single character recognition result to determine the number of characters in each edit result that match the single character recognition result;

[0089] Based on the number of characters that match the recognition results in each editing result and the single character recognition result, the editing result used to determine the final recognition result is selected;

[0090] The selected edited results are compared with the results of single-character recognition to determine the final recognition result. Here, the selected edited results refer to the edited results chosen to determine the final recognition result.

[0091] In one exemplary instance, embodiments of the present invention select the edited result used to determine the final recognition result based on the number of characters whose recognition results match those of each edited result and the single-character recognition result, including:

[0092] If there is only one edit result with the largest number of characters that match the recognition result when the first number is greater than zero, the edit result will be used to determine the final recognition result.

[0093] If, when the first number is greater than zero and there are at least two edit results with the largest number of consistent characters, for each edit result with the largest number of consistent characters, the confidence of the recognition result at the insertion position is calculated. The edit result with the largest sum of confidence is used as the edit result used to determine the final recognition result.

[0094] In one exemplary instance, embodiments of the present invention select an editing result for determining the final recognition result, including:

[0095] If the first number is less than zero and there is only one edit result with the largest number of consistent characters, the edit result will be used to determine the final recognition result.

[0096] If the first number is less than zero and there are at least two edit results with the largest number of characters that match the recognition result, calculate the sum of the confidence scores of the deleted characters for each edit result with the largest number of characters that match the recognition result; and use the edit result with the largest sum of confidence scores as the edit result used to determine the final recognition result.

[0097] In one exemplary instance, embodiments of the present invention compare the selected editing results with the results of single-character recognition to determine the final recognition result, including:

[0098] Compare the selected editing results with the single-character recognition results;

[0099] If the character recognition results are consistent, the edited result will be taken as the final recognition result;

[0100] In cases where character recognition results are inconsistent, the recognition result with the higher confidence value will be taken as the final recognition result.

[0101] To clarify, this embodiment uses a specific example for illustration. Assume the spliced ​​character image is a 10-character image. Table 2 shows the results of multi-character recognition. Since the multi-character recognition result is 9 characters, not equal to 10 characters, this embodiment performs single-character recognition. Assume Table 3 shows the results of single-character recognition. Based on the examples in Tables 2 and 3, this embodiment determines the final recognition result according to the single-character recognition result and the multi-character recognition result, including: determining that the difference in the number of characters contained in the single-character recognition result and the multi-character recognition result is 1; because the difference in the number of characters is 1, in the multi-character recognition results in Table 2, each... Insert an insertion point; specifically, insert insertion point C1 before sorting number 1 in Table 2 for the first edit result; insert insertion point C2 before sorting number 2 in Table 2 for the second edit result; insert insertion point C3 before sorting number 3 in Table 2 for the third edit result; and so on, inserting insertion point C9 before sorting number 9 in Table 2 for the ninth edit result; insert insertion point C10 after sorting number 9 in Table 2 for the tenth edit result; compare each edit result with the single character recognition result to determine the accuracy of each edit result with the single character recognition result. The results show the number of characters with consistent recognition. The edit result with the largest number of consistent characters (e.g., containing 8 identical characters) is used as the edit result for determining the characters contained in the PDF document. If there is only one edit result with the largest number of consistent characters, that edit result is used. If there are two or more edit results with the largest number of consistent characters, each edit result with the largest number of consistent characters is further analyzed. Calculate the sum of confidence scores for the recognition results of the insertion point; take the edit result with the maximum sum of confidence scores as the edit result used to determine the recognition result of the character contained in the PDF document; if the edit result used to determine the recognition result of the character contained in the PDF document matches the single character recognition result, take that recognition result as the recognition result of the character contained in the PDF document; if the edit result used to determine the recognition result of the character contained in the PDF document does not match the single character recognition result, take the recognition result with the larger confidence score as the recognition result of the character contained in the PDF document.

[0102] Assuming the concatenated character image is Figure 4 The image shows 10 characters. Table 4 shows the results of multi-character recognition. Since the result of multi-character recognition is 11 characters, which is not equal to 10 characters, this embodiment of the invention performs single-character recognition. Assuming Table 5 shows the results of single-character recognition, based on the examples in Tables 4 and 5, this embodiment of the invention determines the final recognition result according to the results of single-character recognition and multi-character recognition, including: the difference (first quantity) between the number of characters in the recognition results contained in the single-character recognition result and the multi-character recognition result is 1; because the difference in character values ​​is 1, in the multi-character recognition result, one recognition result in a different sorting position is deleted each time to obtain the corresponding editing result; that is, in the multi-character recognition result in Table 4... In the character recognition results, one recognition result is deleted each time according to the character's sorting number. Specifically, the first deletion is of the recognition result with sorting number 1 in Table 4, resulting in the first edited result; the second deletion is of the recognition result with sorting number 2 in Table 4, resulting in the second edited result; the third deletion is of the recognition result with sorting number 3 in Table 4, resulting in the fourth edited result; and so on, with the tenth deletion being of the recognition result with sorting number 10 in Table 4, resulting in the tenth edited result; and the eleventh deletion is of the recognition result with sorting number 11 in Table 4, resulting in the eleventh edited result. Each edited result is then compared with the single-character recognition result to determine the accuracy of each edited result. The number of characters with identical recognition results in the single-character recognition results is used. The edit result with the largest number of identical characters (e.g., containing 9 identical characters, the number of identical characters is 9) is used as the edit result for determining the characters contained in the PDF document. If, in this application example, there is only one edit result with the largest number of identical characters, that edit result is used as the edit result for determining the characters contained in the PDF document. If there are two or more edit results with the largest number of identical characters, the result with the largest number of identical characters is used for each... The editing results are then used to calculate the sum of the confidence scores of the recognition results after deletion. The editing result with the maximum sum of confidence scores is used as the editing result for determining the recognition results of characters contained in the PDF document. If the editing result for determining the recognition results of characters contained in the PDF document matches the single character recognition result, that recognition result is used as the recognition result of the character contained in the PDF document. If the editing result for determining the recognition results of characters contained in the PDF document does not match the single character recognition result, the recognition result with the larger confidence score is used as the recognition result of the character contained in the PDF document.

[0103] In one exemplary instance, the method of this embodiment of the invention further includes:

[0104] Based on the final identification results, the PDF document is corrected for content.

[0105] The final recognition result determined in this embodiment of the invention, when the multi-character recognition result contains a preset number of characters, can determine the position of the character image in the PDF based on the rendered character image, and can correct the characters at the corresponding positions in the PDF by converting the recognition result into a Unicode. When whitespace characters are included, the multi-character recognition result is corrected to avoid the whitespace characters affecting content correction. For characters in the multi-character recognition result with confidence information less than the confidence threshold, the incorrectly recognized characters are corrected by covering them with single-character recognition results. In cases where the multi-character recognition result does not contain a preset number of characters and there are missed or over-detections, the edited result obtained by editing the characters in the multi-character recognition result based on a preset strategy and a first number is selected to determine the final recognition result. By comparing the edited result with the single-character recognition result, the recognition of over-detection or missed detection is corrected. Based on the final recognition result obtained by the above processing, the character recognition accuracy is improved, and the garbled character problem can be effectively overcome when correcting the content of PDF documents.

[0106] This invention also provides a computer storage medium storing a computer program, which, when executed by a processor, implements the above-described method for character recognition.

[0107] This invention also provides a terminal, comprising: a memory and a processor, wherein the memory stores a computer program; wherein,

[0108] The processor is configured to execute computer programs in memory;

[0109] When a computer program is executed by a processor, it implements the character recognition method described above.

[0110] Figure 2 This is a structural block diagram of a device for character recognition according to an embodiment of the present invention, as shown below. Figure 2 As shown, it includes: a multi-character recognition unit and a determination unit; wherein,

[0111] The multi-character recognition unit is configured to: acquire character images containing a preset number of characters based on a PDF document, and perform multi-character recognition on the character images; the determination unit is configured to: determine the final recognition result of the characters contained in the PDF document based on the result of multi-character recognition when the result of multi-character recognition contains a preset number of characters.

[0112] This invention provides an embodiment of the method for obtaining character images containing a preset number of characters from a PDF document and performing multi-character recognition on these images. If the multi-character recognition result contains the preset number of characters, the final recognition result for the characters contained in the PDF document is determined based on the multi-character recognition result. This invention reads and renders characters in a PDF file, determining which specific character the character image corresponds to in the PDF. When the multi-character recognition result contains the preset number of characters, it achieves rapid confirmation of missed or over-detection and improves the accuracy of character recognition based on the multi-character recognition result. Subsequently, the Unicode encoding of the recognition result is appended to the corresponding character in the PDF, achieving accurate recognition of the characters contained in the PDF document.

[0113] In one exemplary embodiment, the multi-character recognition unit of this invention includes a rendering module and a multi-character recognition module; wherein,

[0114] The rendering module is configured to read characters from a PDF document and render each character as a character image.

[0115] The multi-character recognition module is configured to: stitch together a preset number of character images and perform multi-character recognition on the stitched character images.

[0116] In one exemplary instance, the determining unit of this embodiment of the invention is further configured as follows:

[0117] Determine the dimensions of the spliced ​​character images;

[0118] Based on the determined size of the spliced ​​character image, determine the number of characters contained in the spliced ​​character image;

[0119] The number of characters contained in the determined spliced ​​character image is a preset number.

[0120] In one exemplary instance, the multi-character recognition module of this embodiment of the invention is further configured as follows:

[0121] Record the number of character images to be spliced, which is a preset number.

[0122] In one exemplary instance, the rendering module of this embodiment of the invention is configured as follows:

[0123] Determine if the character being read is a whitespace character;

[0124] The selected blank character is rendered as a blank image, and the blank image is the character image.

[0125] In one exemplary instance, the multi-character recognition module of this embodiment of the invention is further configured as follows:

[0126] If it is determined that the read characters contain whitespace characters, the results of multi-character recognition are corrected.

[0127] In one exemplary instance, the multi-character recognition module of this embodiment of the invention is further configured to correct the multi-character recognition result when it is determined that the read characters contain whitespace characters, including:

[0128] If it is determined that the read characters contain whitespace characters, whitespace characters are inserted into the multi-character recognition results according to the sorting position of the whitespace characters, and the confidence level of the whitespace characters is set to a preset value.

[0129] In one exemplary instance, the determining unit of this embodiment of the invention is configured as follows:

[0130] When the result of multi-character recognition contains a preset number of characters, the final recognition result is determined based on the confidence information of each character in the multi-character recognition result.

[0131] In one exemplary instance, the determining unit of this embodiment of the invention is configured to determine the final recognition result based on the confidence information of each character in the multi-character recognition result, including:

[0132] If the result of multi-character recognition contains characters with confidence information less than the confidence threshold, then single-character recognition is performed on the characters with confidence information less than the confidence threshold.

[0133] The single-character recognition results of characters with confidence information less than the confidence threshold are overwritten with the results obtained when recognizing multiple characters to obtain the final recognition result.

[0134] In one exemplary instance, the determining unit of this embodiment of the invention is configured to determine the final recognition result based on the confidence information of each character in the multi-character recognition result, including:

[0135] If the confidence level of each character in the multi-character recognition result is greater than the preset confidence threshold, the multi-character recognition result will be determined as the final recognition result.

[0136] In one exemplary instance, the determining unit of this embodiment of the invention is further configured as follows:

[0137] If the result of multi-character recognition is not the preset number of characters, it is determined that there is a recognition error in the multi-character recognition result.

[0138] In one exemplary instance, the embodiment of the present invention further includes a single-character recognition unit, configured to: perform single-character recognition on each character image in the spliced ​​character image;

[0139] The determining unit is also set to: determine the final recognition result based on the results of single-character recognition and multi-character recognition.

[0140] In one exemplary instance, the determining unit of this embodiment of the invention is further configured to determine the final recognition result based on the result of single-character recognition and the result of multi-character recognition, including:

[0141] The difference in the number of characters between the single-character recognition result and the multi-character recognition result is used as the first quantity;

[0142] The results of multi-character recognition are edited according to a preset strategy and a first quantity to obtain multiple combinations of edited results, wherein each edited result contains a preset number of characters;

[0143] The final recognition result is determined based on the editing results and the single-character recognition results.

[0144] In one exemplary instance, the determining unit of this embodiment of the invention is further configured to edit the characters of the multi-character recognition result according to a preset strategy and a first quantity, to obtain multiple combinations of edited results, including:

[0145] If the first quantity is greater than zero, determine multiple insertion combinations of inserting the first quantity of caret into the result of multi-character recognition, and obtain the editing result of multiple insertion combinations. The insertion combination includes the insertion position of the determined character and the number of characters inserted at the insertion position.

[0146] If the first quantity is less than zero, determine multiple deletion combinations that delete the first quantity of characters in the multi-character recognition result, and obtain multiple insertion combinations of editing results, wherein the deletion combination includes the characters to be deleted in the multi-character recognition result.

[0147] In one exemplary instance, the determining unit of this embodiment of the invention is configured to determine the final recognition result based on the editing result and the single-character recognition result, including:

[0148] Each edit result is compared with the single character recognition result to determine the number of characters in each edit result that match the single character recognition result;

[0149] Based on the number of characters that match the recognition results in each editing result and the single character recognition result, the editing result used to determine the final recognition result is selected;

[0150] The selected edited results are compared with the single-character recognition results to determine the final recognition result.

[0151] In one exemplary instance, the determining unit of this embodiment of the invention is configured to select the edited result used to determine the final recognition result based on the number of characters whose recognition results are consistent with those of each edited result and the single-character recognition result, including:

[0152] If there is only one edit result with the largest number of characters that match the recognition result when the first number is greater than zero, the edit result will be used to determine the final recognition result.

[0153] If, when the first number is greater than zero and there are at least two edit results with the largest number of consistent characters, for each edit result with the largest number of consistent characters, the confidence of the recognition result at the insertion position is calculated. The edit result with the largest sum of confidence is used as the edit result used to determine the final recognition result.

[0154] In one exemplary instance, the determining unit of this embodiment of the invention is configured to select the edited result used to determine the final recognition result, including:

[0155] If the first number is less than zero and there is only one edit result with the largest number of consistent characters, the edit result will be used to determine the final recognition result.

[0156] If the first number is less than zero and there are at least two edit results with the largest number of characters that match the recognition result, calculate the sum of the confidence scores of the deleted characters for each edit result with the largest number of characters that match the recognition result; and use the edit result with the largest sum of confidence scores as the edit result used to determine the final recognition result.

[0157] In one exemplary instance, the determining unit of this embodiment of the invention is configured to compare the selected editing result with the single-character recognition result to determine the final recognition result, including:

[0158] Compare the selected editing results with the single-character recognition results;

[0159] If the character recognition results are consistent, the edited result will be taken as the final recognition result;

[0160] In cases where character recognition results are inconsistent, the recognition result with the higher confidence value will be taken as the final recognition result.

[0161] In one exemplary embodiment, the apparatus of the present invention further includes a correction unit, configured as follows:

[0162] Based on the final identification results, the PDF document is corrected for content.

[0163] The following application examples briefly illustrate the embodiments of the present invention. These application examples are only used to describe the embodiments of the present invention and are not intended to limit the scope of protection of the present invention.

[0164] Application Examples

[0165] This application example assumes that the PDF document contains garbled characters; after reading the characters in the PDF document, each character is rendered as a 50-pixel * 50-pixel character image; the character images of 10 characters are stitched together to form a 500-pixel * 50-pixel image; in the case where the character read in this embodiment of the invention is a blank character, a blank image is rendered, and the blank image is the character image.

[0166] In this embodiment of the invention, when the character image is a blank image, the sorting position of the blank image is recorded; here, when the number of spliced ​​character images is a preset number, the sorting position of the blank image in this embodiment of the invention can be the sorting position in the spliced ​​character images; Figure 3 This is a schematic diagram of a character image spliced ​​as an application example of the present invention, such as... Figure 3 As shown, the spliced ​​character image consists of 10 character images, where the character image at position 4 is a blank image.

[0167] This application example performs multi-character recognition on a spliced ​​character image using OCR, and obtains the multi-character recognition results shown in Table 1. Based on the sorting position of the blank image, a blank character is inserted into the multi-character recognition results. In this application example, the confidence level of the inserted blank character is set to 1. Table 2 shows the multi-character recognition results after inserting the blank character.

[0168] Sort number 1 2 3 4 5 6 7 8 Recognition results Book department point 1 2 4 5 · Confidence 0.999 1.0 1.0 0.653 0.999 0.999 0.999 0.815

[0169] Table 1

[0170] Sort number 1 2 3 4 5 6 7 8 9 Recognition results Book department point 1 2 4 5 ● Confidence 0.999 1.0 1.0 1.0 0.653 0.999 0.999 0.999 0.815

[0171] Table 2

[0172] The results of multi-character recognition in Table 2 of this application example determine whether the confidence level of each character in the multi-character recognition results is lower than the confidence level threshold. If the confidence level of a character is lower than the confidence level threshold, single-character recognition is performed on that character.

[0173] The single-character recognition results of characters with confidence information less than the confidence threshold are overwritten with the results obtained when recognizing multiple characters to obtain the final recognition result.

[0174] In this application example, when the result of multi-character recognition is not the preset number of characters, it is determined that the multi-character recognition result contains a recognition error, including: the multi-character recognition has missed detections or over-detections. When it is determined that the multi-character recognition result contains a recognition error, the application example method of this invention further includes:

[0175] Perform single-character recognition on each character image in the spliced ​​character image;

[0176] The final recognition result is determined based on the results of single-character recognition and multi-character recognition.

[0177] Table 3 is... Figure 3 The results of single-character recognition of the spliced ​​character image shown;

[0178] Sort number 1 2 3 4 5 6 7 8 9 10 Recognition results Book department point Ⅰ 2 4 5 ● 、 Confidence 0.999 0.999 0.999 1.0 0.136 0.996 0.999 0.999 0.999 0.999

[0179] Table 3

[0180] This application example uses the results of multi-character recognition shown in Table 2 and the results of single-character recognition shown in Table 3 to determine the final recognition result of the characters contained in the PDF document;

[0181] In this application example, based on the results of single-character recognition and multi-character recognition, the final recognition result is determined as follows: The difference in the number of characters contained in the single-character recognition result and the multi-character recognition result is 1. Because the difference in the number of characters is 1, this application example inserts one insertion character at each different sorting position in the multi-character recognition result to obtain the corresponding editing result; that is, in the multi-character recognition result of Table 2, one insertion character is inserted according to the sorting sequence number each time; specifically, the first insertion of insertion character C1 before sorting sequence number 1 in Table 2 obtains the first editing result; the second insertion of insertion character C1 before sorting sequence number 2 in Table 2 obtains the first editing result. Insert insertion point C2 to obtain the second edit result; insert insertion point C3 before sorting number 3 in Table 2 for the third edit result; and so on, inserting insertion point C9 before sorting number 9 in Table 2 for the ninth edit result; insert insertion point C10 after sorting number 9 in Table 2 for the tenth edit result; compare each edit result with the single character recognition result to determine the number of characters that match the recognition result in each edit result; set the number of characters that match the recognition result as the maximum (e.g., containing 8 recognition results). If the characters are identical, the edit result when the number of identical characters is 8 is used as the edit result for determining the characters contained in the PDF document. If, in this application example, there is only one edit result with the largest number of identical characters, that edit result is used as the edit result for determining the characters contained in the PDF document. If there are two or more edit results with the largest number of identical characters, the confidence scores of the recognition results at the insertion point are calculated for each edit result with the largest number of identical characters. The edit result with the largest sum of confidence scores is used as the edit result for determining the characters contained in the PDF document. If the edit result for determining the characters contained in the PDF document matches the single-character recognition result, that recognition result is used as the recognition result for the characters contained in the PDF document. If the edit result for determining the characters contained in the PDF document does not match the single-character recognition result, the recognition result with the larger confidence value is used as the recognition result for the characters contained in the PDF document.

[0182] Figure 4 This is a schematic diagram of another spliced ​​character image as an application example of the present invention, such as... Figure 4 As shown, the spliced ​​character image includes 10 character images and does not contain blank images.

[0183] Table 4 is... Figure 4 The multi-character recognition result corresponding to the spliced ​​character image shown contains 11 characters due to recognition errors.

[0184]

[0185] Table 4

[0186] Table 5 shows the splicing process. Figure 4 The results of single-character recognition in the image shown; the single-character recognition results include recognition results for 10 characters;

[0187]

[0188] Table 5

[0189] In this application example, when the number of characters in the single-character recognition result and the multi-character recognition result are different, the difference in the number of characters (first quantity) between the single-character recognition result and the multi-character recognition result is 1. Because the difference in character value is 1, in this application example, one recognition result with a different sorting position is deleted each time in the multi-character recognition result to obtain the corresponding edit result; that is, in the multi-character recognition result in Table 4, one recognition result is deleted each time according to the sorting number of the character; specifically, the recognition result with sorting number 1 in Table 4 is deleted first to obtain the first edit result. The second deletion of the recognition result with sorting number 2 in Table 4 yields the second edited result; the third deletion of the recognition result with sorting number 3 in Table 4 yields the fourth edited result; and so on, the tenth deletion of the recognition result with sorting number 10 in Table 4 yields the tenth edited result; the eleventh deletion of the recognition result with sorting number 11 in Table 4 yields the eleventh edited result; each edited result is compared with the single-character recognition result to determine the number of characters in each edited result that match the single-character recognition result; the maximum number of characters matching the recognition result is set (e.g., containing 9). If multiple characters have the same recognition result (the number of characters with the same recognition result is 9), the edit result when this result is used to determine the characters contained in the PDF document. If, in this application example, there is only one edit result with the largest number of characters with the same recognition result, that edit result is used to determine the characters contained in the PDF document. If there are two or more edit results with the largest number of characters with the same recognition result, the confidence scores of the deleted recognition results are calculated for each edit result with the largest number of characters with the same recognition result. The edit result with the largest sum of confidence scores is used to determine the characters contained in the PDF document. If the edit result used to determine the characters contained in the PDF document matches the single-character recognition result, that recognition result is used to determine the characters contained in the PDF document. If the edit result used to determine the characters contained in the PDF document does not match the single-character recognition result, the recognition result with the larger confidence value is used to determine the characters contained in the PDF document.

[0190] This application example determines the recognition results of characters contained in a PDF document by comparing the results of single-character recognition and editing, reducing the probability of missed and false detections; when using the determined final recognition results to repair garbled characters in a PDF, it improves the completeness of the PDF repair.

[0191] "Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is commonly understood in the art..." As is known to those skilled in the art, the term "computer storage medium" includes volatile and non-volatile, removable and non-removable media implemented in any method or technique for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium. < / ba6f>

Claims

1. A method for character recognition, comprising: The method involves obtaining character images containing a preset number of characters from a PDF document and performing multi-character recognition on the character images, including: reading characters from the PDF document and rendering each character as a character image; stitching together the preset number of character images and performing multi-character recognition on the stitched character images; If the result of the multi-character recognition contains a preset number of characters, the final recognition result of the characters contained in the PDF document is determined based on the result of the multi-character recognition. If the result of the multi-character recognition is not a preset number of characters, it is determined that the multi-character recognition result has a recognition error; single-character recognition is performed on each character image in the spliced ​​character image; the difference in the number of characters between the single-character recognition result and the multi-character recognition result is taken as a first quantity; the characters of the multi-character recognition result are edited according to a preset strategy and the first quantity to obtain multiple combinations of edited results, wherein each edited result contains a preset number of characters; the final recognition result is determined based on the edited result and the single-character recognition result.

2. The method according to claim 1, characterized in that, The character image is of a preset size. Before determining the final recognition result of the characters contained in the PDF document based on the multi-character recognition result, the method further includes: Determine the size of the spliced ​​character image; Based on the determined size of the spliced ​​character image, the number of characters contained in the spliced ​​character image is determined; The number of characters contained in the spliced ​​character image is the preset number.

3. The method according to claim 1, characterized in that, When splicing together a preset number of character images, the method further includes: The number of character images spliced ​​together is recorded, and the number is the preset quantity.

4. The method according to claim 1, characterized in that, The step of reading characters from a PDF document and rendering each character as a character image includes: Determine if the character being read is a whitespace character; The identified blank characters are rendered as blank images, which are character images.

5. The method according to claim 1, characterized in that, Before determining the final recognition result of the characters contained in the PDF document based on the result of the multi-character recognition, the method further includes: If it is determined that the read characters contain whitespace characters, the result of the multi-character recognition is corrected.

6. The method according to claim 5, characterized in that, The step of correcting the multi-character recognition result when it is determined that the read characters contain whitespace characters includes: If it is determined that the read characters contain whitespace characters, whitespace characters are inserted into the multi-character recognition result according to the sorting position of the whitespace characters, and the confidence level of the whitespace characters is set to a preset value.

7. The method according to any one of claims 1 to 6, characterized in that, When the result of the multi-character recognition includes a preset number of characters, the final recognition result of the characters contained in the PDF document is determined based on the result of the multi-character recognition, including: If the result of multi-character recognition contains a preset number of characters, the final recognition result is determined based on the confidence information of each character in the multi-character recognition result.

8. The method according to claim 7, characterized in that, The step of determining the final recognition result based on the confidence information of each character in the multi-character recognition result includes: If the result of the multi-character recognition includes characters with confidence information less than the confidence threshold, then single-character recognition is performed on the characters with confidence information less than the confidence threshold. The single-character recognition results of characters whose confidence information is less than the confidence threshold are overwritten with the results obtained when recognizing multiple characters to obtain the final recognition result.

9. The method according to claim 7, characterized in that, The step of determining the final recognition result based on the confidence information of each character in the multi-character recognition result includes: If the confidence level of each character in the multi-character recognition result is greater than the preset confidence threshold, the multi-character recognition result is determined as the final recognition result.

10. The method according to claim 1, characterized in that, The process involves editing the characters in the multi-character recognition result according to a preset strategy and the first quantity to obtain various combinations of edited results, including: When the first quantity is greater than zero, determine multiple insertion combinations of inserting the first quantity of caret into the result of multi-character recognition, and obtain the editing result of the multiple insertion combinations, wherein the insertion combination includes determining the insertion position of the character and the number of characters inserted at the insertion position; If the first quantity is less than zero, determine multiple deletion combinations of deleting the first quantity of characters in the result of multi-character recognition, and obtain the editing result of multiple insertion combinations, wherein the deletion combination includes the character to be deleted in the result of multi-character recognition.

11. The method according to claim 1, characterized in that, The step of determining the final recognition result based on the editing result and the single-character recognition result includes: Each of the obtained editing results is compared with the single character recognition result to determine the number of characters in each editing result and the single character recognition result that are consistent; Based on the number of characters whose recognition results match those of the edited results and the single-character recognition results, the edited results used to determine the final recognition result are selected; The selected editing results are compared with the single-character recognition results to determine the final recognition result.

12. The method according to claim 11, characterized in that, The step of selecting the edited result used to determine the final recognition result based on the number of characters whose recognition results are consistent with the edited result and the single character recognition result includes: If the first quantity is greater than zero and there is only one edit result with the largest number of consistent characters, then the edit result is used as the edit result for determining the final recognition result. When the first quantity is greater than zero and there are at least two edit results with the largest number of consistent characters in the recognition result, for each edit result with the largest number of consistent characters in the recognition result, the sum of the confidence scores of the recognition result at the insertion position is calculated; the edit result when the sum of the calculated confidence scores is the largest is used as the edit result for determining the final recognition result.

13. The method according to claim 11, characterized in that, The selection of the edited result used to determine the final recognition result includes: If the first quantity is less than zero, and there is only one edit result with the largest number of consistent characters in the recognition result, then the edit result is used as the edit result for determining the final recognition result; When the first quantity is less than zero and there are at least two edit results with the largest number of consistent characters in the recognition result, for each edit result with the largest number of consistent characters in the recognition result, the cumulative sum of the confidence scores of the deleted characters is calculated; the edit result with the largest cumulative sum of confidence scores is used as the edit result for determining the final recognition result.

14. The method according to claim 12 or 13, characterized in that, The step of comparing the selected editing results with the single-character recognition results to determine the final recognition result includes: Compare the selected editing results with the single-character recognition results; If the character recognition results are consistent, the edited result shall be taken as the final recognition result; In the event of inconsistent character recognition results, the recognition result with the higher confidence value shall be taken as the final recognition result.

15. The method according to any one of claims 1-6 or 10-13, characterized in that, The method further includes: Based on the determined final recognition result, the content of the PDF document is corrected.

16. A computer storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method for character recognition as described in any one of claims 1 to 15.

17. A terminal, comprising: A memory and a processor, wherein the memory stores a computer program; wherein, The processor is configured to execute computer programs in memory; When the computer program is executed by the processor, it implements the method for character recognition as described in any one of claims 1 to 15.

18. An apparatus for realizing character recognition, comprising: Multi-character recognition unit and determination unit; among which, The multi-character recognition unit is configured to: acquire character images containing a preset number of characters based on a PDF document, and perform multi-character recognition on the character images, including: reading characters from the PDF document and rendering each character as a character image; splicing the preset number of character images and performing multi-character recognition on the spliced ​​character images; The determining unit is configured as follows: if the result of multi-character recognition contains a preset number of characters, determine the final recognition result of the characters contained in the PDF document based on the result of multi-character recognition; if the result of multi-character recognition does not contain a preset number of characters, determine that the result of multi-character recognition has a recognition error; perform single-character recognition on each character image in the spliced ​​character image; take the difference in the number of characters between the result of single-character recognition and the result of multi-character recognition as a first quantity; edit the characters in the result of multi-character recognition according to a preset strategy and the first quantity to obtain multiple combinations of edit results, wherein each edit result contains a preset number of characters; determine the final recognition result based on the edit result and the result of single-character recognition.