Text error correction method and device
Through the attention-based sequence-to-sequence model, combined with the attention mechanism and the long and short-term memory network, it solves the problem of only considering the previous words in the existing technology, improves the accuracy of text error correction and model complexity, and achieves more efficient text error correction effect.
Patent Information
- Application Number
- CN201810146360.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-02-12
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2038-02-12
AI Technical Summary
Text error correction methods in the prior art are based on language models, which only consider the words before the current word, and fail to effectively utilize the word information after the current word. Moreover, the complexity of the model results in a large amount of calculation, which affects the error correction accuracy.
An attention-based sequence-to-sequence model is used to construct an error correction model through a training sample set, taking into account the relationship between the current word and the preceding and following words, and using the attention mechanism and long-short-term memory network to improve error correction accuracy.
It reduces the computational complexity, improves the accuracy of text error correction, can comprehensively consider word segmentation replacement in various situations, solves the vanishing gradient problem, and improves the accuracy and output quality of the error correction model.
Smart Images

Figure CN110162767B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for text error correction. Background Art
[0002] In recent years, with the continuous innovation and progress of information technology, intelligent customer service robots have gradually replaced human customer service in the customer service industry with their advantages such as no need for training, long-term continuous work, and no labor costs. The core technology of intelligent customer service robots is to preprocess the user's input, then perform intent recognition and classification on the preprocessing results, and then respond based on the classification results. The text error correction link in the preprocessing process is very important. If the user's input is not corrected, the accuracy of intent recognition will be affected, and ultimately the intelligent customer service robot will respond incorrectly.
[0003] The existing technology is based on language model to perform text error correction, that is, the probability of a sentence is calculated based on the probability of occurrence between words. Assume that sentence s is composed of k words, that is, s = W 1 ,W 2 ,…,W k , (W 1 ,W 2 ,…,W k are the words that make up sentence s), then the probability p(s) of sentence s can be expressed as:
[0004] p(s)=p(W 1 ,W 2 ,…,W k )=p(W 1 )p(W 2 |W 1 )…p(W k |W 1 ,W 2 ,…,W k-1 )
[0005] Among them, W k Represents the current word, W 1 ,W 2 ,…,W k-1 Indicates the word before the current word.
[0006] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: First, in the prior art method of text correction based on language model, the language model only considers the words before the current word, and does not consider the words after the current word; Second, the language model used in the prior art text correction method has the problem of complex model and large amount of calculation. Taking the N-Gram model (a language model commonly used in large vocabulary continuous speech recognition) as an example, assuming that the size of the vocabulary is 100,000, then the number of parameters of the N-Gram model reaches 100,000. N The larger N is, the more accurate the model is, but the more complex the model is and the more computational effort is required. Summary of the invention
[0007] In view of this, an embodiment of the present invention provides a method and device for text error correction, which can reduce the complexity of calculation and improve the accuracy of text error correction.
[0008] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for text error correction is provided.
[0009] A text correction method of an embodiment of the present invention includes: obtaining a text to be corrected according to a text correction requirement; correcting the text to be corrected according to a correction model, and outputting a standard text corresponding to the text to be corrected, wherein the correction model is a trained attention-based sequence-to-sequence model.
[0010] Optionally, before correcting the text to be corrected according to the error correction model and outputting the standard text corresponding to the text to be corrected, the method also includes: acquiring a first sample set and a second sample set, the first sample set containing at least one standard text, and the second sample set containing erroneous text corresponding to the standard sample; constructing a training sample set using the first sample set and the second sample set; training the training sample set to obtain the error correction model, the error correction model inputting the erroneous text of the training sample set and outputting the standard text of the training sample set.
[0011] Optionally, obtaining the first sample set and the second sample set includes: obtaining the first sample set; performing word segmentation processing on the standard text in the first sample set to obtain multiple word segments, and generating a replacement set corresponding to each word segment according to a preset rule; selecting a preset number of replacement words from the replacement set corresponding to the word segment; randomly replacing the standard text according to the replacement words to generate error text, and then using the error text to form the second sample set.
[0012] Optionally, the preset rule includes at least one of the following: a same-sound rule, a fuzzy-sound rule, and a similar-sound word rule.
[0013] Optionally, the trained attention-based sequence-to-sequence model includes: an embedding layer, a forward encoding layer, a backward encoding layer, an attention mechanism, a decoding layer and a conversion layer.
[0014] Optionally, the forward coding layer, the backward coding layer and the decoding layer all include a long short-term memory network.
[0015] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for text error correction is provided.
[0016] A device for text correction according to an embodiment of the present invention includes: an acquisition module, used to acquire a text to be corrected according to a text correction requirement; a correction module, used to correct the text to be corrected according to a correction model, and output a standard text corresponding to the text to be corrected, wherein the correction model is a trained attention-based sequence-to-sequence model.
[0017] Optionally, the acquisition module is also used to: acquire a first sample set and a second sample set, the first sample set containing at least one standard text, and the second sample set containing erroneous text corresponding to the standard sample; construct a training sample set using the first sample set and the second sample set; train the training sample set to obtain the error correction model, the error correction model inputting the erroneous text of the training sample set and outputting the standard text of the training sample set.
[0018] Optionally, the acquisition module is also used to: acquire a first sample set; perform word segmentation processing on the standard text in the first sample set to obtain multiple word segments, and generate a replacement set corresponding to each word segment according to preset rules; select a preset number of replacement words from the replacement set corresponding to the word segment; randomly replace the standard text according to the replacement words to generate error text, and then use the error text to form the second sample set.
[0019] Optionally, the preset rule includes at least one of the following: a same-sound rule, a fuzzy-sound rule, and a similar-sound word rule.
[0020] Optionally, the trained attention-based sequence-to-sequence model includes: an embedding layer, a forward encoding layer, a backward encoding layer, an attention mechanism, a decoding layer and a conversion layer.
[0021] Optionally, the forward coding layer, the backward coding layer and the decoding layer all include a long short-term memory network.
[0022] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.
[0023] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the text error correction method according to the embodiment of the present invention.
[0024] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer readable medium is provided.
[0025] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, the text error correction method according to the embodiment of the present invention is implemented.
[0026] An embodiment of the above invention has the following advantages or beneficial effects: it can use the trained attention-based sequence-to-sequence model to correct text errors, which reduces the complexity of calculation and improves the accuracy of text error correction; in the embodiment of the present invention, the training sample set composed of the first sample set and the second sample set is trained to obtain the error correction model, so that the error correction model can be constructed using massive sample set data, thereby improving the accuracy of the error correction model; in the embodiment of the present invention, the erroneous text in the second sample set is generated based on the standard text in the first sample set, so that the relationship between the erroneous text and its corresponding standard text can be established, further improving the accuracy of the error correction model; in the embodiment of the present invention, a replacement set for each word segment is constructed from multiple angles such as the same sound rule, the fuzzy sound rule and the similar word rule, thereby The replacement words of word segmentation in various situations can be comprehensively considered; the error correction model in the embodiment of the present invention includes: a forward coding layer and a backward coding layer, so that the relationship between the current word and the previous word and the relationship between the current word and the following word can be considered; the error correction model in the embodiment of the present invention includes: an attention mechanism, so that when generating each output, it can make full use of the information carried by the input sequence, find the useful information in the input sequence that is significantly related to the output, improve the quality of the output, and thus improve the accuracy of the error correction model; in the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer can all include a long short-term memory network, so as to solve the problem of gradient disappearance during training and recognition, improve the accuracy of the error correction model, and improve the accuracy of the output result.
[0027] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0029] Figure 1 is a schematic diagram of the main steps of a method for text error correction according to an embodiment of the present invention;
[0030] Figure 2 is a schematic diagram of an error correction model of a text error correction method according to an embodiment of the present invention;
[0031] Figure 3 is a schematic diagram of the main process of training an error correction model according to the text error correction method of an embodiment of the present invention;
[0032] Figure 4 is a schematic diagram of main modules of a text error correction device according to an embodiment of the present invention;
[0033] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0034] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0036] Figure 1 is a schematic diagram of the main steps of the text error correction method according to an embodiment of the present invention, such as Figure 1 As shown, the main steps of the text error correction method of the embodiment of the present invention may include:
[0037] Step S101: According to the text correction requirement, obtain the text to be corrected. In this step, when a text correction request is received, the text to be corrected in the request is obtained. The text to be corrected refers to an erroneous text with problematic sentences, for example, incorrect word composition, incorrect sentences, etc. The text to be corrected can be Chinese text data or other text data, which is not limited in the present invention. The text to be corrected can be text data input by the user or voice data input by the user through voice. If it is voice data, the voice data is first converted into text data. Of course, the text to be corrected in the present invention can also be other forms of data, which is not limited in the present invention.
[0038] Step S102: Correct the text to be corrected according to the error correction model, and output the standard text corresponding to the text to be corrected. The error correction model is a trained attention-based sequence-to-sequence model. In this step, the text to be corrected is input into the trained error correction model, and then the standard text corresponding to the text to be corrected is obtained. The standard text refers to the correct text data that can reflect the true intention. For example, taking intelligent customer service as an example, the user inputs the text to be corrected "Does it support payment on delivery?" The intelligent customer service transmits the text entered by the user to the error correction model, and obtains the corresponding standard text "Does it support cash on delivery?" Therefore, the intelligent customer service can obtain the user's true intention and make a response.
[0039] In an embodiment of the present invention, before correcting the text to be corrected according to the error correction model and outputting the standard text corresponding to the text to be corrected, the method for text correction may also include: obtaining a first sample set and a second sample set, the first sample set may include at least one standard text, and the second sample set may include an erroneous text corresponding to the standard sample; constructing a training sample set using the first sample set and the second sample set; training the training sample set to obtain an error correction model, the error correction model input is the erroneous text of the training sample set, and the standard text of the training sample set is output. In this embodiment, the first sample set and the second sample set are used to generate the training sample set, and then the error correction model is trained using the training sample set. Taking an application platform as an example, the first sample set may be a common user problem maintained by the platform, and these problems that have been cleaned and reviewed belong to high-quality texts and do not contain erroneous words. The second sample set may be a problem containing erroneous words corresponding to high-quality user problems. After a long period of statistics and accumulation, the common problems maintained by the platform belong to massive data, thereby improving the accuracy of the model.
[0040] In an embodiment of the present invention, obtaining the first sample set and the second sample set may include: obtaining the first sample set; performing word segmentation processing on the standard text in the first sample set to obtain multiple word segments, and generating a replacement set corresponding to each word segment according to a preset rule; selecting a preset number of replacement words from the replacement set corresponding to the word segment; randomly replacing the standard text according to the replacement words to generate error text, and then using the error text to form the second sample set.
[0041] In this embodiment, crawler technology (crawler technology is a program or script technology that automatically crawls Internet information according to certain rules and has been widely used in the Internet field) can be used to crawl the first sample set, or other methods can be used to obtain the first sample set, and the present invention is not limited to this.
[0042] For ease of understanding, assume that "Is shipping free?" is the standard text in the first sample set. First, perform word segmentation on "Is shipping free?" to obtain three words: "bao", "you", and "ma". Then generate replacement sets for these three words respectively. Set the preset number of replacements for "bao" to be 5, the preset number of replacements for "you" to be 3, and the preset number of replacements for "ma" to be 2. Then randomly select 5 replacement words from the replacement set of "bao", randomly select 3 replacement words from the replacement set of "you", and randomly select 2 replacement words from the replacement set of "ma". Finally, use the selected replacement words to replace the standard text "Is shipping free?" to obtain 30 corresponding incorrect texts. Therefore, one standard text can correspond to multiple incorrect texts, and each standard text and an incorrect text form an error correction pair. In this way, the standard text "Is shipping free?" and its corresponding 30 incorrect texts can form 30 error correction pairs.
[0043] In this embodiment, perform word segmentation on all standard documents in the first sample set to obtain multiple characters or words. Then calculate the corresponding replacement sets for each character and word. After that, select replacement words for each character and word according to the preset number, and then randomly replace the standard text to generate its corresponding incorrect text. All these incorrect texts form the second sample set.
[0044] In the embodiment of the present invention, the preset rules may include at least one of the following: the same pronunciation rule, the fuzzy pronunciation rule, and the similar form word rule. The same pronunciation rule refers to words with the same pronunciation. Taking Chinese as an example, the replacement word corresponding to "huo" can be "huo", and the replacement word corresponding to "youhui" can be "youhui". Taking English as an example, the replacement word corresponding to "see" can be "sea". The fuzzy pronunciation rule refers to words with similar pronunciations. Taking Chinese as an example, the fuzzy pronunciation corresponding to "zh" can be "z", the fuzzy pronunciation corresponding to "ch" can be "c", the fuzzy pronunciation corresponding to "sh" can be "s", the fuzzy pronunciation corresponding to "ang" can be "an", the fuzzy pronunciation corresponding to "eng" can be "en", the fuzzy pronunciation corresponding to "ing" can be "in", the fuzzy pronunciation corresponding to "n" can be "l", etc. Therefore, the replacement word corresponding to "zhi" can be "zi", and the replacement word corresponding to "zhidao" can be "zidao". Taking English as an example, the replacement word corresponding to "sea" can be "she". The similar form word rule refers to words with similar text representations. Taking Chinese as an example, the replacement word corresponding to "yi" can be "ji", and the replacement word corresponding to "da" can be "tai". Taking English as an example, the replacement word corresponding to "and" can be "aid", and the replacement word corresponding to "new" can be "now".
[0045] In this embodiment, taking Chinese as an example, for the rules of homophones and fuzzy sounds, the first-level Chinese characters and second-level Chinese characters in the GB2312 standard (GB2312 is based on the "Basic Set of Chinese Character Coded Character Sets for Information Exchange" issued in 1980, which is the Chinese national standard for Chinese information processing and a mandatory Chinese encoding) can be counted to obtain homophones and fuzzy sound words. For the rules of similar words, the dot matrix font library of the first-level Chinese characters and second-level Chinese characters in the GB2312 standard can be counted to count the similarity in the dot matrix. If the similarity between two words is greater than a threshold, then they are words with similar glyphs. The dot matrix font library divides each Chinese character into 16×16 or 24×24 dots, and then uses the virtuality and reality of each dot to represent the outline of the Chinese character, which is used as a display font library.
[0046] In an embodiment of the present invention, a trained attention-based sequence-to-sequence model may include: an embedding layer, a forward encoding layer, a backward encoding layer, an attention mechanism, a decoding layer, and a conversion layer. Figure 2 Schematic diagram of an error correction model of a text error correction method according to an embodiment of the present invention. Figure 2 As shown, the error correction model may include: an embedding layer (Embed layer), a forward encoding layer (FOREncoder layer), a backward encoding layer (BACKEncoder layer), an attention mechanism (Attention mechanism), a decoding layer (Decoder layer) and a conversion layer (Softmax function). The FOREncoder layer and the BACKEncoder layer in the error correction model can achieve the effect of considering the relationship between the current word and the previous word, as well as the relationship between the current word and the following word. The Attention mechanism is a model in deep learning. When generating output, an attention range is generated, indicating which parts of the input sequence should be focused on when the next output is generated, and then the next output is generated based on the focused parts. In this way, when generating each output, the information carried by the input sequence can be fully utilized, and useful information in the input sequence that is significantly related to the output can be found, thereby improving the quality of the output and thus improving the accuracy of the recognition model.
[0047] exist Figure 2In the error correction model shown, A, B and C are the inputs of the model, which refer to the multiple segmentations obtained after the error correction text is segmented in the present invention. Then, the segmentation is converted into a word vector through the Embed layer, wherein the dimension of the word vector is generally determined by the number of all segmentations in the first sample set. For example, all standard texts in the first sample set are segmented to obtain multiple segmentations, and the repeated segmentations in the segmentations are removed. Then, the remaining segmentations are encoded from 1, and the maximum number of the encoding can be used as the dimension of the word vector. Of course, the dimension of the word vector can also be set according to the specific scenario in the present invention, which is not limited to this. Then, the converted word vector is encoded through the FOREncoder layer and the BACKEncoder layer. Finally, the encoding results of the FOREncoder layer and the BACKEncoder layer are merged into an intermediate vector S. At the Decoder layer, the intermediate vector S and the output of the Attention mechanism are parsed as input to obtain the output vector output, and then the words X and Y with the highest probability are calculated by the Softmax function of the conversion layer. In addition, start in this model is a feature identifier, corresponding to the beginning of the output, not the output word, and is just a placeholder. end is also a feature identifier, corresponding to the end of the output, and is also just a placeholder.
[0048] In the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer may all include a long short-term memory network. The long short-term memory network LSTM (Long Short-Term Memory) is a time recursive neural network suitable for processing and predicting important events with relatively long intervals and delays in time series. In the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer may all include a long short-term memory network, thereby solving the problem of gradient disappearance during training and recognition, improving the accuracy of the error correction model, and improving the accuracy of the output results.
[0049] Figure 3 FIG. 1 is a schematic diagram of the main process of training an error correction model according to the text error correction method of an embodiment of the present invention. Figure 3As shown, the main process of training the error correction model of the text error correction method of the embodiment of the present invention may include: step S301, obtaining a first sample set; step S302, performing word segmentation processing on the standard text in the obtained first sample set to obtain multiple word segments; step S303, generating a replacement set corresponding to each word segment according to a preset rule; step S304, selecting a preset number of replacement words from the replacement set corresponding to the word segment; step S305, randomly replacing the standard text according to the replacement words to generate an error text; step S306, using all the error texts to form a second sample set; step S307, using the first sample set and the second sample set to construct a training sample set; step S308, training the training sample set to obtain an error correction model. In the present invention, the trained error correction model can be used to correct the text to be corrected and generate its corresponding standard text.
[0050] It can be seen from the technical solution of text error correction according to the embodiment of the present invention that the trained attention-based sequence-to-sequence model can be used to correct text errors, which reduces the complexity of calculation and improves the accuracy of text error correction; in the embodiment of the present invention, the training sample set composed of the first sample set and the second sample set is trained to obtain an error correction model, so that the error correction model can be constructed using massive sample set data, thereby improving the accuracy of the error correction model; in the embodiment of the present invention, the erroneous text in the second sample set is generated based on the standard text in the first sample set, so that the relationship between the erroneous text and its corresponding standard text can be established, further improving the accuracy of the error correction model; in the embodiment of the present invention, a replacement set for each word segment is constructed from multiple angles such as the same sound rule, the fuzzy sound rule and the similar character rule, thereby The replacement words of word segmentation in various situations can be comprehensively considered; the error correction model in the embodiment of the present invention includes: a forward coding layer and a backward coding layer, so that the relationship between the current word and the previous word and the relationship between the current word and the following word can be considered; the error correction model in the embodiment of the present invention includes: an attention mechanism, so that when generating each output, it can make full use of the information carried by the input sequence, find the useful information in the input sequence that is significantly related to the output, improve the quality of the output, and thus improve the accuracy of the error correction model; in the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer can all include a long short-term memory network, so as to solve the problem of gradient disappearance during training and recognition, improve the accuracy of the error correction model, and improve the accuracy of the output result.
[0051] Figure 4 Schematic diagram of the main modules of the text error correction device according to an embodiment of the present invention. Figure 4 As shown, the text error correction device 400 of the embodiment of the present invention mainly includes the following modules: an acquisition module 401 and an error correction module 402.
[0052] Among them, the acquisition module 401 can be used to obtain the text to be corrected according to the text correction requirements. The correction module 402 can be used to correct the text to be corrected according to the correction model and output the standard text corresponding to the text to be corrected. The correction model is a trained attention-based sequence-to-sequence model.
[0053] In an embodiment of the present invention, the acquisition module 401 can also be used to: acquire a first sample set and a second sample set, the first sample set may include at least one standard text, and the second sample set may include erroneous text corresponding to the standard sample; construct a training sample set using the first sample set and the second sample set; train the training sample set to obtain an error correction model, the error correction model input is the erroneous text of the training sample set, and the output is the standard text of the training sample set.
[0054] In an embodiment of the present invention, the acquisition module 401 can also be used to: acquire a first sample set; perform word segmentation processing on the standard text in the first sample set to obtain multiple word segments, and generate a replacement set corresponding to each word segment according to a preset rule; select a preset number of replacement words from the replacement set corresponding to the word segment; randomly replace the standard text according to the replacement words to generate error text, and then use the error text to form a second sample set.
[0055] In the embodiment of the present invention, the preset rules may include at least one of the following: a homophone rule, a fuzzy sound rule, and a similar-looking character rule. Among them, the similar-looking character rule may include a homophone rule and a homophone rule.
[0056] In an embodiment of the present invention, a trained attention-based sequence-to-sequence model may include: an embedding layer, a forward encoding layer, a backward encoding layer, an attention mechanism, a decoding layer, and a conversion layer.
[0057] In the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer may all include a long short-term memory network.
[0058] From the above description, it can be seen that the trained attention-based sequence-to-sequence model can be used to correct text errors, which reduces the complexity of calculation and improves the accuracy of text error correction; in the embodiment of the present invention, the training sample set composed of the first sample set and the second sample set is trained to obtain an error correction model, so that the error correction model can be constructed using massive sample set data, thereby improving the accuracy of the error correction model; in the embodiment of the present invention, the erroneous text in the second sample set is generated based on the standard text in the first sample set, so that the relationship between the erroneous text and its corresponding standard text can be established, further improving the accuracy of the error correction model; in the embodiment of the present invention, the replacement set of each word segmentation is constructed from multiple angles such as the same sound rule, the fuzzy sound rule and the similar character rule, so that the error correction model can be comprehensively considered. Replacement words for word segmentation in various situations; The error correction model in the embodiment of the present invention includes: a forward coding layer and a backward coding layer, so that the relationship between the current word and the previous word and the relationship between the current word and the following word can be considered; The error correction model in the embodiment of the present invention includes: an attention mechanism, so that when generating each output, it can make full use of the information carried by the input sequence, find the useful information in the input sequence that is significantly related to the output, improve the quality of the output, and thus improve the accuracy of the error correction model; In the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer can all include a long short-term memory network, so as to solve the problem of gradient disappearance during training and recognition, improve the accuracy of the error correction model, and improve the accuracy of the output result.
[0059] Figure 5 An exemplary system architecture 500 is shown to which the method for text correction or the apparatus for text correction according to the embodiments of the present invention may be applied.
[0060] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0061] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0062] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0063] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0064] It should be noted that the text correction method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the text correction device is generally set in the server 505 .
[0065] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0066] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0067] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0068] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0069] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0070] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0071] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0072] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an acquisition module and an error correction module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the acquisition module may also be described as "a module for acquiring text to be corrected according to text error correction requirements".
[0073] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: obtaining a text to be corrected according to text correction requirements; correcting the text to be corrected according to a correction model, and outputting a standard text corresponding to the text to be corrected. The correction model is a trained attention-based sequence-to-sequence model.
[0074] According to the technical solution of the embodiment of the present invention, the trained attention-based sequence-to-sequence model can be used to correct text errors, which reduces the complexity of calculation and improves the accuracy of text error correction; in the embodiment of the present invention, the training sample set composed of the first sample set and the second sample set is trained to obtain an error correction model, so that the error correction model can be constructed using massive sample set data, thereby improving the accuracy of the error correction model; in the embodiment of the present invention, the erroneous text in the second sample set is generated based on the standard text in the first sample set, so that the relationship between the erroneous text and its corresponding standard text can be established, further improving the accuracy of the error correction model; in the embodiment of the present invention, a replacement set for each word segment is constructed from multiple angles such as the same sound rule, the fuzzy sound rule and the similar character rule, so that the error correction model can be comprehensively constructed. Consider the replacement words of word segmentation in various situations; the error correction model in the embodiment of the present invention includes: a forward coding layer and a backward coding layer, so that the relationship between the current word and the previous word and the relationship between the current word and the following word can be considered; the error correction model in the embodiment of the present invention includes: an attention mechanism, so that when generating each output, it can make full use of the information carried by the input sequence, find the useful information in the input sequence that is significantly related to the output, improve the quality of the output, and thus improve the accuracy of the error correction model; in the embodiment of the present invention, the forward coding layer, the backward coding layer and the decoding layer can all include a long short-term memory network, so as to solve the problem of gradient disappearance during training and recognition, improve the accuracy of the error correction model, and improve the accuracy of the output results.
[0075] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for text error correction, characterized in that: include: According to the text correction requirements, obtain the text to be corrected; The text to be corrected is corrected according to the error correction model, and the standard text corresponding to the text to be corrected is output. The error correction model is a trained attention-based sequence-to-sequence model, including: an embedding layer, a forward coding layer, a backward coding layer, an attention mechanism, a decoding layer and a conversion layer. The word segmentation of the text to be corrected is converted into a word vector through the embedding layer, and the dimension of the word vector is determined by the number of all word segmentations in the training set of the error correction model; the word vector is encoded through the forward coding layer and the backward coding layer, the encoding results are merged into an intermediate vector, and the encoding results of the forward coding layer and the encoding results of the backward coding layer are processed through the attention mechanism to obtain useful information, and finally the intermediate vector and the useful information are used as inputs of the parsing layer to obtain an output vector, and the output vector is processed through the conversion layer to obtain a word with the highest probability; wherein, through the forward coding layer and the backward coding layer, both the relationship between the current word and the previous word and the relationship between the current word and the following word are considered.
2. The method according to claim 1, characterized in that Before correcting the text to be corrected according to the error correction model and outputting the standard text corresponding to the text to be corrected, the method further includes: Acquire a first sample set and a second sample set, wherein the first sample set includes at least one standard text, and the second sample set includes an error text corresponding to the standard text; constructing a training sample set using the first sample set and the second sample set; The training sample set is trained to obtain the error correction model, wherein the error correction model inputs the erroneous text of the training sample set and outputs the standard text of the training sample set.
3. The method according to claim 2, characterized in that Acquiring the first sample set and the second sample set includes: Obtaining a first sample set; Performing word segmentation processing on the standard text in the first sample set to obtain multiple word segments, and generating a replacement set corresponding to each word segment according to a preset rule; Selecting a preset number of replacement words from the replacement set corresponding to the segmented words; The standard text is randomly replaced according to the replacement word to generate an erroneous text, and then the erroneous text is used to form the second sample set.
4. The method according to claim 3, characterized in that The preset rules include at least one of the following: a same-sound rule, a fuzzy-sound rule, and a similar-sound word rule.
5. The method according to claim 1, characterized in that The forward encoding layer, the backward encoding layer and the decoding layer all include a long short-term memory network.
6. A text error correction device, characterized in that: include: An acquisition module is used to acquire the text to be corrected according to the text correction requirements; The error correction module is used to correct the text to be corrected according to the error correction model, and output the standard text corresponding to the text to be corrected. The error correction model is a trained attention-based sequence-to-sequence model, including: an embedding layer, a forward coding layer, a backward coding layer, an attention mechanism, a decoding layer and a conversion layer. The word segmentation of the text to be corrected is converted into a word vector through the embedding layer, and the dimension of the word vector is determined by the number of all word segmentations in the training set of the error correction model; the word vector is encoded through the forward coding layer and the backward coding layer, the encoding results are merged into an intermediate vector, and the encoding results of the forward coding layer and the encoding results of the backward coding layer are processed through the attention mechanism to obtain useful information, and finally the intermediate vector and the useful information are used as inputs of the parsing layer to obtain an output vector, and the output vector is processed through the conversion layer to obtain the word with the highest probability; wherein, through the forward coding layer and the backward coding layer, both the relationship between the current word and the previous word and the relationship between the current word and the following word are considered.
7. The device according to claim 6, characterized in that The acquisition module is also used for: Acquire a first sample set and a second sample set, wherein the first sample set includes at least one standard text, and the second sample set includes an error text corresponding to the standard text; constructing a training sample set using the first sample set and the second sample set; The training sample set is trained to obtain the error correction model, wherein the error correction model inputs the erroneous text of the training sample set and outputs the standard text of the training sample set.
8. The device according to claim 7, characterized in that The acquisition module is also used for: Obtaining a first sample set; Performing word segmentation processing on the standard text in the first sample set to obtain multiple word segments, and generating a replacement set corresponding to each word segment according to a preset rule; Selecting a preset number of replacement words from the replacement set corresponding to the segmented words; The standard text is randomly replaced according to the replacement word to generate an erroneous text, and then the erroneous text is used to form the second sample set.
9. The device according to claim 8, characterized in that The preset rules include at least one of the following: a same-sound rule, a fuzzy-sound rule, and a similar-sound word rule.
10. The device according to claim 6, characterized in that The forward encoding layer, the backward encoding layer and the decoding layer all include a long short-term memory network.
11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
