CN109408813A - Text correction method and device - Google Patents

Text correction method and device Download PDF

Info

Publication number
CN109408813A
CN109408813A CN201811158046.0A CN201811158046A CN109408813A CN 109408813 A CN109408813 A CN 109408813A CN 201811158046 A CN201811158046 A CN 201811158046A CN 109408813 A CN109408813 A CN 109408813A
Authority
CN
China
Prior art keywords
text
syndrome
weight
sub
semantic vector
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811158046.0A
Other languages
Chinese (zh)
Other versions
CN109408813B (en
Inventor
贾亚伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201811158046.0A priority Critical patent/CN109408813B/en
Publication of CN109408813A publication Critical patent/CN109408813A/en
Application granted granted Critical
Publication of CN109408813B publication Critical patent/CN109408813B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/232Orthographic correction, e.g. spell checking or vowelisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides a text correction method and device. The method comprises the following steps: acquiring an input current text to be corrected; inputting the current text into a neural network, determining a semantic vector and a weight of the current text by an encoding layer of the neural network according to a pre-trained first network parameter, and inputting the semantic vector and the weight into a decoding layer; wherein, the weight is used for representing the possibility of errors of each subfile in the current text; the decoding layer of the neural network determines a corrected text corresponding to the current text according to a pre-trained second network parameter, the semantic vector and the weight; and acquiring corrected text corresponding to the current text determined by the decoding layer. By applying the scheme provided by the embodiment of the application, the processing efficiency of text correction can be improved.

Description

A kind of text correction method and device
Technical field
This application involves text-processing technical fields, more particularly to a kind of text correction method and device.
Background technique
In order to promote convenience of the user using input method when, it is usually provided with to user in input method client The function that the text of input is corrected.Current text i.e. based on user's input, detects the mistake in current text, and export For the text after error correcting.
In the related technology, the technology for carrying out error correction for input text is mainly based upon preset rules.The preset rules can To be the collocation rule of Subject, Predicate and Object in sentence.For example, in English language part of speech mark can be done to the word in input text Note judges to input syntax error present in text, and then to input text according to the part of speech of preset rules and the word of mark Do grammatical corrections.
Above-mentioned text correcting method can be corrected for the type of part grammar mistake.But user inputs in practice When type of error it is very more, in addition to syntax error, there is also misspelling, tense mistakes etc..In such a case, it is possible to needle Corresponding preset rules are pre-established to every kind of type of error.In error correction, needs to input text and preset rule with every kind respectively It is then matched one by one, determines mistake present in input text.When there are many preset rules, the place of this text correcting method It is just very low to manage efficiency.
Summary of the invention
The embodiment of the present application has been designed to provide a kind of text correction method and device, to improve when text is corrected Treatment effeciency.Specific technical solution is as follows.
In a first aspect, the embodiment of the present application provides a kind of text correcting method, this method comprises:
Obtain the current text to be corrected of input;
The current text is inputted into neural network;Wherein the neural network includes coding layer and decoding layer;
The coding layer determines the semantic vector and power of the current text according to preparatory trained first network parameter Weight, and the semantic vector and weight are inputted into the decoding layer;Wherein, the weight is for indicating each in the current text There is a possibility that mistake in a sub- text;
The decoding layer determines institute according to preparatory trained second network parameter and the semantic vector and weight State text after the corresponding correction of current text;
Text after the corresponding correction of the current text that acquisition decoding layer determines.
Optionally, the semantic vector includes the sub- semantic vector of each Ziwen sheet of the current text, the weight The sub- weight of each Ziwen sheet including the current text;The basis trained second network parameter and described in advance Semantic vector and weight, the step of determining text after the corresponding correction of the current text, comprising:
In the following ways determine the corresponding correction of current text after text n-th syndrome text:
Obtain the N-1 syndrome text;Wherein, the N is positive integer, and when the N is greater than 1, the N-1 are entangled Positron text are as follows: according to N-1 sub- semantic vectors and N-1 sub- weights and the N-2 syndrome text of acquisition from It is determined in preset text object library;The text object library includes each text object;
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, from the text N-th syndrome text is determined in library of object.
Optionally, when the N is 1, the step of the N-1 syndrome text of the acquisition, comprising:
Using pre-set text as the N-1 syndrome text, or using the text selected from pre-set text library as N-1 syndrome text.
It is optionally, described according to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, The step of n-th syndrome text is determined from the text object library, comprising:
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, the text pair is determined As the scoring of text object each in library;
According to each scoring, n-th syndrome text is determined from each text object in the text object library.
Optionally, the neural network is obtained using following training method:
Obtain parallel corpora;Wherein, the parallel corpora includes text after sample text and corresponding standard correction;
The sample text is inputted to the coding layer of the neural network;
The coding layer determines the sample semantic vector and sample weights of sample text according to first network parameter, and will The sample semantic vector and sample weights input decoding layer;Wherein, the sample weights are for indicating in the sample text A possibility that this presence of each sample Ziwen is wrong;
The decoding layer determines sample text according to the second network parameter and the sample semantic vector and sample weights Text after this corresponding sample is corrected;
Compare the difference after the sample is corrected after text and the standard correction between text;
When the difference is greater than preset threshold, the first network parameter and second net are modified according to the difference Network parameter returns to the step of executing the coding layer that the sample text is inputted to the neural network;
When the difference is less than preset threshold, determine that the neural metwork training is completed.
Optionally, the coding layer uses the Recognition with Recurrent Neural Network of duplex pyramid form, and/or, the decoding layer is adopted With bidirectional circulating neural network.
Second aspect, the embodiment of the present application provide a kind of text correcting device, and described device includes:
First obtains module, for obtaining the current text to be corrected of input;
First input module, for the current text to be inputted neural network;Wherein the neural network includes coding Layer and decoding layer;The coding layer determines the semantic vector of the current text according to preparatory trained first network parameter And weight, and the semantic vector and weight are inputted into the decoding layer;Wherein, the weight is for indicating the current text In each this presence of Ziwen it is wrong a possibility that;The decoding layer, according to preparatory trained second network parameter and described Semantic vector and weight determine text after the corresponding correction of the current text;
Second obtains module, text after the corresponding correction of the current text for obtaining decoding layer determination.
Optionally, the semantic vector includes the sub- semantic vector of each Ziwen sheet of the current text, the weight The sub- weight of each Ziwen sheet including the current text;The decoding layer, according to preparatory trained second network parameter And the semantic vector and weight, when determining text after the corresponding correction of the current text, comprising:
The n-th syndrome text of text after the corresponding correction of the current text is determined in the following ways:
Obtain the N-1 syndrome text;Wherein, the N is positive integer, and when the N is greater than 1, the N-1 are entangled Positron text are as follows: according to N-1 sub- semantic vectors and N-1 sub- weights and the N-2 syndrome text of acquisition from It is determined in preset text object library;The text object library includes each text object;
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, from the text N-th syndrome text is determined in library of object.
Optionally, the decoding layer, when obtaining the N-1 syndrome text, comprising:
When the N is 1, using pre-set text as the N-1 syndrome text, or will be selected from pre-set text library Text as the N-1 syndrome text.
Optionally, the decoding layer, according to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 correction Ziwen sheet, when determining n-th syndrome text from the text object library, comprising:
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, the text pair is determined As the scoring of text object each in library;
According to each scoring, n-th syndrome text is determined from each text object in the text object library.
Optionally, described device further include: training module, for obtaining the neural network using following training operation:
Obtain parallel corpora;Wherein, the parallel corpora includes text after sample text and corresponding standard correction;
The sample text is inputted to the coding layer of the neural network;
The coding layer determines the sample semantic vector and sample weights of sample text according to first network parameter, and will The sample semantic vector and sample weights input decoding layer;Wherein, the sample weights are for indicating in the sample text A possibility that this presence of each sample Ziwen is wrong;
The decoding layer determines sample text according to the second network parameter and the sample semantic vector and sample weights Text after this corresponding sample is corrected;
Compare the difference after the sample is corrected after text and the standard correction between text;
When the difference is greater than preset threshold, the first network parameter and second net are modified according to the difference Network parameter returns to the step of executing the coding layer that the sample text is inputted to the neural network;
When the difference is less than preset threshold, determine that the neural metwork training is completed.
Optionally, the coding layer uses the Recognition with Recurrent Neural Network of duplex pyramid form, and/or, the decoding layer is adopted With bidirectional circulating neural network.
The third aspect, the embodiment of the present application provide a kind of electronic equipment, the electronic equipment include processor, communication connect Mouth, memory and communication bus, wherein processor, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes the text correcting method that first aspect provides.
Fourth aspect, the embodiment of the present application provide a kind of computer readable storage medium, the computer-readable storage medium It is stored with computer program in matter, the text correction side that first aspect provides is realized when the computer program is executed by processor Method.
Current text to be corrected can be inputted nerve net by text correction method and device provided by the embodiments of the present application Network is determined the semantic vector and weight of current text by coding layer, by decoding layer according to the second network according to first network parameter Parameter and semantic vector and weight determine text after the corresponding correction of current text.Due to first network parameter and the second net Network parameter can determine the corresponding correction of current text hereinafter to be trained in advance according to great amount of samples, using the neural network This, when great amount of samples includes the text of a variety of type of errors, the neural network can text to a variety of type of errors into Row is corrected, and without matching a variety of preset rules one by one, therefore can be improved treatment effeciency when text is corrected.Certainly, implement this Any product or method of application do not necessarily require achieving all the advantages described above at the same time.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below There is attached drawing needed in technical description to be briefly described.It should be evident that the accompanying drawings in the following description is only this Some embodiments of application for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is a kind of flow diagram of text correcting method provided by the embodiments of the present application;
Fig. 2A is a kind of schematic diagram when neural network provided by the embodiments of the present application corrects text;
Fig. 2 B is a kind of structural schematic diagram of neural network provided by the embodiments of the present application;
Fig. 3 is a kind of structural schematic diagram of text correcting device provided by the embodiments of the present application;
Fig. 4 is a kind of structural schematic diagram of electronic equipment provided by the embodiments of the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete Whole description.Obviously, described embodiment is only a part of the embodiment of the application, instead of all the embodiments.Base Embodiment in the application, those of ordinary skill in the art are obtained all without making creative work Other embodiments shall fall in the protection scope of this application.
In order to improve treatment effeciency when text is corrected, the embodiment of the present application provides a kind of text correcting method and dress It sets.Below by specific embodiment, the application is described in detail.
Fig. 1 is a kind of flow diagram of text correcting method provided by the embodiments of the present application.This method is applied to electronics Equipment.The electronic equipment can be common computer, server, tablet computer, smart phone etc..Specifically, this method can be with Applied to the client in electronic equipment.Client can be mounted in the input method application program in electronic equipment.This method Include the following steps:
Step S101: the current text to be corrected of input is obtained.
Wherein, above-mentioned current text can be the text of user's input.When client receive user input ought be above This when, can carry out error correcting to the current text that user inputs, that improves user uses body in order to facilitate the use of user It tests.
When obtaining current text, client can get current text when correction condition meets, i.e. triggering text It corrects.When correction condition may include: that the pause duration after detecting user's input current text is greater than preset duration threshold value; Alternatively, after user inputs current text, when correction button is triggered;Alternatively, when detecting default input content, such as Default input content can be space etc..
In different language form, current text may include different situations.For example, in English language, when Preceding text can be that a part of a word or a sentence perhaps sentence for example can be injury I hope That etc..In Chinese language, current text can be a word, or phrase or complete words.
Step S102: current text is inputted into neural network.
Wherein, neural network includes coding layer and decoding layer.Coding layer, it is true according to preparatory trained first network parameter Determine the semantic vector and weight of current text, and semantic vector and weight are inputted into decoding layer.Weight is for indicating current text In each this presence of Ziwen it is wrong a possibility that.Semantic vector and weight can be the amount indicated using matrix.
Decoding layer determines current text pair according to preparatory trained second network parameter and semantic vector and weight Text after the correction answered.
When current text is inputted neural network, directly by the coding layer of current text input neural network.Coding layer In the semantic vector and weight for determining current text, semantic vector and weight are inputted into decoding layer.Decoding layer receives coding layer The semantic vector and weight of input, and according to the second network parameter and semantic vector and weight, determine that current text is corresponding Text after correction.
First network parameter and the second network parameter are to instruct previously according to text after sample text and corresponding standard correction It gets.
Neural network can be located in electronic equipment, can also be located in the other equipment in addition to electronic equipment.
Step S103: text after the corresponding correction of current text that decoding layer determines is obtained.
The output result of decoding layer can be text after the corresponding correction of current text.The present embodiment can directly acquire solution The output result of code layer.
For example, current text can be with are as follows: i dont even know to say what;Text after corresponding correction are as follows: I don't even know what to say.Current text can be with are as follows: I hope that no people are injured, no building are destructed;Text after corresponding correction are as follows: I hope that no people are Injured, no buildings are destroyed.Current text are as follows: she are an goad girl;Corresponding correction Text afterwards are as follows: She is a good girl.
Various mistakes in sentence, including misspelling, syntax error, word can be corrected using the method for the present embodiment Mistake, Mistaken punctuations etc..
As shown in the above, current text to be corrected can be inputted neural network by the present embodiment, by coding layer root The semantic vector and weight that current text is determined according to first network parameter, from decoding layer according to the second network parameter and it is semantic to Amount and weight, determine text after the corresponding correction of current text.Since first network parameter and the second network parameter are according to big It is trained in advance to measure sample, text after the corresponding correction of current text can determine using the neural network, work as great amount of samples When text comprising a variety of type of errors, which can correct the text of a variety of type of errors, be not necessarily to one The one a variety of preset rules of matching, therefore can be improved treatment effeciency when text is corrected.
In another embodiment of the application, it is based on embodiment illustrated in fig. 1, semantic vector includes each height of current text The sub- semantic vector of text, weight include the sub- weight of each Ziwen sheet of current text.Semantic vector and weight can use Matrix indicates.Every a line in the matrix of semantic vector or each column indicate the son of each Ziwen sheet of current text it is semantic to Amount.Every a line or each column in the matrix of weight indicate the sub- weight of each Ziwen sheet of current text.
It, ought be above according to preparatory trained second network parameter and semantic vector and weight, determination in step S102 After this corresponding correction the step of text, comprising:
The n-th syndrome text of text after the corresponding correction of current text is determined using following steps 1a and step 2a:
Step 1a: the N-1 syndrome text is obtained.
Wherein, N is positive integer, can be the integers such as 1,2,3,4.When N is greater than 1, the N-1 syndrome text are as follows: root According to N-1 sub- semantic vectors and N-1 sub- weights and the N-2 syndrome text of acquisition from preset text object It is determined in library.
When N is 1, the N-1 syndrome text can be obtained in the following ways: using pre-set text as N-1 Syndrome text, or using the text selected from pre-set text library as the N-1 syndrome text.From pre-set text library When middle selection text, it can be randomly selected.
It include M sub- texts in current text, wherein M is the positive integer more than or equal to N.N-th Ziwen this correspondence n-th Syndrome text.In current text the sequence of each Ziwen sheet respectively with the sequence of each sub- semantic vector in semantic vector, power The sequence of each sub- weight is corresponding in weight.
It include each text object in preset text object library, text object may include vocabulary, punctuation mark etc..? One word is there are in the language form of different versions, such as in English language type, vocabulary may include each vocabulary Various difference versions.For example, tall, taller, drink, drank, drunk, apple, apples etc.;Punctuation mark packet Include comma, fullstop, colon, dash etc..
Step 2a: according to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, from text pair As determining n-th syndrome text in library.
Wherein, n-th syndrome text can be vocabulary, or punctuation mark etc..It include mark in text object library Point symbol can be realized the correction to punctuation mark in current text.
To sum up, the present embodiment can according to previous syndrome text and the corresponding sub- semantic vector of current Ziwen sheet and Weight, the text after determining the corresponding correction of current Ziwen sheet in text object library, can be improved determining syndrome text Accuracy.
In another embodiment of the application, it is based on embodiment illustrated in fig. 1, step 2a, i.e., according to the sub- semantic vector of n-th With the sub- weight of n-th and the N-1 syndrome text, from text object library the step of determining n-th syndrome text, packet Include step 2a-1 and step 2a-2.
Step 2a-1: according to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, text is determined The scoring of each text object in this library of object.
Step 2a-2: according to each scoring, determine that n-th corrects Ziwen from each text object in text object library This.
In this step, the highest text object that can will specifically score in text object library is determined as n-th correction Ziwen sheet.The syndrome text of each Ziwen sheet of the current text obtained in this way is the highest text object of scoring.It can also To be, the highest k text object that will score in text object library is determined as n-th syndrome text.In this way, determining N+ When 1 syndrome text, according to i-th (i is the positive integer less than or equal to k) in k text object of n-th syndrome text A syndrome text and N+1 sub- semantic vectors and N+1 sub- weights determine the N+1 syndrome text.
In the present embodiment, decoding layer can use Recognition with Recurrent Neural Network (Recurrent Neural Network, RNN). The present embodiment when determining syndrome text according to the scoring of text object each in text object library, in this way can be more acurrate Ground determines syndrome text from the numerous text object in text object library.
In another embodiment of the application, it is based on embodiment illustrated in fig. 1, using training shown in following steps 1b-5b Mode obtains above-mentioned neural network:
Step 1b: parallel corpora is obtained.Wherein, parallel corpora includes text after sample text and corresponding standard correction. For example, a sample text is she are an goad girl, text after corresponding standard correction are as follows: She is a good girl。
Step 2b: by the coding layer of sample text input neural network.
Coding layer, determines the sample semantic vector and sample weights of sample text according to first network parameter, and by sample Semantic vector and sample weights input decoding layer.Wherein, sample weights are for indicating that each sample Ziwen is originally deposited in sample text The mistake a possibility that.
The decoding layer of above-mentioned neural network is determined according to the second network parameter and sample semantic vector and sample weights Text after the corresponding sample of sample text is corrected.
Wherein, the initial value of above-mentioned first network parameter and the second network parameter can be preset value.
Step 3b: the difference after comparative sample is corrected after text and standard correction between text.
Above-mentioned difference may include uncorrected error text and the Error Text that is corrected to correct text.The difference It is different to be indicated using the data of parametrization.
Step 4b: when above-mentioned difference is greater than preset threshold, first network parameter and the second network are modified according to the difference Parameter returns and executes the step of sample text is inputted the coding layer of the neural network, i.e. execution step 2b.
Preset threshold can according to the pre-set parameter value of experience.When difference is greater than preset threshold, it is believed that from solution Gap is larger between text after text and standard correction after sample that code layer obtains is corrected, and is unable to reach the required precision of correction, It needs to continue to adjust network parameter.
Modifying first network parameter and when the second network parameter, it can be according to the difference, by first network parameter and the Two network parameters are modified to the direction for reducing the difference.
It may include text after great amount of samples text and corresponding standard correction in above-mentioned parallel corpora.In parallel corpora It may include various mistakes, such as misspelling, malaprop, tense mistake etc. in sample text.
After modification first network parameter and the second network parameter, it can choose and next sample text is inputted into nerve Network.
Step 5b: when above-mentioned difference is less than preset threshold, determine that neural metwork training is completed.
When above-mentioned difference is less than preset threshold, it is believed that after the sample that obtains from decoding layer is corrected after text and standard correction Gap is smaller between text, can reach the required precision of correction, and network parameter has trained.
When above-mentioned difference is equal to preset threshold, first network parameter can be modified according to the difference and the second network is joined Number, returns to step 2b, can also determine that neural metwork training is completed.
It in the present embodiment, is trained using decoding layer and coding layer of the parallel corpora to neural network, constantly adjustment net Network parameter determines that neural metwork training is completed until the network parameter of neural network is adjusted so as to reach correction required precision.
In another embodiment of the application, it is based on embodiment illustrated in fig. 1, above-mentioned coding layer uses duplex pyramid form Recognition with Recurrent Neural Network, and/or, decoding layer use bidirectional circulating neural network.
In the present embodiment, coding layer is designed using the network structure of duplex pyramid form, can greatly reduce model Parameter reduces the inference time of neural network.Decoding layer uses Recognition with Recurrent Neural Network, can be improved accuracy when correction, into And improve the accuracy of neural network.
It elaborates again below with reference to specific example to the application.
Fig. 2A is a kind of schematic diagram when neural network provided by the embodiments of the present application corrects text.Wherein, left side box For coding layer (encoder), right side is decoding layer (decoder).When the current text of input coding layer is she are an When goad girl, the semantic vector and weight (attention) of the current text can be determined in coding layer, and will be semantic Vector sum weight inputs decoding layer (indicating using two dotted arrows).Decoding layer according to the semantic vector and weight of input, for Each Ziwen is originally predicted, determines text after the correction of each Ziwen sheet.Decoding layer, based on text after previous correction, and Current sub- weight in sub- semantic vector, weight in semantic vector currently, determines text after current correct.It can determine in this way Text after each correction, and final output is combined into as a result, i.e. She is a good girl.<S>is beginning of the sentence mark Symbol, positioned at the beginning of the sentence of current text.When decoding layer detects beginning of the sentence identifier, can using pre-set text as previous correction after Text.When current text neutron text exist mistake a possibility that it is larger when, correspondence the Ziwen is originally entangled in decoding layer A possibility that positive, is also bigger.
Fig. 2 B is a kind of structural schematic diagram of neural network provided by the embodiments of the present application.The neural network is based on coding The sequence with attention mechanism of layer-decoding layer architecture is to sequence (seq2seq) model.Wherein, coding layer uses two-way gold The Recognition with Recurrent Neural Network decoding layer of the tower-shaped formula of word uses bidirectional circulating neural network.Coding layer may include multiple sublayers, for example, J=0 sublayer and j=1 sublayer etc..Coding layer be directed toward the two dotted arrow presentation code layers input decoding layer of decoding layer it is semantic to Amount and weight.
In coding layer, each box represents a network unit (Gated Recurrent Unit, GRU).GRU is also referred to as For door.It is in a sublayer of each GRU composition coding layer in a row.Between each GRU, exists and exported with ventrocephalad It is exported with backward:
Forward direction:
It is backward:
The activation primitive of hidden layer are as follows:
Wherein,
For parameter preset matrix.xtFor the current text of the input coding layer of t moment, j is the sublayer in coding layer Number, j=0,1,2,3 ....It is exported for the forward direction of t-th of GRU network unit in jth sublayer,For in jth sublayer The backward output of t-th of GRU network unit.T is the transposition symbol of vector.
In the attention mechanism of coding layer, weight atFor at=∑jαtjcj, wherein
Wherein, k is the value in j.Φ (X) is the function that linear transformation is carried out to X, such as Φ (X)=wX+z.W and z are Parameter preset.
The output of the jth sublayer of coding layer isCoding layer is by last sublayer OutputAs semantic vector, decoding layer is inputted.
Decoding layer is in the semantic vector for receiving coding layer inputWith weight atWhen, it can be by semantic vectorAnd power Weight atIt is converted by line rectification function (Rectified Linear Unit, ReLU), obtains each text in text object library The scoring vector of object, by the scoring vector input decoding layer in softmax, softmax to scoring vector in scoring into Row normalization, obtains the scoring of each text object.Decoding layer is according to the highest text that will score from text object library that scores Object is determined as text after correcting.
Fig. 3 is a kind of structural schematic diagram of text correcting device provided by the embodiments of the present application.The device and side shown in Fig. 1 Method embodiment is corresponding, which is applied to electronic equipment.The electronic equipment can be common computer, server, plate electricity Brain, smart phone etc..Specifically, the device can be applied to the client in electronic equipment.The device includes:
First obtains module 301, for obtaining the current text to be corrected of input;
First input module 302, for the current text to be inputted neural network;Wherein the neural network includes compiling Code layer and decoding layer;The coding layer, according to preparatory trained first network parameter determine the current text it is semantic to Amount and weight, and the semantic vector and weight are inputted into the decoding layer;Wherein, the weight for indicate it is described ought be above A possibility that each this presence of Ziwen is wrong in this;The decoding layer, according to preparatory trained second network parameter and institute Predicate justice vector sum weight, determines text after the corresponding correction of the current text;
Second obtains module 303, text after the corresponding correction of the current text for obtaining decoding layer determination.
In another embodiment of the application, it is based on embodiment illustrated in fig. 3, above-mentioned semantic vector includes each of current text The sub- semantic vector of a sub- text, above-mentioned weight include the sub- weight of each Ziwen sheet of current text;Decoding layer, according to preparatory Trained second network parameter and the semantic vector and weight determine text after the corresponding correction of the current text When, comprising:
The n-th syndrome text of text after the corresponding correction of the current text is determined in the following ways:
Obtain the N-1 syndrome text;Wherein, the N is positive integer, and when the N is greater than 1, the N-1 are entangled Positron text are as follows: according to N-1 sub- semantic vectors and N-1 sub- weights and the N-2 syndrome text of acquisition from It is determined in preset text object library;The text object library includes each text object;
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, from the text N-th syndrome text is determined in library of object.
In another embodiment of the application, it is based on embodiment illustrated in fig. 3, decoding layer obtains the N-1 syndrome text When, comprising:
When the N is 1, using pre-set text as the N-1 syndrome text, or will be selected from pre-set text library Text as the N-1 syndrome text.
In another embodiment of the application, be based on embodiment illustrated in fig. 3, decoding layer according to the sub- semantic vector of n-th and The sub- weight of n-th and the N-1 syndrome text, when determining n-th syndrome text from text object library, comprising:
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, the text pair is determined As the scoring of text object each in library;
According to each scoring, n-th syndrome text is determined from each text object in the text object library.
In another embodiment of the application, it is based on embodiment illustrated in fig. 3, the device further include: training module is (in figure not Show), for obtaining above-mentioned neural network using following training operation:
Obtain parallel corpora;Wherein, the parallel corpora includes text after sample text and corresponding standard correction;
The sample text is inputted to the coding layer of the neural network;
The coding layer determines the sample semantic vector and sample weights of sample text according to first network parameter, and will The sample semantic vector and sample weights input decoding layer;Wherein, the sample weights are for indicating in the sample text A possibility that this presence of each sample Ziwen is wrong;
The decoding layer determines sample text according to the second network parameter and the sample semantic vector and sample weights Text after this corresponding sample is corrected;
Compare the difference after the sample is corrected after text and the standard correction between text;
When the difference is greater than preset threshold, the first network parameter and second net are modified according to the difference Network parameter returns to the step of executing the coding layer that the sample text is inputted to the neural network;
When the difference is less than preset threshold, determine that the neural metwork training is completed.
In another embodiment of the application, it is based on embodiment illustrated in fig. 3, coding layer can use duplex pyramid form Recognition with Recurrent Neural Network, and/or, decoding layer can use bidirectional circulating neural network.
Since above-mentioned apparatus embodiment is obtained based on embodiment of the method, and this method technical effect having the same, Therefore details are not described herein for the technical effect of Installation practice.For device embodiment, since it is substantially similar to method Embodiment, so describing fairly simple, the relevent part can refer to the partial explaination of embodiments of method.
Fig. 4 is a kind of structural schematic diagram of electronic equipment provided by the embodiments of the present application.The electronic equipment includes processor 401, communication interface 402, memory 403 and communication bus 404, wherein processor 401, communication interface 402, memory 403 are logical It crosses communication bus 404 and completes mutual communication;
Memory 403, for storing computer program;
Processor 401 when for executing the program stored on memory 403, realizes text provided by the embodiments of the present application This correcting method.This method comprises:
Obtain the current text to be corrected of input;
Current text is inputted into neural network;Wherein neural network includes coding layer and decoding layer;
Coding layer determines the semantic vector and weight of the current text according to preparatory trained first network parameter, And the semantic vector and weight are inputted into the decoding layer;Wherein, the weight is for indicating each in the current text A possibility that this presence of Ziwen is wrong;
Decoding layer is worked as described in determination according to preparatory trained second network parameter and the semantic vector and weight Text after the corresponding correction of preceding text;
Text after the corresponding correction of current text that acquisition decoding layer determines.
The communication bus 404 that above-mentioned electronic equipment is mentioned can be Peripheral Component Interconnect standard (Peripheral Component Interconnect, PCI) bus or expanding the industrial standard structure (Extended Industry Standard Architecture, EISA) bus etc..The communication bus 404 can be divided into address bus, data/address bus, control bus etc..For Convenient for indicating, only indicated with a thick line in figure, it is not intended that an only bus or a type of bus.
Communication interface 402 is for the communication between above-mentioned electronic equipment and other equipment.
Memory 403 may include random access memory (Random Access Memory, RAM), also may include Nonvolatile memory (Non-Volatile Memory, NVM), for example, at least a magnetic disk storage.Optionally, memory 403 can also be that at least one is located remotely from the storage device of aforementioned processor.
Above-mentioned processor 401 can be general processor, including central processing unit (Central Processing Unit, CPU), network processing unit (Network Processor, NP) etc.;It can also be digital signal processor (Digital Signal Processing, DSP), it is specific integrated circuit (Application Specific Integrated Circuit, ASIC), existing It is field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete Door or transistor logic, discrete hardware components.
To sum up, current text to be corrected can be inputted neural network by the present embodiment, by coding layer according to first network Parameter determines the semantic vector and weight of current text, by decoding layer according to the second network parameter and semantic vector and weight, Determine text after the corresponding correction of current text.Since first network parameter and the second network parameter are preparatory according to great amount of samples It is trained, text after the corresponding correction of current text can determine using the neural network, when great amount of samples includes a variety of mistakes Accidentally when the text of type, which can correct the text of a variety of type of errors, a variety of without matching one by one Preset rules, therefore can be improved treatment effeciency when text is corrected.
The embodiment of the present application also provides a kind of computer readable storage medium, stored in the computer readable storage medium There is computer program, text correcting method provided by the embodiments of the present application is realized when computer program is executed by processor.The party Method includes:
Obtain the current text to be corrected of input;
Current text is inputted into neural network;Wherein neural network includes coding layer and decoding layer;
Coding layer determines the semantic vector and weight of the current text according to preparatory trained first network parameter, And the semantic vector and weight are inputted into the decoding layer;Wherein, the weight is for indicating each in the current text A possibility that this presence of Ziwen is wrong;
Decoding layer is worked as described in determination according to preparatory trained second network parameter and the semantic vector and weight Text after the corresponding correction of preceding text;
Text after the corresponding correction of current text that acquisition decoding layer determines.
To sum up, current text to be corrected can be inputted neural network by the present embodiment, by coding layer according to first network Parameter determines the semantic vector and weight of current text, by decoding layer according to the second network parameter and semantic vector and weight, Determine text after the corresponding correction of current text.Since first network parameter and the second network parameter are preparatory according to great amount of samples It is trained, text after the corresponding correction of current text can determine using the neural network, when great amount of samples includes a variety of mistakes Accidentally when the text of type, which can correct the text of a variety of type of errors, a variety of without matching one by one Preset rules, therefore can be improved treatment effeciency when text is corrected.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or any other variant be intended to it is non- It is exclusive to include, so that the process, method, article or equipment for including a series of elements not only includes those elements, It but also including other elements that are not explicitly listed, or further include solid by this process, method, article or equipment Some elements.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including There is also other identical elements in the process, method, article or equipment of the element.
Each embodiment in this specification is all made of relevant mode and describes, same and similar portion between each embodiment Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.
The foregoing is merely the preferred embodiments of the application, are not intended to limit the protection scope of the application.It is all Any modification, equivalent substitution, improvement and etc. done within spirit herein and principle are all contained in the protection scope of the application It is interior.

Claims (10)

1. a kind of text correcting method, which is characterized in that the described method includes:
Obtain the current text to be corrected of input;
The current text is inputted into neural network;Wherein the neural network includes coding layer and decoding layer;
The coding layer determines the semantic vector and weight of the current text according to preparatory trained first network parameter, And the semantic vector and weight are inputted into the decoding layer;Wherein, the weight is for indicating each in the current text A possibility that this presence of Ziwen is wrong;
The decoding layer is worked as described in determination according to preparatory trained second network parameter and the semantic vector and weight Text after the corresponding correction of preceding text;
Text after the corresponding correction of the current text that acquisition decoding layer determines.
2. the method according to claim 1, wherein the semantic vector includes each height of the current text The sub- semantic vector of text, the weight include the sub- weight of each Ziwen sheet of the current text;The basis is instructed in advance The second network parameter and the semantic vector and weight perfected, determine the step of text after the corresponding correction of the current text Suddenly, comprising:
In the following ways determine the corresponding correction of current text after text n-th syndrome text:
Obtain the N-1 syndrome text;Wherein, the N is positive integer, when the N is greater than 1, the N-1 syndrome Text are as follows: according to N-1 sub- semantic vectors and N-1 sub- weights and the N-2 syndrome text of acquisition from presetting Text object library in determine;The text object library includes each text object;
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, from the text object N-th syndrome text is determined in library.
3. according to the method described in claim 2, it is characterized in that, when the N be 1 when, the N-1 correction Ziwen of the acquisition This step of, comprising:
Using pre-set text as the N-1 syndrome text, or using the text selected from pre-set text library as N-1 Syndrome text.
4. according to the method described in claim 2, it is characterized in that, described according to the sub- semantic vector of n-th and the sub- weight of n-th And the N-1 syndrome text, from the text object library the step of determining n-th syndrome text, comprising:
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, the text object library is determined In each text object scoring;
According to each scoring, n-th syndrome text is determined from each text object in the text object library.
5. the method according to claim 1, wherein obtaining the neural network using following training method:
Obtain parallel corpora;Wherein, the parallel corpora includes text after sample text and corresponding standard correction;
The sample text is inputted to the coding layer of the neural network;
The coding layer determines the sample semantic vector and sample weights of sample text according to first network parameter, and will be described Sample semantic vector and sample weights input decoding layer;Wherein, the sample weights are for indicating each in the sample text A possibility that this presence of sample Ziwen is wrong;
The decoding layer determines sample text pair according to the second network parameter and the sample semantic vector and sample weights Text after the sample answered is corrected;
Compare the difference after the sample is corrected after text and the standard correction between text;
When the difference is greater than preset threshold, the first network parameter is modified according to the difference and second network is joined Number returns to the step of executing the coding layer that the sample text is inputted to the neural network;
When the difference is less than preset threshold, determine that the neural metwork training is completed.
6. the method according to claim 1, wherein circulation mind of the coding layer using duplex pyramid form Through network, and/or, the decoding layer uses bidirectional circulating neural network.
7. a kind of text correcting device, which is characterized in that described device includes:
First obtains module, for obtaining the current text to be corrected of input;
First input module, for the current text to be inputted neural network;Wherein the neural network include coding layer and Decoding layer;The coding layer determines the semantic vector and power of the current text according to preparatory trained first network parameter Weight, and the semantic vector and weight are inputted into the decoding layer;Wherein, the weight is for indicating each in the current text There is a possibility that mistake in a sub- text;The decoding layer, according to preparatory trained second network parameter and the semanteme Vector sum weight determines text after the corresponding correction of the current text;
Second obtains module, text after the corresponding correction of the current text for obtaining decoding layer determination.
8. device according to claim 7, which is characterized in that the semantic vector includes each height of the current text The sub- semantic vector of text, the weight include the sub- weight of each Ziwen sheet of the current text;The decoding layer, according to Preparatory trained second network parameter and the semantic vector and weight determine the corresponding correction of the current text hereinafter This when, comprising:
The n-th syndrome text of text after the corresponding correction of the current text is determined in the following ways:
Obtain the N-1 syndrome text;Wherein, the N is positive integer, when the N is greater than 1, the N-1 syndrome Text are as follows: according to N-1 sub- semantic vectors and N-1 sub- weights and the N-2 syndrome text of acquisition from presetting Text object library in determine;The text object library includes each text object;
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, from the text object N-th syndrome text is determined in library.
9. device according to claim 8, which is characterized in that the decoding layer, when obtaining the N-1 syndrome text, Include:
When the N is 1, using pre-set text as the N-1 syndrome text, or the text that will be selected from pre-set text library This is as the N-1 syndrome text.
10. device according to claim 8, which is characterized in that the decoding layer, according to the sub- semantic vector of n-th and N A sub- weight and the N-1 syndrome text, when determining n-th syndrome text from the text object library, packet It includes:
According to the sub- semantic vector of n-th and the sub- weight of n-th and the N-1 syndrome text, the text object library is determined In each text object scoring;
According to each scoring, n-th syndrome text is determined from each text object in the text object library.
CN201811158046.0A 2018-09-30 2018-09-30 Text correction method and device Active CN109408813B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811158046.0A CN109408813B (en) 2018-09-30 2018-09-30 Text correction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811158046.0A CN109408813B (en) 2018-09-30 2018-09-30 Text correction method and device

Publications (2)

Publication Number Publication Date
CN109408813A true CN109408813A (en) 2019-03-01
CN109408813B CN109408813B (en) 2023-07-21

Family

ID=65466681

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811158046.0A Active CN109408813B (en) 2018-09-30 2018-09-30 Text correction method and device

Country Status (1)

Country Link
CN (1) CN109408813B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109922371A (en) * 2019-03-11 2019-06-21 青岛海信电器股份有限公司 Natural language processing method, equipment and storage medium
CN110232191A (en) * 2019-06-17 2019-09-13 无码科技(杭州)有限公司 Autotext error-checking method
CN110232129A (en) * 2019-06-11 2019-09-13 北京百度网讯科技有限公司 Scene error correction method, device, equipment and storage medium
CN110276069A (en) * 2019-05-17 2019-09-24 中国科学院计算技术研究所 A kind of Chinese braille mistake automatic testing method, system and storage medium
CN111274785A (en) * 2020-01-21 2020-06-12 北京字节跳动网络技术有限公司 Text error correction method, device, equipment and medium
CN111310447A (en) * 2020-03-18 2020-06-19 科大讯飞股份有限公司 Grammar error correction method, grammar error correction device, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488488A (en) * 2013-09-26 2014-01-01 贝壳网际(北京)安全技术有限公司 Text input check method, device ad mobile terminal
US20150261743A1 (en) * 2014-03-17 2015-09-17 Accenture Global Services Limited Generating a semantic network based on semantic connections between subject-verb-object units
US20170235721A1 (en) * 2016-02-17 2017-08-17 The King Abdulaziz City For Science And Technology Method and system for detecting semantic errors in a text using artificial neural networks
CN107085471A (en) * 2017-04-25 2017-08-22 北京百度网讯科技有限公司 A kind of input method error correction method and device based on user's input speed
CN107357775A (en) * 2017-06-05 2017-11-17 百度在线网络技术(北京)有限公司 The text error correction method and device of Recognition with Recurrent Neural Network based on artificial intelligence
CN107451106A (en) * 2017-07-26 2017-12-08 阿里巴巴集团控股有限公司 Text method and device for correcting, electronic equipment
CN108563634A (en) * 2018-03-29 2018-09-21 广州视源电子科技股份有限公司 Recognition methods, system, computer equipment and the storage medium of word misspelling

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488488A (en) * 2013-09-26 2014-01-01 贝壳网际(北京)安全技术有限公司 Text input check method, device ad mobile terminal
US20150261743A1 (en) * 2014-03-17 2015-09-17 Accenture Global Services Limited Generating a semantic network based on semantic connections between subject-verb-object units
US20170235721A1 (en) * 2016-02-17 2017-08-17 The King Abdulaziz City For Science And Technology Method and system for detecting semantic errors in a text using artificial neural networks
CN107085471A (en) * 2017-04-25 2017-08-22 北京百度网讯科技有限公司 A kind of input method error correction method and device based on user's input speed
CN107357775A (en) * 2017-06-05 2017-11-17 百度在线网络技术(北京)有限公司 The text error correction method and device of Recognition with Recurrent Neural Network based on artificial intelligence
CN107451106A (en) * 2017-07-26 2017-12-08 阿里巴巴集团控股有限公司 Text method and device for correcting, electronic equipment
CN108563634A (en) * 2018-03-29 2018-09-21 广州视源电子科技股份有限公司 Recognition methods, system, computer equipment and the storage medium of word misspelling

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
黄浩等: "汉语语音识别声调模型集成中基于决策树的上下文相关权重参数聚类方法", 《新疆大学学报(自然科学版)》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109922371A (en) * 2019-03-11 2019-06-21 青岛海信电器股份有限公司 Natural language processing method, equipment and storage medium
CN109922371B (en) * 2019-03-11 2021-07-09 海信视像科技股份有限公司 Natural language processing method, apparatus and storage medium
CN110276069A (en) * 2019-05-17 2019-09-24 中国科学院计算技术研究所 A kind of Chinese braille mistake automatic testing method, system and storage medium
CN110276069B (en) * 2019-05-17 2021-04-02 中国科学院计算技术研究所 Method, system and storage medium for automatically detecting Chinese braille error
CN110232129A (en) * 2019-06-11 2019-09-13 北京百度网讯科技有限公司 Scene error correction method, device, equipment and storage medium
CN110232129B (en) * 2019-06-11 2020-09-29 北京百度网讯科技有限公司 Scene error correction method, device, equipment and storage medium
CN110232191A (en) * 2019-06-17 2019-09-13 无码科技(杭州)有限公司 Autotext error-checking method
CN111274785A (en) * 2020-01-21 2020-06-12 北京字节跳动网络技术有限公司 Text error correction method, device, equipment and medium
CN111274785B (en) * 2020-01-21 2023-06-20 北京字节跳动网络技术有限公司 Text error correction method, device, equipment and medium
CN111310447A (en) * 2020-03-18 2020-06-19 科大讯飞股份有限公司 Grammar error correction method, grammar error correction device, electronic equipment and storage medium
CN111310447B (en) * 2020-03-18 2024-02-02 河北省讯飞人工智能研究院 Grammar error correction method, grammar error correction device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN109408813B (en) 2023-07-21

Similar Documents

Publication Publication Date Title
CN109408813A (en) Text correction method and device
US11373090B2 (en) Techniques for correcting linguistic training bias in training data
US11366970B2 (en) Semantic analysis method and apparatus, and storage medium
US11640515B2 (en) Method and neural network system for human-computer interaction, and user equipment
CN109033068B (en) Method and device for reading and understanding based on attention mechanism and electronic equipment
CN108959246B (en) Answer selection method and device based on improved attention mechanism and electronic equipment
US20180329897A1 (en) Processing text sequences using neural networks
CN110347799B (en) Language model training method and device and computer equipment
CN112417102B (en) Voice query method, device, server and readable storage medium
US11681872B2 (en) Language sequence labeling method and apparatus, storage medium, and computing device
CN111310440B (en) Text error correction method, device and system
WO2018060450A1 (en) Question generation
CN110232923B (en) Voice control instruction generation method and device and electronic equipment
CN111931517A (en) Text translation method and device, electronic equipment and storage medium
CN109002186A (en) Input prediction method and device
CN110909144A (en) Question-answer dialogue method and device, electronic equipment and computer readable storage medium
CN112528637A (en) Text processing model training method and device, computer equipment and storage medium
CN111339775A (en) Named entity identification method, device, terminal equipment and storage medium
CN114818729A (en) Method, device and medium for training semantic recognition model and searching sentence
CN114490953B (en) Method for training event extraction model, method, device and medium for extracting event
US20230205994A1 (en) Performing machine learning tasks using instruction-tuned neural networks
CN112183513B (en) Method and device for recognizing characters in image, electronic equipment and storage medium
CN113806645A (en) Label classification system and training system of label classification model
WO2021082570A1 (en) Artificial intelligence-based semantic identification method, device, and semantic identification apparatus
CN112016281B (en) Method and device for generating wrong medical text and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant