Method for generating obfuscated Chinese characters, terminal device and computer-readable storage medium
By extracting a set of Chinese characters from a preset corpus and generating pronunciation and structural features, it automatically generates words with similar sounds and similar shapes, solving the problems of low efficiency and poor versatility in confusing word dictionary generation in the existing technology, and improving the accuracy of text error correction. Accuracy.
Patent Information
- Application Number
- CN202110693430.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-22
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-06-22
AI Technical Summary
In the existing technology, the generation efficiency of the obfuscated word dictionary is low and the versatility is poor, which affects the accuracy of text error correction.
By extracting a set of Chinese characters from a preset corpus, the pronunciation features and structural features of each Chinese character are generated. Based on these features, similar-sounding and similar-sounding characters are determined, and confusing words are automatically generated to improve the efficiency and accuracy of confusing word dictionary generation.
It improves the efficiency and versatility of confusing word dictionary generation, and improves the accuracy of text error correction.
Smart Images

Figure CN113536786B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of data processing, and particularly relates to a method for generating confused Chinese characters, a terminal device, and a computer-readable storage medium. Background Art
[0002] With the development of artificial intelligence technology, the application of natural language processing technology has become more and more extensive. In the process of natural language processing, as the number of incorrect words in the text to be processed increases, the accuracy of the natural language processing results also decreases accordingly. Therefore, text error correction is a key step in natural language processing. Text error correction refers to the process of correcting incorrect words in the text to correct words. For example: correcting the word "count" in the text "The conference adopted the voting method of on-site counting votes" to "record".
[0003] Text error correction mainly relies on a confused character dictionary, which includes correct characters and the confused characters of each correct character. In the prior art, usually a confused character dictionary is constructed manually. This method has a large workload and low efficiency; and due to the lack of unified standards, the generated confused character dictionary has poor universality, thus affecting the accuracy of text error correction. Summary of the Invention
[0004] The embodiments of this application provide a method for generating confused Chinese characters, a terminal device, and a computer-readable storage medium, which can effectively improve the generation efficiency of the confused character dictionary, effectively improve the universality of the confused character dictionary, and thus improve the accuracy of text error correction.
[0005] In a first aspect, the embodiments of this application provide a method for generating confused Chinese characters, including:
[0006] Extracting a set of Chinese characters from a preset corpus, where the set of Chinese characters includes multiple Chinese characters;
[0007] Generating the pronunciation feature and structure feature of each Chinese character in the set of Chinese characters;
[0008] Determining the homophonic characters of a target character in the set of Chinese characters according to the pronunciation feature, where the target character is any Chinese character in the set of Chinese characters;
[0009] Determining the similar-shaped characters of the target character in the set of Chinese characters according to the structure feature;
[0010] Generating the confused characters of the target character according to the homophonic characters and the similar-shaped characters of the target character in the set of Chinese characters.
[0011] In the embodiment of the present application, by extracting a set of Chinese characters from a preset corpus, commonly used Chinese characters can be obtained; then the pronunciation characteristics and structural characteristics of each Chinese character are generated, and the phonetic and morphologically similar characters of each Chinese character are generated respectively according to the pronunciation characteristics and structural characteristics of each Chinese character; since the errors of Chinese characters are mainly phonetic and morphologically similar errors, the above method can be used to obtain comprehensive and accurate similar characters for each Chinese character; finally, the confusing characters of each Chinese character are generated according to the phonetic and morphologically similar characters of each Chinese character. Through the above method, the confusing characters of each Chinese character can be automatically generated, which effectively improves the generation efficiency of the confusing character dictionary; in addition, the confusing character dictionary generated by the above method is accurate and comprehensive, and has strong versatility, which is conducive to improving the accuracy of text error correction.
[0012] In a possible implementation manner of the first aspect, extracting a set of Chinese characters from a preset corpus includes:
[0013] Counting the occurrence frequency of each Chinese character in the preset corpus;
[0014] Sorting the Chinese characters in the preset corpus in order of the occurrence frequency from high to low to obtain a first Chinese character sequence;
[0015] The first N Chinese characters in the first Chinese character sequence are used to generate the Chinese character set, wherein N is a large positive integer greater than 1.
[0016] In a possible implementation manner of the first aspect, generating a pronunciation feature and a structural feature of each Chinese character in the Chinese character set includes:
[0017] For any Chinese character in the Chinese character set, generating a pronunciation string for each pronunciation of the Chinese character according to the tone and syllable of each pronunciation of the Chinese character;
[0018] Determine the pronunciation character string of each pronunciation of the Chinese character as the pronunciation feature of the Chinese character;
[0019] According to the preset Chinese character structure rules, the Chinese character is split into multiple radicals;
[0020] Generate a structure tree from the radicals, wherein each radical is a node of the structure tree;
[0021] The structure tree is determined as the structural feature of the Chinese character.
[0022] In a possible implementation manner of the first aspect, determining a phonetically similar character of the target character in the Chinese character set according to the pronunciation feature includes:
[0023] Calculating a first edit distance between the target character and each non-target character according to the pronunciation feature, wherein the non-target character is any Chinese character in the Chinese character set except the target character;
[0024] Calculate the similarity between the target word and each of the non-target words according to the first edit distance;
[0025] The similar-sounding characters of the target character are determined from the non-target characters according to the similarity.
[0026] In a possible implementation manner of the first aspect, calculating a first edit distance between the target word and each non-target word according to the pronunciation feature includes:
[0027] The first edit distance between each of the pronunciation strings of the target characters and each of the pronunciation strings of the non-target characters is calculated.
[0028] In a possible implementation manner of the first aspect, calculating the similarity between the target word and each of the non-target words according to the first edit distance includes:
[0029] Calculating the maximum character length corresponding to each of the first edit distances, wherein the maximum character length is the maximum value of the length of the pronunciation string of the target word and the length of the pronunciation string of the non-target word;
[0030] Calculate the pronunciation distance ratio corresponding to each first edit distance according to the maximum character length;
[0031] The maximum value among the target ratios is determined as the similarity between the target word and the non-target word, wherein the target ratio is the pronunciation distance ratio corresponding to the first edit distance between the target word and the non-target word.
[0032] In a possible implementation manner of the first aspect, determining, according to the structural feature, a character similar in shape to the target character in the Chinese character set includes:
[0033] Calculating a second edit distance between the structure tree of the target character and the structure tree of each non-target character, wherein the non-target character is any Chinese character in the Chinese character set except the target character;
[0034] Sort the non-target characters in ascending order according to the second edit distance to obtain a second Chinese character sequence;
[0035] The first M Chinese characters in the second Chinese character sequence are determined as the characters similar in shape to the target character, wherein M is a positive integer.
[0036] In a possible implementation manner of the first aspect, generating a confused character of the target character according to the characters with similar pronunciation and the characters with similar appearance in the Chinese character set includes:
[0037] Deduplication processing is performed on the characters with similar pronunciation and the characters with similar appearance of the target character in the Chinese character set to obtain Chinese characters after deduplication processing;
[0038] The Chinese character after the deduplication process is determined as the confusing character of the target character.
[0039] In a second aspect, an embodiment of the present application provides a device for generating obfuscated Chinese characters, including:
[0040] A Chinese character extraction unit, used to extract a Chinese character set from a preset corpus, wherein the Chinese character set includes a plurality of Chinese characters;
[0041] A feature generating unit, used to generate a pronunciation feature and a structural feature of each Chinese character in the Chinese character set;
[0042] A phonetically similar character generating unit, configured to determine a phonetically similar character of a target character in the Chinese character set according to the pronunciation feature, wherein the target character is any Chinese character in the Chinese character set;
[0043] A similar character generating unit, used for determining a similar character of the target character in the Chinese character set according to the structural feature;
[0044] The confusing character generating unit is used to generate a confusing character of the target character according to the characters with similar pronunciation and the characters with similar appearance in the Chinese character set.
[0045] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a method for generating confusing Chinese characters as described in any one of the first aspects above when executing the computer program.
[0046] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and wherein when the computer program is executed by a processor, the method for generating confusing Chinese characters as described in any one of the above-mentioned first aspects is implemented.
[0047] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the method for generating confusing Chinese characters described in any one of the above-mentioned first aspects.
[0048] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0050] Figure 1 It is a flowchart of a method for generating obfuscated Chinese characters provided in an embodiment of the present application;
[0051] Figure 2 is a schematic diagram of a structure tree provided in an embodiment of the present application;
[0052] Figure 3 is a flow chart of a method for generating obfuscated Chinese characters provided by another embodiment of the present application;
[0053] Figure 4 It is a structural block diagram of a device for generating confusing Chinese characters provided in an embodiment of the present application;
[0054] Figure 5 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0055] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0056] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0057] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting" depending on the context.
[0058] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0059] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0060] See also Figure 1 , is a flow chart of a method for generating obfuscated Chinese characters provided in an embodiment of the present application. As an example but not a limitation, the method may include the following steps:
[0061] S101, extracting a Chinese character set from a preset corpus, where the Chinese character set includes a plurality of Chinese characters.
[0062] You can obtain a preset corpus based on the category of the text. For example, when you need to correct the text of a company's financial report, you can use the company's historical financial report as the preset corpus. When you need to correct the text of an academic paper, you can use the academic literature in the field of the academic paper as the preset corpus.
[0063] The preset corpus can be obtained from a preset file library or from the Internet through a crawler operation.
[0064] In one embodiment, S101 may include the following steps:
[0065] The occurrence frequency of each Chinese character in the preset corpus is counted; the Chinese characters in the preset corpus are sorted in descending order of occurrence frequency to obtain a first Chinese character sequence; the first N Chinese characters in the first Chinese character sequence are used to generate a Chinese character set, where N is a large positive integer greater than 1.
[0066] In another embodiment, S101 may further include the following steps:
[0067] Count the occurrence frequency of each Chinese character in the preset corpus; add Chinese characters with an occurrence frequency greater than the preset frequency to the Chinese character set.
[0068] The occurrence frequency of Chinese character A refers to the ratio of the number of occurrences of Chinese character A to the total number of Chinese characters in a preset corpus. The higher the occurrence frequency of a Chinese character, the more times it is used. In practical applications, errors in characters such as English letters, numbers, and punctuation are usually not considered. Therefore, it is only necessary to count the occurrence probability of each Chinese character in the preset corpus.
[0069] The larger the value of N, the more Chinese characters there are in the Chinese character set, and the lower the subsequent generation efficiency of confused Chinese characters, but the coverage range of the confused character dictionary is relatively large. The larger the preset frequency, the fewer Chinese characters there are in the Chinese character set, the higher the subsequent generation efficiency of confused Chinese characters, and the relatively smaller the coverage range of the generated confused character dictionary. Therefore, N and the preset frequency in the above embodiments can be set according to actual needs.
[0070] Through the above method, Chinese characters with a relatively large number of usage times (i.e., common Chinese characters) in the preset corpus can be obtained. Since the occurrence frequencies of some rare Chinese characters (such as 喌, 壣, 夁, etc.) in the text are relatively low, if confused Chinese characters are generated for each Chinese character in the preset corpus, it will affect the generation efficiency of the confused character dictionary. And through the above method, rare Chinese characters with relatively low usage frequencies can be effectively filtered out, thereby effectively improving the generation efficiency of the confused character dictionary.
[0071] S102, generate the pronunciation features and structural features of each Chinese character in the Chinese character set.
[0072] Chinese pronunciation includes syllables and tones. Homophonic characters can include two situations: the syllables are the same but the tones are different, and the syllables are different but the tones are the same. For example, the two characters "金" and "进" are homophonic characters with the same syllable but different tones, and the two characters "静" and "进" are homophonic characters with different syllables but the same tone (ing and in are easily confused). Therefore, if it is necessary to determine whether two characters are homophonic characters, both syllables and tones need to be considered.
[0073] In one embodiment, for any Chinese character A in the Chinese character set, the steps of generating the pronunciation feature of the Chinese character A may include:
[0074] Generate a pronunciation string for each pronunciation of Chinese character A according to the tone and syllable of each pronunciation of Chinese character A; determine the pronunciation string of each pronunciation of Chinese character A as the pronunciation feature of Chinese character A.
[0075] There are cases of polyphonic Chinese characters, and one Chinese character may correspond to multiple pronunciations. Therefore, it is necessary to generate pronunciation strings for each possible pronunciation of the Chinese character. In this way, the subsequent generated confused Chinese characters will be more comprehensive and accurate.
[0076] Optionally, generating a pronunciation string of Chinese character A in a certain pronunciation according to the tone and syllable of any pronunciation of Chinese character A may include:
[0077] Obtain a preset character corresponding to the tone of the pronunciation of Chinese character A; combine the preset character with each character in the syllable of the pronunciation of Chinese character A to form a pronunciation string of Chinese character A in this pronunciation.
[0078] Chinese tones include four types: flat tone (i.e., the first tone, usually represented by "ˉ"), rising tone (i.e., the second tone, usually represented by "ˊ"), falling-rising tone (i.e., the third tone, usually represented by "ˇ"), and falling tone (i.e., the fourth tone, usually represented by "ˋ"). The preset characters representing different tones can be characters recognizable by a computer, such as numbers or letters, etc.
[0079] Exemplarily, assume that the pronunciation of "薄" is báo, assume that the preset character corresponding to the flat tone is 1, the preset character corresponding to the rising tone is 2, the preset character corresponding to the falling-rising tone is 3, and the preset character corresponding to the falling tone is 4. Then the preset character corresponding to the tone of the pronunciation báo is 2. The syllable bao of this pronunciation includes 3 characters. The generated pronunciation string of the pronunciation báo is "bao2".
[0080] In practical applications, the pronunciation string can be generated in the format of style.TONE2 or style.TONE3 in the PyPinyin library of Python. The PyPinyin library can be used to convert Chinese characters into pinyin. This library has the characteristics of intelligently matching the most correct pinyin according to phrases, supporting polyphonic characters, supporting traditional Chinese, supporting phonetic notations, and supporting multiple different pinyin / phonetic notation styles. Among them, style.TONE2 means that the tone is after the final of the syllable and is represented by numbers 1-4, such as ba2o. The style.TONE3 format means that the tone of the pronunciation is after the syllable and is represented by numbers 1-4. Of course, the format of the pronunciation string can also be set by oneself, such as making the tone after or before the initial consonant (b2ao or 2bao).
[0081] Optionally, for any Chinese character A in the Chinese character set, the steps of generating the structural feature of the Chinese character A may include:
[0082] Split Chinese character A into multiple radicals according to a preset structural rule; generate a structure tree from the radicals, where each radical is a node of the structure tree; determine the structure tree as the structural feature of Chinese character A.
[0083] The preset structural rules can be the stroke structures of Chinese characters. For example, the stroke structures of Chinese characters include left-right, up-down, up-middle-down, semi-surrounded, and fully surrounded, etc. According to the stroke structure, the Chinese character "Qiao" is split into three radicals: "Yao", "Pie", and "Shu". Of course, each radical can be further split into multiple basic strokes (such as horizontal, vertical, left-falling, right-falling, dot, fold, etc.). However, the higher the granularity of the split, the greater the amount of data processing for generating confused Chinese characters in the subsequent process, and the lower the efficiency. Since it is sufficient to use radicals to judge the similarity of two Chinese characters, therefore, it is only necessary to split Chinese characters into radicals, which is conducive to reducing the amount of data processing for the method of generating confused Chinese characters and improving the processing efficiency.
[0084] The radicals can be used to generate a structure tree in the order of Chinese character writing. Specifically, the radical ranked first in the writing order can be used as the root node in the structure tree, and the radical ranked second in the writing order can be used as the child node of the root node, and so on. Exemplarily, refer to Figure 2 , which is a schematic diagram of the structure tree provided by the embodiment of the present application. As Figure 2 shown in (a) of, the root node of the structure tree of the character "Qiao" is "Yao", and the child nodes of "Yao" are "Pie" and "Shu".
[0085] Alternatively, the stroke structure of a Chinese character can be used as the root node in the structure tree, and then each child node can be determined in turn according to the stroke structure. As Figure 2 shown in (b) of, the stroke structure of the character "Qiao" is an up-down structure, and the identifier corresponding to the up-down structure is used as the root node in the structure tree; "Yao" in the upper part is a child node under the root node, and the lower part structure is composed of a left-right structure, and the identifier corresponding to the left-right structure is used as another child node under the root node; "Pie" and "Shu" are respectively used as the two child nodes under the node of the left-right structure. In the above example, for the convenience of representation, the identifiers of the structures are shown in the form of graphics. In practical applications, the identifiers of the structures are usually represented by symbols that can be recognized by a computer. For example, different strokes can be represented by different numbers or letters, and then the numbers or letters are used as nodes.
[0086] Through the above embodiments, the pronunciation features and structural features of Chinese characters that can be processed by a computer are generated, providing a reliable data basis for the subsequent generation of confused Chinese characters.
[0087] S103. Determine the homophonic characters of the target character in the Chinese character set according to the pronunciation features.
[0088] The target character is any Chinese character in the Chinese character set.
[0089] In one embodiment, S103 may include the following steps:
[0090] The first edit distance between the target character and each non-target character is calculated according to the pronunciation feature, and the non-target character is any Chinese character in the Chinese character set except the target character; the similarity between the target character and each non-target character is calculated according to the first edit distance; and the pronunciation-similar characters of the target character are determined from the non-target characters according to the similarity.
[0091] Since the pronunciation feature may include multiple pronunciation character strings, it is necessary to calculate the first edit distance between each pronunciation character string of the target character and each pronunciation character string of the non-target character.
[0092] Edit distance is an indicator used to measure the similarity between two sequences. In layman's terms, edit distance refers to the distance between two strings.<w1,w2> The minimum number of single-character editing operations required to convert one string w1 into another string w2. There are only three single-character editing operations: insert, delete, and replace.
[0093] Optionally, the first edit distance can be calculated using the Levenstein algorithm. The formula is as follows:
[0094]
[0095] Among them, lev a,b (a i ,b i ) represents the i-th character a in the pronunciation string a i The jth character b in the pronunciation string b j The first edit distance between them. The three formulas in the min formula correspond to the string insertion, deletion, and replacement operations, and each operation will cause the edit distance to increase by 1. Indicates when a i ≠b j When the value is 1, when a i =b j The value is 0. The final calculated lev a,b (|a|,|b|) is the first edit distance between the pronunciation string a and the pronunciation string b, |a| is the number of characters in the pronunciation string a, and |b| is the number of characters in the pronunciation string b.
[0096] Due to the different lengths of the pronunciation strings, the edit distance between long pronunciation strings is generally larger than the edit distance between short pronunciation strings. In order to unify the metric standard and improve the reliability of distinguishing similar-sounding characters, optionally, calculating the similarity between the target character and any non-target character according to the first edit distance may include the following steps:
[0097] Calculate the maximum character length corresponding to each first edit distance, where the maximum character length is the maximum of the length of the pronunciation string of the target character and the length of the pronunciation string of the non-target character; calculate the pronunciation distance ratio corresponding to each first edit distance according to the maximum character length; determine the maximum value in the target ratio as the similarity between the target character and the non-target character, where the target ratio is the pronunciation distance ratio corresponding to the first edit distance between the target character and the non-target character.
[0098] Specifically, the calculation formula for the pronunciation distance ratio is as follows:
[0099]
[0100] Where Sim a,b is the pronunciation distance ratio corresponding to the first edit distance lev a,b (|a|, |b|) between the pronunciation string a and the pronunciation string b, and max(|a|, |b|) represents the maximum character length corresponding to the first edit distance lev a,b (|a|, |b|).
[0101] Exemplarily, according to the above method, the pronunciation distance ratios between the pronunciation strings bao2, bo, bu4, and bo4 of the character "薄" and the pronunciation string bao3 of the character "保" are respectively: 1 - 1 / 4 = 0.75, 1 - 2 / 4 = 0.5, 1 - 3 / 4 = 0.25, 1 - 2 / 4 = 0.5. Take the maximum value 0.75 among them as the similarity between "薄" and "保".
[0102] In the above method, the case of polyphonic characters is considered, and the pronunciation strings of each pronunciation are counted; and the edit distances of the pronunciation strings are effectively unified through the calculation method of the pronunciation distance ratio, avoiding the situation where there are differences in the edit distances of long and short pronunciation strings. Through the above embodiments, relatively accurate and comprehensive phonetically similar characters can be obtained.
[0103] S104. Determine the visually similar characters of the target character in the Chinese character set according to the structural features.
[0104] In one embodiment, S104 may include the following steps:
[0105] Calculate the second edit distance between the structure tree of the target character and the structure tree of each non-target character; sort the non-target characters in ascending order of the second edit distance to obtain the second Chinese character sequence; determine the first M Chinese characters in the second Chinese character sequence as the visually similar characters of the target character, where M is a positive integer.
[0106] Calculating the edit distance between structural trees refers to the minimum number of operations required to map one structural tree to another. However, the calculation method of the edit distance between structural trees is much more complex. Optionally, in the embodiments of the present application, the APTED algorithm is used to calculate the edit distance between structural trees.
[0107] The basic idea of the APTED algorithm is as follows: First, recursively traverse all subtrees included in the structural trees from left to right and from right to left respectively; then match the nodes in the two structural trees to determine the same nodes between the two structural trees and calculate the number of steps required for node transformation; finally, calculate the edit distance between the structural trees based on the number of nodes in the structural trees and the number of steps required for node transformation.
[0108] For example, the second edit distance between the character "乔" and "不" calculated by the above method is 0.935, the second edit distance between the character "乔" and "介" is 0.935, the second edit distance between the character "乔" and "齐" is 0.935, and the second edit distance between the character "乔" and "万" is 0.875. Assuming M = 1, the Chinese character corresponding to the minimum second edit distance is determined as the similar-looking character of "乔", that is, "万".
[0109] Similar to the processing of homophonic characters, in the embodiments of the present application, the structural distance ratio corresponding to the second edit distance can also be calculated. The calculation method can refer to the calculation method of the pronunciation distance ratio, which will not be elaborated here.
[0110] S105. Generate confusing characters for the target character based on the homophonic characters and similar-looking characters of the target character in the Chinese character set.
[0111] In one embodiment, S105 may include the following steps:
[0112] Deduplicate the homophonic characters and similar-looking characters of the target character in the Chinese character set to obtain the Chinese characters after deduplication processing; determine the Chinese characters after deduplication processing as the confusing characters of the target character.
[0113] In practical applications, there may be a situation where the homophonic characters and similar-looking characters of a certain Chinese character are the same character. In this case, there are two identical Chinese characters in the confusing characters of this Chinese character. Deduplicating the homophonic characters and similar-looking characters of each Chinese character can improve the accuracy of the confusing character dictionary and save the storage space required for storing the confusing character dictionary.
[0114] See Figure 3 which is a schematic flowchart of a method for generating confusing Chinese characters provided by another embodiment of the present application. As Figure 3 shown, generating confusing Chinese characters can be divided into two parts: generating homophonic characters and generating similar-looking characters.
[0115] In the embodiments of the present application, by extracting a Chinese character set from a preset corpus (such as Figure 3Common Chinese characters shown in the figure) can obtain commonly used Chinese characters; then generate the pronunciation features of each Chinese character (such as Figure 3 The pronunciation and tone of the Chinese characters shown) and structural features (such as Figure 3 The Chinese character glyph structure and binary tree structure shown in FIG. 1 are used to generate the pronunciation-similar characters and the shape-similar characters of each Chinese character according to the pronunciation characteristics and structure characteristics of each Chinese character. Figure 3 =The pronunciation distance ratio shown in the figure); Since the errors of Chinese characters are mainly errors of similar-sounding characters and similar-shaped characters, the above method can obtain comprehensive and accurate similar characters for each Chinese character; finally, the confusing characters of each Chinese character are generated according to the similar-sounding characters and similar-shaped characters of each Chinese character. Through the above method, the confusing characters of each Chinese character can be automatically generated, which effectively improves the generation efficiency of the confusing character dictionary; in addition, the confusing character dictionary generated by the above method is accurate and comprehensive, and has strong versatility, which is conducive to improving the accuracy of text error correction.
[0116] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0117] Corresponding to the method described in the above embodiment, Figure 4 This is a structural block diagram of a device for generating confusing Chinese characters provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0118] Reference Figure 4 , the device comprises:
[0119] The Chinese character extraction unit 41 is used to extract a Chinese character set from a preset corpus, wherein the Chinese character set includes a plurality of Chinese characters.
[0120] The feature generating unit 42 is used to generate the pronunciation feature and the structural feature of each Chinese character in the Chinese character set.
[0121] The phonetic-similar character generating unit 43 is used to determine the phonetic-similar character of the target character in the Chinese character set according to the pronunciation feature, and the target character is any Chinese character in the Chinese character set.
[0122] The similar character generating unit 44 is used to determine the similar characters of the target character in the Chinese character set according to the structural features.
[0123] The confusing character generating unit 45 is used to generate a confusing character of the target character according to the characters with similar pronunciation and the characters with similar appearance in the Chinese character set.
[0124] Optionally, the Chinese character extraction unit 41 is further used for:
[0125] The occurrence frequency of each Chinese character in the preset corpus is counted; the Chinese characters in the preset corpus are sorted in descending order of the occurrence frequency to obtain a first Chinese character sequence; the first N Chinese characters in the first Chinese character sequence are used to generate the Chinese character set, wherein N is a large positive integer greater than 1.
[0126] Optionally, the feature generating unit 42 is further used for:
[0127] For any Chinese character in the Chinese character set, a pronunciation string for each pronunciation of the Chinese character is generated according to the tone and syllable of each pronunciation of the Chinese character; the pronunciation string for each pronunciation of the Chinese character is determined as the pronunciation feature of the Chinese character; according to a preset Chinese character structure rule, the Chinese character is split into multiple radicals; a structure tree is generated from the radicals, wherein each radical is a node of the structure tree; and the structure tree is determined as the structural feature of the Chinese character.
[0128] Optionally, the phonetic-similar character generating unit 43 is further used for:
[0129] The first edit distance between the target character and each non-target character is calculated according to the pronunciation feature, and the non-target character is any Chinese character in the Chinese character set except the target character; the similarity between the target character and each non-target character is calculated according to the first edit distance; and the phonetically similar character of the target character is determined from the non-target characters according to the similarity.
[0130] Optionally, the phonetic-similar character generating unit 43 is further used for:
[0131] The first edit distance between each of the pronunciation strings of the target characters and each of the pronunciation strings of the non-target characters is calculated.
[0132] Optionally, the phonetic similar character generating unit 43 is further used for:
[0133] Calculate the maximum character length corresponding to each of the first edit distances, wherein the maximum character length is the maximum value of the length of the pronunciation string of the target word and the length of the pronunciation string of the non-target word; calculate the pronunciation distance ratio corresponding to each of the first edit distances according to the maximum character length; determine the maximum value of the target ratio as the similarity between the target word and the non-target word, wherein the target ratio is the pronunciation distance ratio corresponding to the first edit distance between the target word and the non-target word.
[0134] Optionally, the similar character generation unit 44 is further used to: calculate a second edit distance between the structure tree of the target character and the structure tree of each non-target character, wherein the non-target character is any Chinese character in the Chinese character set except the target character; sort the non-target characters in ascending order according to the second edit distance to obtain a second Chinese character sequence; and determine the first M Chinese characters in the second Chinese character sequence as the similar characters of the target character, wherein M is a positive integer.
[0135] Optionally, the confusing character generating unit 45 is further used for:
[0136] The characters with similar pronunciation and similar appearance of the target character in the Chinese character set are deduplicated to obtain deduplicated Chinese characters; and the deduplicated Chinese characters are determined as confusing characters of the target character.
[0137] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0138] in addition, Figure 4 The device shown may be a software unit, a hardware unit, or a combination of software and hardware, which is built into an existing terminal device, or may be integrated into the terminal device as an independent accessory, or may exist as an independent terminal device.
[0139] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0140] Figure 5 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Figure 5 As shown, the terminal device 5 of this embodiment includes: at least one processor 50 ( Figure 5Only one is shown in the figure) a processor, a memory 51, and a computer program 52 stored in the memory 51 and executable on the at least one processor 50. When the processor 50 executes the computer program 52, the steps in any of the above-mentioned embodiments of the method for generating confusing Chinese characters are implemented.
[0141] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 5 It is only an example of the terminal device 5 and does not constitute a limitation on the terminal device 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0142] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0143] In some embodiments, the memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or memory of the terminal device 5. In other embodiments, the memory 51 may also be an external storage device of the terminal device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 5. Further, the memory 51 may also include both an internal storage unit and an external storage device of the terminal device 5. The memory 51 is used to store an operating system, an application program, a boot loader, data, and other programs, such as the program code of the computer program. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0144] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0145] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0146] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0147] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0148] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0149] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for generating confusing Chinese characters, characterized in that: include: Extracting a Chinese character set from a preset corpus, wherein the Chinese character set includes a plurality of Chinese characters; Generate pronunciation features and structural features of each Chinese character in the Chinese character set; Determine a character with similar pronunciation to the target character in the Chinese character set according to the pronunciation feature, wherein the target character is any Chinese character in the Chinese character set; Determine the similar characters of the target character in the Chinese character set according to the structural features; Generate a confusing character of the target character according to the characters with similar pronunciation and the characters with similar appearance in the Chinese character set; The step of extracting a set of Chinese characters from a preset corpus includes: counting the occurrence frequency of each Chinese character in the preset corpus; Sorting the Chinese characters in the preset corpus in the order of the occurrence frequency from high to low to obtain a first Chinese character sequence, and generating the Chinese character set from the first N Chinese characters in the first Chinese character sequence; or adding Chinese characters whose occurrence frequency is greater than a preset frequency to the Chinese character set; The generating of the pronunciation feature and the structural feature of each Chinese character in the Chinese character set includes: For any Chinese character in the Chinese character set, generating a pronunciation string for each pronunciation of the Chinese character according to the tone and syllable of each pronunciation of the Chinese character; Determine the pronunciation character string of each pronunciation of the Chinese character as the pronunciation feature of the Chinese character; According to the preset Chinese character structure rules, the Chinese character is split into multiple radicals; Generating a structure tree from the radicals, including: taking the radical that ranks first in the writing order as a root node in the structure tree, taking the radical that ranks second in the writing order as a child node of the root node, and so on; Determining the structure tree as the structural feature of the Chinese character; Wherein, determining the pronunciation-similar characters of the target character in the Chinese character set according to the pronunciation feature includes: Calculating a first edit distance between the target word and each non-target word according to the pronunciation feature; Calculate the similarity between the target word and each of the non-target words according to the first edit distance; Determine the pronunciation-similar character of the target character from the non-target characters according to the similarity; The step of determining the similar characters of the target character in the Chinese character set according to the structural features comprises: Calculating a second edit distance between the structure tree of the target word and the structure tree of each non-target word using an APTED algorithm, wherein the non-target word is any Chinese character in the Chinese character set except the target word; Sort the non-target characters in ascending order according to the second edit distance to obtain a second Chinese character sequence; The first M Chinese characters in the second Chinese character sequence are determined as the characters similar in shape to the target character, wherein M is a positive integer.
2. The method for generating confusing Chinese characters as claimed in claim 1, characterized in that: The N is a positive integer greater than 1.
3. The method for generating confusing Chinese characters as claimed in claim 1, characterized in that: Each of the radicals is a node of the structure tree.
4. The method for generating confusing Chinese characters as claimed in claim 3, characterized in that: The non-target character is any Chinese character in the Chinese character set except the target character.
5. The method for generating confusing Chinese characters as claimed in claim 4, characterized in that: The calculating the first edit distance between the target word and each non-target word according to the pronunciation feature comprises: The first edit distance between each of the pronunciation strings of the target characters and each of the pronunciation strings of the non-target characters is calculated.
6. The method for generating confusing Chinese characters as claimed in claim 5, characterized in that: The calculating the similarity between the target word and each of the non-target words according to the first edit distance comprises: Calculating the maximum character length corresponding to each of the first edit distances, wherein the maximum character length is the maximum value of the length of the pronunciation string of the target word and the length of the pronunciation string of the non-target word; Calculate the pronunciation distance ratio corresponding to each first edit distance according to the maximum character length; The maximum value among the target ratios is determined as the similarity between the target word and the non-target word, wherein the target ratio is the pronunciation distance ratio corresponding to the first edit distance between the target word and the non-target word.
7. The method for generating confusing Chinese characters as claimed in claim 1, characterized in that: The generating of the confusing character of the target character according to the characters with similar pronunciation and the characters with similar appearance in the Chinese character set comprises: Deduplication processing is performed on the characters with similar pronunciation and the characters with similar appearance of the target character in the Chinese character set to obtain Chinese characters after deduplication processing; The Chinese character after the deduplication process is determined as the confusing character of the target character.
8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
