A method and device for constructing a training data set for a text error correction model
By perturbing and converting the pinyin sequence of the correct text in the corpus, a training data set for the text error correction model is constructed, which solves the problems of low efficiency and poor simulation errors in the existing technology, and achieves the rapid construction of high-quality large-scale training data set effect.
Patent Information
- Application Number
- CN202410273413.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-03-11
AI Technical Summary
Existing text error correction model training data set construction methods are inefficient and difficult to construct large-scale data sets. Traditional methods cannot effectively simulate manual input errors, resulting in poor training results.
Convert the correct text in the preset corpus into a correct pinyin sequence through the Chinese character pinyin comparison table, perturb the pinyin sequence based on the preset perturbation ratio and method, generate a perturbed pinyin sequence, divide it into small segments, and finally convert it into an incorrect text. Construct training data that includes correct text and incorrect text.
Construct high-quality training data sets quickly and in large batches to simulate manual input errors. The effect is close to manual annotation, avoiding a lot of manual work, and has both scale and quality.
Smart Images

Figure CN118153559B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data set construction, and in particular to a method and device for constructing a training data set for a text error correction model. Background Art
[0002] A text error correction model is a model that can calculate the corresponding correct text based on the erroneous text, but this model requires a large number of samples as a training data set during training.
[0003] At present, a commonly used method for constructing training data sets is to use manual annotation methods, but this method is extremely inefficient and it is difficult to construct a large-scale data set; another method is to obtain incorrect text by randomly replacing the words in the correct text. This can quickly construct a large number of data sets, but the constructed incorrect text cannot reflect the real rules of manual input errors, resulting in a large difference between the distribution of the constructed data set and the real data set, which affects the training effect of the text error correction model. Summary of the invention
[0004] The present invention provides a method and device for constructing a training data set for a text error correction model, which is used to solve at least one of the above-mentioned technical problems.
[0005] The present invention adopts the following technical solutions:
[0006] On the one hand, the present invention provides a method for constructing a training data set for a text error correction model, the method comprising: converting correct text in a preset corpus into a correct pinyin sequence through a Chinese character pinyin comparison table; based on a preset disturbance ratio, perturbing the correct pinyin sequence through a preset disturbance method to obtain a perturbed pinyin sequence, the preset disturbance ratio is used to indicate the proportion of the number of perturbed words in the correct text to the total number of words; dividing the perturbed pinyin sequence into a number of small segments, so that each small segment corresponds to the pinyin of a Chinese character; converting the several small segments into incorrect text through the Chinese character pinyin comparison table to obtain training data including correct text and incorrect text.
[0007] In a possible implementation of the present invention, the method for constructing the preset corpus includes: obtaining text materials on a preset website, the text materials at least including papers, journals and news manuscripts; performing sentence segmentation on the text materials according to punctuation marks, and constructing the preset corpus based on the segmentation results.
[0008] In a possible implementation of the present invention, the correct pinyin sequence is disturbed by a preset disturbance method, including: segmenting the correct text; rounding up the product of the total number of words corresponding to the correct text and the preset disturbance ratio to obtain the number of words to be disturbed; determining the pinyin to be disturbed corresponding to any word to be disturbed in the correct pinyin sequence; determining the preset disturbance method according to the error type distribution probability corresponding to the training data set to be generated, the error type distribution probability corresponds one-to-one to the preset disturbance method; and perturbing the pinyin to be disturbed by the preset disturbance method.
[0009] In a possible implementation of the present invention, the preset disturbance method includes at least one of confusing approximate pinyin, reversing the order of letters, adding letters, deleting letters and replacing wrong letters.
[0010] In a possible implementation of the present invention, when the preset disturbance mode is the confusing approximate pinyin, the method further includes: determining whether there is an approximate pinyin for the pinyin to be disturbed; if not, determining a new preset disturbance mode according to the error type distribution probability.
[0011] In a possible implementation of the present invention, the disturbed pinyin sequence is divided into several small segments, including: judging whether the segment formed by the i-th letter to the j-th letter in the disturbed pinyin sequence is a legal pinyin, wherein the initial values of i and j are 1; if so, storing the segment formed by the i-th letter to the j-th letter in an array F, and setting i=j+1, j=j+1; if not, setting j=j+1, and when j is greater than L1, storing the i-th letter in the array F, and setting i=i+1, j=i+1.
[0012] In a possible implementation of the present invention, after obtaining the array F, the method also includes: determining the length L2 of the array F; judging in the array F whether the kth legal pinyin and the k+1th legal pinyin can constitute a legal pinyin, and the initial value of k is 1; if so, merging the kth legal pinyin and the k+1th legal pinyin, replacing the kth legal pinyin, and setting L2=L2-1; if not, setting k=k+1, and ending the judgment when k is greater than or equal to L2.
[0013] In a possible implementation of the present invention, when the kth legal pinyin and the k+1th legal pinyin in the array F can constitute a legal pinyin, the method also includes: generating a random number a; if the random number a is less than or equal to a merging parameter, merging the kth legal pinyin and the k+1th legal pinyin in the array F; if the random number a is greater than the merging parameter, not merging the kth legal pinyin and the k+1th legal pinyin in the array F.
[0014] In a possible implementation of the present invention, the several small segments are converted into erroneous texts through the Chinese-character-pinyin comparison table, including: for any of the several small segments, all corresponding Chinese characters are determined in the Chinese-character-pinyin comparison table, and one of all Chinese characters is randomly selected as the corresponding Chinese character of the any small segment; if the any small segment is an illegal pinyin, a legal pinyin small segment with the highest similarity to the any small segment is determined among the several small segments, and any one of all Chinese characters corresponding to the legal pinyin small segment in the Chinese-character-pinyin comparison table is determined as the corresponding Chinese character of the any small segment; the erroneous text is obtained according to all corresponding Chinese characters of the several small segments.
[0015] On the other hand, the present invention also provides a device for constructing a training data set for a text error correction model, the device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor so that the at least one processor can execute, converting correct text in a preset corpus into a correct pinyin sequence through a Chinese character pinyin comparison table; based on a preset disturbance ratio, perturbing the correct pinyin sequence through a preset disturbance method to obtain a perturbed pinyin sequence, the preset disturbance ratio is used to indicate the proportion of the number of perturbed words in the correct text to the total number of words; dividing the perturbed pinyin sequence into a number of small segments, so that each small segment corresponds to the pinyin of a Chinese character; converting the several small segments into incorrect text through the Chinese character pinyin comparison table to obtain training data including correct text and incorrect text.
[0016] The present invention provides a method and device for constructing a training data set for a text error correction model, which has the following beneficial effects:
[0017] By randomly selecting correct text from a good corpus, and then randomly perturbing the correct pinyin sequence of the correct text to simulate human errors, the corresponding incorrect pinyin sequence is obtained, and finally the incorrect pinyin sequence is converted into text to obtain incorrect text. This method can quickly and massively construct "correct text + incorrect text" pairs, and obtain a large-scale training data set at an extremely low cost, avoiding a lot of manual work in traditional annotation methods. In addition, this method can also make the constructed incorrect text simulate the errors that occur during manual input very well, and its effect is close to that of a manually annotated data set, while avoiding manual workload, and having both quality and scale. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0019] Figure 1 A flow chart of a method for constructing a training data set for a text error correction model provided by the present invention;
[0020] Figure 2 A schematic diagram of error text generation in an application scenario provided by the present invention;
[0021] Figure 3 A schematic diagram of the structure of a device for constructing a training data set for a text error correction model provided by the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0023] The method of the present invention is described in detail below with reference to the accompanying drawings.
[0024] Figure 1 A flow chart of a method for constructing a training data set for a text error correction model provided by the present invention, such as Figure 1 As shown, the method for constructing a data set in the present invention at least includes the following execution steps:
[0025] Step 101: Convert the correct text in the preset corpus into a correct pinyin sequence through a Chinese character pinyin comparison table.
[0026] The core of the data set construction method in the present invention is to generate erroneous texts through correct texts, thereby obtaining a set of training data including correct texts and erroneous texts.
[0027] In a possible implementation manner of the present invention, the correctness of the correct text determines the accuracy of the finally constructed training data set. Therefore, to ensure the correctness of the obtained correct text, the present invention constructs a preset corpus. By obtaining news materials on official media websites and text materials such as papers and periodicals on literature retrieval websites, the text materials are split into sentences according to punctuation marks to obtain correct sentences. The text materials obtained by the present invention usually go through a strict review and proofreading process, and the probability of errors is extremely low, which can meet the high-quality requirements of the corpus, so that the corpus rarely contains incorrect texts. In this way, any sentence randomly selected from the corpus can be considered as a correct text.
[0028] Further, after extracting the correct text, the corresponding pinyin of each Chinese character is found through the Chinese character pinyin对照表 to form a correct pinyin sequence.
[0029] Step 102: Based on a preset perturbation ratio, the correct pinyin sequence is perturbed through a preset perturbation method to obtain a perturbed pinyin sequence.
[0030] In a possible implementation manner of the present invention, through the following method, the letters in the correct pinyin sequence of the correct text are randomly perturbed with a certain probability. This kind of perturbation can simulate various errors that are likely to occur during manual input, making the perturbed pinyin letter sequence closer to the content containing errors input in the natural state of manual input:
[0031] First, the correct text is segmented. The segmentation process here can be implemented through existing algorithms or methods, and the present invention will not elaborate on this.
[0032] After that, the total number of words is multiplied by the preset perturbation ratio and rounded up to obtain the number N of words to be perturbed. In an example of the present invention, the preset perturbation ratio refers to the ratio of the number of words perturbed in a correct text to the total number of words in the text. For example, if the preset perturbation ratio is set to 2%, then for a correct text containing 100 words, it is necessary to randomly select the pinyin letter sequences corresponding to 2 of these words for perturbation.
[0033] Finally, randomly select N words from the segmentation result, and for each of these N words, perform the following steps: first, find the corresponding pinyin letter sequence of the word through the correct pinyin sequence, and this pinyin letter sequence is the pinyin to be perturbed. For example, the pinyin letter sequence corresponding to "好的" is "haode"; then, according to the probability distribution of error types, randomly select an error type and perturb the pinyin letter sequence for this error type. It should be noted that when the present invention perturbs the correct pinyin sequence, multiple preset perturbation methods can be used, and different perturbation methods correspond to different error types, that is, different errors are generated in the correct pinyin sequence.
[0034] In one example of the present invention, the aforementioned preset disturbance method includes at least one of confusing approximate pinyin, reversing the order of letters, adding letters, deleting letters, and replacing correct letters with incorrect letters.
[0035] In one example of the present invention, confusion of approximate pinyin includes: confusion of flat tongue sounds and retroflex tongue sounds: z and zh, c and ch, s and sh; confusion of front nasal sounds and back nasal sounds: ing and in, en and eng, an and ang; confusion of nasal sounds and lateral sounds: n and l; missing letters, for example, inputting haode as hade; inputting extra letters, for example, inputting hulai as huilai; reversing the order of letters: for example, inputting meiyou as mieyou; inputting wrong letters, especially pressing letters that are adjacent to each other on the keyboard, for example, o and i are adjacent to each other on the keyboard, it is easy to input hao as hai.
[0036] In one example of the present invention, the probability distribution of error types refers to assigning a probability to each of the above five error types (the sum of the five probabilities must be 1), and then randomly selecting an error type with this probability to perturb the correct pinyin sequence. For example, the probability of confusing approximate pinyin is set to 0.3, the probability of missing input letters is set to 0.1, the probability of inputting extra letters is set to 0.2, the probability of reversed letter order is set to 0.25, and the probability of inputting wrong letters is set to 0.15. Then, on average, for every 100 perturbations, 30 of them are perturbations that confuse approximate pinyin, and the rest are similar.
[0037] Furthermore, if the disturbance method or error type selected when disturbing the correct pinyin sequence is "confusing approximate pinyin", then it is necessary to determine whether there are approximate pinyins in the pinyin to be disturbed. If the pinyin to be disturbed does not contain approximate pinyins, then another disturbance method or error type is selected instead.
[0038] After the disturbance of the correct pinyin sequence is completed, a disturbed pinyin sequence is obtained. It should be noted that when the correct pinyin sequence is disturbed, the part that is not determined as the pinyin to be disturbed is not processed and is always kept as it is.
[0039] Step 103: Divide the disturbed pinyin sequence into several small segments, so that each small segment corresponds to the pinyin of a Chinese character.
[0040] After the disturbance, the correct pinyin sequence may not correspond one-to-one with the text sequence in the original correct text, and some illegal pinyin may appear in it. Therefore, the disturbed pinyin sequence obtained after the disturbance must be re-divided into small segments, and each small segment must be mapped to a legal pinyin according to certain rules. Only then can the disturbed pinyin sequence be restored to a Chinese character sequence.
[0041] The division of the perturbed pinyin sequence is responsible for re - dividing the perturbed pinyin sequence into small segments for use in the next stage. In a possible implementation of the present invention, the division of the perturbed pinyin sequence mainly includes the following processes:
[0042] First, for describing the division steps, the following symbol conventions are made: Denote the length of the perturbed pinyin sequence as L1; Denote the number of letters contained in the longest pinyin in the Chinese character pinyin comparison table as M; [i:j] represents the segment composed of the letters from the i - th to the j - th position of the perturbed pinyin sequence (for example, if the pinyin letter sequence is "xiang", then [2:3] is the segment "ia" therein); F is an array used to store the division result, and the elements in the array are the divided small segments (for example, if the pinyin letter sequence is "xiang", then the division result F can be [xi, ang], which is an array with a length of 2); F[i] is the i - th element in the array F; L2 is the length of the array F; mp is a preset parameter greater than or equal to 0 and less than or equal to 1.
[0043] Secondly, the division steps of the perturbed pinyin sequence can be described as follows:
[0044] (1) Let F be an empty array, let i = 1, j = 1;
[0045] (2) If i > L1, jump to step (5); if i ≤ L, enter step (3);
[0046] (3) If [i:j] is a legal pinyin, add [i:j] to the array F, let i = j + 1, j = j + 1, and jump to step (2); if [i:j] is an illegal pinyin, let j = j + 1;
[0047] (4) If j - i + 1 > M or j > L, add [i:i] to the array F, let i = i + 1, and jump to step (2); if j - i + 1 ≤ M, directly jump to step (2);
[0048] (5) Let k = 1;
[0049] (6) If k ≥ L2, the algorithm ends; otherwise, enter step (7);
[0050] (7) If the combination of F[k] and F[k + 1] is still a legal pinyin, enter step (8); otherwise, jump to step (9);
[0051] (8) Generate a random number r greater than or equal to 0 and less than or equal to 1. If r < mp, merge the contents of F[k] and F[k + 1], overwrite the position of F[k], delete F[k + 1], and the length L2 of F is reduced by 1; enter step (9);
[0052] (9) Let k=k+1 and jump to step (6).
[0053] Through the above process, the present invention first realizes the division of the disturbed pinyin sequence, divides the disturbed pinyin sequence into several small segments and stores them in an array F, and then merges the legal pinyins in the array F through a random number r, so that the final array F can represent the division of the disturbed pinyin sequence and is applied to the next stage, that is, the text conversion stage.
[0054] Step 104: convert several short segments into erroneous texts through a Chinese character and pinyin comparison table to obtain training data including correct texts and erroneous texts.
[0055] In a possible implementation of the present invention, after obtaining a disturbed pinyin sequence, for any small segment in the disturbed pinyin sequence, that is, any pinyin, if it is a legal pinyin, all corresponding Chinese characters are determined in the Chinese character pinyin comparison table, and one is randomly selected from all Chinese characters as the corresponding Chinese character of the any small segment; and if any small segment is an illegal pinyin, a legal pinyin with the highest similarity to the illegal pinyin is determined in the array F, and then all Chinese characters corresponding to the legal pinyin with the highest similarity are determined in the Chinese character pinyin comparison table, and one is randomly selected from all Chinese characters as the corresponding Chinese character of the illegal any small segment.
[0056] After the corresponding Chinese characters are determined for each pinyin segment in the array F, the erroneous text is obtained, thereby obtaining the training data of the correct text + the erroneous text.
[0057] In one example of the present invention, the perturbed pinyin sequence is converted into an erroneous text, which can also be described by the following process:
[0058] First, to describe the conversion steps, we first make the following symbolic conventions: F is an array, which is the division result obtained by the pinyin letter sequence division algorithm; F[i] is the i-th element in the array F; the length of the array F is L2;
[0059] Secondly, the steps to convert the error text can be described as follows:
[0060] (1) Let k = 1;
[0061] (2) If k>L2, the algorithm ends; otherwise, go to step (3);
[0062] (3) If F[k] is a legal pinyin, find all the Chinese characters corresponding to F[k] from the Chinese character pinyin comparison table, randomly select one as the Chinese character corresponding to position k, and jump to step (5); if F[k] is an illegal pinyin, go to step (4);
[0063] (4) Calculate the similarity between all legal pinyins in array F and F[k] (any method or algorithm for calculating string similarity can be used, such as BLEU, etc., which will not be elaborated in this invention), find the legal pinyin with the highest similarity to F[k] (if there are multiple, randomly select one of the legal pinyins), randomly select one Chinese character from all the Chinese characters corresponding to this legal pinyin, and use it as the Chinese character corresponding to position k, then proceed to step (5);
[0064] (5) Let k = k + 1, and jump to step (2);
[0065] Thus, a new text is obtained, that is, the incorrect text corresponding to the correct text initially extracted from the corpus.
[0066] Furthermore, by performing the above process on all correct texts in the corpus, several groups of training data of correct text + incorrect text can be obtained, and then the training dataset is obtained.
[0067] Figure 2 This is a schematic diagram of incorrect text generation in an application scenario provided by the present invention. Taking Figure 2 as an example, the generation process of the training dataset in the present invention includes:
[0068] (1) Randomly extract a correct text from the corpus, such as "Arrived in Xi'an".
[0069] (2) Convert the correct text into a sequence of pinyin letters, that is, the correct pinyin sequence. For example, convert "Arrived in Xi'an" into "xiandaole".
[0070] (3) Through the pinyin letter sequence perturbation algorithm, that is, the above process of generating the perturbed pinyin sequence, generate the perturbed pinyin sequence. For example, perturb "xiandaole" to get "xinadaole" and "xiandale".
[0071] (4) Through the pinyin letter sequence division algorithm, that is, the above process of dividing the perturbed pinyin sequence into several segments, divide the aforementioned perturbed pinyin sequence. For example, divide "xinadaole" into "xi na dao le" and "xin ada o le", and for another example, divide "xiandale" into "xian da le".
[0072] (5) Through the pinyin-Chinese character conversion algorithm, that is, the process of converting to incorrect text as described above, convert the segmented pinyin segments into incorrect text. For example, convert "xi na dao le" into "吸纳到了" and "席纳倒了", convert "xin a dao le" into "心啊大哦了", and for another example, convert "xian da le" into "先打了" and "嫌大了".
[0073] So far, the incorrect text corresponding to the correct text is obtained. Construct a set of training data by combining one correct text and one incorrect text. In this way, multiple sets of training data (with different incorrect texts) can be generated through the conversion of one correct text. By performing the conversion process in the method of the present invention on several correct texts in the corpus, several sets of training data can be obtained, that is, the construction of the training data set is completed.
[0074] Based on the same inventive concept, the present invention also provides a device for constructing a training data set for a text error correction model, and its structure is as Figure 3 shown.
[0075] Figure 3 It is a schematic structural diagram of a device for constructing a training data set for a text error correction model provided by the present invention. As Figure 3 shown, the device 300 for constructing a training data set for a text error correction model in the present invention specifically includes: at least one processor 301; and a memory 303 communicatively connected to the at least one processor 301 (connected through a bus 302); wherein, the memory 303 stores instructions that can be executed by the at least one processor 301, so that the at least one processor 301 can execute a method for constructing a training data set for a text error correction model as described in the above embodiments.
[0076] In one or more possible implementation manners of the present invention, the foregoing processor is used to execute: convert the correct text in the preset corpus into a correct pinyin sequence through a Chinese character-pinyin look-up table; based on a preset perturbation ratio, perturb the correct pinyin sequence through a preset perturbation method to obtain a perturbed pinyin sequence, where the preset perturbation ratio is used to indicate the proportion of the number of words perturbed in the correct text to all the words; divide the perturbed pinyin sequence into several small segments, so that each small segment corresponds to the pinyin of a Chinese character; convert the several small segments into incorrect text through the Chinese character-pinyin look-up table to obtain training data including correct text and incorrect text.
[0077] The method for constructing a training data set in the present invention has at least the following beneficial effects:
[0078] 1) It can quickly and in large quantities construct "correct text + incorrect text" pairs, thereby constituting a large-scale training data set for a text error correction model.
[0079] 2) The constructed error text can well simulate the errors that occur during manual input, and its effect is close to that of manually annotated datasets, while avoiding manual workload and combining quality and scale.
[0080] Each embodiment of the present invention is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the IoT device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0081] The system and medium provided by the present invention correspond one-to-one to the method, and therefore, the system and medium also have similar beneficial technical effects to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the system and medium will not be repeated here.
[0082] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0083] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0084] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0086] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0087] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0088] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0089] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0090] The above are only embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for constructing a training data set for a text error correction model, characterized in that: The method comprises: Convert the correct text in the preset corpus into the correct pinyin sequence through the Chinese character pinyin comparison table; Based on a preset disturbance ratio, the correct pinyin sequence is disturbed by a preset disturbance method to obtain a disturbed pinyin sequence, wherein the preset disturbance ratio is used to indicate the ratio of the number of disturbed words in the correct text to the total number of words, specifically comprising: segmenting the correct text, rounding up the product of the total number of words corresponding to the correct text and the preset disturbance ratio to obtain the number of words to be disturbed, determining the pinyin to be disturbed corresponding to any word to be disturbed in the correct pinyin sequence, determining the preset disturbance method according to the error type distribution probability corresponding to the training data set to be generated, the error type distribution probability corresponds to the preset disturbance method one by one, disturbing the pinyin to be disturbed by the preset disturbance method, the preset disturbance method including at least one of confusing approximate pinyin, reversing the order of letters, adding letters, deleting letters and replacing wrong letters, and judging whether the pinyin to be disturbed has an approximate pinyin when the preset disturbance method is confusing approximate pinyin, and if not, determining a new preset disturbance method according to the error type distribution probability; Dividing the disturbed pinyin sequence into a plurality of small segments, so that each small segment corresponds to the pinyin of a Chinese character; The plurality of short sections are converted into erroneous texts by using the Chinese character and pinyin comparison table, so as to obtain training data including correct texts and erroneous texts.
2. The method for constructing a training data set for a text error correction model according to claim 1, characterized in that: The method for constructing the preset corpus comprises: Acquiring text materials on a preset website, wherein the text materials at least include papers, journals and news manuscripts; The text data is segmented into sentences according to punctuation marks, and the preset corpus is constructed according to the segmentation results.
3. The method for constructing a training data set for a text error correction model according to claim 1, characterized in that: The disturbed pinyin sequence is divided into several small segments, including: In the disturbed pinyin sequence, judging whether the segment formed by the i-th letter to the j-th letter is a legal pinyin, wherein the initial values of i and j are 1; If yes, store the fragment from the i-th letter to the j-th letter in the array F, and let i=j+1, j=j+1; If not, set j=j+1, and when j is greater than L1, store the i-th letter in array F, and set i=i+1, j=i+1.
4. The method for constructing a training data set for a text error correction model according to claim 3, characterized in that: After obtaining the array F, the method further includes: Determine the length L2 of the array F; In the array F, it is determined whether the kth legal pinyin and the k+1th legal pinyin can constitute a legal pinyin, where the initial value of k is 1; If yes, then merge the kth legal pinyin and the k+1th legal pinyin, replace the kth legal pinyin, and set L2=L2-1; If not, set k=k+1, and end the determination when k is greater than or equal to L2.
5. The method for constructing a training data set for a text error correction model according to claim 4, characterized in that: When the kth legal pinyin and the k+1th legal pinyin in the array F can constitute a legal pinyin, the method further includes: Generate a random number a; If the random number a is less than or equal to the merging parameter, the kth legal pinyin and the k+1th legal pinyin of the array F are merged; If the random number a is greater than the merging parameter, the kth legal pinyin and the k+1th legal pinyin in the array F will not be merged.
6. The method for constructing a training data set for a text error correction model according to claim 1, characterized in that: The plurality of small segments are converted into erroneous texts by using the Chinese character pinyin comparison table, including: For any of the several small segments, all corresponding Chinese characters are determined in the Chinese character pinyin comparison table, and one of the Chinese characters is randomly selected as the corresponding Chinese character of the any of the small segments; If any of the small segments is an illegal pinyin, then a legal pinyin small segment with the highest similarity to the any small segment is determined from among the several small segments, and any one of all Chinese characters corresponding to the legal pinyin small segment in the Chinese character pinyin comparison table is determined as the corresponding Chinese character of the any small segment; The error text is obtained according to all corresponding Chinese characters of the several small segments.
7. A device for constructing a training data set for a text error correction model, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, so that the at least one processor can execute the method for constructing a training data set for a text error correction model according to any one of claims 1-6.
