Text recognition method, list scanning method and apparatus
By splitting and matching characters based on stroke order encoding, and utilizing BK trees and local longest matching sequence thresholds, the problem of low efficiency in misidentification and error correction in character recognition is solved, achieving efficient list scanning and risk control.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2023-01-31
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies suffer from low efficiency in misidentification and error correction in text recognition, especially in list scanning scenarios where it is difficult to effectively identify and prevent missing abnormal lists.
The method based on stroke order encoding is adopted. The stroke order encoding of the character to be recognized is divided into encoding segments. The candidate known characters are searched in the dictionary using BK tree and tolerance limit. The target known character is determined by combining the length threshold of the longest local matching sequence.
It improves the accuracy and efficiency of text recognition, effectively prevents the omission of abnormal lists, and meets the performance requirements of real-time systems.
Smart Images

Figure CN116229484B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to computer technology in one or more embodiments, and more particularly to character recognition methods, list scanning methods and apparatus. Background Technology
[0002] In many business scenarios, text recognition is required to identify the specific character being identified and then perform appropriate processing. For example, in a list scanning scenario, it's necessary to recognize the characters within the input entity, such as a person's name, company name, or address, to determine if that entity, such as a person's name, is on an abnormal list, and then take different risk control measures. Another example is OCR (Optical Character Recognition) technology. Due to the inherent error in OCR recognition, misidentification of similar-looking characters may occur. Therefore, error correction can be performed on the OCR-recognized text to find the correct character corresponding to the incorrectly identified character.
[0003] Therefore, an effective character recognition method is needed. Summary of the Invention
[0004] This specification describes one or more embodiments of a text recognition method and apparatus, as well as a list scanning method and apparatus, which can more effectively recognize input text.
[0005] According to the first aspect, a character recognition method is provided, wherein the method includes:
[0006] The text to be recognized is obtained;
[0007] Based on the pre-set stroke order encoding rules and the writing stroke order of the character to be recognized, the stroke order code corresponding to the character to be recognized is obtained;
[0008] Extract at least one encoded segment from the stroke order encoding;
[0009] For each encoded segment, the following is performed: based on a pre-set tolerance limit, a set of candidate known characters corresponding to the current encoded segment is collected from a pre-generated dictionary; wherein, the dictionary includes multiple known characters;
[0010] The intersection of candidate known characters corresponding to each encoded segment is calculated, and the target known character in the dictionary corresponding to the character to be identified is obtained based on the intersection.
[0011] The method further includes:
[0012] For each known character in the dictionary, the following steps are performed: Based on pre-defined stroke order encoding rules and the stroke order of the currently known character, obtain its corresponding stroke order code; extract at least one encoding segment from the stroke order code; establish a correspondence between the currently known character and each encoding segment extracted from it; and...
[0013] A BK tree is formed using all the coded segments extracted from each known character; each node in the BK tree represents a coded segment.
[0014] Accordingly, the step of collecting a set of candidate known characters corresponding to the current encoded segment from a pre-generated dictionary according to a pre-set tolerance limit includes:
[0015] Using the BK tree search method, at least one target node is found in the formed BK tree; wherein the edit distance between the encoded segment represented by the target node and the current encoded segment is not greater than the tolerance limit.
[0016] Obtain at least one target encoded segment representing at least one target node;
[0017] Each known character corresponding to at least one target encoded segment is used as a set of candidate known characters corresponding to the current encoded segment.
[0018] The step of finding the intersection among all groups of candidate known characters corresponding to all encoded segments, and obtaining the target known character in the dictionary corresponding to the character to be identified based on the intersection, includes:
[0019] For each encoding segment extracted from the stroke order encoding of the character to be identified, if at least two consecutive encoding segments correspond to the same known character, and the length of the longest local matching sequence is not less than the length of the stroke order encoding of the character to be identified multiplied by a preset percentage threshold, then the same known character corresponding to the at least two consecutive encoding segments is taken as the target known character in the dictionary corresponding to the character to be identified.
[0020] Wherein, the step of splitting at least one encoded segment from the stroke order encoding includes:
[0021] i = 1;
[0022] Divide the N consecutive codes starting from the i-th code in the stroke order encoding into a single encoding segment; where N is the pre-defined unit segment length.
[0023] i = i + L; where L is the preset step size of the sliding window;
[0024] Return to the execution step "divide the N consecutive codes starting from the i-th code in the stroke order code into a code segment" until the last code in the stroke order code has been divided into a code segment.
[0025] The text in question is Chinese characters or other languages with a defined stroke order.
[0026] And / or,
[0027] The dictionary includes all the text contained in each list record in the list database.
[0028] According to the second aspect, a list scanning method is provided, wherein the method includes:
[0029] Obtain the main object to be scanned; wherein, the main object to be scanned includes more than one character;
[0030] Each character in the subject object to be scanned is sequentially taken as the character to be recognized, and the following steps are performed: using any one of the character recognition methods in the embodiments of this specification, the target known characters in the dictionary corresponding to the current character to be recognized are obtained; wherein, the dictionary includes: all characters included in each list record in the list database; and the candidate list record corresponding to the current character to be recognized and including the target known characters is searched in the list database.
[0031] Based on all the candidate list records found, determine whether there is a list record that matches the subject to be scanned.
[0032] The method further includes:
[0033] For each list record in the list database, the following steps are performed: For each character in the current list record, establish a correspondence between the character and the current list record to obtain an inverted index for the character;
[0034] The step of searching the candidate list records in the list database for the current character to be identified, which also includes known characters of the target character, includes:
[0035] Based on the inverted index of the known text of the target, search the list database for the candidate list record corresponding to the known text of the target.
[0036] The inverted index further includes: the correspondence between the text and the field position of the text in the current list record;
[0037] The step of determining whether a record matches the candidate list of the subject to be scanned, based on all the candidate list records found, includes:
[0038] Find the intersection of the different candidate list records corresponding to different characters in the subject object to be scanned, and thus obtain the candidate list record;
[0039] A global score is calculated based on the similarity between all the text in the subject object to be scanned and the field at the field position of each text in each candidate list record;
[0040] If the score is greater than the predetermined threshold, the subject object to be scanned is considered to have matched the candidate list record.
[0041] According to the third aspect, a character recognition device is provided, wherein the device includes:
[0042] The input module is configured to obtain the text to be recognized.
[0043] The stroke order encoding acquisition module is configured to obtain the stroke order encoding corresponding to the character to be recognized based on the pre-set stroke order encoding rules and the writing stroke order of the character to be recognized.
[0044] The encoding fragment acquisition module is configured to extract at least one encoding fragment from the stroke order encoding;
[0045] The recognition processing module is configured to perform the following for each encoded segment: according to a pre-set tolerance limit, collect a set of candidate known characters corresponding to the current encoded segment from a pre-generated dictionary; wherein, the dictionary includes multiple known characters; find the intersection between each set of candidate known characters corresponding to each encoded segment, and obtain the target known character in the dictionary corresponding to the character to be recognized based on the intersection.
[0046] According to the fourth aspect, a list scanning device is provided, wherein the device includes:
[0047] The module for obtaining the object to be scanned is configured to obtain the main object to be scanned; wherein, the main object to be scanned includes more than one character.
[0048] The candidate list record acquisition module is configured to sequentially treat each character in the subject object to be scanned as the character to be identified, and execute the following: obtain the target known characters in the dictionary corresponding to the current character to be identified; wherein, the dictionary includes: all characters included in each list record in the list database; and search in the list database for the candidate list record that corresponds to the current character to be identified and includes the target known characters.
[0049] The matching module is configured to determine whether there is a matching record for the subject to be scanned, based on all the candidate list records found.
[0050] According to a fifth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method described in any embodiment of this specification.
[0051] The character recognition method and apparatus, and list scanning method and apparatus provided in the embodiments of this specification employ a novel approach to recognize a character. For example, the writing of Chinese characters and Korean script is based on specific stroke orders and stroke order combinations. Since the similarity of stroke order combinations implies the similarity of characters, this specification embodiment uses stroke order encoding to recognize the character. First, the stroke order encoding corresponding to the character to be recognized is obtained, that is, which stroke orders are sequentially included in the character to be recognized. Then, at least one encoding segment is extracted from the stroke order encoding. Each encoding segment represents a combination of stroke orders, and each encoding segment, i.e., each stroke order combination, can correspond to a set of candidate known characters. That is, the character to be recognized may be one of the candidate known characters in this set. Thus, multiple sets of candidate known characters corresponding to multiple encoding segments represent multiple possibilities. Finally, the intersection of the candidate known characters corresponding to each encoding segment is calculated to obtain the target known character in the dictionary corresponding to the character to be recognized.
[0052] Compared with the prior art which uses a preset similar character table, the embodiments in this specification break the limitations of enumeration, effectively prevent omissions, better ensure risk coverage, have high search efficiency, and meet the performance requirements of real-time systems. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 This is a flowchart of a text recognition method in one embodiment of this specification.
[0055] Figure 2 This is a schematic diagram of a BK tree structure formed by various encoded segments of known characters in a dictionary, as described in one embodiment of this specification.
[0056] Figure 3 This is a schematic diagram of a list scanning method in one embodiment of this specification.
[0057] Figure 4 This is a schematic diagram of the structure of a character recognition device in one embodiment of this specification.
[0058] Figure 5 This is a schematic diagram of the structure of a list scanning device in one embodiment of this specification. Detailed Implementation
[0059] The solution provided in this specification will now be described with reference to the accompanying drawings.
[0060] First, it should be noted that the terminology used in the embodiments of this invention is for the purpose of describing specific embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” used in the embodiments of this invention and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise.
[0061] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0062] Figure 1 This is a flowchart of a text recognition method in one embodiment of this specification. The method is executed by a text recognition device. It is understood that this method can also be executed by any device, equipment, platform, or cluster of devices with computing and processing capabilities. See also... Figure 1 The method includes:
[0063] Step 101: Obtain the text to be recognized.
[0064] Step 103: Obtain the stroke order code corresponding to the character to be identified according to the pre-set stroke order encoding rules and the writing stroke order of the character to be identified.
[0065] Step 105: Extract at least one encoded segment from the stroke order encoding.
[0066] Step 107: For each encoded segment, perform the following: Based on a pre-set tolerance limit, collect a set of candidate known characters corresponding to the current encoded segment from a pre-generated dictionary; wherein, the dictionary includes multiple known characters.
[0067] Step 109: Find the intersection between each group of candidate known characters corresponding to all encoded segments, and obtain the target known character in the dictionary corresponding to the character to be identified based on the intersection.
[0068] As can be seen, this embodiment employs a novel method to identify a character. Many types of characters exist in daily life, and the writing rules for many types are based on specific stroke orders / stroke combinations. For example, the writing of Chinese characters and Korean script are based on specific stroke orders and stroke combinations. For this type of character, since the similarity of stroke order combinations implies the similarity of the characters, this embodiment identifies the character based on stroke order encoding. As... Figure 1 As shown, the stroke order code corresponding to the character to be identified is first obtained, that is, which stroke order is included in the character to be identified. Then, at least one code segment is extracted from the stroke order code. Each code segment reflects the combination of stroke order. Each code segment, that is, each stroke order combination, can correspond to a set of candidate known characters. In other words, the character to be identified should be one of the candidate known characters in this set. In this way, the multiple sets of candidate known characters corresponding to multiple code segments are multiple possibilities. Then, the intersection of the candidate known characters corresponding to each code segment is calculated to obtain the target known character in the dictionary corresponding to the character to be identified.
[0069] Figure 1 The methods shown in the embodiments of this specification can be applied to a variety of business scenarios.
[0070] Scenario 1: Analyze a piece of text with unknown semantics to determine the corresponding text with semantic meaning.
[0071] Scenario 2: After recognizing text in an image using OCR technology, because OCR technology is prone to recognition errors, it is possible to utilize... Figure 1 The method shown is used for text correction.
[0072] Business Scenario 3: Utilizing Figure 1 The method shown is used for list scanning. For example, the server stores a list database containing abnormal lists of various names, addresses, and company names. When the server receives a piece of text, it can use the method shown in Figure 1 to perform list scanning, thereby determining whether the text contains a record in the abnormal list, thus achieving risk control.
[0073] The following section, in conjunction with accompanying diagrams and specific examples, will... Figure 1 Each step shown is explained separately.
[0074] First, for step 101: obtain the text to be recognized.
[0075] As described above, in this step 101, the text to be recognized can be a text in any of the above business scenarios. The text in the embodiments of this specification is Chinese characters or characters with writing stroke orders in other languages. For example, the text to be recognized is "暖".
[0076] Next, for step 103: According to the pre-set stroke order coding rules and the writing stroke order of the text to be recognized, obtain the stroke order coding corresponding to the text to be recognized.
[0077] First, explain the stroke order coding rules involved in step 103.
[0078] In the embodiments of this specification, for each type of character, the stroke order coding rules corresponding to that type of character can be pre-set. For example, for Korean Hangul, according to the writing method of Hangul, the stroke order coding rules corresponding to Hangul can be set. Another example is for Chinese characters, according to the writing method of Chinese characters, the stroke order coding rules corresponding to Chinese characters can be set.
[0079] In the embodiments of this specification, the stroke order coding is a specific stroke number set to record the writing order of the strokes of a character. Different strokes of the characters in this language are represented by different numbers, so as to represent a character with a string of numbers. Taking Chinese characters as an example, the stroke order rules of Chinese characters are: first horizontal then vertical (e.g., "干"), first left-falling stroke then right-falling stroke (e.g., "八"), from top to bottom (e.g., "主"), from left to right (e.g., "林"), first enclosing then closing (e.g., "田"), first middle then both sides (e.g., "水"), from outside to inside (e.g., "回"), etc. For example, for the Chinese character "仗", the stroke order is 丿, 丨, 一, 丿, 丶 in sequence.
[0080] The stroke order coding rules for Chinese characters are: Represent the 5 types of strokes (horizontal, vertical, left-falling stroke, right-falling stroke, fold) of Chinese characters with 1, 2, 3, 4, 5 respectively. Note: The rising stroke is regarded as a horizontal stroke, the dot is regarded as a right-falling stroke, the vertical hook is regarded as a vertical stroke, the horizontal fold is regarded as a fold stroke, and the vertical rising stroke is regarded as a vertical stroke. Just encode the Chinese characters according to the stroke order.
[0081] Correspondingly, in this step 103, according to the pre-set stroke order coding rules and the writing stroke order of the text to be recognized, the stroke order coding corresponding to the text to be recognized can be obtained. For example, if the current text to be recognized is written as "里", its writing stroke order is: vertical, horizontal fold, horizontal, horizontal, vertical, horizontal, horizontal, so the stroke order coding is 2511211. Another example is that the text recognized by OCR is written as The stroke order coding corresponding to this text is 32511211.
[0082] Next, for step 1: Split at least one coding segment from this stroke order coding.
[0083] If a text to be recognized (such as the text recognized by OCR )If it is very similar to a known character, such as "里" in terms of the writing stroke order, especially the combination of stroke orders, that is, it has some or all of the same stroke order combinations, then it can be considered that the character to be recognized is actually the known character. That is to say, the similarity of the stroke order combination means the similarity or identity of the characters. A stroke order code is actually a string, such as a string of numbers. Then, the stroke order combination is the combination of each code in the stroke order code, that is, a code segment.
[0084] In this step 105, at least one code segment is split from the stroke order code corresponding to the character to be recognized. Each code segment can be used to represent a stroke order combination. For example, the code segment "32" can be used to represent the stroke order combination "亻". In this way, in the subsequent process, the known characters similar or identical to the character to be recognized can be found by comparing the code segments.
[0085] In an embodiment of this specification, the implementation process of this step 105 includes:
[0086] Step 1051: Set the variable i = 1;
[0087] Step 1053: Divide the consecutive N codes starting from the i-th code in the stroke order code into a code segment; where N is the pre-set unit segment length;
[0088] Step 1055: Determine whether the last code in the stroke order code has been divided into a code segment. If so, end the current process; otherwise, execute step 1057;
[0089] Step 1057: i = i + L, where L is the pre-set step length of the sliding window, and then return to step 1053.
[0090] According to the process from step 1051 to step 1057 above, M - L + 1 code segments will be divided, where M is the length of the stroke order code of the character, that is, the number of digits, and L is the above-mentioned unit segment length, that is, the number of digits included in each code segment.
[0091] Illustrate the process from step 1051 to step 1057 above with an example. The unit segment length is pre-set to 3, that is, every 3-digit codes are used as a code segment. And the number of code segments is obtained by sliding the window. The pre-set step length of the sliding window is 1, that is, a code segment is divided every other digit code. Then, for example, for the stroke order code "123451", 4 code segments will be divided, namely 123, 234, 345, 451.
[0092] In the actual business implementation, for the last code segment, its length may be less than the unit segment length.
[0093] Next, for step 107: for each encoded segment, perform the following: according to the pre-set tolerance limit, collect a set of candidate known characters corresponding to the current encoded segment from the pre-generated dictionary; wherein, the dictionary includes multiple known characters.
[0094] when Figure 1 When the illustrated process is applied to business scenario one and business scenario two described above, the dictionary in the embodiments of this specification may include: all characters with known semantics involved in the corresponding business scenario. When Figure 1 When the process shown is applied to the above-mentioned business scenario three, the dictionary in this embodiment includes: all the text included in each list record in the list database.
[0095] In this embodiment of the specification, to improve matching efficiency, a text index structure can be constructed and set as a BK tree, that is, a BK tree is used to represent all the text in the dictionary. In step 107, the search and collection are performed in this BK tree, thereby greatly improving the efficiency of searching and collection. Here, BK tree, short for Burkhard Keller Tree, is a data structure used to perform spell checking based on the concept of edit distance (Levenshtein distance). BK trees are also used for approximate string matching. In this embodiment of the specification, the idea of using a BK tree to represent all the text in the dictionary is as follows: for each known text in the dictionary, it is also represented by stroke order encoding, and the stroke order encoding is split into at least one encoding segment. Then, a BK tree is constructed using all the encoding segments of all known texts. It can be seen that in the BK tree, each node represents an encoding segment, different nodes represent different encoding segments, and the edge between two nodes in the BK tree represents the edit distance between the two nodes.
[0096] In the embodiments of this specification, the method of using a BK tree to represent all characters in a dictionary includes the following steps A and B:
[0097] Step A specifically includes steps A1 through A5. In step A, steps A1 through A5 are performed for each known character in the dictionary:
[0098] Step A1: Based on the pre-set stroke order encoding rules and the stroke order of the currently known characters, obtain the stroke order code corresponding to the currently known characters.
[0099] Step A3: Extract at least one encoded segment from the stroke order encoding.
[0100] The implementation method for step A3 is the same as that for step 105 above.
[0101] Step A5: Establish the correspondence between the currently known text and each coded segment extracted from the currently known text.
[0102] Step B: All the encoded fragments extracted from each known character are formed into a BK tree; where each node in the BK tree represents an encoded fragment.
[0103] For example, the dictionary includes all the characters in a list database, storing various abnormal lists, such as names that are not allowed to appear. For example, for the Chinese characters 1 and 2 in the abnormal list, according to the pre-set stroke order encoding rules and the writing stroke order of Chinese characters 1 and 2, the stroke order codes corresponding to the two Chinese characters are 123451 and 45345 respectively. According to the method of splitting the unit segment length of 3 and the step size of the sliding window of 1, all the encoding segments split from the two Chinese characters include the following 6 encoding segments: 123, 234, 345, 451, 453, 534. The ID of Chinese character 1 is 1, and the ID of Chinese character 2 is 2. Then, the correspondence is {123:[1], 234:[1], 345:[1,2], 451:[1], 453:[2], 534:[2]}. Thus, the six encoded segments 123, 234, 345, 451, 453, and 534 correspond to six nodes on the BK tree. Specifically, the three nodes representing encoded segments 123, 234, and 451 each correspond to the Chinese character 1; the two nodes representing encoded segments 453 and 534 each correspond to the Chinese character 2; and the node representing encoded segment 345 corresponds to both the Chinese character 1 and the Chinese character 2. For example, a BK tree can be seen in [reference needed]. Figure 2 As shown.
[0104] Thus, through the nodes (i.e., the various encoded fragments derived from various characters in the dictionary) and edges (i.e., edit distances) on the BK tree, all encoded fragments derived from all characters in the dictionary and the edit distances between any two encoded fragments are represented. Accordingly, one implementation of step 107 includes: performing steps 1071 to 1075 for each encoded fragment corresponding to the character to be recognized.
[0105] Step 1071: Using the BK tree search method, at least one target node is found in the formed BK tree; wherein the edit distance between the encoded segment represented by the target node and the current encoded segment is not greater than the tolerance limit;
[0106] Step 1073: Obtain at least one target encoded segment representing at least one target node;
[0107] Step 1075: Take each known character corresponding to at least one target encoded segment as a set of candidate known characters corresponding to the current encoded segment; wherein each set of candidate known characters includes at least one candidate known character.
[0108] The set of candidate known characters obtained in step 1075 satisfies the following conditions: the stroke order corresponding to the current encoded segment appears in every candidate known character in the set (corresponding to the case where the tolerance limit is 0); or, a stroke order that is similar to the stroke order corresponding to the current encoded segment appears in every candidate known character in the set (corresponding to the case where the tolerance limit is not 0).
[0109] For each encoded segment corresponding to the text to be recognized, a set of candidate known texts will be obtained. For example, if there are 4 encoded segments corresponding to the text to be recognized, then there will be 4 sets of candidate known texts.
[0110] Next, for step 109: find the intersection between each group of candidate known characters corresponding to each encoded segment, and obtain the target known character in the dictionary corresponding to the character to be identified based on the intersection.
[0111] One implementation of step 109 includes: for each encoded segment extracted from the stroke order encoding corresponding to the character to be identified, if at least two consecutive encoded segments correspond to the same known character, and the length of the longest local matching sequence is not less than the length of the stroke order encoding corresponding to the character to be identified multiplied by a preset percentage threshold, then the same known character corresponding to the at least two consecutive encoded segments is taken as the target known character in the dictionary corresponding to the character to be identified. The percentage threshold is the minimum proportion of the encoding length of the similar or identical portion to the stroke order encoding length of the character to be identified when the character to be identified is similar to or identical to a known character in the dictionary. The longest local matching sequence is the encoding sequence corresponding to the at least two consecutive encoded segments in the stroke order encoding corresponding to the character to be identified.
[0112] The following example illustrates one implementation process of step 109.
[0113] The stroke order code of the Chinese character to be identified is 123451252. In a dictionary, such as an exception list dictionary, the stroke order codes of Chinese characters 1, 2, and 3 are 2345, 25234512, and 45123, respectively.
[0114] The encoding segments corresponding to the Chinese characters to be identified include: 123, 234, 345, 451, 512, 125, 252.
[0115] The encoding segments corresponding to the Chinese character 1 include: 234 and 345.
[0116] The encoding segments corresponding to the Chinese character 2 include: 252, 523, 234, 345, 451, 512.
[0117] The encoding segments corresponding to the Chinese character 3 include: 451, 512, 123.
[0118] The stroke order code of the Chinese character to be identified has a length of 9. Assuming a percentage threshold of 0.65, the length of the longest local matching sequence must be no less than 6 (9 * 0.65 rounded to 6). The matching process starts from the first encoding segment 123 of the stroke order code of the Chinese character to be identified and proceeds sequentially, as follows:
[0119] 1. For the first encoding segment 123 of the stroke order code of the Chinese character to be identified, the encoding segment of the Chinese character 3 includes 123. Therefore, the Chinese character 3 is located. However, the Chinese character 3 cannot be found using the next encoding segment 234 of the Chinese character to be identified. Therefore, the longest local matching sequence between the Chinese character to be identified and the Chinese character 3 is 123. The length of the longest local matching sequence is 3, which does not meet the requirement of not less than 6.
[0120] 2. For the second stroke order code segment 234 of the Chinese character to be identified, since the code segments of Chinese characters 1 and 2 include 234, Chinese characters 1 and 2 can be found. Extending to the third stroke order code 345 of the Chinese character to be identified, since the code segments of Chinese characters 1 and 2 include 345, Chinese characters 1 and 2 can be found. And so on, extending to the fourth stroke order code 451 of the Chinese character to be identified, only Chinese character 2 is found. Therefore, the longest local matching sequence between the Chinese character to be identified and Chinese character 1 is 2345, which does not meet the requirement of not less than 6. Continuing to the fifth stroke order code 512 of the Chinese character to be identified, Chinese character 2 can be found. Extending to the sixth stroke order code 125 of the Chinese character to be identified, no matching Chinese character is found, so the process stops. Therefore, the longest local matching sequence between the Chinese character to be identified and Chinese character 2 is 234512, which meets the requirement of not less than 6. Therefore, Chinese character 2 is considered similar to the Chinese character to be identified.
[0121] It should be noted that although each encoded segment of Chinese character 3 matches some encoded segments of the Chinese character to be identified, the longest local matching sequence is 4512, which does not meet the requirement of not less than 6. Therefore, it is considered that Chinese character 3 is not similar to the Chinese character to be identified.
[0122] The above method of finding the longest local matching sequence actually achieves the effect of finding the intersection between each group of candidate known characters.
[0123] As in business scenario three above, the text recognition method proposed in the embodiments of this specification can be applied to list scanning, such as list scanning for risk control in the financial field. The server stores a list database, such as abnormal lists of various names, addresses, and company names. When the server receives a piece of text, it can use the text recognition method in the embodiments of this specification to perform list scanning, thereby determining whether the text matches a record in the abnormal list, thus achieving risk control. See also... Figure 3 This specification provides an embodiment of a list scanning method, wherein the dictionary includes: a list database formed by at least one list record, for example, the list database being an abnormal list; the method includes:
[0124] Step 301: Obtain the main object to be scanned; wherein, the main object to be scanned includes more than one character.
[0125] The subject to be scanned could be a name or address to be identified.
[0126] Step 303: Take each character in the subject object to be scanned in sequence as the character to be recognized, and use the character recognition method in any embodiment of this specification to obtain the target known character in the dictionary corresponding to the character to be recognized; search the list database for candidate list records that correspond to the current character to be recognized and include the target known character.
[0127] Step 305: Based on all the candidate list records found, determine whether there is a list record that matches the subject to be scanned.
[0128] In one embodiment of this specification, the method further includes:
[0129] For each record in the list database, such as the abnormal list, the following is performed: For each character in the current list record, a correspondence is established between the character and the current list record, thereby obtaining an inverted index for the character;
[0130] In step 303, the process of searching the candidate list records in the list database that correspond to the currently identified text and include the target known text includes: searching the candidate list records in the list database that correspond to the target known text according to the inverted index of the target known text.
[0131] In one embodiment of this specification, the inverted index further includes: the correspondence between the text and the field position of the text in the current list record;
[0132] Accordingly, step 305 determines whether there is a record in the candidate list that matches the subject to be scanned, based on all the candidate list records found, including:
[0133] Find the intersection of the different candidate list records corresponding to different characters in the main object to be scanned, and thus obtain the candidate list record;
[0134] A global score is calculated based on the similarity between all the text in the main object to be scanned and the text at the corresponding field position in each candidate list record;
[0135] If the score is greater than the predetermined threshold, the subject object to be scanned is considered to have matched the candidate list record.
[0136] For example, the subject to be scanned includes a person's name. Figure 3 The method shown can identify whether a person's name matches a record in the anomaly list, i.e., whether it is a name in the anomaly list, thus enabling subsequent corresponding control. For example, if a person's name consists of three characters, the first character can be used as the character to be identified. Then, using the character recognition method in any embodiment of this specification, the dictionary corresponding to the character to be identified, i.e., the first known target character in the anomaly list, is obtained. The inverted index of the first known target character is used to find the list records 1, 10, and 15 (the first group of candidate list records) in the anomaly list where the first known target character is located. Next, the second character of the name is used as the character to be identified. Then, using the character recognition method in any embodiment of this specification, the dictionary corresponding to the character to be identified, i.e., the second known target character in the anomaly list, is obtained. The inverted index of the second known target character is used to find the list records 2, 10, and 15 (the second group of candidate list records) in the anomaly list where the second known target character is located. Next, the third character in the person's name is taken as the character to be identified. Then, using the character recognition method in any embodiment of this specification, the dictionary corresponding to the character to be identified, i.e., the third known target character in the anomaly list, is obtained. The inverted index of the third known target character is used to find the third known target character in the anomaly list, specifically in list records 5, 10, and 15 (the third set of candidate list records). The intersection of the three sets of candidate list records is calculated to obtain the candidate list records: list record 10 and list record 15. Then, the similarity between the three characters in the person's name and the characters at the corresponding field positions in list record 10 is compared. After global scoring, the similarity score is 80 points (greater than the threshold of 70 points). At the same time, the similarity between the three characters in the person's name and the characters at the corresponding field positions in list record 15 is compared. After global scoring, the similarity score is 40 points (less than the threshold of 70 points). Therefore, it is considered that the subject object to be scanned has matched list record 10 in the anomaly list.
[0137] In one embodiment of this specification, a character recognition device is provided. See also Figure 4The device includes:
[0138] Input module 401 is configured to obtain the text to be recognized;
[0139] The stroke order encoding acquisition module 402 is configured to obtain the stroke order encoding corresponding to the character to be recognized according to the pre-set stroke order encoding rules and the writing stroke order of the character to be recognized.
[0140] The encoding segment acquisition module 403 is configured to extract at least one encoding segment from the stroke order encoding;
[0141] The recognition processing module 404 is configured to perform the following for each encoded segment: according to a pre-set tolerance limit, collect a set of candidate known characters corresponding to the current encoded segment in a pre-generated dictionary; wherein, the dictionary includes multiple known characters; find the intersection between each set of candidate known characters corresponding to each encoded segment, and obtain the target known character in the dictionary corresponding to the character to be recognized based on the intersection.
[0142] In one embodiment of the device described in this specification, the character recognition device further includes: a BK tree forming module (not shown in the figure);
[0143] The BK tree forming module is configured to perform the following for each known character in the dictionary: obtaining the stroke order code corresponding to the current known character based on pre-defined stroke order encoding rules and the stroke order of the current known character; extracting at least one encoding segment from the stroke order code; establishing a correspondence between the current known character and each encoding segment extracted from the current known character; and forming a BK tree using all the encoding segments extracted from each known character; wherein each node in the BK tree represents an encoding segment.
[0144] Accordingly, the identification processing module 404 is configured to execute:
[0145] Using the BK tree search method, at least one target node is found in the formed BK tree; wherein the edit distance between the encoded segment represented by the target node and the current encoded segment is not greater than the tolerance limit.
[0146] Obtain at least one target encoded segment representing at least one target node;
[0147] Each known character corresponding to at least one target encoded segment is used as a set of candidate known characters corresponding to the current encoded segment.
[0148] In one embodiment of the device described in this specification, the identification processing module 404 is configured to perform:
[0149] For each encoding segment extracted from the stroke order encoding of the character to be identified, if at least two consecutive encoding segments correspond to the same known character, and the length of the longest local matching sequence is not less than the length of the stroke order encoding of the character to be identified multiplied by a preset percentage threshold, then the same known character corresponding to the at least two consecutive encoding segments is taken as the target known character in the dictionary corresponding to the character to be identified.
[0150] In one embodiment of the device described in this specification, the encoded fragment acquisition module 403 is configured to perform:
[0151] Set variable i = 1;
[0152] Divide the N consecutive codes starting from the i-th code in the stroke order encoding into a single encoding segment; where N is the pre-defined unit segment length.
[0153] i = i + L; where L is the preset step size of the sliding window;
[0154] Return to the execution step "divide the N consecutive codes starting from the i-th code in the stroke order code into a code segment" until the last code in the stroke order code has been divided into a code segment.
[0155] In one embodiment of the device described in this specification, the text is Chinese characters or characters in other languages with a writing stroke order.
[0156] In one embodiment of the device described in this specification, the dictionary includes all the text contained in each list record in the list database.
[0157] In one embodiment of this specification, a list scanning device is provided. See also Figure 5 The device includes:
[0158] The object acquisition module 501 is configured to obtain the main object to be scanned; wherein the main object to be scanned includes more than one character.
[0159] The candidate list record acquisition module 502 is configured to sequentially use each character in the subject object to be scanned as the character to be recognized, and perform the following: inputting the character to be recognized into the character recognition device in any embodiment of this specification, and obtaining the target known character in the dictionary corresponding to the current character to be recognized output by the character recognition device; wherein, the dictionary includes: all characters included in each list record in the list database; and searching in the list database for a candidate list record that corresponds to the current character to be recognized and includes the target known character;
[0160] Matching module 503 is configured to determine whether there is a list record that the subject to be scanned matches based on all the candidate list records found.
[0161] In one embodiment of the device described in this specification, it further includes: an inverted index building module ( Figure 5 (Not shown in the text), configured to perform the following for each list record in the list database: for each character in the current list record, establish a correspondence between the character and the current list record, thereby obtaining an inverted index for the character;
[0162] The candidate list record acquisition module 502 is configured to perform the following: based on the inverted index of the known text of the target, search the list database for the candidate list record corresponding to the known text of the target.
[0163] In one embodiment of the device described in this specification, the inverted index further includes: the correspondence between the text and the field position of the text in the current list record;
[0164] Matching module 503 is configured to execute:
[0165] Find the intersection of the different candidate list records corresponding to different characters in the subject object to be scanned, and thus obtain the candidate list record;
[0166] A global score is assigned based on the similarity between all the text in the subject object to be scanned and the text at the corresponding field position in each candidate list record;
[0167] If the score is greater than the predetermined threshold, the subject object to be scanned is considered to have matched the candidate list record.
[0168] It should be noted that the above-mentioned devices are typically implemented on the server side. They can be set up on independent servers, or some or all of the devices can be combined and installed on the same server. This server can be a single server or a server cluster consisting of multiple servers. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system. The above-mentioned devices can also be implemented on computer terminals with strong computing capabilities.
[0169] This specification provides, in one embodiment, a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the methods of any embodiment in the specification.
[0170] This specification provides a computing device according to one embodiment, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to perform the method of any embodiment of the specification.
[0171] It is understood that the structures illustrated in the embodiments of this specification do not constitute a specific limitation on the apparatus of the embodiments of this specification. In other embodiments of the specification, the above-described apparatus may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0172] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0173] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this invention can be implemented using hardware, software, widgets, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium.
[0174] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.
Claims
1. Character recognition methods, among which, The method includes: The text to be recognized is obtained; Based on the pre-set stroke order encoding rules and the writing stroke order of the character to be recognized, the stroke order code corresponding to the character to be recognized is obtained; Based on a pre-defined step size of the sliding window, at least one encoding segment is extracted from the stroke order encoding using a sliding window method; wherein the step size of the sliding window is less than the length of each encoding segment; For each encoded segment, the following is performed: based on a pre-set tolerance limit, a set of candidate known characters corresponding to the current encoded segment is collected from a pre-generated dictionary; wherein, the dictionary includes multiple known characters; Find the intersection between each group of candidate known characters corresponding to each encoded segment, and obtain the target known character in the dictionary corresponding to the character to be identified based on the intersection; The method further includes: For each known character in the dictionary, the following steps are performed: Based on pre-defined stroke order encoding rules and the stroke order of the currently known character, obtain its corresponding stroke order code; extract at least one encoding segment from the stroke order code; establish a correspondence between the currently known character and each encoding segment extracted from it; and... A BK tree is formed using all the encoded fragments extracted from each known text; each node in the BK tree represents an encoded fragment; and the edge between two nodes in the BK tree represents the edit distance between the two nodes. Accordingly, the step of collecting a set of candidate known characters corresponding to the current encoded segment from a pre-generated dictionary according to a pre-set tolerance limit includes: Using the BK tree search method, at least one target node is found in the formed BK tree; wherein the edit distance between the encoded segment represented by the target node and the current encoded segment is not greater than the tolerance limit. Obtain at least one target encoded segment representing at least one target node; Each known character corresponding to at least one target encoded segment is used as a set of candidate known characters corresponding to the current encoded segment; The step of finding the intersection among all groups of candidate known characters corresponding to all encoded segments, and obtaining the target known character in the dictionary corresponding to the character to be identified based on the intersection, includes: For each encoding segment split from the stroke order encoding corresponding to the character to be identified, if at least two consecutive encoding segments can match the same known character, and the length of the longest local matching sequence is not less than the length of the stroke order encoding corresponding to the character to be identified multiplied by a preset percentage threshold, then the same known character corresponding to the at least two consecutive encoding segments is taken as the target known character in the dictionary corresponding to the character to be identified. The longest local matching sequence is the encoding sequence corresponding to the at least two consecutive encoded segments that can match the same known character.
2. The method according to claim 1, wherein, Extracting at least one encoded segment from the stroke order encoding includes: i=1; Divide the N consecutive codes starting from the i-th code in the stroke order encoding into a single encoding segment; where N is the pre-defined unit segment length. i = i + L; where L is the preset step size of the sliding window; Return to the execution step "divide the N consecutive codes starting from the i-th code in the stroke order code into a code segment" until the last code in the stroke order code has been divided into a code segment.
3. The method according to claim 1, wherein, The text is Chinese characters or other languages with a written stroke order; And / or, The dictionary includes all the text contained in each list record in the list database.
4. List scanning method, among which, The method includes: Obtain the main object to be scanned; wherein, the main object to be scanned includes more than one character; Each character in the subject object to be scanned is sequentially taken as the character to be identified, and the following steps are performed: using the method described in any one of claims 1 to 3, the target known character in the dictionary corresponding to the current character to be identified is obtained; wherein, the dictionary includes: all characters included in each list record in the list database; and the candidate list record corresponding to the current character to be identified and including the target known character is searched in the list database. Based on all the candidate list records found, determine whether there is a list record that matches the subject to be scanned.
5. The method according to claim 4, wherein, The method further includes: For each list record in the list database, the following steps are performed: For each character in the current list record, establish a correspondence between the character and the current list record to obtain an inverted index for the character; The step of searching the candidate list records in the list database for the current character to be identified, which also includes known characters of the target character, includes: Based on the inverted index of the known text of the target, search the list database for the candidate list record corresponding to the known text of the target.
6. The method according to claim 5, wherein, The inverted index further includes: the correspondence between the text and the field position of the text in the current list record; The step of determining whether a record matches the candidate list of the subject to be scanned, based on all the candidate list records found, includes: Find the intersection of the different candidate list records corresponding to different characters in the main object to be scanned, and thus obtain the candidate list record; A global score is assigned based on the similarity between all the text in the subject object to be scanned and the text at the corresponding field position in each candidate list record; If the score is greater than the predetermined threshold, the subject object to be scanned is considered to have matched the candidate list record.
7. A character recognition device, wherein, The device includes: The input module is configured to obtain the text to be recognized; The stroke order encoding acquisition module is configured to obtain the stroke order encoding corresponding to the character to be recognized based on the pre-set stroke order encoding rules and the writing stroke order of the character to be recognized. The encoding segment acquisition module is configured to extract at least one encoding segment from the stroke order encoding in a sliding window manner according to a pre-set step size of the sliding window; wherein the step size of the sliding window is less than the length of each encoding segment. The recognition processing module is configured to perform the following for each encoded segment: according to a pre-set tolerance limit, collect a set of candidate known characters corresponding to the current encoded segment from a pre-generated dictionary; wherein, the dictionary includes multiple known characters; find the intersection between each set of candidate known characters corresponding to each encoded segment, and obtain the target known character in the dictionary corresponding to the character to be recognized based on the intersection; The text recognition device further includes: a BK tree forming module; The BK tree forming module is configured to perform the following for each known character in the dictionary: obtaining the stroke order code corresponding to the current known character based on pre-defined stroke order encoding rules and the stroke order of the current known character; extracting at least one encoding segment from the stroke order code; establishing a correspondence between the current known character and each encoding segment extracted from the current known character; and forming a BK tree using all the encoding segments extracted from each known character; wherein each node in the BK tree represents an encoding segment; and the edge between two nodes in the BK tree represents the edit distance between the two nodes. The identification processing module is configured to execute: Using the BK tree search method, at least one target node is found in the formed BK tree; wherein the edit distance between the encoded segment represented by the target node and the current encoded segment is not greater than the tolerance limit. Obtain at least one target encoded segment representing at least one target node; Each known character corresponding to at least one target encoded segment is used as a set of candidate known characters corresponding to the current encoded segment; For each encoding segment split from the stroke order encoding corresponding to the character to be identified, if at least two consecutive encoding segments correspond to the same known character, and the length of the longest local matching sequence is not less than the length of the stroke order encoding corresponding to the character to be identified multiplied by a preset percentage threshold, then the same known character corresponding to the at least two consecutive encoding segments is taken as the target known character in the dictionary corresponding to the character to be identified. The longest local matching sequence is the encoding sequence corresponding to the at least two consecutive encoded segments that can match the same known character.
8. List scanning device, wherein, The device includes: The module for obtaining the object to be scanned is configured to obtain the main object to be scanned; wherein, the main object to be scanned includes more than one character. The candidate list record acquisition module is configured to sequentially take each character in the subject object to be scanned as the character to be identified, and perform the following: using the device described in claim 7, obtain the target known character in the dictionary corresponding to the current character to be identified; wherein, the dictionary includes: all characters included in each list record in the list database; and search in the list database for a candidate list record that corresponds to the current character to be identified and includes the target known character. The matching module is configured to determine whether there is a matching record for the subject to be scanned, based on all the candidate list records found.
9. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-6.