Grammatical error identification method and device
By generating statement feature vectors and predicting transformation category labels, the problem of low syntax error recognition accuracy in the prior art is solved, and a higher syntax error recognition accuracy is achieved.
Patent Information
- Application Number
- CN202110282569.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-16
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-03-16
AI Technical Summary
In the prior art, grammatical error recognition methods rely on manual extraction of features and expert experience, resulting in no universal unified model, and the characteristics of machine learning models are shallow and have lower accuracy.
By obtaining the statement to be identified, the statement feature vector is generated, including the word vector and position feature vector of the vocabulary, predict the target transformation category label, and determine the grammar error type.
The accuracy of syntax error recognition is improved, and the syntax error is more significantly reflected by transforming the category label, which enhances the accurate recognition of syntax error types for the recognition statement.
Smart Images

Figure CN113705207B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for identifying grammatical errors. Background Art
[0002] With the development of Internet technology, grammatical error recognition is an important branch of natural language processing. Its main task is to detect whether there are grammatical errors in a text and automatically correct the detected grammatical errors.
[0003] The grammatical error recognition method proposed in the related art mainly extracts features manually and trains the machine learning model based on expert experience. The trained machine learning model can be used for grammatical error recognition. In the grammatical error recognition method in the related art, different machine learning models need to be trained for different error types to perform grammatical error recognition, and there is no universal unified model; in addition, the features extracted by the above machine learning models are all shallow features, which makes the accuracy of grammatical error recognition by the machine learning model low. Summary of the invention
[0004] The embodiments of the present application provide a grammatical error recognition method and device, which can improve the accuracy of grammatical error recognition.
[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0006] According to one aspect of an embodiment of the present application, a method for identifying grammatical errors is provided, comprising: obtaining a sentence to be identified; based on the sentence to be identified, generating a sentence feature vector corresponding to the sentence to be identified, the sentence feature vector comprising word vectors corresponding to each word contained in the sentence to be identified and a position feature vector of each word contained in the sentence to be identified at the position of the sentence to be identified; based on the sentence feature vector corresponding to the sentence to be identified, predicting a target transformation category label, the target transformation category label refers to a transformation category label of each word contained in the sentence to be identified when being transformed into a grammatically correct sentence corresponding to the sentence to be identified; based on the sentence to be identified and the target transformation category label, determining the grammatical error type of the sentence to be identified.
[0007] According to one aspect of an embodiment of the present application, a grammatical error identification device is provided, comprising: a first acquisition unit, configured to acquire a sentence to be identified; a first generation unit, configured to generate, based on the sentence to be identified, a sentence feature vector corresponding to the sentence to be identified, wherein the sentence feature vector comprises a word vector corresponding to each word contained in the sentence to be identified and a position feature vector of each word contained in the sentence to be identified at the position of the sentence to be identified; a prediction unit, configured to predict a target transformation category label based on the sentence feature vector corresponding to the sentence to be identified, wherein the target transformation category label refers to a transformation category label of each word contained in the sentence to be identified when the words are transformed into a grammatically correct sentence corresponding to the sentence to be identified; and a grammatical error determination unit, configured to determine the grammatical error type of the sentence to be identified based on the sentence to be identified and the target transformation category label.
[0008] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error determination unit includes: a grammatically correct sentence determination subunit, used to determine a grammatically correct sentence corresponding to the sentence to be recognized based on the target transformation category label and the sentence to be recognized; a grammatical error recognition subunit, used to classify and identify grammatical errors on the sentence to be recognized based on the grammatically correct sentence and preset grammatical error classification rules, and determine the grammatical error type of the sentence to be recognized.
[0009] In some embodiments of the present application, based on the aforementioned scheme, the prediction unit includes: a fusion subunit, used to perform fusion processing on the sentence feature vector corresponding to the sentence to be recognized, and generate a semantic feature vector containing contextual semantic information; a fully connected subunit, used to perform full connection processing on the semantic feature vector to obtain a processed semantic feature vector; a prediction subunit, used to predict the target transformation category label based on the processed semantic feature vector.
[0010] In some embodiments of the present application, based on the aforementioned scheme, the prediction subunit includes: a generation module, used to normalize the processed semantic feature vector, and generate the probability corresponding to the candidate transformation category label when each word contained in the sentence to be recognized is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; a selection module, used to select the candidate transformation category label with the highest probability as the target transformation category label.
[0011] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error recognition subunit is specifically used to perform grammatical error classification and identification on the sentence to be recognized based on the grammatically correct sentence and preset grammatical error classification rules if the probability corresponding to the target transformation category label is higher than a predetermined probability threshold, and determine the grammatical error type of the sentence to be recognized.
[0012] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error identification device further includes: an error correction suggestion generation unit, which is used to generate error correction suggestion information corresponding to the sentence to be identified based on the grammatical error type of the sentence to be identified and the sentence to be identified.
[0013] In some embodiments of the present application, based on the aforementioned scheme, the target transformation category label and the sentence feature vector corresponding to the sentence to be recognized are generated by a pre-trained machine learning model.
[0014] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error identification device further includes: a second acquisition unit, used to acquire training set sample data for training the machine learning model to be trained, each sample data in the training set sample data includes a sample sentence pair, and the sample sentence pair includes a grammatically incorrect sample sentence and a grammatically correct sample sentence; a word segmentation unit, used to perform word segmentation processing on the grammatically incorrect sample sentence and the grammatically correct sample sentence respectively, to obtain a first word segmentation result corresponding to the grammatically incorrect sample sentence and a second word segmentation result corresponding to the grammatically correct sample sentence; a second generation unit, used to generate a sentence feature vector corresponding to the grammatically incorrect sample sentence based on the first word segmentation result; a third generation unit, used to generate a sample transformation category label based on the first word segmentation result and the second word segmentation result, the sample transformation category label refers to the transformation category label of each vocabulary contained in the grammatically incorrect sample sentence when it is transformed into the grammatically correct sentence sample; a training unit, used to train the machine learning model to be trained by using the sample transformation category label and the sentence feature vector corresponding to the grammatically incorrect sample sentence to obtain a pre-trained machine learning model.
[0015] In some embodiments of the present application, based on the aforementioned scheme, the third generation unit includes: an editing subunit, which is used to edit each word included in the first word segmentation result so that the word is transformed into the word included in the second word segmentation result; an editing distance determination subunit, which is used to determine the editing distance between the first word segmentation result and the second word segmentation result based on the editing processing category of the editing processing of the word; and a selection subunit, which is used to select the editing processing category of the editing processing of the word under the premise of the minimum editing distance as the transformation category label.
[0016] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the grammatical error recognition method as described in the above embodiment is implemented.
[0017] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the grammatical error recognition method as described in the above embodiments.
[0018] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the grammatical error recognition method provided in the above various optional embodiments.
[0019] In the technical solutions provided in some embodiments of the present application, a sentence feature vector corresponding to the sentence to be recognized is generated based on the sentence to be recognized, and a target transformation category label is predicted based on the sentence feature vector corresponding to the sentence to be recognized, the target transformation category label refers to the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized, and based on the sentence to be recognized and the target transformation category label, the grammatical error type of the sentence to be recognized is determined. Compared with directly identifying the grammatical errors contained in the sentence to be recognized through the features contained in the sentence to be recognized, by first determining the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized, since the transformation category label can more significantly reflect the grammatical errors existing in the sentence to be recognized, the accuracy of grammatical error recognition for the sentence to be recognized can be effectively improved.
[0020] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0022] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.
[0023] Figure 2 A flowchart of a grammatical error identification method according to an embodiment of the present application is shown.
[0024] Figure 3 A flowchart of a grammatical error identification method according to an embodiment of the present application is shown.
[0025] Figure 4 A specific flow chart of step S340 of the grammatical error identification method according to an embodiment of the present application is shown.
[0026] Figure 5 A specific flow chart of step S230 of the grammatical error identification method according to an embodiment of the present application is shown.
[0027] Figure 6 A schematic diagram of the structure of a pre-trained machine learning model according to an embodiment of the present application is shown.
[0028] Figure 7 A specific flow chart of step S530 of the grammatical error identification method according to an embodiment of the present application is shown.
[0029] Figure 8 A specific flow chart of step S240 of the grammatical error identification method according to an embodiment of the present application is shown.
[0030] Fig. 9 A schematic diagram of the overall process of essay correction according to an embodiment of the present application is shown.
[0031] Fig.10 A schematic diagram of an interface for inputting text or pictures containing a composition according to an embodiment of the present application is shown.
[0032] Fig.11 A schematic diagram of the overall process of training a pre-trained machine learning model according to an embodiment of the present application.
[0033] Fig.12 A schematic diagram of an interface showing a grammatical error recognition result obtained by performing grammatical error recognition on a composition according to an embodiment of the present application is shown.
[0034] Fig.13 A block diagram of a grammatical error identification device according to an embodiment of the present application is shown.
[0035] Fig.14 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0036] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0037] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0038] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0039] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0040] Artificial Intelligence (AI): It is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
[0041] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0042] Machine Learning (ML) is a multi-disciplinary cross-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithmic complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all fields of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning. For example, in an embodiment of the present application, by inputting the sentence feature vector corresponding to the sentence to be recognized into a pre-trained machine learning model, and the machine learning model determines the target transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized, and then the determined target transformation category label determines the grammatical error type of the sentence to be recognized.
[0043] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.
[0044] like Figure 1 As shown, the system architecture may include a client 101, a network 102, and a server 103. The client 101 and the server 103 are connected via the network 102 and perform data exchange based on the network 102. The network may include various connection types, such as wired communication links, wireless communication links, and the like.
[0045] It should be understood that Figure 1 The number of clients 101, networks 102, and servers 103 in the embodiment is only for illustration. Any number of clients 101, networks 102, and servers 103 may be provided as required. For example, the server 103 may be a server providing grammatical error recognition services, or a server cluster composed of servers, which is not limited here. The client 101 is a client corresponding to the server 103, which may be one or more of a mobile phone, a tablet, a portable computer, and a desktop computer, but is not limited thereto.
[0046] The client 101 obtains a sentence to be recognized; and based on the sentence to be recognized, generates a sentence feature vector corresponding to the sentence to be recognized, the sentence feature vector includes a word vector corresponding to each word included in the sentence to be recognized and a position feature vector of each word included in the sentence to be recognized in the sentence to be recognized; based on the sentence feature vector corresponding to the sentence to be recognized, predicts a target transformation category label, the target transformation category label refers to a transformation category label of each word included in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; based on the sentence to be recognized and the target transformation category label, determines the grammatical error type of the sentence to be recognized.
[0047] From the above, it can be seen that compared with directly identifying the grammatical errors contained in the sentence to be recognized through the features contained in the sentence to be recognized, by first determining the transformation category labels of each word contained in the sentence to be recognized when it is transformed into the grammatically correct sentence corresponding to the sentence to be recognized, since the transformation category labels can more significantly reflect the grammatical errors existing in the sentence to be recognized, the accuracy of grammatical error recognition of the sentence to be recognized can be effectively improved.
[0048] It should be noted that the grammatical error recognition method provided in the embodiment of the present application is generally executed by the client 101, and accordingly, the grammatical error recognition device is generally arranged in the client 101. However, in other embodiments of the present application, the server 103 may also have similar functions as the client 101, so as to execute the scheme of the grammatical error recognition method provided in the embodiment of the present application. The implementation details of the technical scheme of the embodiment of the present application are described in detail below.
[0049] Figure 2 A flowchart of a grammatical error recognition method according to an embodiment of the present application is shown. The grammatical error recognition method can be executed by a client, which can be Figure 1 The client 101 shown in FIG. Figure 2 As shown, the grammatical error identification method at least includes steps S210 to S240, which are described in detail as follows.
[0050] In step S210, a sentence to be recognized is obtained.
[0051] In one embodiment of the present application, the sentence to be recognized refers to a single sentence information that needs to be recognized for grammatical errors, such as "I ate apples yesterday." The sentence to be recognized can be obtained from a text or picture containing sentence information input to the client. If the input is a picture, the input picture can be processed by optical character recognition (OCR) to determine the character information contained in the picture as the sentence to be recognized.
[0052] It can be understood that when the text or image input to the client contains multiple sentences to be recognized, for the text, it can be directly processed by specific characters, such as punctuation marks, to obtain multiple sentences to be recognized. For the image, it is necessary to first perform OCR optical character recognition on the input image to obtain the recognition result, and then perform sentence processing on the recognition result to obtain multiple sentences to be recognized.
[0053] In step S220, based on the sentence to be recognized, a sentence feature vector corresponding to the sentence to be recognized is generated, and the sentence feature vector includes a word vector corresponding to each word included in the sentence to be recognized and a position feature vector of each word included in the sentence to be recognized at the position of the sentence to be recognized.
[0054] In one embodiment of the present application, the sentence feature vector corresponding to the sentence to be recognized is used as feature information generated according to the sentence to be recognized, and the sentence feature vector can reflect the characteristic information of the sentence to be recognized. The sentence feature vector includes the word vector corresponding to each word included in the sentence to be recognized and the position feature vector of each word included in the sentence to be recognized in the sentence to be recognized.
[0055] When generating word vectors corresponding to the words contained in the sentence to be recognized, the sentence to be recognized can be segmented first to obtain the segmentation result corresponding to the sentence to be recognized, the segmentation result includes the words obtained by segmenting the sentence to be recognized, and further generate the word vectors corresponding to the words in the segmentation result. When generating the word vectors corresponding to the words, a pre-trained machine learning model can be used to implement it. The machine learning model can be a Word2vec word vector calculation model, or a GloVe word vector model, etc., which is not limited here.
[0056] When generating the position feature vector of the position of each word contained in the sentence to be recognized, the position feature vector can be obtained by performing position encoding processing on the position of each word contained in the sentence to be recognized. The position encoding processing can be performed by generating a corresponding word vector according to the position information of each word contained in the sentence to be recognized, or by using a sinusoidal position encoding algorithm to generate the position feature vector, which is not limited here.
[0057] In step S230, based on the sentence feature vector corresponding to the sentence to be recognized, a target transformation category label is predicted, where the target transformation category label refers to the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0058] In one embodiment of the present application, the transformation category label refers to the category label corresponding to the transformation operation performed on the vocabulary contained in the erroneous sentence during the process of transforming the erroneous sentence into a correct sentence. It can include basic operation transformation labels and special operation transformation labels.
[0059] Specifically, the basic operation transformation labels include conventional operation transformation labels such as (keep) operation label, (delete) operation label, (replace) operation label, (add) operation label, etc. Take the incorrect sentence "I has a apples." and the correct sentence "I have apples." as an example, then the transformation category label corresponding to the transformation operation performed by the word "I" in the incorrect sentence is the keep operation label, and the transformation category label corresponding to the transformation operation performed by the word "a" in the incorrect sentence is the delete operation label.
[0060] Special operation transformation labels include verb tense transformation operation labels, noun singular and plural transformation operation labels, etc. Taking the incorrect sentence "I ate apples yesterday." and the correct sentence "I ate apples yesterday." as an example, the transformation category label corresponding to the transformation operation performed on the word "eat" in the incorrect sentence is the verb tense transformation operation label.
[0061] It can be understood that the verb tense transformation operation label can be further subdivided into more detailed operation transformation labels such as "present continuous tense", "infinitive", "past form of verb", and "past perfect form of verb".
[0062] In one embodiment, based on the sentence feature vector corresponding to the sentence to be recognized, predicting the target transformation category label can be achieved by a pre-trained machine learning model. The pre-trained machine learning model is trained with sample data of sample sentence pairs including grammatically incorrect sample sentences and grammatically correct sample sentences.
[0063] It should be pointed out that when training a pre-trained machine learning model, it is necessary to generate a sentence feature vector corresponding to the sentence to be recognized based on the sentence to be recognized, and to generate a data preprocessing process of sample transformation category labels based on the incorrect sample sentences and grammatically correct sample sentences, and to train the machine learning model based on the data obtained in the data preprocessing process. The pre-trained machine learning model can be a BERT model, a RoBERTa model, an xlnet model, etc.
[0064] refer to Figure 3 , Figure 3A flowchart of a grammatical error recognition method according to an embodiment of the present application is shown. The grammatical error recognition method in this embodiment may further include steps S310 to S350, which are described in detail as follows.
[0065] In step S310, training set sample data for training the machine learning model to be trained is obtained, each sample data in the training set sample data includes a sample sentence pair, and the sample sentence pair includes a grammatically incorrect sample sentence and a grammatically correct sample sentence.
[0066] In one embodiment of the present application, the training set sample data is data used to train the machine learning model to be trained, and the training set sample data includes multiple sample sentence pairs. The sample sentence pairs refer to sentence pairs consisting of grammatically incorrect sample sentences and grammatically correct sample sentences corresponding to the grammatically incorrect sample sentences. The sample sentence pairs can be obtained from an existing database of grammar practice questions, or from other databases containing a large number of sample sentence pairs, which is not limited here.
[0067] In step S320, word segmentation processing is performed on the grammatically incorrect sample sentences and the grammatically correct sample sentences respectively to obtain a first word segmentation result corresponding to the grammatically incorrect sample sentences and a second word segmentation result corresponding to the grammatically correct sample sentences.
[0068] In one embodiment of the present application, for the grammatically incorrect sample sentences and grammatically correct sample sentences contained in each sample sentence pair, the grammatically incorrect sample sentences and the grammatically correct sample sentences can be respectively segmented to obtain a first segmentation result corresponding to the grammatically incorrect sample sentence and a second segmentation result corresponding to the grammatically correct sample sentence.
[0069] In step S330, a sentence feature vector corresponding to the grammatically incorrect sample sentence is generated based on the first word segmentation result.
[0070] In one embodiment of the present application, when generating a sentence feature vector corresponding to a grammatically incorrect sample sentence based on the first word segmentation result, a pre-trained machine learning model can be used to implement it. The machine learning model can be a Word2vec word vector calculation model, or a GloVe word vector model, etc., which is not limited here.
[0071] In step S340, based on the first word segmentation result and the second word segmentation result, a sample transformation category label is generated. The sample transformation category label refers to the transformation category label of each word included in the grammatically incorrect sample sentence when it is transformed into a grammatically correct sentence sample.
[0072] In one embodiment of the present application, the sample transformation category label refers to the transformation category label of each word contained in the grammatically incorrect sample sentence when it is transformed into a grammatically correct sentence sample. Taking the grammatically incorrect sample sentence "I has apples." and the grammatically correct sample sentence "I have apples." as an example, the transformation category labels are pre-set as ["I has apples.", "I"-retained operation label, "has"-verb tense transformation operation label, "apples"-retained operation label, "."-retained operation label].
[0073] In one embodiment, the process of determining the sample transformation category label may be manually preset.
[0074] In one embodiment, when generating sample transformation category labels, the first word segmentation result and the second word segmentation result may also be processed by an alignment algorithm based on edit distance, thereby generating transformation category labels for each word contained in a grammatically incorrect sample sentence when it is transformed into a grammatically correct sentence sample.
[0075] refer to Figure 4 , Figure 4 A specific flow chart of step S340 of the grammatical error identification method according to an embodiment of the present application is shown. Step S340 may include steps S410 to S430, which are described in detail as follows.
[0076] In step S410, for each word included in the first word segmentation result, the word is edited so that the word is transformed into a word included in the second word segmentation result.
[0077] In one embodiment of the present application, when determining the sample transformation category label by an alignment algorithm based on edit distance, the object targeted is vocabulary. Specifically, for each vocabulary included in the first word segmentation result, it is aligned with the vocabulary included in the second word segmentation result, and between the two aligned vocabulary, the vocabulary of the first word segmentation result is edited so that the vocabulary is transformed into the vocabulary aligned with the second word segmentation result. Executing the editing process on the vocabulary may include (keep) retention operation, (delete) deletion operation, (replace) replacement operation, (add) insertion operation, verb tense conversion operation and noun singular and plural conversion operation, etc.
[0078] In step S420, based on the editing processing category of the vocabulary to be edited, an edit distance between the first word segmentation result and the second word segmentation result is determined.
[0079] In one embodiment of the present application, the edit distance between the first word segmentation result and the second word segmentation result refers to the sum of the edit distances corresponding to the edit processing categories of each word in the first word segmentation result.
[0080] It can be understood that for the vocabulary of the (keep) retention operation, the edit distance value corresponding to the editing processing category can be considered to be 0; and for other editing processing categories such as delete operations, (replace) replacement operations, (add) insertion operations, verb tense conversion operations, and noun singular and plural conversion operations, the edit distance value corresponding to the editing processing category can be considered to be a predetermined normal number.
[0081] After determining the editing processing category for editing each word in the first word segmentation result, the editing distance between the first word segmentation result and the second word segmentation result may be determined according to the sum of the editing distance values corresponding to the editing processing categories.
[0082] In step S430, an editing processing category for editing the vocabulary under the premise of the minimum editing distance is selected as a transformation category label.
[0083] In one embodiment of the present application, for each word in the first word segmentation result, the editing processing category of the word under the premise of the minimum edit distance is used as a transformation category label.
[0084] Please continue to refer to Figure 3 In step S350, the machine learning model to be trained is trained by using the sample transformation category labels and the sentence feature vectors corresponding to the grammatically incorrect sample sentences to obtain a pre-trained machine learning model.
[0085] In one embodiment of the present application, after obtaining the sentence feature vector and sample transformation category label corresponding to the grammatically incorrect sample sentence, the machine learning model to be trained is trained according to the sentence feature vector and sample transformation category label corresponding to the grammatically incorrect sample sentence to obtain a pre-trained machine learning model. The process of training the machine learning model is to adjust the coefficients in the network layer corresponding to the machine learning model so that for the sentence feature vector corresponding to the input sentence to be recognized, after the coefficients in the network layer corresponding to the machine learning model are calculated, the target transformation category label of each word contained in the sentence to be recognized is obtained when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0086] refer to Figure 5 , Figure 5 A specific flow chart of step S230 of the grammatical error identification method according to an embodiment of the present application is shown. Step S230 may specifically include steps S510 to S530.
[0087] refer to Figure 6 , Figure 6 A schematic diagram of the structure of a pre-trained machine learning model according to an embodiment of the present application is shown. Figure 6 The pre-trained machine learning model shown may specifically include a transformer network layer 602, a fully connected layer 603, and a Softmax network layer 604. Figure 5 as well as Figure 6 Steps S510 to S530 are described in detail.
[0088] In step S510, the sentence feature vectors corresponding to the sentence to be recognized are fused to generate a semantic feature vector containing contextual semantic information.
[0089] In one embodiment of the present application, Figure 6 As shown, the input data 601 is a sentence feature vector corresponding to the sentence to be recognized, and the sentence feature vector specifically includes the word vector corresponding to each word contained in the sentence to be recognized and the position feature vector of each word contained in the sentence to be recognized. After the input data 601 is input into the pre-trained machine learning model, the machine learning model fuses the sentence feature vector corresponding to the sentence to be recognized through the transformer network layer 602 to generate a semantic feature vector containing contextual semantic information.
[0090] The transformer network layer 602 fuses the sentence feature vectors corresponding to the sentence to be recognized to generate a semantic feature vector, which refers to a feature vector containing contextual semantic information. The transformer network layer 602 includes a self-attention network layer, which can fully mine the relationship between each word, and further fully mine the contextual semantic relationship between the words contained in the sentence to be recognized, and further generate a semantic feature vector containing contextual semantic information.
[0091] In step S520, full connection processing is performed on the semantic feature vector to obtain a processed semantic feature vector.
[0092] In one embodiment of the present application, for the semantic feature vector obtained after being processed by the transformer network layer 602, the machine learning model performs full connection processing on the semantic feature vector through the fully connected layers 603 to obtain the processed semantic feature vector. The process of performing full connection processing on the semantic feature vector is actually the process of performing convolution calculation on the semantic feature vector, which is used to achieve dimensionality reduction processing on the semantic feature vector. The dimensionality reduction processing on the semantic feature vector can further mine the semantic relationship in the sentence to be recognized, so as to predict the target transformation category label of the sentence to be recognized when it is transformed into a grammatically correct sentence based on the semantic feature vector.
[0093] In step S530, the target transformation category label is predicted based on the processed semantic feature vector.
[0094] In one embodiment of the present application, for the processed semantic feature vector obtained through the fully connected layers 603, the machine learning model classifies and predicts the processed semantic feature vector through the Softmax network layer 604, and predicts the target transformation category label, that is, the transformation category label 605 of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0095] refer to Figure 7 , Figure 7 A specific flow chart of step S530 of the grammatical error identification method according to an embodiment of the present application is shown. Step S530 in this embodiment may specifically include steps S710 to S720, which are described in detail as follows.
[0096] In step S710, the processed semantic feature vector is normalized to generate the probability corresponding to the candidate transformation category label when each word included in the sentence to be recognized is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0097] In one embodiment of the present application, when the machine learning model performs classification prediction on the processed semantic feature vector through the Softmax network layer 604, the processed semantic feature vector can be first normalized by a preset Softmax function. The result of the normalization includes the probabilities of various candidate transformation category labels corresponding to the transformation operations performed on each word included in the sentence to be recognized when the sentence to be recognized is transformed into a grammatically correct sentence. For each word, the probabilities of various candidate transformation category labels corresponding to the transformation operations performed on it are real numbers between 0 and 1, and the sum of the probabilities corresponding to various candidate transformation category labels is 1.
[0098] In step S720, the candidate transformation category label with the highest probability is selected as the target transformation category label when each word included in the sentence to be recognized is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0099] In one embodiment of the present application, the candidate transformation category label with the highest probability is selected as the target transformation category label when each word contained in the sentence to be recognized is transformed into a grammatically correct sentence corresponding to the sentence to be recognized. This can predict the target transformation category label when each word contained in the sentence to be recognized is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0100] exist Figure 5 as well as Figure 7 In the technical solution of the illustrated embodiment, through a pre-trained machine learning model, it is possible to accurately determine the target transformation category label corresponding to the transformation operation performed on each vocabulary contained in the sentence to be recognized when the sentence to be recognized is transformed into a grammatically correct sentence, which is conducive to improving the accuracy of grammatical error recognition.
[0101] Please continue to refer to Figure 2 In step S240, based on the sentence to be recognized and the target transformation category label, the grammatical error type of the sentence to be recognized is determined.
[0102] In one embodiment of the present application, after obtaining the target transformation category label, the grammatical errors in the sentence to be recognized can be analyzed according to the sentence to be recognized and the determined target transformation category label, and then the grammatical error type of the sentence to be recognized can be determined.
[0103] Optionally, when determining the grammatical error type of the sentence to be recognized based on the sentence to be recognized and the target transformation category label, the grammatical error type of the sentence to be recognized can be determined according to the sentence to be recognized, and the correspondence between the preset target transformation category label and the grammatical error type.
[0104] refer to Figure 8 , Figure 8 A specific flow chart of step S240 of the grammatical error identification method according to an embodiment of the present application is shown. Step S240 may include steps S810 to S820, which are described in detail as follows.
[0105] In step S810, based on the target transformation category label and the sentence to be recognized, a grammatically correct sentence corresponding to the sentence to be recognized is determined.
[0106] In one embodiment of the present application, when determining the grammatical error type of the sentence to be recognized based on the target transformation category label and the sentence to be recognized, a grammatically correct sentence corresponding to the sentence to be recognized can be generated based on the target transformation category label and the sentence to be recognized. Specifically, a transformation operation corresponding to the target transformation category label can be performed on each vocabulary included in the sentence to be recognized, and the transformation result after performing the transformation operation is used as the grammatically correct sentence corresponding to the sentence to be recognized.
[0107] In step S820, based on the grammatically correct sentence and the preset grammatical error classification rules, the sentence to be recognized is classified and recognized for grammatical errors, and the grammatical error type of the sentence to be recognized is determined.
[0108] In one embodiment of the present application, the grammatical error type refers to the category of grammatical errors existing in the sentence to be recognized, which may include article or determiner errors, verb tense errors, subject-verb agreement errors, preposition collocation errors, noun errors, etc.
[0109] The grammatical error classification rules include a variety of rules for grammatical error classification and identification, which may specifically include grammatical error rules for judging grammatical errors based on the word part of speech of the vocabulary, grammatical error rules for judging grammatical errors based on the target transformation category label of the vocabulary, and grammatical error rules for judging grammatical errors based on the exchange position of the vocabulary. For example, if the sentence to be recognized is "I eat apples yesterday.", and the grammatically correct sentence corresponding to the sentence to be recognized is "I ate apples yesterday.", the grammatical error rule for judging grammatical errors based on the word part of speech of the vocabulary can determine that the sentence to be recognized is to write the past tense of the verb "ate" as the general present tense "eat", so the grammatical error type of the sentence to be recognized includes verb tense errors.
[0110] In one embodiment of the present application, step S820 may specifically include: if the probability corresponding to the target transformation category label is higher than a predetermined probability threshold, based on the grammatically correct sentence and preset grammatical error classification rules, the sentence to be recognized is classified and identified for grammatical errors to determine the grammatical error type of the sentence to be recognized.
[0111] In one embodiment of the present application, the pre-trained machine learning model can also output the probability corresponding to the target transformation category label. When determining whether the sentence to be recognized has a grammatical error, the probability corresponding to the target transformation category label can also be compared with a predetermined probability threshold. The predetermined probability threshold is a preset error threshold for determining whether the sentence to be recognized has a grammatical error. When the probability corresponding to the target transformation category label is higher than the predetermined probability threshold, it is considered that the sentence to be recognized has a grammatical error. By setting the error threshold, it is possible to effectively avoid identifying sentences without grammatical errors as having grammatical errors, thereby improving the accuracy of grammatical error recognition for the sentence to be recognized.
[0112] From the above, it can be seen that by generating a sentence feature vector corresponding to the sentence to be recognized based on the sentence to be recognized, and predicting the target transformation category label based on the sentence feature vector corresponding to the sentence to be recognized, the target transformation category label refers to the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized, and determining the grammatical error type of the sentence to be recognized based on the sentence to be recognized and the target transformation category label. Compared with directly identifying the grammatical errors contained in the sentence to be recognized through the features contained in the sentence to be recognized, by first determining the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized, since the transformation category label can more significantly reflect the grammatical errors existing in the sentence to be recognized, the accuracy of grammatical error recognition for the sentence to be recognized can be effectively improved.
[0113] In one embodiment of the present application, after step S240 of determining the grammatical error type of the sentence to be recognized based on the target transformation category label, the grammatical error recognition method in this embodiment further includes: generating error correction suggestion information corresponding to the sentence to be recognized based on the grammatical error type of the sentence to be recognized and the sentence to be recognized.
[0114] In one embodiment, after determining the grammatical error type of the sentence to be recognized, based on the grammatical error type of the sentence to be recognized and the sentence to be recognized, error correction suggestion information corresponding to the sentence to be recognized is generated. The error correction suggestion information refers to a type of information that describes the grammatical error type existing in the sentence to be recognized and the modification method corresponding to each grammatical error type. If the sentence to be recognized is "I ate apples yesterday." and the grammatical error type corresponding to the sentence to be recognized is a verb tense error, then the error correction suggestion information corresponding to the sentence to be recognized generated is "[verb tense error] suspected eat error, should be replaced with ate."
[0115] The generated error correction suggestion information can be used to promptly obtain suggestions for correcting grammatical errors in the sentence to be recognized, so as to achieve the purpose of learning methods or modifying texts in scenarios such as language learning or text modification.
[0116] The following takes the scenario of essay correction as an example to illustrate the process of grammatical error identification method.
[0117] Fig. 9 The figure shows the overall process of essay correction according to an embodiment of the present application. Fig.10 A schematic diagram of an interface for inputting text or pictures containing compositions according to an embodiment of the present application is shown.
[0118] Combination Fig. 9 and Fig.10 When correcting a composition, the grammatical error recognition method in the embodiment of the present application can be used to recognize grammatical errors in each sentence in the composition. First, the user needs to input the composition to be corrected into a client such as a smart phone or a laptop computer.
[0119] like Fig.10 As shown, the user can input the composition containing the sentence to be recognized in the display interface provided by the client. Specifically, the composition to be corrected can be input in the form of text in the text editing bar 1001 of the display interface, or the composition containing the sentence to be recognized can be input in the form of a picture by clicking the picture input button 1002 (one-click picture upload) on the display interface. After the composition is input in the form of text or picture, the grammatical error recognition of the input composition can be triggered by clicking the correction button 1003.
[0120] When the composition text is input to the client, the client divides the composition text into sentences using specific characters, such as punctuation marks, to obtain multiple sentences to be recognized. For images, the client needs to first perform OCR optical character recognition on the input image to obtain a recognition result containing the composition text, and then divide the recognition result into sentences to obtain multiple sentences to be recognized.
[0121] A pre-trained machine learning model is pre-stored in the client, and multiple sentences to be recognized will be input into the pre-trained machine learning model. The pre-trained machine learning model may specifically include a transformer network layer, a fully connected layer, and a Softmax network layer, and the above network layers are used to process multiple sentences to be recognized respectively, and the output result of the processing by the pre-trained machine learning model is the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized.
[0122] Fig.11 The overall process diagram of training a pre-trained machine learning model according to an embodiment of the present application is shown. The pre-trained machine learning model pre-stored in the client needs to be trained. When training the pre-trained machine learning model, a large number of sample data pairs need to be obtained. The sample sentence pairs refer to sentence pairs consisting of grammatically incorrect sample sentences and grammatically correct sample sentences corresponding to the grammatically incorrect sample sentences. The sample sentence pairs can be obtained from the existing grammar exercise question database, or from other databases containing a large number of sample sentence pairs. For the sample sentence pairs, the transformation category labels of each vocabulary contained in the grammatically incorrect sample sentences when they are transformed into grammatically correct sentence samples are determined, and the training sample data input to the pre-trained machine learning model is generated based on the sample sentence pairs and the transformation category labels of each vocabulary contained in the grammatically incorrect sample sentences when they are transformed into grammatically correct sentence samples. The pre-trained machine learning model performs multiple rounds of iterative training through these training sample data, and when the training is completed, it can be used to process the sentences to be recognized.
[0123] The client obtains the result output by the pre-trained machine learning model, that is, obtains the transformation category label when the grammatically correct sentence to be recognized corresponds to the sentence to be recognized. Under the premise that there are grammatical errors in the sentence to be recognized, the client will further generate the grammatical error type, error correction suggestion and error probability of the sentence to be recognized based on the transformation category label when the grammatically correct sentence to be recognized corresponds to the sentence to be recognized. It can be understood that the above error probability can be used to compare with a predetermined probability threshold, and only when the error probability is higher than the predetermined probability threshold, the grammatical error type and the error correction suggestion for correcting the grammatical error of the sentence to be recognized are output. The client will display the grammatical error type and the error correction suggestion for correcting the grammatical error of the sentence to be recognized on the display interface, so that the user can view the sentences with grammatical errors in the composition, the grammatical error type of the sentences with grammatical errors, and the error correction suggestions corresponding to the sentences with grammatical errors.
[0124] Fig.12 A schematic diagram of an interface of a grammatical error recognition result obtained by performing grammatical error recognition on a composition according to an embodiment of the present application is shown. As shown in the figure, "Almost every child will complaining about their parent sometimes." is a sentence 1201 with a grammatical error, "[verb tense error]" is a grammatical error type 1202 corresponding to the grammatical error sentence, and "There may be an error in the use of future tense. It is recommended to replace will complaining with complainS." is an error correction suggestion 1203 corresponding to the sentence with a grammatical error.
[0125] Compared with directly identifying grammatical errors in sentences in compositions by the features contained in the sentences, by first determining the transformation category labels of each word contained in the sentences in the composition when they are transformed into the grammatically correct sentences corresponding to the sentences, the transformation category labels can more significantly reflect the grammatical errors in the sentences in the composition, thereby effectively improving the accuracy of grammatical error identification in the composition.
[0126] The following describes an apparatus embodiment of the present application, which can be used to execute the grammatical error identification method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned method embodiment of the present application.
[0127] Fig.13 A block diagram of a grammatical error identification device according to an embodiment of the present application is shown.
[0128] Reference Fig.13 As shown, according to an embodiment of the present application, the device 1300 includes: a first acquisition unit 1310, a first generation unit 1320, a prediction unit 1330, and a grammatical error determination unit 1340. The first acquisition unit 1310 is used to acquire a sentence to be recognized; the first generation unit 1320 is used to generate a sentence feature vector corresponding to the sentence to be recognized based on the sentence to be recognized, the sentence feature vector includes a word vector corresponding to each word included in the sentence to be recognized and a position feature vector of each word included in the sentence to be recognized at the position of the sentence to be recognized; the prediction unit 1330 is used to predict a target transformation category label based on the sentence feature vector corresponding to the sentence to be recognized, the target transformation category label refers to the transformation category label of each word included in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; the grammatical error determination unit 1340 is used to determine the grammatical error type of the sentence to be recognized based on the sentence to be recognized and the target transformation category label.
[0129] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error determination unit 1340 includes: a grammatically correct sentence determination subunit, used to determine a grammatically correct sentence corresponding to the sentence to be recognized based on the target transformation category label and the sentence to be recognized; a grammatical error recognition subunit, used to perform grammatical error classification and recognition on the sentence to be recognized based on the grammatically correct sentence and preset grammatical error classification rules, and determine the grammatical error type of the sentence to be recognized.
[0130] In some embodiments of the present application, based on the aforementioned scheme, the prediction unit 1330 includes: a fusion subunit, used to perform fusion processing on the sentence feature vector corresponding to the sentence to be recognized, and generate a semantic feature vector containing contextual semantic information; a fully connected subunit, used to perform full connection processing on the semantic feature vector to obtain a processed semantic feature vector; a prediction subunit, used to predict the target transformation category label based on the processed semantic feature vector.
[0131] In some embodiments of the present application, based on the aforementioned scheme, the prediction subunit includes: a generation module, used to normalize the processed semantic feature vector, and generate the probability corresponding to the candidate transformation category label when each word contained in the sentence to be recognized is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; a selection module, used to select the candidate transformation category label with the highest probability as the target transformation category label.
[0132] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error recognition subunit is specifically used to perform grammatical error classification and identification on the sentence to be recognized based on the grammatically correct sentence and preset grammatical error classification rules if the probability corresponding to the target transformation category label is higher than a predetermined probability threshold, and determine the grammatical error type of the sentence to be recognized.
[0133] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error identification device further includes: an error correction suggestion generation unit, which is used to generate error correction suggestion information corresponding to the sentence to be identified based on the grammatical error type of the sentence to be identified and the sentence to be identified.
[0134] In some embodiments of the present application, based on the aforementioned scheme, the target transformation category label and the sentence feature vector corresponding to the sentence to be recognized are generated by a pre-trained machine learning model.
[0135] In some embodiments of the present application, based on the aforementioned scheme, the grammatical error identification device further includes: a second acquisition unit, used to acquire training set sample data for training the machine learning model to be trained, each sample data in the training set sample data includes a sample sentence pair, and the sample sentence pair includes a grammatically incorrect sample sentence and a grammatically correct sample sentence; a word segmentation unit, used to perform word segmentation processing on the grammatically incorrect sample sentence and the grammatically correct sample sentence respectively, to obtain a first word segmentation result corresponding to the grammatically incorrect sample sentence and a second word segmentation result corresponding to the grammatically correct sample sentence; a second generation unit, used to generate a sentence feature vector corresponding to the grammatically incorrect sample sentence based on the first word segmentation result; a third generation unit, used to generate a sample transformation category label based on the first word segmentation result and the second word segmentation result, the sample transformation category label refers to the transformation category label of each vocabulary contained in the grammatically incorrect sample sentence when it is transformed into the grammatically correct sentence sample; a training unit, used to train the machine learning model to be trained by using the sample transformation category label and the sentence feature vector corresponding to the grammatically incorrect sample sentence to obtain a pre-trained machine learning model.
[0136] In some embodiments of the present application, based on the aforementioned scheme, the third generation unit includes: an editing subunit, which is used to edit each word included in the first word segmentation result so that the word is transformed into the word included in the second word segmentation result; an editing distance determination subunit, which is used to determine the editing distance between the first word segmentation result and the second word segmentation result based on the editing processing category of the editing processing of the word; and a selection subunit, which is used to select the editing processing category of the editing processing of the word under the premise of the minimum editing distance as the transformation category label.
[0137] Fig.14 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0138] It should be noted that Fig.14 The computer system 1400 of the electronic 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 application.
[0139] like Fig.14As shown, the computer system 1400 includes a central processing unit (CPU) 1401, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1402 or the program loaded from the storage part 1408 to the random access memory (RAM) 1403, such as executing the method described in the above embodiment. In the RAM 1403, various programs and data required for system operation are also stored. The CPU 1401, the ROM 1402 and the RAM 1403 are connected to each other through the bus 1404. The input / output (I / O) interface 1405 is also connected to the bus 1404.
[0140] The following components are connected to the I / O interface 1405: an input section 1406 including a keyboard, a mouse, etc.; an output section 1407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1408 including a hard disk, etc.; and a communication section 1409 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1409 performs communication processing via a network such as the Internet. A drive 1410 is also connected to the I / O interface 1405 as needed. A removable medium 1411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1410 as needed so that a computer program read therefrom is installed into the storage section 1408 as needed.
[0141] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1409, and / or installed from a removable medium 1411. When the computer program is executed by a central processing unit (CPU) 1401, various functions defined in the system of the present application are executed.
[0142] It should be noted that the computer-readable medium shown in the embodiment of the present application 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), a 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 application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals 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 programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0143] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the 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 flowchart, and the combination of boxes in the block diagram or flowchart 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.
[0144] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0145] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.
[0146] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0147] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0148] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0149] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for identifying grammatical errors, characterized in that: include: Get the sentence to be recognized; Based on the sentence to be recognized, generating a sentence feature vector corresponding to the sentence to be recognized, wherein the sentence feature vector includes a word vector corresponding to each word included in the sentence to be recognized and a position feature vector of each word included in the sentence to be recognized at a position in the sentence to be recognized; The sentence feature vector corresponding to the sentence to be recognized is subjected to fusion processing to generate a semantic feature vector containing contextual semantic information, and the semantic feature vector is subjected to full connection processing to obtain a processed semantic feature vector; based on the processed semantic feature vector, a target transformation category label is predicted, and the target transformation category label refers to the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; Based on the sentence to be recognized and the target transformation category label, a grammatically correct sentence corresponding to the sentence to be recognized is determined; based on the grammatically correct sentence and preset grammatical error classification rules, grammatical error classification and identification are performed on the sentence to be recognized to determine the grammatical error type of the sentence to be recognized.
2. The grammatical error recognition method according to claim 1, characterized in that: The step of predicting a target transformation category label based on the processed semantic feature vector includes: Normalizing the processed semantic feature vector to generate the probability corresponding to the candidate transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; The candidate transformation category label with the highest probability is selected as the target transformation category label.
3. The grammatical error recognition method according to claim 2, characterized in that: The step of classifying and identifying grammatical errors of the sentence to be identified based on the grammatically correct sentence and the preset grammatical error classification rules, and determining the grammatical error type of the sentence to be identified includes: If the probability corresponding to the target transformation category label is higher than a predetermined probability threshold, the sentence to be recognized is classified and recognized for grammatical errors based on the grammatically correct sentence and preset grammatical error classification rules to determine the grammatical error type of the sentence to be recognized.
4. The grammatical error recognition method according to claim 1, characterized in that: After determining the grammatical error type of the sentence to be recognized based on the sentence to be recognized and the target transformation category label, the grammatical error recognition method further includes: Based on the grammatical error type of the sentence to be recognized and the sentence to be recognized, error correction suggestion information corresponding to the sentence to be recognized is generated.
5. The grammatical error recognition method according to any one of claims 1 to 4, characterized in that: The target transformation category label and the sentence feature vector corresponding to the sentence to be recognized are generated through a pre-trained machine learning model.
6. The grammatical error identification method according to claim 5, characterized in that: The grammatical error identification method further includes: Acquire training set sample data for training a machine learning model to be trained, wherein each sample data in the training set sample data includes a sample sentence pair, and the sample sentence pair includes a grammatically incorrect sample sentence and a grammatically correct sample sentence; Performing word segmentation processing on the grammatically incorrect sample sentence and the grammatically correct sample sentence respectively, to obtain a first word segmentation result corresponding to the grammatically incorrect sample sentence and a second word segmentation result corresponding to the grammatically correct sample sentence; Based on the first word segmentation result, generating a sentence feature vector corresponding to the grammatically incorrect sample sentence; Based on the first word segmentation result and the second word segmentation result, generating a sample transformation category label, wherein the sample transformation category label refers to a transformation category label of each word included in the grammatically incorrect sample sentence when it is transformed into the grammatically correct sample sentence; The machine learning model to be trained is trained using the sample transformation category label and the sentence feature vector corresponding to the grammatically incorrect sample sentence to obtain a pre-trained machine learning model.
7. The grammatical error identification method according to claim 6, characterized in that: The generating a sample transformation category label based on the first word segmentation result and the second word segmentation result includes: For each word included in the first word segmentation result, editing the word so that the word is transformed into the word included in the second word segmentation result; Determining an edit distance between the first word segmentation result and the second word segmentation result based on an edit processing category of the word segmentation; The editing processing category for editing the vocabulary under the premise of the minimum editing distance is selected as the transformation category label.
8. A grammatical error recognition device, characterized in that: include: A first acquisition unit, used to acquire a sentence to be recognized; A first generating unit is used to generate a sentence feature vector corresponding to the sentence to be recognized based on the sentence to be recognized, wherein the sentence feature vector includes a word vector corresponding to each word included in the sentence to be recognized and a position feature vector of each word included in the sentence to be recognized at a position in the sentence to be recognized; A prediction unit is used to perform fusion processing on the sentence feature vector corresponding to the sentence to be recognized, generate a semantic feature vector containing contextual semantic information, perform full connection processing on the semantic feature vector, and obtain a processed semantic feature vector; based on the processed semantic feature vector, predict a target transformation category label, the target transformation category label refers to the transformation category label of each word contained in the sentence to be recognized when it is transformed into a grammatically correct sentence corresponding to the sentence to be recognized; A grammatical error determination unit is used to determine a grammatically correct sentence corresponding to the sentence to be recognized based on the sentence to be recognized and the target transformation category label, and to classify and identify grammatical errors on the sentence to be recognized based on the grammatically correct sentence and preset grammatical error classification rules to determine the grammatical error type of the sentence to be recognized.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the grammatical error identification method according to any one of claims 1 to 7 is implemented.
10. A computer device, characterized in that: include: one or more processors; A memory for storing one or more computer programs, which, when executed by the one or more processors, enables the computer device to implement the grammatical error identification method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a computer-readable storage medium. A processor of a computer device reads and executes the computer program from the computer-readable storage medium, so that the computer device executes the grammatical error identification method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for converting text
CN106354716A
Grammar error correction method and device, electronic equipment and storage medium
CN111310447A