CN115169330B - Chinese text error correction and verification method, device, equipment and storage medium - Google Patents

Chinese text error correction and verification method, device, equipment and storage medium Download PDF

Info

Publication number
CN115169330B
CN115169330B CN202210824618.4A CN202210824618A CN115169330B CN 115169330 B CN115169330 B CN 115169330B CN 202210824618 A CN202210824618 A CN 202210824618A CN 115169330 B CN115169330 B CN 115169330B
Authority
CN
China
Prior art keywords
error correction
text
model
error
training
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.)
Active
Application number
CN202210824618.4A
Other languages
Chinese (zh)
Other versions
CN115169330A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202210824618.4A priority Critical patent/CN115169330B/en
Publication of CN115169330A publication Critical patent/CN115169330A/en
Application granted granted Critical
Publication of CN115169330B publication Critical patent/CN115169330B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Character Discrimination (AREA)
  • Machine Translation (AREA)

Abstract

The invention relates to artificial intelligence technology, and discloses a Chinese text error correction and verification method, which comprises the following steps: and labeling the texts in the original error correction training text set with template texts to obtain a standard error correction training text set, performing joint training on a double-stage error correction model comprising a text error recognition model and a text error correction model by using the standard error correction training text set to obtain a standard error correction model, performing error correction on the text to be corrected by using the standard error correction model to obtain an error corrected text, constructing an error correction pair, performing error correction type recognition on the error correction pair, performing error correction verification on the error correction pair by using an editing distance cost method based on the error correction type, and obtaining an error correction verification result. Furthermore, the present invention relates to blockchain techniques, and the error correction verification results may be stored in nodes of the blockchain. The invention also provides a Chinese text error correction and verification device, electronic equipment and a readable storage medium. The invention can solve the problem of lower Chinese error correction efficiency.

Description

Chinese text error correction and verification method, device, equipment and storage medium
Technical Field
The present invention relates to the field of artificial intelligence technologies, and in particular, to a method and apparatus for correcting and verifying chinese text, an electronic device, and a readable storage medium.
Background
The Chinese error correction is an important application in artificial intelligence, and the Chinese error correction method commonly used in the industry mostly traverses each sentence to perform Chinese error correction, and mainly comprises the following two methods: 1. based on the edit distance algorithm, edit cost such as adding, deleting, replacing and other edit values is calculated, and traversal comparison is performed with a correct sentence library, so that an error correction process is completed. However, the method is relatively mechanical, a huge and correct sentence library needs to be preset, sentence levels are used, the whole sentence is input for editing distance calculation, the editing distance cost is calculated for the correct part of the sentence by the editing distance algorithm, the calculation cost is high, the time for error correction is long, and error correction cannot be performed on the unregistered sentence or word, so that the error correction efficiency is low. 2. The language model is used for correcting Chinese, for example, the models of the structures of the encoder and the decoder are used for correcting the Chinese, but the corrected sentences are required to be decoded one by one according to the sequence in the decoding process, so that the efficiency is low; or a single BERT language model is used for text correction, but all single words or a plurality of words continuously combined in sentences still need to be traversed to mask, so that the model guesses the position of the mask to achieve the correction effect, and the efficiency is very low.
Disclosure of Invention
The invention provides a method, a device, electronic equipment and a readable storage medium for correcting and verifying Chinese text, which mainly aim to solve the problem of low Chinese correction efficiency.
In order to achieve the above purpose, the method for correcting and verifying the Chinese text provided by the invention comprises the following steps:
acquiring an original error correction training text set, and labeling a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set;
constructing a double-stage error correction model comprising a text error recognition model and a text error correction model;
performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model;
obtaining a text to be corrected, correcting the text to be corrected by using the standard correction model, and obtaining a corrected text;
constructing an error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain an error correction type;
and based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result.
Optionally, the constructing a dual-stage error correction model including a text error recognition model and a text error correction model includes:
acquiring a first BERT model, and splicing a full connection layer and an output layer after the first BERT model to obtain the text error recognition model;
and obtaining a second BERT model and taking the second BERT model as the text error correction model, and connecting the text error correction models of the text error recognition model machine in series to obtain the double-stage error correction model.
Optionally, the training the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model includes:
performing iterative training on the text error recognition model by using the standard error correction training text set;
outputting standard word vectors corresponding to sentences in the standard error correction training text set by using the trained text error recognition model;
copying and combining the standard word vectors, and performing attention training on the text error correction model based on the copied combined word vectors and a preset loss function;
and summarizing the text error recognition model and the text error correction model which are completed by training to obtain the double-stage error correction model.
Optionally, the training the text error recognition model iteratively by using the standard error correction training text set includes:
converting sentences in the standard error correction training text set into word vectors by using the first BERT model, and masking preset positions in the word vectors to obtain masked word vectors;
extracting a standard word vector of the mask word vector by using the full connection layer, and outputting a predicted value of the standard word vector by using the output layer;
and calculating a loss value based on the predicted value, if the loss value is greater than or equal to a preset loss threshold value, updating parameters in the first BERT model, and returning to the step of converting sentences in the standard error correction training text set into word vectors by using the first BERT model until the loss value is less than the preset loss threshold value, stopping training, and obtaining a trained text error recognition model.
Optionally, the performing error correction on the text to be subjected to error correction by using the standard error correction model to obtain error corrected text includes:
identifying the error probability of the text to be corrected by using a text error identification model in the standard error correction model;
If the error probability is smaller than a preset error threshold, the text to be corrected is not processed;
and if the error probability is greater than or equal to the error threshold, performing text error correction on the text to be subjected to error correction by using a text error correction model in the standard error correction model to obtain an error corrected text.
Optionally, the constructing an error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain an error correction type, including:
word segmentation processing is carried out on the corrected text and the text to be corrected corresponding to the corrected text;
and extracting the phrase related to error correction after word segmentation to form an error correction pair, and outputting the error correction type of the error correction pair by using the classification model.
Optionally, based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result, including:
if the error correction type is the first error correction type, calculating the editing cost of the error correction pair by using an editing distance cost method for adjusting characters;
if the error correction type is the second error correction type, calculating the editing cost of the error correction pair by using a keyboard-level editing distance cost method;
And determining that the error correction verification result of the error correction pair with the editing cost smaller than or equal to the preset cost threshold is error correction success, and determining that the error correction verification result of the error correction pair with the editing cost larger than the preset cost threshold is error correction failure.
In order to solve the above problems, the present invention also provides a device for correcting and verifying chinese text, the device comprising:
the error correction model training module is used for acquiring an original error correction training text set, marking a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set, constructing a double-stage error correction model comprising a text error recognition model and a text error correction model, and performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain the standard error correction model;
the text correction module is used for acquiring a text to be corrected, correcting the text to be corrected by using the standard correction model, and obtaining corrected text;
the error correction type identification module is used for constructing error correction pairs based on the error corrected text, and carrying out error correction type identification on the error correction pairs by utilizing a preset classification model to obtain error correction types;
And the error correction verification module is used for carrying out error correction verification on the error correction pair by utilizing an edit distance cost method based on the error correction type to obtain an error correction verification result.
In order to solve the above-mentioned problems, the present invention also provides an electronic apparatus including:
a memory storing at least one computer program; a kind of electronic device with high-pressure air-conditioning system
And the processor executes the computer program stored in the memory to realize the Chinese text error correction and verification method.
In order to solve the above-mentioned problems, the present invention also provides a computer-readable storage medium having stored therein at least one computer program that is executed by a processor in an electronic device to implement the above-mentioned chinese text error correction and verification method.
According to the method, the template text is marked according to the correctness of the text in the original error correction training text set, a standard error correction training text set with more abundant information can be obtained, the standard error correction training text set is utilized to carry out joint training on a double-stage error correction model comprising a text error recognition model and a text error correction model, the standard error correction model obtained through training is utilized to recognize and correct the text to be corrected, and the accuracy and the efficiency of text error correction are improved. Meanwhile, an error correction pair is constructed based on the corrected text, error correction verification is carried out on the error correction pair by using an edit distance cost method, and as the calculation of the edit distance cost is word-level, the calculation efficiency is greatly improved, and the error correction verification efficiency is also improved. Therefore, the method, the device, the electronic equipment and the computer readable storage medium for correcting and verifying the Chinese text can solve the problem of lower Chinese correction efficiency.
Drawings
FIG. 1 is a flow chart of a method for correcting and verifying Chinese text according to an embodiment of the present invention;
FIG. 2 is a detailed flow chart of one of the steps shown in FIG. 1;
FIG. 3 is a detailed flow chart of another step of FIG. 1;
FIG. 4 is a detailed flow chart of another step of FIG. 1;
FIG. 5 is a detailed flow chart of another step of FIG. 1;
FIG. 6 is a functional block diagram of a device for correcting and verifying Chinese text according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device for implementing the method for correcting and verifying chinese text according to an embodiment of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The embodiment of the invention provides a Chinese text error correction and verification method. The execution subject of the Chinese text error correction and verification method includes, but is not limited to, at least one of a server, a terminal, and the like, which can be configured to execute the method provided by the embodiment of the invention. In other words, the chinese text error correction and verification method may be performed by software or hardware installed in a terminal device or a server device, and the software may be a blockchain platform. The service end includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server may be an independent server, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (ContentDelivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.
Referring to fig. 1, a flow chart of a method for correcting and verifying chinese text according to an embodiment of the invention is shown. In this embodiment, the method for correcting and verifying Chinese text includes the following steps S1-S4:
s1, acquiring an original error correction training text set, and labeling a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set.
In the embodiment of the invention, the original error correction training text set is manually marked text data, and the format is that an error sentence corresponds to a correct sentence, for example, "my biology is good-my body is good". The labeling template text is a labeling text constructed according to the correctness of the sentence, and the template text is 'the sentence is < >', so as to distinguish whether the sentence is correct or not.
In detail, the labeling the template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set includes:
correct labeling is carried out on correct sentences in the original error correction training text set, and error labeling is carried out on error sentences in the original error correction training text set;
And summarizing all sentence texts with completed labels to obtain the standard error correction training text set.
In an embodiment of the present invention, different sentences are labeled with template text, for example, the erroneous sentence is labeled as "the sentence is wrong" and the correct sentence is labeled as "the sentence is correct".
S2, constructing a double-stage error correction model comprising a text error recognition model and a text error correction model.
In the embodiment of the invention, the text error recognition model and the text error correction model are mask language models (masked language model, MLM) based on BERT models, wherein the text error recognition model is used for recognizing whether wrongly written words exist in sentences, and the text error correction model is used for correcting misspelled parts.
In detail, referring to fig. 2, the construction of the dual-stage error correction model including the text error recognition model and the text error correction model includes the following steps S20 to S21:
s20, acquiring a first BERT model, and splicing a full connection layer and an output layer after the first BERT model to obtain the text error recognition model;
s21, acquiring a second BERT model and taking the second BERT model as the text error correction model, and connecting the text error correction models of the text error recognition model machine in series to obtain the double-stage error correction model.
In the embodiment of the invention, the first BERT model is a traditional BERT model, the input is text, words in the text are independently segmented according to the character sequence, and word vectors and [ CLS ] feature vectors can be output through the first BERT model; the fully connected layer consists of two MLPs (a single MLP network structure is shown in the upper diagram, and consists of two linear layers and a ReLu activation function) fully connected network for further extracting features; the output layer includes a sigmoid activation function to calculate the probability of whether there is a spelling error. The input of the second BERT model is a word vector of text and is output as a correct sentence.
And S3, performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model.
In the embodiment of the invention, the text of the standard error correction training text set comprises the template text marked based on text correctness, and the accuracy of error correction recognition can be improved through the mask training of the BERT model.
In detail, referring to fig. 3, the training the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model includes the following steps S30-S33:
S30, performing iterative training on the text error recognition model by using the standard error correction training text set;
s31, outputting standard word vectors corresponding to sentences in the standard error correction training text set by using the trained text error recognition model;
s32, carrying out copying and combining processing on the standard word vector, and carrying out attention training on the text error correction model based on the copied combined word vector and a preset loss function;
and S33, summarizing the text error recognition model and the text error correction model which are trained to obtain the double-stage error correction model.
In the embodiment of the present invention, the preset loss function may be a cross entropy loss function. After a standard word vector corresponding to sentences in a standard error correction training text set is output by using a training-completed text error recognition model, the standard word vector is copied into two parts to serve as Q and K in a second BERT model, and then a result of g x w is used as V, wherein g represents the average value of the word vector, w is a parameter matrix, the matrix size of w is LxD, D is 512 dimensions, and L is the number of words in an input text. And performing self-attention calculation in the second BERT model by using the < Q, K and V >, and performing iterative training on the second BERT model based on the cross entropy loss function to obtain a trained text error correction model.
Specifically, the performing iterative training on the text error recognition model by using the standard error correction training text set includes:
converting sentences in the standard error correction training text set into word vectors by using the first BERT model, and masking preset positions in the word vectors to obtain masked word vectors;
extracting a standard word vector of the mask word vector by using the full connection layer, and outputting a predicted value of the standard word vector by using the output layer;
and calculating a loss value based on the predicted value, if the loss value is greater than or equal to a preset loss threshold value, updating parameters in the first BERT model, and returning to the step of converting sentences in the standard error correction training text set into word vectors by using the first BERT model until the loss value is less than the preset loss threshold value, stopping training, and obtaining a trained text error recognition model.
In an alternative embodiment of the present invention, the text error recognition model is actually a two-class classifier, for example: the 'My organism is well' input into a first BERT model, and the output mask word vector consists of three parts, wherein the first part is a [ CLS ] vector, and the [ CLS ] is used for judging whether a sentence has misspellings; the second is the word vector of each word, and the 'my living body' has 6 words, so that a matrix of 6xD is formed, each row in the matrix represents the word vector of one word, D is 512-dimension, a mean value is calculated for the vector of each word to obtain g, and the g is multiplied by another matrix w, wherein the w is a learnable matrix, namely, the value in the matrix can be updated through each iteration training model, and the matrix can reflect the salient value of each word after learning. Because the probabilities of the words that are likely to be wrong are different for a sentence of input text, "my living good", the "body" of "me" is generally "good" and is less prone to be wrong than "body", while the "body" of "me" is relatively prone to be wrong, this w can learn these regular distributions through training data; the third is the masked template. Namely, the mask word vector output by the first BERT model is: [ CLS ], I, raw, somatic, very good, [ sep ], this sentence, if any, < mask >, [ seq ]. Compared with the traditional BERT model, the vector corresponding to [ CLS ] and [ Masked ] is spliced and then used as a new [ CLS ] vector.
In an alternative embodiment of the present invention, after the [ CLS ] feature vector (i.e., the mask word vector) is obtained, the [ CLS ] feature vector is sent to two MLP fully connected networks, and then the probability of spelling errors is calculated by using a sigmoid activation function, where the [ CLS ] feature vector is output by using a sigmoid function, and the output is a fraction of 0-1, which represents the probability of errors. A threshold of 0.72 may be used, if greater than 0.72, a misspelling is considered, and if less than, no. Meanwhile, a loss value is calculated using a cross entropy loss function.
In an alternative embodiment of the present invention, the calculation of the cross entropy loss function is known in the art, and will not be described herein.
S4, acquiring a text to be corrected, and correcting the text to be corrected by using the standard correction model to obtain a corrected text.
In the embodiment of the invention, the text to be corrected can be subjected to text error recognition and text correction by using the standard correction model.
Further, referring to fig. 4, the correcting the text to be corrected by using the standard correction model to obtain corrected text includes the following steps S40-S42:
s40, recognizing the error probability of the text to be corrected by using a text error recognition model in the standard error correction model;
S41, if the error probability is smaller than a preset error threshold, the text to be corrected is not processed;
s42, if the error probability is greater than or equal to the error threshold, performing text error correction on the text to be corrected by using a text error correction model in the standard error correction model to obtain corrected text.
In an alternative embodiment of the present invention, the error threshold may be 0.72. Meanwhile, only sentences which are identified to have errors are corrected, so that correction of correct sentences is avoided, and the efficiency of text correction is improved.
S5, constructing error correction pairs based on the error corrected text, and identifying error correction types of the error correction pairs by using a preset classification model to obtain error correction types.
In the embodiment of the present invention, the preset classification model may also be a BERT model.
In detail, the constructing the error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain the error correction type, including:
word segmentation processing is carried out on the corrected text and the text to be corrected corresponding to the corrected text;
and extracting the phrase related to error correction after word segmentation to form an error correction pair, and outputting the error correction type of the error correction pair by using the classification model.
In an alternative embodiment of the invention, the corrected text needs to be verified for the second time, the original sentence and the sentence corrected by the double-stage BERT are segmented, the corrected positions (different positions) of the two sentences after segmentation are compared, and the words related to the corrected positions are extracted, so that the specific part of the sentence corrected can be known. The extracted words are again input into the BERT model (i.e., classification model), and the vectors are output via the [ CLS ] of the BERT model. For example, the modification is obtained: original sentence-error correction word, the BERT input is: the [ CLS ] vector is input into softmax for category classification, and the error correction type of the error correction pair can be obtained.
And S6, based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result.
In the embodiment of the invention, the error correction types comprise a first error correction type and a second error correction type, wherein the first error correction type comprises: correction of harmonic words, such as fitting eyes-fitting glasses; the confusing sound word correction, such as wandering boy-cattle boy, the second correction type includes: and correction of the shape-like words, such as sorghum-sorghum.
In detail, referring to fig. 5, the error correction verification is performed on the error correction pair by using an edit distance cost method based on the error correction type to obtain an error correction verification result, which includes the following steps S60-S62:
s60, if the error correction type is a first error correction type, calculating the editing cost of the error correction pair by using an editing distance cost method for adjusting characters;
s61, if the error correction type is a second error correction type, calculating the editing cost of the error correction pair by using a keyboard-level editing distance cost method;
s62, determining that the error correction verification result of the error correction pair with the editing cost smaller than or equal to the preset cost threshold is error correction success, and determining that the error correction verification result of the error correction pair with the editing cost larger than the preset cost threshold is error correction failure.
In the embodiment of the invention, for the first error correction type, the original sentence words and the error correction words are converted into pinyin, the pinyin is used for calculating the editing distance, and the adjustment characters comprise adding, deleting, replacing characters and the like. The method for adjusting the editing distance cost of the character and the editing distance cost of the keyboard level are known in the prior art, and are not described herein.
In an alternative embodiment of the present invention, the preset cost threshold may be 1.
In the embodiment of the invention, two verification methods of editing distance are used for carrying out secondary confirmation on the error correction part, thereby effectively improving the error correction capability and reducing the probability of correcting the error into another error. And the error parts of the voice errors and the shape errors are treated differently, so that the error correction accuracy is improved. Because the edit distance has high calculation cost, if only the traditional edit distance method is used, words and sentences are input, so that the calculation cost is greatly increased, but the edit distance based on word level is not used, and the calculation efficiency is greatly improved.
According to the method, the template text is marked according to the correctness of the text in the original error correction training text set, a standard error correction training text set with more abundant information can be obtained, the standard error correction training text set is utilized to carry out joint training on a double-stage error correction model comprising a text error recognition model and a text error correction model, the standard error correction model obtained through training is utilized to recognize and correct the text to be corrected, and the accuracy and the efficiency of text error correction are improved. Meanwhile, an error correction pair is constructed based on the corrected text, error correction verification is carried out on the error correction pair by using an edit distance cost method, and as the calculation of the edit distance cost is word-level, the calculation efficiency is greatly improved, and the error correction verification efficiency is also improved. Therefore, the Chinese text error correction and verification method provided by the invention can solve the problem of lower Chinese error correction efficiency.
Fig. 6 is a functional block diagram of a chinese text error correction and verification device according to an embodiment of the present invention.
The apparatus 100 for correcting and verifying chinese text according to the present invention may be installed in an electronic device. Depending on the implemented functionality, the chinese text correction and verification device 100 may include a correction model training module 101, a text correction module 102, a correction type identification module 103, and a correction verification module 104. The module of the invention, which may also be referred to as a unit, refers to a series of computer program segments, which are stored in the memory of the electronic device, capable of being executed by the processor of the electronic device and of performing a fixed function.
In the present embodiment, the functions concerning the respective modules/units are as follows:
the error correction model training module 101 is configured to obtain an original error correction training text set, label a template text according to correctness of a text in the original error correction training text set, obtain a standard error correction training text set, construct a dual-stage error correction model including a text error recognition model and a text error correction model, and perform joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model;
The text correction module 102 is configured to obtain a text to be corrected, and correct the text to be corrected by using the standard correction model to obtain a corrected text;
the error correction type recognition module 103 is configured to construct an error correction pair based on the error corrected text, and perform error correction type recognition on the error correction pair by using a preset classification model to obtain an error correction type;
the error correction verification module 104 is configured to perform error correction verification on the error correction pair by using an edit distance cost method based on the error correction type, so as to obtain an error correction verification result.
In detail, the specific implementation modes of the modules of the chinese text error correction and verification apparatus 100 are as follows:
step one, acquiring an original error correction training text set, and labeling a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set.
In the embodiment of the invention, the original error correction training text set is manually marked text data, and the format is that an error sentence corresponds to a correct sentence, for example, "my biology is good-my body is good". The labeling template text is a labeling text constructed according to the correctness of the sentence, and the template text is 'the sentence is < >', so as to distinguish whether the sentence is correct or not.
In detail, the labeling the template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set includes:
correct labeling is carried out on correct sentences in the original error correction training text set, and error labeling is carried out on error sentences in the original error correction training text set;
and summarizing all sentence texts with completed labels to obtain the standard error correction training text set.
In an embodiment of the present invention, different sentences are labeled with template text, for example, the erroneous sentence is labeled as "the sentence is wrong" and the correct sentence is labeled as "the sentence is correct".
And secondly, constructing a double-stage error correction model comprising a text error recognition model and a text error correction model.
In the embodiment of the invention, the text error recognition model and the text error correction model are mask language models (masked language model, MLM) based on BERT models, wherein the text error recognition model is used for recognizing whether wrongly written words exist in sentences, and the text error correction model is used for correcting misspelled parts.
In detail, the constructing a dual-stage error correction model including a text error recognition model and a text error correction model includes:
Acquiring a first BERT model, and splicing a full connection layer and an output layer after the first BERT model to obtain the text error recognition model;
and obtaining a second BERT model and taking the second BERT model as the text error correction model, and connecting the text error correction models of the text error recognition model machine in series to obtain the double-stage error correction model.
In the embodiment of the invention, the first BERT model is a traditional BERT model, the input is text, words in the text are independently segmented according to the character sequence, and word vectors and [ CLS ] feature vectors can be output through the first BERT model; the fully connected layer consists of two MLPs (a single MLP network structure is shown in the upper diagram, and consists of two linear layers and a ReLu activation function) fully connected network for further extracting features; the output layer includes a sigmoid activation function to calculate the probability of whether there is a spelling error. The input of the second BERT model is a word vector of text and is output as a correct sentence.
And thirdly, performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model.
In the embodiment of the invention, the text of the standard error correction training text set comprises the template text marked based on text correctness, and the accuracy of error correction recognition can be improved through the mask training of the BERT model.
In detail, the training the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model includes:
performing iterative training on the text error recognition model by using the standard error correction training text set;
outputting standard word vectors corresponding to sentences in the standard error correction training text set by using the trained text error recognition model;
copying and combining the standard word vectors, and performing attention training on the text error correction model based on the copied combined word vectors and a preset loss function;
and summarizing the text error recognition model and the text error correction model which are completed by training to obtain the double-stage error correction model.
In the embodiment of the present invention, the preset loss function may be a cross entropy loss function. After a standard word vector corresponding to sentences in a standard error correction training text set is output by using a training-completed text error recognition model, the standard word vector is copied into two parts to serve as Q and K in a second BERT model, and then a result of g x w is used as V, wherein g represents the average value of the word vector, w is a parameter matrix, the matrix size of w is LxD, D is 512 dimensions, and L is the number of words in an input text. And performing self-attention calculation in the second BERT model by using the < Q, K and V >, and performing iterative training on the second BERT model based on the cross entropy loss function to obtain a trained text error correction model.
Specifically, the performing iterative training on the text error recognition model by using the standard error correction training text set includes:
converting sentences in the standard error correction training text set into word vectors by using the first BERT model, and masking preset positions in the word vectors to obtain masked word vectors;
extracting a standard word vector of the mask word vector by using the full connection layer, and outputting a predicted value of the standard word vector by using the output layer;
and calculating a loss value based on the predicted value, if the loss value is greater than or equal to a preset loss threshold value, updating parameters in the first BERT model, and returning to the step of converting sentences in the standard error correction training text set into word vectors by using the first BERT model until the loss value is less than the preset loss threshold value, stopping training, and obtaining a trained text error recognition model.
In an alternative embodiment of the present invention, the text error recognition model is actually a two-class classifier, for example: the 'My organism is well' input into a first BERT model, and the output mask word vector consists of three parts, wherein the first part is a [ CLS ] vector, and the [ CLS ] is used for judging whether a sentence has misspellings; the second is the word vector of each word, and the 'my living body' has 6 words, so that a matrix of 6xD is formed, each row in the matrix represents the word vector of one word, D is 512-dimension, a mean value is calculated for the vector of each word to obtain g, and the g is multiplied by another matrix w, wherein the w is a learnable matrix, namely, the value in the matrix can be updated through each iteration training model, and the matrix can reflect the salient value of each word after learning. Because the probabilities of the words that are likely to be wrong are different for a sentence of input text, "my living good", the "body" of "me" is generally "good" and is less prone to be wrong than "body", while the "body" of "me" is relatively prone to be wrong, this w can learn these regular distributions through training data; the third is the masked template. Namely, the mask word vector output by the first BERT model is: [ CLS ], I, raw, somatic, very good, [ sep ], this sentence, if any, < mask >, [ seq ]. Compared with the traditional BERT model, the vector corresponding to [ CLS ] and [ Masked ] is spliced and then used as a new [ CLS ] vector.
In an alternative embodiment of the present invention, after the [ CLS ] feature vector (i.e., the mask word vector) is obtained, the [ CLS ] feature vector is sent to two MLP fully connected networks, and then the probability of spelling errors is calculated by using a sigmoid activation function, where the [ CLS ] feature vector is output by using a sigmoid function, and the output is a fraction of 0-1, which represents the probability of errors. A threshold of 0.72 may be used, if greater than 0.72, a misspelling is considered, and if less than, no. Meanwhile, a loss value is calculated using a cross entropy loss function.
In an alternative embodiment of the present invention, the calculation of the cross entropy loss function is known in the art, and will not be described herein.
And step four, acquiring a text to be corrected, and correcting the text to be corrected by using the standard correction model to obtain a corrected text.
In the embodiment of the invention, the text to be corrected can be subjected to text error recognition and text correction by using the standard correction model.
Further, the performing error correction on the text to be subjected to error correction by using the standard error correction model to obtain error corrected text, including:
identifying the error probability of the text to be corrected by using a text error identification model in the standard error correction model;
If the error probability is smaller than a preset error threshold, the text to be corrected is not processed;
and if the error probability is greater than or equal to the error threshold, performing text error correction on the text to be subjected to error correction by using a text error correction model in the standard error correction model to obtain an error corrected text.
In an alternative embodiment of the present invention, the error threshold may be 0.72. Meanwhile, only sentences which are identified to have errors are corrected, so that correction of correct sentences is avoided, and the efficiency of text correction is improved.
And fifthly, constructing error correction pairs based on the error corrected text, and identifying error correction types of the error correction pairs by using a preset classification model to obtain error correction types.
In the embodiment of the present invention, the preset classification model may also be a BERT model.
In detail, the constructing the error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain the error correction type, including:
word segmentation processing is carried out on the corrected text and the text to be corrected corresponding to the corrected text;
and extracting the phrase related to error correction after word segmentation to form an error correction pair, and outputting the error correction type of the error correction pair by using the classification model.
In an alternative embodiment of the invention, the corrected text needs to be verified for the second time, the original sentence and the sentence corrected by the double-stage BERT are segmented, the corrected positions (different positions) of the two sentences after segmentation are compared, and the words related to the corrected positions are extracted, so that the specific part of the sentence corrected can be known. The extracted words are again input into the BERT model (i.e., classification model), and the vectors are output via the [ CLS ] of the BERT model. For example, the modification is obtained: original sentence-error correction word, the BERT input is: the [ CLS ] vector is input into softmax for category classification, and the error correction type of the error correction pair can be obtained.
And step six, based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result.
In the embodiment of the invention, the error correction types comprise a first error correction type and a second error correction type, wherein the first error correction type comprises: correction of harmonic words, such as fitting eyes-fitting glasses; the confusing sound word correction, such as wandering boy-cattle boy, the second correction type includes: and correction of the shape-like words, such as sorghum-sorghum.
In detail, the performing error correction verification on the error correction pair by using an edit distance cost method based on the error correction type to obtain an error correction verification result includes:
if the error correction type is the first error correction type, calculating the editing cost of the error correction pair by using an editing distance cost method for adjusting characters;
if the error correction type is the second error correction type, calculating the editing cost of the error correction pair by using a keyboard-level editing distance cost method;
and determining that the error correction verification result of the error correction pair with the editing cost smaller than or equal to the preset cost threshold is error correction success, and determining that the error correction verification result of the error correction pair with the editing cost larger than the preset cost threshold is error correction failure.
In the embodiment of the invention, for the first error correction type, the original sentence words and the error correction words are converted into pinyin, the pinyin is used for calculating the editing distance, and the adjustment characters comprise adding, deleting, replacing characters and the like. The method for adjusting the editing distance cost of the character and the editing distance cost of the keyboard level are known in the prior art, and are not described herein.
In an alternative embodiment of the present invention, the preset cost threshold may be 1.
In the embodiment of the invention, two verification methods of editing distance are used for carrying out secondary confirmation on the error correction part, thereby effectively improving the error correction capability and reducing the probability of correcting the error into another error. And the error parts of the voice errors and the shape errors are treated differently, so that the error correction accuracy is improved. Because the edit distance has high calculation cost, if only the traditional edit distance method is used, words and sentences are input, so that the calculation cost is greatly increased, but the edit distance based on word level is not used, and the calculation efficiency is greatly improved.
According to the method, the template text is marked according to the correctness of the text in the original error correction training text set, a standard error correction training text set with more abundant information can be obtained, the standard error correction training text set is utilized to carry out joint training on a double-stage error correction model comprising a text error recognition model and a text error correction model, the standard error correction model obtained through training is utilized to recognize and correct the text to be corrected, and the accuracy and the efficiency of text error correction are improved. Meanwhile, an error correction pair is constructed based on the corrected text, error correction verification is carried out on the error correction pair by using an edit distance cost method, and as the calculation of the edit distance cost is word-level, the calculation efficiency is greatly improved, and the error correction verification efficiency is also improved. Therefore, the device for correcting and verifying the Chinese text can solve the problem of lower efficiency of Chinese correction.
Fig. 7 is a schematic structural diagram of an electronic device for implementing the method for correcting and verifying chinese text according to an embodiment of the present invention.
The electronic device may comprise a processor 10, a memory 11, a communication interface 12 and a bus 13, and may further comprise a computer program, such as a chinese text error correction and verification program, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, including flash memory, a mobile hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, such as a mobile hard disk of the electronic device. The memory 11 may in other embodiments also be an external storage device of the electronic device, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only for storing application software installed in an electronic device and various types of data, such as codes of chinese text correction and verification programs, but also for temporarily storing data that has been output or is to be output.
The processor 10 may be comprised of integrated circuits in some embodiments, for example, a single packaged integrated circuit, or may be comprised of multiple integrated circuits packaged with the same or different functions, including one or more central processing units (Central Processing Unit, CPU), microprocessors, digital processing chips, graphics processors, combinations of various control chips, and the like. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the entire electronic device using various interfaces and lines, and executes various functions of the electronic device and processes data by running or executing programs or modules (e.g., chinese text error correction and verification programs, etc.) stored in the memory 11, and calling data stored in the memory 11.
The communication interface 12 is used for communication between the electronic device and other devices, including network interfaces and user interfaces. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), typically used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a Display (Display), an input unit such as a Keyboard (Keyboard), or alternatively a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the electronic device and for displaying a visual user interface.
The bus 13 may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The bus 13 may be classified into an address bus, a data bus, a control bus, and the like. The bus 13 is arranged to enable a connection communication between the memory 11 and at least one processor 10 etc.
Fig. 7 shows only an electronic device with components, and it will be understood by those skilled in the art that the structure shown in fig. 7 is not limiting of the electronic device and may include fewer or more components than shown, or may combine certain components, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power source (such as a battery) for supplying power to the respective components, and preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management, and the like are implemented through the power management device. The power supply may also include one or more of any of a direct current or alternating current power supply, recharging device, power failure detection circuit, power converter or inverter, power status indicator, etc. The electronic device may further include various sensors, bluetooth modules, wi-Fi modules, etc., which are not described herein.
Further, the electronic device may also include a network interface, optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), typically used to establish a communication connection between the electronic device and other electronic devices.
Optionally, the electronic device may further comprise a user interface, which may be a Display, an input unit, such as a Keyboard (Keyboard), or a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the electronic device and for displaying a visual user interface.
It should be understood that the embodiments described are for illustrative purposes only and are not limited to this configuration in the scope of the patent application.
The chinese text error correction and verification program stored in the memory 11 of the electronic device is a combination of instructions that, when executed in the processor 10, may implement:
acquiring an original error correction training text set, and labeling a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set;
constructing a double-stage error correction model comprising a text error recognition model and a text error correction model;
Performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model;
obtaining a text to be corrected, correcting the text to be corrected by using the standard correction model, and obtaining a corrected text;
constructing an error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain an error correction type;
and based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result.
In particular, the specific implementation method of the above instructions by the processor 10 may refer to the description of the relevant steps in the corresponding embodiment of the drawings, which is not repeated herein.
Further, the electronic device integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or nonvolatile. For example, the computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM).
The present invention also provides a computer readable storage medium storing a computer program which, when executed by a processor of an electronic device, can implement:
acquiring an original error correction training text set, and labeling a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set;
constructing a double-stage error correction model comprising a text error recognition model and a text error correction model;
performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model;
obtaining a text to be corrected, correcting the text to be corrected by using the standard correction model, and obtaining a corrected text;
constructing an error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain an error correction type;
and based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result.
In the several embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The embodiment of the invention can acquire and process the related data based on the artificial intelligence technology. Among these, artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (4)

1. A method for error correction and verification of chinese text, the method comprising:
acquiring an original error correction training text set, and labeling a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set;
constructing a double-stage error correction model comprising a text error recognition model and a text error correction model;
performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model;
Obtaining a text to be corrected, correcting the text to be corrected by using the standard correction model, and obtaining a corrected text;
constructing an error correction pair based on the error corrected text, and identifying the error correction type of the error correction pair by using a preset classification model to obtain an error correction type;
based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result;
the construction of the double-stage error correction model comprising a text error recognition model and a text error correction model comprises the following steps: acquiring a first BERT model, and splicing a full connection layer and an output layer after the first BERT model to obtain the text error recognition model; obtaining a second BERT model and taking the second BERT model as the text error correction model, and connecting the text error recognition model and the text error correction model in series to obtain the double-stage error correction model;
the training the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model comprises the following steps: performing iterative training on the text error recognition model by using the standard error correction training text set; outputting standard word vectors corresponding to sentences in the standard error correction training text set by using the trained text error recognition model; copying and combining the standard word vectors, and performing attention training on the text error correction model based on the copied combined word vectors and a preset loss function; summarizing the text error recognition model and the text error correction model which are completed by training to obtain the double-stage error correction model;
The iterative training of the text error recognition model using the standard error correction training text set includes: converting sentences in the standard error correction training text set into word vectors by using the first BERT model, and masking preset positions in the word vectors to obtain masked word vectors; extracting a standard word vector of the mask word vector by using the full connection layer, and outputting a predicted value of the standard word vector by using the output layer; calculating a loss value based on the predicted value, if the loss value is greater than or equal to a preset loss threshold value, updating parameters in the first BERT model, and returning to the step of converting sentences in the standard error correction training text set into word vectors by using the first BERT model, until the loss value is less than the preset loss threshold value, stopping training, and obtaining a trained text error recognition model;
and correcting the text to be corrected by using the standard correction model to obtain corrected text, wherein the correcting comprises the following steps: identifying the error probability of the text to be corrected by using a text error identification model in the standard error correction model; if the error probability is smaller than a preset error threshold, the text to be corrected is not processed; if the error probability is greater than or equal to the error threshold, performing text error correction on the text to be corrected by using a text error correction model in the standard error correction model to obtain corrected text;
The step of constructing error correction pairs based on the error corrected text, and performing error correction type identification on the error correction pairs by using a preset classification model to obtain error correction types, comprises the following steps: word segmentation processing is carried out on the corrected text and the text to be corrected corresponding to the corrected text; extracting word groups related to error correction after word segmentation to form error correction pairs, and outputting error correction types of the error correction pairs by utilizing the classification model;
based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result, including: if the error correction type is the first error correction type, calculating the editing cost of the error correction pair by using an editing distance cost method for adjusting characters; if the error correction type is the second error correction type, calculating the editing cost of the error correction pair by using a keyboard-level editing distance cost method; and determining that the error correction verification result of the error correction pair with the editing cost smaller than or equal to the preset cost threshold is error correction success, and determining that the error correction verification result of the error correction pair with the editing cost larger than the preset cost threshold is error correction failure.
2. A chinese text correction and verification apparatus, the apparatus comprising:
The error correction model training module is used for acquiring an original error correction training text set, marking a template text according to the correctness of the text in the original error correction training text set to obtain a standard error correction training text set, constructing a double-stage error correction model comprising a text error recognition model and a text error correction model, and performing joint training on the text error recognition model and the text error correction model by using the standard error correction training text set to obtain the standard error correction model;
the text correction module is used for acquiring a text to be corrected, correcting the text to be corrected by using the standard correction model, and obtaining corrected text;
the error correction type identification module is used for constructing error correction pairs based on the error corrected text, and carrying out error correction type identification on the error correction pairs by utilizing a preset classification model to obtain error correction types;
the error correction verification module is used for carrying out error correction verification on the error correction pair by utilizing an edit distance cost method based on the error correction type to obtain an error correction verification result;
the construction of the double-stage error correction model comprising a text error recognition model and a text error correction model comprises the following steps: acquiring a first BERT model, and splicing a full connection layer and an output layer after the first BERT model to obtain the text error recognition model; obtaining a second BERT model and taking the second BERT model as the text error correction model, and connecting the text error recognition model and the text error correction model in series to obtain the double-stage error correction model;
The training the text error recognition model and the text error correction model by using the standard error correction training text set to obtain a standard error correction model comprises the following steps: performing iterative training on the text error recognition model by using the standard error correction training text set; outputting standard word vectors corresponding to sentences in the standard error correction training text set by using the trained text error recognition model; copying and combining the standard word vectors, and performing attention training on the text error correction model based on the copied combined word vectors and a preset loss function; summarizing the text error recognition model and the text error correction model which are completed by training to obtain the double-stage error correction model;
the iterative training of the text error recognition model using the standard error correction training text set includes: converting sentences in the standard error correction training text set into word vectors by using the first BERT model, and masking preset positions in the word vectors to obtain masked word vectors; extracting a standard word vector of the mask word vector by using the full connection layer, and outputting a predicted value of the standard word vector by using the output layer; calculating a loss value based on the predicted value, if the loss value is greater than or equal to a preset loss threshold value, updating parameters in the first BERT model, and returning to the step of converting sentences in the standard error correction training text set into word vectors by using the first BERT model, until the loss value is less than the preset loss threshold value, stopping training, and obtaining a trained text error recognition model;
And correcting the text to be corrected by using the standard correction model to obtain corrected text, wherein the correcting comprises the following steps: identifying the error probability of the text to be corrected by using a text error identification model in the standard error correction model; if the error probability is smaller than a preset error threshold, the text to be corrected is not processed; if the error probability is greater than or equal to the error threshold, performing text error correction on the text to be corrected by using a text error correction model in the standard error correction model to obtain corrected text;
the step of constructing error correction pairs based on the error corrected text, and performing error correction type identification on the error correction pairs by using a preset classification model to obtain error correction types, comprises the following steps: word segmentation processing is carried out on the corrected text and the text to be corrected corresponding to the corrected text; extracting word groups related to error correction after word segmentation to form error correction pairs, and outputting error correction types of the error correction pairs by utilizing the classification model;
based on the error correction type, performing error correction verification on the error correction pair by using an edit distance cost method to obtain an error correction verification result, including: if the error correction type is the first error correction type, calculating the editing cost of the error correction pair by using an editing distance cost method for adjusting characters; if the error correction type is the second error correction type, calculating the editing cost of the error correction pair by using a keyboard-level editing distance cost method; and determining that the error correction verification result of the error correction pair with the editing cost smaller than or equal to the preset cost threshold is error correction success, and determining that the error correction verification result of the error correction pair with the editing cost larger than the preset cost threshold is error correction failure.
3. An electronic device, the electronic device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the chinese text error correction and verification method of claim 1.
4. A computer readable storage medium storing a computer program which when executed by a processor implements a chinese text error correction and verification method according to claim 1.
CN202210824618.4A 2022-07-13 2022-07-13 Chinese text error correction and verification method, device, equipment and storage medium Active CN115169330B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210824618.4A CN115169330B (en) 2022-07-13 2022-07-13 Chinese text error correction and verification method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210824618.4A CN115169330B (en) 2022-07-13 2022-07-13 Chinese text error correction and verification method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115169330A CN115169330A (en) 2022-10-11
CN115169330B true CN115169330B (en) 2023-05-02

Family

ID=83493177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210824618.4A Active CN115169330B (en) 2022-07-13 2022-07-13 Chinese text error correction and verification method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115169330B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012039686A1 (en) * 2010-09-24 2012-03-29 National University Of Singapore Methods and systems for automated text correction
CN111626047A (en) * 2020-04-23 2020-09-04 平安科技(深圳)有限公司 Intelligent text error correction method and device, electronic equipment and readable storage medium
CN112016310A (en) * 2020-09-03 2020-12-01 平安科技(深圳)有限公司 Text error correction method, system, device and readable storage medium
CN112329476A (en) * 2020-11-11 2021-02-05 北京京东尚科信息技术有限公司 Text error correction method and device, equipment and storage medium
CN112836496A (en) * 2021-01-25 2021-05-25 之江实验室 Text error correction method based on BERT and feedforward neural network
CN113177405A (en) * 2021-05-28 2021-07-27 中国平安人寿保险股份有限公司 Method, device and equipment for correcting data errors based on BERT and storage medium
CN113807973A (en) * 2021-09-16 2021-12-17 平安科技(深圳)有限公司 Text error correction method and device, electronic equipment and computer readable storage medium
CN113887200A (en) * 2021-09-29 2022-01-04 平安银行股份有限公司 Text variable-length error correction method and device, electronic equipment and storage medium
CN114154486A (en) * 2021-11-09 2022-03-08 浙江大学 Intelligent error correction system for Chinese corpus spelling errors
CN114417834A (en) * 2021-12-24 2022-04-29 深圳云天励飞技术股份有限公司 Text processing method and device, electronic equipment and readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11886812B2 (en) * 2020-03-02 2024-01-30 Grammarly, Inc. Proficiency and native language-adapted grammatical error correction

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012039686A1 (en) * 2010-09-24 2012-03-29 National University Of Singapore Methods and systems for automated text correction
CN111626047A (en) * 2020-04-23 2020-09-04 平安科技(深圳)有限公司 Intelligent text error correction method and device, electronic equipment and readable storage medium
CN112016310A (en) * 2020-09-03 2020-12-01 平安科技(深圳)有限公司 Text error correction method, system, device and readable storage medium
CN112329476A (en) * 2020-11-11 2021-02-05 北京京东尚科信息技术有限公司 Text error correction method and device, equipment and storage medium
CN112836496A (en) * 2021-01-25 2021-05-25 之江实验室 Text error correction method based on BERT and feedforward neural network
CN113177405A (en) * 2021-05-28 2021-07-27 中国平安人寿保险股份有限公司 Method, device and equipment for correcting data errors based on BERT and storage medium
CN113807973A (en) * 2021-09-16 2021-12-17 平安科技(深圳)有限公司 Text error correction method and device, electronic equipment and computer readable storage medium
CN113887200A (en) * 2021-09-29 2022-01-04 平安银行股份有限公司 Text variable-length error correction method and device, electronic equipment and storage medium
CN114154486A (en) * 2021-11-09 2022-03-08 浙江大学 Intelligent error correction system for Chinese corpus spelling errors
CN114417834A (en) * 2021-12-24 2022-04-29 深圳云天励飞技术股份有限公司 Text processing method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN115169330A (en) 2022-10-11

Similar Documents

Publication Publication Date Title
CN114822812A (en) Character dialogue simulation method, device, equipment and storage medium
CN113051356B (en) Open relation extraction method and device, electronic equipment and storage medium
CN113378970B (en) Sentence similarity detection method and device, electronic equipment and storage medium
CN113807973B (en) Text error correction method, apparatus, electronic device and computer readable storage medium
CN112507663A (en) Text-based judgment question generation method and device, electronic equipment and storage medium
CN114511038A (en) False news detection method and device, electronic equipment and readable storage medium
CN115238115A (en) Image retrieval method, device and equipment based on Chinese data and storage medium
CN113743101B (en) Text error correction method, apparatus, electronic device and computer storage medium
CN113344125B (en) Long text matching recognition method and device, electronic equipment and storage medium
CN113360654B (en) Text classification method, apparatus, electronic device and readable storage medium
CN113704393A (en) Keyword extraction method, device, equipment and medium
CN116450829A (en) Medical text classification method, device, equipment and medium
CN116821373A (en) Map-based prompt recommendation method, device, equipment and medium
CN116701574A (en) Text semantic similarity calculation method, device, equipment and storage medium
CN114757154B (en) Job generation method, device and equipment based on deep learning and storage medium
CN116665878A (en) Intelligent inquiry method, device, equipment and storage medium for improving accumulated errors
CN116341646A (en) Pretraining method and device of Bert model, electronic equipment and storage medium
CN116468025A (en) Electronic medical record structuring method and device, electronic equipment and storage medium
CN116501846A (en) Open dialogue method, device, electronic equipment and medium
CN115169330B (en) Chinese text error correction and verification method, device, equipment and storage medium
CN114610855A (en) Dialog reply generation method and device, electronic equipment and storage medium
CN115146064A (en) Intention recognition model optimization method, device, equipment and storage medium
CN115346095A (en) Visual question answering method, device, equipment and storage medium
CN114298032A (en) Text punctuation detection method, computer device and storage medium
CN112749264A (en) Problem distribution method and device based on intelligent robot, electronic equipment 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