Grammar correction method and training method and device, electronic equipment and storage medium
By constructing a reference set of grammatical errors and generating a pseudo-error corpus through corruption processing, a neural network model is trained. This solves the problem of low error correction accuracy of existing models when there are multiple adjacent grammatical errors, and achieves higher error correction accuracy and model versatility.
Patent Information
- Application Number
- CN202111527229.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2041-12-14
AI Technical Summary
Existing text syntax error correction models have low accuracy when faced with grammatical errors in multiple adjacent words in a text sentence, and cannot meet the error correction requirements.
By constructing a reference set of grammatical errors, the second monolingual corpus is corrupted based on a neural network model to generate a pseudo-error corpus. The grammatical error correction model is then trained by combining weight assignment and different probability corruption methods.
This improves the accuracy and versatility of the grammar correction model, enabling it to more effectively correct grammatical errors in multiple adjacent words.
Smart Images

Figure CN114239557B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present specification relate to the technical field of computer natural language processing, and particularly relate to a grammar correction method and training method, device, electronic equipment, and storage medium. BACKGROUND
[0002] With the development of deep learning technology, text grammar correction technology has developed rapidly. At present, grammar correction models are often used to check the grammar of user input text (emails, compositions, papers, etc.) and correct the grammar errors therein.
[0003] However, the existing text grammar correction model can only correct a grammar error in a text sentence when one word in the text sentence has a grammar error. When one grammar error in a text sentence includes multiple adjacent words, the accuracy of the obtained grammar correction result is low, and the correction requirement cannot be met. SUMMARY
[0004] Therefore, embodiments of the present specification provide a grammar correction method and training method, device, electronic equipment, and storage medium, which can improve the accuracy of grammar correction.
[0005] First, the embodiments of the present specification provide a grammar correction method, comprising:
[0006] A first training corpus set and a second monolingual corpus set containing annotation information are obtained, wherein the annotation information is used to represent a grammar error pair of each training corpus in the first training corpus set, and the grammar error pair includes a source segment in error form and a target segment in correct form corresponding to the source segment in error form;
[0007] The grammar error pairs of each training corpus in the first training corpus set are extracted to construct a grammar error pair reference set;
[0008] Based on the grammar error pair reference set, the second monolingual corpus set is subjected to corruption processing to obtain a pseudo-error corpus set corresponding to the second monolingual corpus set;
[0009] The pseudo-error corpus set and the first training corpus set are input into a preset neural network model, the preset neural network model is trained, and a grammar correction model is obtained.
[0010] The embodiments of the present specification also provide a grammar correction method, comprising:
[0011] Obtain a corpus to be corrected;
[0012] Input the corpus to be corrected into a grammar correction model, generate a grammar correction result, and output;
[0013] The syntax error correction model is obtained by sequentially inputting the pseudo error corpus set and the first training corpus set into a preset neural network model and training the preset neural network model.
[0014] Correspondingly, an embodiment of the specification provides a syntax error correction training apparatus, comprising:
[0015] A training corpus acquisition module is adapted to acquire a first training corpus set containing annotation information and a second monolingual corpus set, wherein the annotation information is used to represent a syntax error pair of each training corpus in the first training corpus set, and the syntax error pair comprises a source segment in an error form and a target segment in a correct form corresponding to the source segment in the error form.
[0016] A syntax error pair reference set construction module is adapted to extract the syntax error pair of each training corpus in the first training corpus set and construct a syntax error pair reference set.
[0017] A processing module is adapted to perform corruption processing on the second monolingual corpus set based on the syntax error pair reference set, so as to obtain a pseudo error corpus set corresponding to the second monolingual corpus set.
[0018] A training module is adapted to input the pseudo error corpus set and the first training corpus set into a preset neural network model, train the preset neural network model, and obtain a syntax error correction model.
[0019] An embodiment of the specification further provides a syntax error correction apparatus, comprising:
[0020] A corpus acquisition module is adapted to acquire a to-be-corrected corpus.
[0021] A correction module is adapted to input the to-be-corrected corpus into a syntax error correction model, generate a syntax error correction result, and output the syntax error correction result.
[0022] The syntax error correction model is obtained by sequentially inputting the pseudo error corpus set and the first training corpus set into a preset neural network model and training the preset neural network model; the pseudo error corpus set is obtained by performing corruption processing on the second monolingual corpus set based on a syntax error pair reference set; and the syntax error pair reference set is obtained by extracting a syntax error pair from the first training corpus set containing annotation information.
[0023] The embodiment of the present specification provides an electronic device, comprising a memory and a processor, wherein the memory is adapted to store one or more computer instructions, and the processor executes the computer instructions to perform the steps of the training method in any of the foregoing embodiments; or perform the steps of the grammar correction method in the foregoing embodiments.
[0024] The embodiment of the present specification provides a computer readable storage medium, which stores computer instructions, and the computer instructions perform the steps of the training method in any of the foregoing embodiments; or perform the steps of the grammar correction method in the foregoing embodiments.
[0025] The training method of the grammar correction in the embodiment of the present specification takes the grammar error pair reference set as the benchmark, and performs corruption processing on the second monolingual corpus set, so that a pseudo error corpus set with one or more adjacent words can be obtained, and the data quantity of the obtained pseudo error corpus set can be increased. The pre-set neural network model is trained by using the pseudo error corpus set and the first training corpus set, and the obtained grammar correction model has better universality, so that the accuracy of grammar correction can be improved when the grammar correction model is used to perform grammar correction on the corpus.
[0026] Further, the grammar error pairs corresponding to each training corpus in the first training corpus set are extracted, and the frequency of occurrence of each grammar error pair in the grammar error pair is counted; the weight of each grammar error pair is assigned according to the frequency of occurrence of each grammar error pair, and the grammar error pair reference set is obtained. By assigning weights to each grammar error pair according to the frequency of occurrence, the weight value of the obtained grammar error pair is more accurate compared with directly randomly assigning weights to the grammar error pair.
[0027] Further, each corpus in the second monolingual corpus set is searched with the grammar error pair reference set to obtain a grammar error pair list; grammar error pairs are selected from the grammar error pair list with a first preset probability, and the second monolingual corpus set is subjected to grammar error pair replacement processing to obtain error corpora corresponding to each corpus in the second monolingual corpus set; grammar error pairs are selected from the grammar error pair list with a second preset probability, and the second monolingual corpus set is subjected to word insertion processing to obtain error corpora corresponding to each corpus in the second monolingual corpus set; each corpus in the second monolingual corpus set and the error corpus corresponding thereto are combined to obtain the pseudo error corpus set. By selecting grammar error pairs from the grammar error pair list with different probabilities and using different corruption processing methods on the second monolingual corpus set, the number of the obtained pseudo error corpus set can be expanded, and the pseudo error corpus set can include multiple different types of grammar error pairs, thereby improving the accuracy of the grammar correction model. BRIEF DESCRIPTION OF DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present specification, the following will briefly introduce the drawings needed to be used in the embodiments of the present specification or the prior art description. Obviously, the drawings described below are only some embodiments of the present specification, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0029] Figure 1 A flowchart of a training method of a grammar correction model in an embodiment of the present specification is shown.
[0030] Figure 2 A flowchart of obtaining pseudo error corpus in an embodiment of the present specification is shown.
[0031] Figure 3 A flowchart of obtaining pseudo error corpus in another embodiment of the present specification is shown.
[0032] Figure 4 A flowchart of obtaining pseudo error corpus in still another embodiment of the present specification is shown.
[0033] Figure 5 A flowchart of obtaining pseudo error corpus in still another embodiment of the present specification is shown.
[0034] Figure 6 A flowchart of a training method of a grammar correction model in an embodiment of the present specification is shown.
[0035] Figure 7 A flowchart of a grammar correction method in an embodiment of the present specification is shown.
[0036] Figure 8 A structural schematic diagram of a grammar correction training device in an embodiment of the present specification is shown.
[0037] Figure 9 A structural schematic diagram of a grammar correction device in an embodiment of the present specification is shown.
[0038] Figure 10 A structural schematic diagram of an electronic device in an embodiment of the present specification is shown. DETAILED DESCRIPTION
[0039] As described above, the accuracy of the grammar correction result obtained by using the current grammar correction model is low, which cannot meet the correction requirements.
[0040] To solve the above problems, the embodiment of the present specification provides a training method for grammar correction, comprising: obtaining a first training corpus set containing annotation information and a second monolingual corpus set, wherein the annotation information is used to represent a grammar error pair of each training corpus in the first training corpus set, and the grammar error pair comprises a source segment in an incorrect form and a target segment in a correct form corresponding to the source segment in the incorrect form; extracting the grammar error pair of each training corpus in the first training corpus set to construct a grammar error pair reference set; based on the grammar error pair reference set, performing corruption processing on the second monolingual corpus set to obtain a pseudo error corpus set corresponding to the second monolingual corpus set; inputting the pseudo error corpus set and the first training corpus set into a preset neural network model to train the preset neural network model to obtain a grammar correction model.
[0041] By using the above method, the grammar error pair reference set is used as a reference, and the second monolingual corpus set is subjected to corruption processing, so that a pseudo error corpus set with one or more adjacent words can be obtained, and the data amount of the obtained pseudo error corpus set can be increased. The grammar correction model obtained by training the preset neural network model using the pseudo error corpus set and the first training corpus set has better universality, so that the accuracy of grammar correction can be improved when the grammar correction model is used to correct the grammar of a text.
[0042] To make those skilled in the art more clearly understand and implement the embodiments of the present specification, the technical solutions in the embodiments of the present specification will be described clearly and completely below with reference to the drawings in the embodiments of the present specification.
[0043] In the embodiments of the present specification, in order to improve the accuracy of grammar correction and improve the readability of a text, a training corpus with a grammar error pair can be established first, and a preset neural network model is trained using the obtained training corpus to obtain a grammar correction model. The grammar correction model obtained by training is used to correct a text or a sentence with a grammar error to obtain a text or a sentence with correct grammar.
[0044] Referring to Figure 1 The flowchart of the training method for grammar correction in the embodiment of the present specification can specifically include the following steps:
[0045] S11, obtaining a first training corpus set containing annotation information.
[0046] The annotation information is used to represent a grammar error pair of each training corpus in the first training corpus set, and the grammar error pair comprises a source segment in an incorrect form and a target segment in a correct form corresponding to the source segment in the incorrect form.
[0047] In specific implementations, the first training corpus is in the form of sentence pairs.
[0048] Specifically, the first training corpus can include first sample sentences and first target sentences, where the first sample sentences (source) can be sentences with grammatical errors, and the first target sentences (target) can be grammatically correct sentences corresponding to the first sample sentences. The first training corpus can be represented in the form of [(error1, correct1), (error2, correct2), …, (errori, correcti), …, (errorn, correctn)], where i and n are integers greater than 0, and i is less than or equal to n.
[0049] For example, one of the training corpora in the first training corpus can be (I go to home tomorrow by bike, I will go home tomorrow by bike), where "I go to home tomorrow by bike" can be taken as a first sample sentence, and "I will go home tomorrow by bike" can be taken as a first target sentence.
[0050] In specific implementations, if the amount of data in the first training corpus is small, in order to ensure the correctness of the annotation information in the first training corpus, a proofread corpus can be obtained.
[0051] S12, extracting the grammatical error pairs of each training corpus in the first training corpus, and constructing a grammatical error pair reference set.
[0052] In specific implementations, for any training corpus in the first training corpus, the grammatical error pairs of each training corpus in the first training corpus can be extracted by various methods.
[0053] For example, the minimum edit distance algorithm and the rule based on the syntax dependency tree can be used to obtain the grammatical error pairs of the training corpus, and each grammatical error pair can be counted to obtain a grammatical error pair reference set with a large number of grammatical error pairs.
[0054] As a specific example, for the training corpus (I go to home tomorrow by bike, I will go home tomorrow by bike), the minimum edit distance algorithm can obtain the error pair go to->will go, and the rule based on the syntax dependency tree can obtain two grammatical error pairs go->will go and to->blank.
[0055] wherein, for a syntax error pair to->blank, to is a source segment of an error form in the syntax error pair, blank is a target segment of a correct form corresponding to the source segment of the error form to in the syntax error pair, and the target segment of the correct form corresponding to to is an empty set, i.e., the syntax pair of the correct form corresponding to the source segment of the error form to does not exist.
[0056] S13, obtaining a second monolingual corpus.
[0057] In specific implementations, the second monolingual corpus is a corpus with correct syntax, and the more extensive the source of the second monolingual corpus is, the more beneficial it is to subsequent pre-training of the neural network model, which can increase the generality and accuracy of the trained model. Therefore, on the one hand, in order to make the source of the second monolingual corpus more extensive, the corpus can be obtained as much as possible in different fields, and on the other hand, in order to ensure the accuracy of the syntax of each corpus in the second monolingual corpus, the proofread corpus can be obtained.
[0058] In specific implementations, the obtained first training corpus and the second monolingual corpus can be a paragraph including multiple sentences, or can be a document including more sentences. The specific form of the training corpus obtained by the embodiments of the present disclosure is not limited as long as the format requirement of the training corpus is met.
[0059] S14, performing corruption processing on the second monolingual corpus based on the syntax error pair reference set to obtain a pseudo error corpus corresponding to the second monolingual corpus.
[0060] Specifically, by pre-establishing a syntax error pair reference set and performing corruption processing on the second monolingual corpus based on the syntax error pair reference set, a pseudo error corpus with one or more adjacent words can be obtained, and the data amount of the obtained pseudo error corpus can be increased. In subsequent training of the preset neural network model, the syntax error correction rate of the obtained syntax error correction model can be improved.
[0061] In specific implementations, the pseudo error corpus also exists in the form of a sentence pair, and the specific form can be referred to the description of the first training corpus, which will not be described here.
[0062] S15, inputting the pseudo error corpus and the first training corpus into a preset neural network model, training the preset neural network model to obtain a syntax error correction model.
[0063] In specific implementations, as an optional example, the preset neural network model can include an embedding layer, an encoding layer coupled with the embedding layer, and a decoding layer coupled with the encoding layer.
[0064] The preset neural network model is pre-trained using the pseudo error corpus, to obtain an initial grammar correction model, and the initial grammar correction model is fine-tuned using the first training corpus with annotation information, so that the obtained grammar correction model has better universality.
[0065] By using the above method, the pseudo error corpus with one or more adjacent words can be obtained by taking the reference set of grammar error pairs as a benchmark and corrupting the second monolingual corpus, and the data quantity of the obtained pseudo error corpus can be increased. The preset neural network model is trained using the pseudo error corpus and the first training corpus, so that the obtained grammar correction model has better universality, thereby improving the accuracy of grammar correction when the grammar correction model is used to correct the text.
[0066] In a specific implementation, the frequency of occurrence of some grammar error pairs in the grammar error pair reference set is low, or the probability of occurrence of these grammar error pairs in a real scenario is small. If the grammar error pair reference set is used without distinction, and the second monolingual corpus is randomly corrupted, the obtained pseudo error corpus may not match the actual situation, and the grammar correction model obtained by training also does not have good universality.
[0067] To avoid the above situation, in some embodiments of the present specification, when extracting grammar error pairs of each training corpus in the first training corpus to construct a grammar error pair reference set, the following strategies can be used:
[0068] The grammar error pairs corresponding to each training corpus in the first training corpus are extracted, and the frequency of occurrence of each grammar error pair in the grammar error pair is counted.
[0069] According to the frequency of occurrence of each grammar error pair, the weight of each grammar error pair is assigned to obtain the grammar error pair reference set.
[0070] Specifically, for the first training corpus, each training corpus in the first training corpus may have the same grammar error pair. When constructing the grammar error pair reference set, the frequency of occurrence of the grammar error pair corresponding to each corpus (i.e., the number of grammar error pairs) is counted, and then the weight of each grammar error pair is assigned according to the frequency of each grammar error pair, to obtain the probability of occurrence of each grammar error pair. The greater the weight value of the grammar error pair, the greater the probability of using the grammar error pair to corrupt the second training corpus.
[0071] As a specific example, assuming that the frequency of occurrence of the first grammar error pair extracted from each training corpus in the first training corpus is A1, the frequency of occurrence of the second grammar error pair is A2, …, and the frequency of occurrence of the pth grammar error pair is Ap.p The frequency of the qth syntax error pair is A. q ,but:
[0072] The probability of the first syntax error occurring is:
[0073] The probability of the second syntax error occurring is:
[0074] …
[0075] The probability of the p-th syntax error occurring is
[0076] …
[0077] The probability of the qth syntax error occurring is
[0078] After obtaining the probability of each syntax error pair, the probability values can be normalized, and weights can be selected from the weight values [0, 1] and assigned to each syntax error pair.
[0079] By assigning weights to each syntax error pair based on its frequency of occurrence, the resulting weight values for syntax error pairs are more accurate than those assigned randomly.
[0080] In the embodiments of this specification, by assigning weights to each pair of grammatical errors, a corrupting operation can be performed on the grammatically correct second monolingual corpus to obtain a pseudo-error corpus.
[0081] In specific implementation, the corruption processing method may include: syntax error pair replacement processing and syntax error pair insertion processing. Depending on the different corruption processing types and processing methods, a variety of different methods can be adopted to obtain a pseudo-error corpus corresponding to the second monolingual corpus.
[0082] Reference Figure 2 The flowchart shown in this embodiment of the specification illustrates one method for obtaining a pseudo-error corpus. In some embodiments of this specification, the specific steps can be followed:
[0083] S21, perform a retrieval operation between each corpus in the second monolingual corpus and the grammatical error pair reference set to obtain a list of grammatical error pairs.
[0084] The retrieval operation may include a syntax error pair matching operation and a syntax error pair selection operation.
[0085] In practice, for different types of corruption processing, when performing retrieval operations on each corpus and the reference set of grammatical error pairs to obtain a list of grammatical error pairs, the following two methods are specifically included.
[0086] Method one: performing word segmentation processing on each corpus in the second monolingual corpus set to obtain word units corresponding to each corpus in the second monolingual corpus set; combining the word units corresponding to each corpus in the second monolingual corpus set to obtain sub-intervals corresponding to each corpus in the second monolingual corpus set; performing matching operation on the sub-intervals corresponding to each corpus in the second monolingual corpus set and the reference set of syntax error pairs to obtain a first syntax error pair list corresponding to each corpus in the second monolingual corpus set, and taking the first syntax error pair list as the syntax error pair list.
[0087] In a specific implementation, the word segmentation processing on each corpus in the second monolingual corpus set can be performed by using a word segmentation dictionary or other word segmentation units. The segmented corpus is compared with each word in the word segmentation dictionary, and when a word in the corpus is the same as a word in the word segmentation dictionary, the corresponding word is set as the word of the corpus.
[0088] It can be understood that the word segmentation unit corresponds to the smallest sentence constituent unit of the language category of the second monolingual corpus set. For example, the smallest sentence constituent unit of Chinese is "word", and the smallest sentence constituent unit of English is "word". Therefore, the specific expression of the word segmentation unit is determined by the language category in the second monolingual corpus set.
[0089] Then, the obtained word units are combined to obtain a plurality of sub-intervals corresponding to each corpus, wherein the sub-interval refers to a set composed of all continuous fragments in the corpus. After obtaining the sub-interval, the error pairs corresponding to the sub-interval can be searched in the reference set of syntax error pairs to obtain a corresponding syntax error pair list.
[0090] As a specific example, it is assumed that one of the training corpora in the second monolingual corpus set is {I will go home tomorrow by bike}. After performing word segmentation processing, {I will go home tomorrow by bike} can be obtained. Eight words are combined to obtain a plurality of sub-intervals, such as sub-interval {I will}, {will go},..., {by bike}, {I will go}, {will go home},..., {tomorrow by bike},..., {I will go home tomorrow by}, {will go home tomorrow by bike}, {I will go home tomorrow by bike}, and so on.
[0091] Then, the obtained plurality of sub-intervals and the syntax error pair reference set are matched, and a syntax error pair list with 9 syntax error pairs is obtained, wherein the 9 syntax error pairs are: go->will go, went->will go, would->will, am going->will go, is going->will go, are going->will go, was going->will go, were going->will go, and bikes->bike, and the corresponding weight values of the syntax error pairs can be different.
[0092] It can be understood that the “{}” herein is only used to limit the content range of the example, and is not an essential part when representing the content of the training corpus. A person skilled in the art can use other symbols that are not easy to confuse to limit the content range of the training corpus.
[0093] Method two: performing word segmentation processing on each corpus in the second monolingual corpus set to obtain word units corresponding to each corpus in the second monolingual corpus set; selecting, from the syntax error pair reference set, a syntax error pair in which the target fragment of the correct form corresponding to the word unit of each corpus in the second monolingual corpus set is empty, to obtain a second syntax error pair list corresponding to each corpus in the second monolingual corpus set, and taking the second syntax error pair list as the syntax error pair list.
[0094] In specific implementation, the second training corpus can be subjected to word segmentation processing according to the above-described word segmentation processing to obtain word units corresponding to each corpus.
[0095] Then, from the syntax error pair reference set, a syntax error pair in which the target fragment of the correct form corresponding to each word unit is empty is selected to obtain a corresponding syntax error pair list. For example, for the training corpus: {I will go to hometomorrow by bike}, a syntax error pair: to->blank can be obtained.
[0096] S22, selecting a syntax error pair from the syntax error pair list with a first preset probability, and performing syntax error pair replacement processing on the second monolingual corpus set to obtain error corpora corresponding to each corpus in the second monolingual corpus set.
[0097] In specific implementation, two syntax error pair lists can be obtained after step S21, and different error corpora in different syntax error forms can be obtained by using different syntax error pair lists. In the embodiments of the present specification, a syntax error pair can be selectively selected from one of the syntax error pair lists with a first preset probability, and error pair replacement processing is performed on the second monolingual corpus set to obtain corresponding error corpora.
[0098] In a specific application, since the probabilities of occurrence of each syntax error pair in an actual scenario are different, after one of the syntax error pairs is selected from the first syntax error pair list at a first preset probability, the second monolingual corpus needs to be processed by error pair replacement according to the weight values of the syntax error pairs, specifically including:
[0099] Obtaining the weights of each syntax error pair in the first syntax error pair list;
[0100] According to the weight values of the syntax error pairs, randomly selecting any one of the syntax error pairs from the first syntax error pair list, and replacing the corresponding part of the corresponding corpus of the second monolingual corpus with the source segment of the error form in the arbitrary syntax error pair, to obtain the error corpus corresponding to each corpus in the second monolingual corpus.
[0101] As can be seen from the foregoing, the weight values of each syntax error pair in the syntax error pair reference set are different, so the weight values of each syntax error pair in the syntax error pair list obtained by matching each corpus in the second monolingual corpus with the syntax error pair reference set are different, and the greater the weight value, the greater the probability of occurrence of the syntax error pair. Therefore, when replacing the syntax error pairs of the corresponding corpus of the second monolingual corpus, the syntax error pairs can be randomly selected according to the weight values of each syntax error pair in the first syntax error pair list, and the syntax error pair replacement operation is performed on the second monolingual corpus.
[0102] As a specific example, if the weight of the am going->will go pair is the largest among the 9 syntax error pairs obtained in step S21, the probability of using the syntax error pair am going->will go to perform the syntax error pair replacement operation on the second monolingual corpus is greater, for example, the syntax error pair obtained by performing the syntax error pair replacement operation on {I will go home tomorrow by bike} is {I am going home tomorrow by bike}.
[0103] In other embodiments, the first t syntax error pairs with the largest weight values can also be selected to replace the syntax error pairs in the second monolingual corpus to obtain a plurality of error corpora, wherein t is greater than 1 and less than the number of syntax error pairs.
[0104] S23, selecting a syntax error pair from the syntax error pair list at a second preset probability, and performing syntax error pair insertion processing on the second monolingual corpus to obtain an error corpus corresponding to each corpus in the second monolingual corpus.
[0105] In a specific implementation, after step S21, two lists of error pairs of grammar are obtained, and different lists of error pairs of grammar are used to obtain error corpora of different error forms of grammar. In the embodiment of the present disclosure, the error pairs of grammar are selectively selected from one of the lists of error pairs of grammar at a second preset probability, and the error pairs of grammar are inserted into the second monolingual corpus to obtain error corpora corresponding to the second monolingual corpus.
[0106] In a specific application, because the probabilities of occurrence of different error pairs of grammar in actual scenarios are different, after one of the lists of error pairs of grammar is selected at the second preset probability, the error pairs of grammar are inserted into the second monolingual corpus according to the weight values of the error pairs of grammar, and the specific operations include the following steps.
[0107] Obtaining the weight values of the error pairs of grammar in the second list of error pairs of grammar.
[0108] Randomly selecting one of the error pairs of grammar from the second list of error pairs of grammar according to the weight values of the error pairs of grammar, and inserting the source segment of the error form in the selected error pair of grammar into the corresponding part of the corpus in the second monolingual corpus to obtain error corpora corresponding to the corpora in the second monolingual corpus.
[0109] As known from the foregoing, the weight values of the error pairs of grammar in the reference set are different, and therefore the weight values of the error pairs of grammar in the second list of error pairs of grammar are different. The greater the weight value, the greater the probability of occurrence of the error pair of grammar. When the error pairs of grammar are inserted into the corpora in the second monolingual corpus, the error pair of grammar with the highest weight value can be selected.
[0110] As a specific example, if the weight value of the error pair of grammar to->blank is the highest among the error pairs of grammar obtained in step S22, the probability of using the error pair of grammar to->blank to insert the error pairs of grammar into the second monolingual corpus is higher. For example, when the error pairs of grammar are inserted into {I will go home tomorrow by bike}, the error pairs of grammar obtained are {I will go to home tomorrow by bike} or {I will go home to tomorrow by bike}.
[0111] In other embodiments, the first r error pairs of grammar with the highest weight values can also be selected to insert the error pairs of grammar into the second monolingual corpus to obtain a plurality of error corpora, where r is greater than 1 and less than the number of error pairs of grammar.
[0112] In an actual scenario, the probability of a correct form of a syntax error pair being a null set is small, and thus, when performing corruption processing on the second monolingual corpus, the syntax error pair replacement method is preferred, and thus, the first preset probability can be greater than the second preset probability.
[0113] In an embodiment of the present disclosure, the sum of the first preset probability and the second preset probability can be 1, and the first preset probability can be greater than the second preset probability.
[0114] As a specific example, the first preset probability can be 0.8, and the second preset probability can be 0.2.
[0115] It can be understood that, when the first preset probability and the second preset probability are used to select a syntax error pair from a syntax error pair list and perform corruption processing on the second monolingual corpus, all of the error corpora obtained by the syntax error pair replacement processing method, all of the error corpora obtained by the syntax error pair insertion processing method, or a part of the error corpora obtained by the syntax error pair replacement processing method and a part of the error corpora obtained by the syntax error pair insertion processing method can be included, and thus, the error corpora corresponding to the second training corpus obtained can have multiple errors.
[0116] For example, for one of the training corpora in the second monolingual corpus: {I will go home tomorrow by bike}, after the syntax error pair replacement processing or the syntax error pair insertion processing, a corpus with one error can be obtained, and after the syntax error pair replacement processing or the syntax error pair insertion processing, a corpus with two errors can be obtained.
[0117] As a specific example, assuming that the probability of the training corpus {I will go home tomorrow by bike} generating one error number is v1, and the probability of generating two error numbers is v2, after the syntax error pair replacement processing is performed on the training corpus, the probability P r :
[0118]
[0119] P am going->will go represents the probability of the syntax error pair am going->will go; P total represents the sum of the probabilities of all syntax error pairs of the training corpus {I will go home tomorrow by bike}, and u represents the second preset probability, and 1-u represents the first preset probability.
[0120] Continue to perform the grammar error pair insertion processing on the training corpus, and generate the probability P of the error corpus with 2 error numbers {I am going to home tomorrow by bike} Q :
[0121]
[0122] wherein, Q to is used to represent the probability of insertion of to; 1 / 8 is used to represent the probability of to being inserted into the position of {I am going home tomorrow by bike}.
[0123] S24, combine each corpus in the second monolingual corpus set and the error corpus corresponding thereto to obtain the pseudo error corpus set.
[0124] In a specific implementation, through steps S21 to S23, a plurality of error corpora corresponding to each corpus in the second monolingual corpus set can be obtained. At this time, each corpus in the second monolingual corpus set and the error corpus corresponding thereto can be combined to obtain a pseudo error corpus set in the form of a sentence pair. The pseudo error corpus set can be expressed in the form of [(error corpus 1, second training corpus 1), (error corpus 12, second training corpus 2), …, (error corpus i, second training corpus i), …, (error corpus m, second training corpus m)], wherein error corpus i can be a sample sentence of the pseudo error corpus set, second training corpus i can be a target sentence of the pseudo error corpus set, i and m are both integers greater than 0, and i≤m.
[0125] By selecting a grammar error pair from the grammar error pair list with different probabilities and adopting different corruption processing modes on the second monolingual corpus set, the number of the obtained pseudo error corpus set can be expanded, and the obtained pseudo error corpus set can include a plurality of different types of grammar error pairs, thereby increasing the accuracy of the grammar correction model.
[0126] The embodiment of the present specification also provides another method for obtaining a pseudo error corpus set. Referring to the flowchart of another method for obtaining a pseudo error corpus set in the embodiment of the present specification shown in Figure 3 , the difference between Figure 2 is that, Figure 3 in the embodiment of the present specification, only the second monolingual corpus set is subjected to grammar error pair replacement processing to obtain a pseudo error corpus set. The specific implementation can be performed according to the following steps:
[0127] S31, search each corpus in the second monolingual corpus set and the grammar error pair reference set to obtain a grammar error pair list.
[0128] S32, selecting a syntax error pair from the syntax error pair list, and performing syntax error pair replacement processing on the second monolingual corpus to obtain error corpora corresponding to each corpus in the second monolingual corpus.
[0129] S33, combining each corpus in the second monolingual corpus and the error corpus corresponding thereto to obtain the pseudo error corpus set.
[0130] In the process of obtaining the pseudo error corpus, the description of the retrieval operation, the syntax error pair replacement processing, and the corpus combination involved, please refer to the corresponding content in Figure 2 , which will not be expanded here. The difference is that when step S32 is performed, only the second monolingual corpus is subjected to syntax error pair replacement processing, that is, when the first preset probability in step S21 in Figure 2 is set to 1 and the second preset probability is set to 0, the corresponding scheme in Figure 3 is obtained.
[0131] In specific implementation, only the second monolingual corpus can be subjected to syntax error pair insertion processing to obtain the pseudo error corpus set. For details, please refer to the flowchart of another process of obtaining the pseudo error corpus set in the embodiment of the present specification shown in Figure 4
[0132] S41, performing a retrieval operation on each corpus in the second monolingual corpus and the syntax error pair reference set to obtain a syntax error pair list.
[0133] S42, selecting a syntax error pair from the syntax error pair list, and performing syntax error pair insertion processing on the second monolingual corpus to obtain error corpora corresponding to each corpus in the second monolingual corpus.
[0134] S43, combining each corpus in the second monolingual corpus and the error corpus corresponding thereto to obtain the pseudo error corpus set.
[0135] In the process of obtaining the pseudo error corpus, the description of the retrieval operation, the syntax error pair replacement processing, and the corpus combination involved, please refer to the corresponding content in Figure 2 , which will not be expanded here. The difference is that when step S42 is performed, only the second monolingual corpus is subjected to syntax error pair insertion processing, that is, when the second preset probability in step S22 in Figure 2 is set to 1 and the first preset probability is set to 0, the corresponding scheme in Figure 2 is obtained. Figure 4
[0136] The scheme in Figures 2 to 4 The described scheme can or only be processed by a kind of corruption processing method to the second monolingual corpus, so that there is only one type of syntax error in the error corpus obtained, which is not conducive to subsequent model training, therefore, the embodiment of the present specification also provides another flowchart for obtaining pseudo error corpus.
[0137] Referring to Figure 5 The flowchart for obtaining pseudo error corpus in the embodiment of the present specification can be executed according to the following steps:
[0138] S51, each corpus in the second monolingual corpus is searched in the syntax error pair reference set to obtain a syntax error pair list.
[0139] S52, select a syntax error pair from the syntax error pair list, and perform syntax error pair replacement processing on the first part of training corpus in the second monolingual corpus, to obtain the first error corpus corresponding to the first part of training corpus in the second monolingual corpus.
[0140] S53, combine the first part of training corpus in the second monolingual corpus with the first error corpus to obtain the pseudo error corpus.
[0141] S54, select a syntax error pair from the syntax error pair list, and perform syntax error pair insertion processing on the second part of training corpus in the second monolingual corpus, to obtain the second error corpus corresponding to the second part of training corpus in the second monolingual corpus.
[0142] S55, combine the second part of training corpus in the second monolingual corpus with the second error corpus to obtain the pseudo error corpus.
[0143] Wherein, in the process of obtaining pseudo error corpus, the description of the retrieval operation, syntax error pair replacement processing and corpus combination involved, please refer to the corresponding content in Figure 2 , which will not be expanded here. With Figure 2 The difference between the scheme is that in the Figure 5 Corresponding scheme, the pseudo error corpus corresponding to the second monolingual corpus obtained has pseudo error corpus obtained by performing syntax error pair replacement processing on the second training corpus, and also has pseudo error corpus obtained by performing syntax error pair insertion processing on the second training corpus.
[0144] In a specific implementation, when the first part of training corpus and the second part of training corpus in the second monolingual corpus set are subjected to corruption processing, the first part of training corpus can be subjected to grammar error pair replacement processing, and the second part of training corpus can be subjected to grammar error pair insertion processing; or, the first part of training corpus and the second part of training corpus can be subjected to grammar error pair insertion processing and grammar error pair replacement processing simultaneously; or, the first part of training corpus can be subjected to grammar error pair replacement processing, the second part of training corpus can be subjected to grammar error pair insertion processing, and other parts of training corpus can be subjected to at least one corruption processing mode.
[0145] It should be noted that there is no necessary sequence between some steps in the above embodiments, which can be executed simultaneously or in sequence without contradiction, and the sequence can be changed. For example, when the step of obtaining the pseudo error corpus set is actually executed, steps S52 and S42 are executed after step S51, and steps S54 and S55 are executed after step S51; for example, steps S52 and S42 can be executed simultaneously with steps S54 and S55. The sequence of steps is not limited in the embodiments of the present specification.
[0146] The second monolingual corpus set is subjected to corruption processing to obtain a pseudo error corpus set corresponding to the second monolingual corpus set, and the pseudo error corpus set and the first training corpus set can be used to train the preset neural network model.
[0147] In a specific implementation, the preset neural network model can be pre-trained using the pseudo error corpus set to obtain an initial grammar correction model.
[0148] Referring to Figure 6 The flowchart of the training method of the text sentence segmentation model in the embodiments of the present specification, in some embodiments of the present specification, the preset neural network model can include an embedding layer, a coding layer coupled with the embedding layer, and a decoding layer coupled with the coding layer; the pseudo error corpus set and the first training corpus set are input into the preset neural network model to train the preset neural network model to obtain a grammar correction model, which can be specifically performed according to the following steps:
[0149] S61, the pseudo error corpus set is input into the embedding layer, and the embedding layer is used to perform segmentation processing on the pseudo error corpus set to obtain a plurality of word units.
[0150] S62, the word units are input into the coding layer, and the coding layer is used to code the word units to obtain corresponding coding vectors.
[0151] S63, input the encoding vector to the decoding layer, and calculate the cross entropy between the encoding vector and the target value thereof through the decoding layer, and take the cross entropy as a loss function.
[0152] The target value refers to correct corpus in the pseudo error corpus set, for example, the first training corpus.
[0153] S64, the loss function is minimized by using a back propagation algorithm, and the preset neural network model is iteratively trained to obtain an initial grammar correction model.
[0154] S65, input the error part corpus set in the first training corpus set to the initial grammar correction model to obtain a corrected corpus set corresponding to the first training corpus set.
[0155] S66, the loss value between the correct part corpus set in the first training corpus set and the corrected corpus set corresponding to the first training corpus set is minimized, and the initial grammar correction model is fine-tuned to obtain the grammar correction model.
[0156] After the above training process, the grammar correction model can be obtained, and the grammar correction model can be used to correct the corpus with grammar errors to obtain the grammar correction result and output.
[0157] Referring to Figure 7 The flowchart of a grammar correction method in some embodiments of the present specification specifically includes the following steps:
[0158] S71, obtaining a to-be-corrected corpus.
[0159] In specific implementation, the to-be-punctuated text can be obtained from multiple different fields, and the to-be-punctuated text can be obtained in one or more of the following manners: grabbing to-be-corrected corpus in the Internet; manually inputting to-be-corrected corpus; grabbing voice data in the Internet, and obtaining to-be-corrected corpus through voice recognition and annotation.
[0160] S72, inputting the to-be-corrected corpus to a grammar correction model to generate and output a grammar correction result.
[0161] The grammar correction model is obtained by sequentially inputting a pseudo error corpus set and a first training corpus set to a preset neural network model, and training the preset neural network model; the pseudo error corpus set is obtained by corrupting a second monolingual corpus set based on a grammar error pair reference set; and the grammar error pair reference set is obtained by extracting a grammar error pair from a first training corpus set containing annotation information.
[0162] By using the above grammar correction method, since the grammar correction model is obtained by training the preset neural network model by using the pseudo error corpus set with grammar error pairs and the first training corpus set, and the pseudo error corpus set with one or more adjacent words can be obtained by corrupting the second monolingual corpus set based on the grammar error pair reference set, and the data quantity of the obtained pseudo error corpus set can be increased, and the grammar correction model obtained by training the preset neural network model has better universality, so that the accuracy of grammar correction can be improved when the grammar correction model is used to correct the corpus.
[0163] In some optional examples in some embodiments of the present specification, the preset neural network model can include an embedding layer, a coding layer coupled with the embedding layer, and a decoding layer coupled with the coding layer.
[0164] The inputting the to-be-corrected corpus into the grammar correction model, generating a grammar correction result and outputting, includes:
[0165] The inputting the to-be-corrected corpus into the embedding layer, performing splitting processing on the to-be-corrected corpus by the embedding layer, and obtaining a plurality of word units;
[0166] The inputting the word units into the coding layer, performing coding on the word units by the coding layer, and obtaining corresponding coding vectors;
[0167] The inputting the coding vectors into the decoding layer, performing decoding on the coding vectors by the decoding layer, obtaining a grammar correction result corresponding to the to-be-corrected corpus and outputting.
[0168] The present specification also provides an apparatus corresponding to the above grammar correction training method, which will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0169] Referring to Figure 8 In some embodiments of the present specification, the grammar correction training apparatus 80 can include:
[0170] A training corpus acquisition module 81 is adapted to acquire a first training corpus set containing annotation information and a second monolingual corpus set, wherein the annotation information is used to represent grammar error pairs of each training corpus in the first training corpus set, and the grammar error pairs include an error form source segment and a correct form target segment corresponding to the error form source segment.
[0171] A grammar error pair reference set construction module 82 is adapted to extract grammar error pairs of each training corpus in the first training corpus set, and construct a grammar error pair reference set.
[0172] The processing module 83 is adapted to perform corruption processing on the second monolingual corpus based on the grammar error pair reference set, to obtain a pseudo error corpus corresponding to the second monolingual corpus.
[0173] The training module 84 is adapted to input the pseudo error corpus and the first training corpus into a preset neural network model, train the preset neural network model, and obtain a grammar correction model.
[0174] The grammar correction training device can obtain a pseudo error corpus with one or more adjacent words by performing corruption processing on the second monolingual corpus based on the grammar error pair reference set, and can increase the data amount of the obtained pseudo error corpus. The grammar correction model obtained by training the preset neural network model using the pseudo error corpus and the first training corpus has better universality, so that the accuracy of grammar correction can be improved when the grammar correction model is used to perform grammar correction on a corpus.
[0175] Correspondingly, the embodiments of the present specification also provide a device corresponding to the above grammar correction method, which will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0176] Referring to Figure 9 The grammar correction device 90 can include the following components in the embodiments of the present specification:
[0177] The corpus acquisition module 91 is adapted to acquire a to-be-corrected corpus.
[0178] The correction module 92 is adapted to input the to-be-corrected corpus into a grammar correction model, generate a grammar correction result, and output the grammar correction result.
[0179] The grammar correction model is obtained by sequentially inputting a pseudo error corpus and a first training corpus into a preset neural network model and training the preset neural network model; the pseudo error corpus is obtained by performing corruption processing on a second monolingual corpus based on a grammar error pair reference set; and the grammar error pair reference set is obtained by extracting grammar error pairs from a first training corpus containing annotation information.
[0180] The grammar correction device is obtained by training a preset neural network model by using the pseudo error corpus with the grammar error pairs and the first training corpus. The pseudo error corpus with one or more adjacent words is obtained by corrupting the second monolingual corpus based on the grammar error pair reference set, and the data quantity of the obtained pseudo error corpus is increased. The grammar correction model obtained by training the preset neural network model has better universality. Therefore, when the grammar correction device is used to correct the grammar of the corpus, the accuracy of grammar correction can be improved.
[0181] The embodiments of the present specification also provide an electronic device for implementing text grammar correction, such as Figure 10 As shown in the figure, the electronic device 100 can include a memory 101 and a processor 102, wherein the memory 101 is adapted to store one or more computer instructions, and the processor 102 executes the computer instructions to perform the steps of the training method according to any one of the preceding embodiments or the steps of the grammar correction method according to any one of the preceding embodiments.
[0182] In specific implementation, as shown in the figure, Figure 10 The electronic device 100 can further include an expansion interface 103 adapted to be connected with other devices to realize data interaction.
[0183] In specific implementation, the memory 101, the processor 102 and the expansion interface 103 can be connected through a bus.
[0184] In specific implementation, the processor can be implemented by a central processing unit (CPU), a graphics processing unit (GPU), a field programmable gate array (FPGA) or the like processing chip, and can also be implemented by an application specific integrated circuit (ASIC) or one or more integrated circuits configured to implement the embodiments of the present specification.
[0185] The memory can include a random access memory (RAM) memory, and can also include a non-volatile memory (NVM), for example, at least one disk memory.
[0186] This specification also provides a computer-readable storage medium storing computer instructions. When these computer instructions are executed, they can perform the steps of the training method or the syntax correction method described in any of the foregoing embodiments. The computer-readable storage medium can be any suitable readable storage medium such as an optical disc, a hard disk drive, or a solid-state drive. The instructions stored on the computer-readable storage medium execute the steps of the training method or the syntax correction method described in any of the foregoing embodiments, which will not be described further.
[0187] The computer-readable storage medium may include, for example, any suitable type of memory cell, memory device, memory article, memory medium, storage device, storage article, storage medium and / or storage cell, such as memory, removable or non-removable medium, erasable or non-erasable medium, writable or rewritable medium, digital or analog medium, hard disk, floppy disk, optical disc read-only memory (CD-ROM), recordable optical disc (CD-R), rewritable optical disc (CD-RW), optical disc, magnetic medium, magneto-optical medium, removable memory card or disk, various types of digital universal optical disc (DVD), magnetic tape, cassette tape, etc.
[0188] Computer instructions may include any suitable type of code implemented using any appropriate high-level, low-level, object-oriented, visual, compiled, and / or interpreted programming language, such as source code, compiled code, interpreted code, executable code, static code, dynamic code, encrypted code, etc.
[0189] It should be understood that terms such as "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with terms such as "first" and "second" may explicitly or implicitly include one or more of that feature. Furthermore, terms such as "first" and "second" are used to distinguish similar objects and are not necessarily used to describe a specific order or indicate importance. It is understood that such terms can be used interchangeably where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein.
[0190] While the embodiments disclosed in this specification are as described above, they are not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the embodiments in this specification. Therefore, the scope of protection of the embodiments in this specification should be determined by the scope defined in the claims.
Claims
1. A training method of syntax error correction, characterized by, The method comprises: respectively acquiring a first training corpus set and a second monolingual corpus set containing annotation information, wherein the annotation information is used to represent a grammatical error pair of each training corpus in the first training corpus set, and the grammatical error pair comprises a source segment in an incorrect form and a target segment in a correct form corresponding to the source segment in the incorrect form; extracting the grammatical error pair of each training corpus in the first training corpus set to construct a grammatical error pair reference set; based on the grammatical error pair reference set, performing corruption processing on the second monolingual corpus set to obtain a pseudo error corpus set corresponding to the second monolingual corpus set; inputting the pseudo error corpus set and the first training corpus set into a preset neural network model, training the preset neural network model, and obtaining a grammatical error correction model.
2. The training method of claim 1, wherein, The method comprises: extracting the grammatical error pair corresponding to each training corpus in the first training corpus set, and counting the frequency of occurrence of each grammatical error pair in the grammatical error pair; according to the frequency of occurrence of each grammatical error pair, performing weight assignment on each grammatical error pair to obtain the grammatical error pair reference set.
3. The training method of claim 2, wherein, The method comprises: performing retrieval operation on each corpus in the second monolingual corpus set and the grammatical error pair reference set to obtain a grammatical error pair list; selecting a grammatical error pair from the grammatical error pair list at a first preset probability, and performing grammatical error pair replacement processing on the second monolingual corpus set to obtain an error corpus corresponding to each corpus in the second monolingual corpus set; selecting a grammatical error pair from the grammatical error pair list at a second preset probability, and performing grammatical error pair insertion processing on the second monolingual corpus set to obtain an error corpus corresponding to each corpus in the second monolingual corpus set; combining each corpus in the second monolingual corpus set and the error corpus corresponding thereto to obtain the pseudo error corpus set.
4. The training method of claim 3, wherein, The sum of the first preset probability and the second preset probability is 1, and the first preset probability is greater than the second preset probability.
5. The training method of claim 2, wherein, The method comprises: performing retrieval operation on each corpus in the second monolingual corpus set and the grammatical error pair reference set to obtain a grammatical error pair list; selecting a grammatical error pair from the grammatical error pair list, and performing grammatical error pair replacement processing on the second monolingual corpus set to obtain an error corpus corresponding to each corpus in the second monolingual corpus set; combining each corpus in the second monolingual corpus set and the error corpus corresponding thereto to obtain the pseudo error corpus set.
6. The training method of claim 2, wherein, The method comprises: The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; A syntax error pair is selected from the syntax error pair list, and syntax error pair insertion processing is performed on the second monolingual corpus to obtain error corpus corresponding to each corpus in the second monolingual corpus; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set.
7. The training method of claim 2, wherein, The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; A syntax error pair is selected from the syntax error pair list, and syntax error pair insertion processing is performed on the second monolingual corpus to obtain error corpus corresponding to each corpus in the second monolingual corpus; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; 8. Training method according to any one of claims 3 to 7, characterized in that, The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; 9. The training method of claim 8, wherein, The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set.
10. The training method according to any one of claims 3 to 7, characterized in that, The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The second monolingual corpus and the corresponding error corpus are combined to obtain the pseudo error corpus set. The second monolingual corpus is searched against the syntax error pair reference set to obtain a syntax error pair list; The Obtaining a second grammar error pair list corresponding to each corpus in the second monolingual corpus set by selecting, from the grammar error pair reference set, grammar error pairs corresponding to correct forms of word units in the second monolingual corpus set, and taking the grammar error pair list as the grammar error pair list.
11. The training method of claim 10, wherein, The grammar error pair insertion processing on the second monolingual corpus set to obtain error corpora corresponding to each corpus in the second monolingual corpus set comprises: Obtaining weights of each grammar error pair in the second grammar error pair list; According to the weight values of the grammar error pairs, randomly selecting any one grammar error pair from the second grammar error pair list, and inserting the source segment of the error form in the any one grammar error pair into the corresponding part of the corresponding corpus in the second monolingual corpus set to obtain error corpora corresponding to each corpus in the second monolingual corpus set.
12. The training method of claim 1, wherein, The preset neural network model includes an embedding layer, a coding layer coupled to the embedding layer, and a decoding layer coupled to the coding layer; The training of the preset neural network model by inputting the pseudo error corpus set and the first training corpus set into the preset neural network model comprises: Inputting the pseudo error corpus set into the embedding layer to perform segmentation processing on the pseudo error corpus set by the embedding layer to obtain a plurality of word units; Inputting the word units into the coding layer to encode the word units by the coding layer to obtain corresponding encoding vectors; Inputting the encoding vectors into the decoding layer, and calculating the cross entropy between the encoding vectors and their target values by the decoding layer to obtain a loss function; Minimizing the loss function by using a back propagation algorithm to iteratively train the preset neural network model to obtain an initial grammar error correction model; Inputting the error part corpus set in the first training corpus set into the initial grammar error correction model to obtain a correction corpus set corresponding to the first training corpus set; Minimizing the loss value between the correct part corpus set in the first training corpus set and the correction corpus set corresponding to the first training corpus set to fine-tune the initial grammar error correction model to obtain the grammar error correction model.
13. A syntax error correction method, characterized by, It comprises: Obtaining a to-be-corrected corpus; Inputting the to-be-corrected corpus into the grammar error correction model to generate and output a grammar error correction result. The grammar error correction model is obtained by sequentially inputting a pseudo error corpus set and a first training corpus set into a preset neural network model and training the preset neural network model; the pseudo error corpus set is obtained by corrupting a second monolingual corpus set based on a grammar error pair reference set; and the grammar error pair reference set is obtained by extracting grammar error pairs from a first training corpus set containing annotation information.
14. The syntax error correction method of claim 13, wherein, The preset neural network model includes an embedding layer, a coding layer coupled to the embedding layer, and a decoding layer coupled to the coding layer; The inputting of the to-be-corrected corpus into the grammar error correction model to generate and output a grammar error correction result comprises: input the to-be-corrected corpus into the embedding layer, perform splitting processing on the to-be-corrected corpus by the embedding layer, and obtain a plurality of word units; input the word units into the encoding layer, encode the word units by the encoding layer, and obtain corresponding encoding vectors; input the encoding vectors into the decoding layer, decode the encoding vectors by the decoding layer, obtain a grammar correction result corresponding to the to-be-corrected corpus, and output the grammar correction result.
15. A syntax error correction training apparatus, characterized by comprising: The training corpus acquisition module is adapted to acquire a first training corpus set containing annotation information and a second monolingual corpus set, wherein the annotation information is used to represent a grammar error pair of each training corpus in the first training corpus set, and the grammar error pair includes a source segment in an error form and a target segment in a correct form corresponding to the source segment in the error form. The grammar error pair reference set construction module is adapted to extract the grammar error pair of each training corpus in the first training corpus set and construct a grammar error pair reference set. The processing module is adapted to perform corruption processing on the second monolingual corpus set based on the grammar error pair reference set, and obtain a pseudo-error corpus set corresponding to the second monolingual corpus set. The training module is adapted to input the pseudo-error corpus set and the first training corpus set into a preset neural network model, train the preset neural network model, and obtain a grammar correction model. The corpus acquisition module is adapted to acquire a to-be-corrected corpus.
16. A syntax error correction apparatus, characterized by comprising: The correction module is adapted to input the to-be-corrected corpus into a grammar correction model, generate a grammar correction result, and output the grammar correction result. The grammar correction model is obtained by sequentially inputting a pseudo-error corpus set and a first training corpus set into a preset neural network model, training the preset neural network model, and obtaining the grammar correction model; the pseudo-error corpus set is obtained by performing corruption processing on a second monolingual corpus set based on a grammar error pair reference set; and the grammar error pair reference set is obtained by extracting a grammar error pair from a first training corpus set containing annotation information. The memory is adapted to store one or more computer instructions, and when the processor runs the computer instructions, the steps of the training method of any one of claims 1 to 12 are executed; or the steps of the grammar correction method of claim 13 or 14 are executed. The computer instructions run to execute the steps of the training method of any one of claims 1 to 12; or the steps of the grammar correction method of claim 13 or 14 are executed.
17. An electronic device comprising a memory and a processor, wherein, 18. A computer readable storage medium having stored thereon computer instructions, wherein,
Citation Information
Patent Citations
Method and system for correcting term mistranslation in translation and related device
CN108804428A
Grammar error correction model training method and device and grammar error correction method and device
CN111767731A