Punctuation mark misuse detection and correction method, device, equipment and storage medium
By conducting multiple detection and analysis of the detected text, combining error correction models, acoustic models and preset rule databases, automated detection and correction of misuse of punctuation marks, the problem of inefficiency in the existing technology is solved and efficient and accurate error correction results are achieved.
Patent Information
- Application Number
- CN202210474457.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-04-29
AI Technical Summary
In the prior art, the detection and correction of misuse of punctuation marks mainly relies on manual labor, resulting in inefficiency. In the case of machine input and voice input, the misuse situation is complex, and existing methods are difficult to effectively solve.
A method for detecting and correcting punctuation misuse is proposed. By inputting the text to be detected to the trained error correction model for first detection, the first prediction correction result of multiple positions is obtained, and the detection method of the second detection is determined based on the result, including an acoustic model and a preset rule library, the second detection is performed, and the target correction result is finally determined based on the multiple prediction results.
Automatic detection and correction of punctuation misuse is realized. Compared with manual error correction, manpower and time are saved, and error correction efficiency and accuracy are improved.
Smart Images

Figure CN115099222B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically to a method, device, equipment and storage medium for detecting and correcting misuse of punctuation marks. Background Art
[0002] With the development of information technology, more and more information is presented in the form of text. Punctuation marks in texts play a role in indicating pauses and tone, and can assist in indicating the components of sentences / phrases / words, helping to understand the text content and eliminate lexical ambiguity. However, in some scenarios, punctuation marks may be misused in texts. For example, modern text input is usually machine input (i.e. typing through devices such as computers or mobile phones) or voice input. Typing input often results in punctuation marks being accidentally touched; and voice input has problems such as missing punctuation marks.
[0003] Currently, manual error correction is mostly used to detect and correct incorrect punctuation marks in texts. However, manual error correction consumes a lot of manpower and time and is inefficient.
[0004] Therefore, improvements are needed to solve the above problems. Summary of the invention
[0005] In view of the above problems, the present application provides a method for detecting and correcting misuse of punctuation marks, the method comprising the following steps:
[0006] Input the acquired text to be detected into the trained error correction model for a first detection to obtain first predicted correction results of multiple positions, wherein the first predicted correction results include a modification operation type predicted to be performed on each position and a predicted corrected punctuation type corresponding to each position;
[0007] Determine, based on the modification operation type predicted to be performed at each of the positions, a detection mode of a second detection to be performed at each of the positions, wherein the detection mode includes at least two detection modes;
[0008] Performing a second detection based on the determined detection method to obtain a second prediction correction result for each of the positions;
[0009] A target correction result for each of the positions is determined based on the first predicted correction result and / or the second predicted correction result corresponding to each of the positions.
[0010] In one embodiment, the at least two detection methods include detection method one and detection method two, wherein detection method one includes detecting the positions among the multiple positions whose modification operation type is insertion based on an acoustic model, and detection method two includes detecting the positions among the multiple positions whose modification operation type is other operations except the insertion based on a preset rule base.
[0011] In one embodiment, when the determined detection mode is the detection mode 1, performing a second detection based on the determined detection mode to obtain a second prediction correction result for each of the positions includes:
[0012] Converting at least part of the preceding text before the position where the modification operation type is insert into a speech signal;
[0013] The speech signal is input into the acoustic model for detection to obtain the second prediction and correction result.
[0014] In one embodiment, the step of inputting the speech signal into the acoustic model for detection to obtain the second prediction and correction result includes:
[0015] Extracting pause duration and prosodic features from the speech signal based on the acoustic model;
[0016] Based on the length of the pause and the rhythmic feature, the second prediction correction result is obtained, and the second prediction correction result includes one or more punctuation mark types that can be inserted into the predicted corresponding position.
[0017] In one embodiment, the first prediction correction result includes a plurality of candidate prediction results and a first probability corresponding to each of the candidate prediction results, the second prediction correction result includes the plurality of candidate prediction results and a second probability corresponding to each of the candidate prediction results, and determining the target correction result for each of the positions based on the first prediction correction result and the second prediction correction result corresponding to each of the positions includes:
[0018] Multiplying the first probability corresponding to each of the candidate prediction results by a first preset weight to obtain a first estimated probability corresponding to each of the candidate prediction results;
[0019] Multiplying the second probability corresponding to each of the candidate prediction results by a second preset weight to obtain a second estimated probability corresponding to each of the candidate prediction results;
[0020] The first estimated probability and the second estimated probability corresponding to the candidate prediction results having the same punctuation mark type are added together to obtain the prediction probability corresponding to each of the candidate prediction results, wherein the target correction result is the candidate prediction result with the highest prediction probability.
[0021] In one embodiment, when the determined detection mode is the second detection mode, performing a second detection based on the determined detection mode to obtain a second prediction correction result for each of the positions includes:
[0022] Modify the position whose modification operation type is other than the insert operation according to the first prediction correction result to obtain a modified text;
[0023] Matching the modified text with the rules in the preset rule library to obtain one or more rules matching the modified text;
[0024] Based on one or more rules, the correctness of the modified text is scored, and the second predicted correction result includes the score, wherein the score is determined based on the proportion of the one or more rules that characterize the modified text as correct.
[0025] In one embodiment, scoring the correctness of the modified text based on one or more rules includes:
[0026] The proportion of the one or more rules that represent the correctness of the modified text is calculated, and the score is represented by the proportion.
[0027] In one embodiment, the first prediction correction result includes a plurality of candidate prediction results and a first probability corresponding to each of the candidate prediction results, and determining a target correction result for each of the positions based on the first prediction correction result and the second prediction correction result corresponding to each of the positions includes:
[0028] Multiplying the first probability corresponding to each of the candidate prediction results by a third preset weight to obtain a third estimated probability corresponding to each of the candidate prediction results;
[0029] Multiplying the score corresponding to each of the candidate prediction results by a fourth preset weight to obtain a fourth estimated probability corresponding to each of the candidate prediction results;
[0030] The first estimated probability and the second estimated probability corresponding to the candidate prediction results having the same punctuation mark type are added together to obtain the prediction probability corresponding to each of the candidate prediction results, wherein the target correction result is the candidate prediction result with the highest prediction probability.
[0031] On the other hand, the present application also provides a device for detecting and correcting misuse of punctuation marks, the device comprising:
[0032] A first detection module, used for inputting the acquired text to be detected into a trained error correction model for a first detection to obtain first predicted correction results of multiple positions, wherein the first predicted correction results include a modification operation type predicted to be performed on each position and a predicted corrected punctuation type corresponding to each position;
[0033] A detection mode determination module, used to determine a detection mode of a second detection to be performed at each of the positions based on the modification operation type predicted to be performed at each of the positions, wherein the detection mode includes at least two detection modes;
[0034] A second detection module, configured to perform a second detection based on the determined detection method to obtain a second prediction correction result for each of the positions;
[0035] The target correction result determination module is used to determine the target correction result of each position based on the first predicted correction result and / or the second predicted correction result corresponding to each position.
[0036] On the other hand, the present application also provides a device for detecting and correcting the misuse of punctuation marks, the device comprising a memory and a processor, the memory storing a computer program executed by the processor, and the computer program, when executed by the processor, causes the processor to execute the aforementioned method for detecting and correcting the misuse of punctuation marks.
[0037] Another aspect of the present application is a storage medium having a computer program stored thereon, and when the computer program is run, the aforementioned punctuation mark misuse detection and correction method is executed.
[0038] In order to solve the current technical problems, the present application provides a method, device, equipment and storage medium for detecting and correcting the misuse of punctuation marks. Through the method for detecting and correcting the misuse of punctuation marks of the present application, the text to be detected can be detected through an error correction model to obtain a first predicted correction result, and a target correction result can be obtained based on the first predicted correction result, or based on the first predicted correction result and the second predicted correction result. Based on the above scheme, the punctuation marks of the text to be detected can be corrected according to the target correction result, and compared with the manual error correction method, it can save manpower and time, and thus improve the error correction efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The following drawings of the present application are hereby used as part of the present application for understanding the present application. The drawings show the embodiments of the present application and their descriptions, and are used to explain the device and principle of the present application. In the drawings,
[0040] Figure 1 A schematic flowchart of a method for detecting and correcting misuse of punctuation marks according to an embodiment of the present application is shown.
[0041] Figure 2 A schematic diagram showing an example of pre-training input of a multi-domain language model for punctuation proofreading according to an embodiment of the present application.
[0042] Figure 3 An exemplary schematic diagram of an error correction model structure for punctuation error correction according to an embodiment of the present application is shown.
[0043] Figure 4 A schematic block diagram of a device for detecting and correcting misuse of punctuation marks according to an embodiment of the present application is shown.
[0044] Figure 5 A schematic block diagram of a device for detecting and correcting misuse of punctuation marks according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of the present application more obvious, the example embodiments according to the present application will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application, and it should be understood that the present application is not limited to the example embodiments described herein. Based on the embodiments of the present application described in the present application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of the present application.
[0046] The applicant of this application has found that among the current related technologies, the technology for punctuation marks is firstly the text punctuation completion technology in the field of natural language processing. Secondly, in the field of speech signal processing, there are also related speech transcription, sentence segmentation and punctuation prediction technologies. In the field of natural language processing, punctuation prediction can be performed using text features through sequence annotation. In the field of speech signal processing, punctuation prediction is usually performed when converting semantic signals into text based on acoustic features, that is, prediction is performed based on special signals such as pauses or rhythms of the speaker in the speech signal. Based on the above two types of features, common punctuation prediction technologies can be divided into the following categories:
[0047] 1) Prediction method based on natural language processing
[0048] In the field of Natural Language Processing (NLP), the methods for predicting punctuation can be divided into two categories: rule-based punctuation prediction and model-based punctuation prediction. Rule-based punctuation proofreading can only determine whether a very small number of punctuation marks are correct, such as detecting symbol redundancy in "," and detecting missing "》" in "xxx《xxx". Model-based methods are mainly implemented by language model models or sequence labeling models. Language models can predict whether a word needs to be connected with punctuation marks and what kind of punctuation marks to connect based on the punctuation distribution characteristics of the training corpus; sequence labeling models can predict the correct characters (including text, punctuation, etc.) at a certain position, and whether a certain position should be segmented. In addition, the structure of the machine translation model (encoder-decoder structure) can be used to manually construct a large number of parallel corpora to convert the punctuation prediction task into a translation task from the source language (without punctuation) to the target language (with punctuation).
[0049] However, the natural language processing method has the following disadvantages: (1) The rule-based method has strict matching conditions and high error detection accuracy, but it cannot correct errors, such as whether "," should be changed to "," or ";" or other symbols; where should the missing "》" in "xxx《xxx" be added? (2) The language model-based method relies on training corpus. The language model mainly learns the distribution of text. The punctuation marks in most corpus data account for less than 5%, and the use of punctuation marks is closely related to the field type. If it is to be used in a field different from the training corpus, it will not be suitable, and there will be a large number of false positives, and the generalization performance will be poor. (3) The method based on machine translation tasks requires manual annotation of the transcribed data, which is too costly. At the same time, a large amount of data will also limit the efficiency of the model and the amount of computing resources consumed, limiting the application scenarios and usage effects of the model in reality.
[0050] 2) Prediction method based on acoustic signal processing
[0051] This method predicts punctuation marks based on the acoustic signal features such as pauses and rhythms of the speaker when speaking, and combines them with algorithms such as the Hidden Markov Model (HMM). It can predict punctuation marks with obvious features such as "," "." "!" "?" based on the length of pauses, intonation and other characteristics.
[0052] However, the acoustic signal processing method has the following disadvantages: (1) Although punctuation marks and the length of pauses in speech information are related, there is no fixed and inevitable connection. They can only be used as a reference for prediction. In addition, the characteristics of speech speed and rhythm will also change according to the speaker's context, speaker's emotions and other external factors. Therefore, the accuracy of predicting punctuation marks based on acoustic signal features is low. (2) Since the only information available in a single acoustic signal is pauses, speech speed, rhythm, etc., it is impossible to distinguish most of the punctuation marks in the sentence (such as ",",",",";,",":", etc.). (3) Some punctuation marks that have no effect on these features or have a small impression when reading aloud (such as "《","》,"
","
[0053] 3) Prediction method combining acoustic features and text semantic features
[0054] This method combines acoustic signal features and text semantic features and is mainly used in the field of speech transcription. First, it is necessary to use Automatic Speech Recognition (ASR) technology to transcribe the speech text into text form, and then insert punctuation marks into the transcribed text through language model prediction. Since the two tasks are combined, the model training process is cumbersome, this method is prone to error cascading, and training corpus is difficult to obtain.
[0055] Based on the above problems, Figure 1 As shown, the present application provides a method 100 for detecting and correcting punctuation mark misuse, the method comprising the following steps:
[0056] Step S110, inputting the acquired text to be detected into the trained error correction model for a first detection to obtain first predicted correction results of multiple positions, wherein the first predicted correction results include a modification operation type predicted to be performed on each position and a predicted corrected punctuation type corresponding to each position;
[0057] Step S120, determining a detection mode of a second detection to be performed at each of the positions based on the modification operation type predicted to be performed at each of the positions, wherein the detection mode includes at least two detection modes;
[0058] Step S130, performing a second detection based on the determined detection method to obtain a second prediction correction result for each of the positions;
[0059] Step S140: determining a target correction result for each of the positions based on the first predicted correction result and / or the second predicted correction result corresponding to each of the positions.
[0060] In one embodiment of the present application, the text to be detected may be text input by machine (i.e., typing input through a device such as a computer or a mobile phone) or voice input.
[0061] The text to be detected includes: one or more characters of languages of various countries such as Chinese characters, English characters, Korean characters, Japanese characters, etc. The text to be detected also includes punctuation marks.
[0062] In one embodiment, in step S110, the trained error correction model can be used to detect the misuse of punctuation marks in the text to be detected, and output the first predicted correction results of multiple positions, wherein the first predicted correction result can predict the type of modification operation to be performed on each of the positions, and the type of punctuation marks predicted after correction corresponding to each of the positions. Optionally, the trained error correction model can also output the first probability corresponding to the first predicted correction result while outputting the first predicted correction result. In some embodiments, the first predicted correction result can include multiple candidate prediction results, each of which corresponds to a first probability. Optionally, the multiple candidate prediction results can be all the results output by the error correction model detection, or multiple candidate prediction results with a first probability greater than a preset probability. The preset probability is reasonably set according to actual needs, for example, the preset probability can be greater than or equal to 0.5. In other embodiments, the first predicted correction result can also include a candidate prediction result, which can be a candidate prediction result with a first probability greater than a preset probability, or a candidate prediction result can be a candidate prediction result with the largest first probability.
[0063] The trained error correction model may adopt a model commonly used in natural language processing, including but not limited to a bidirectional encoder representation model based on transformers (Bidirectional Encoder Representation from Transformers, referred to as Bert) and other models that can be used for punctuation error correction.
[0064] The following describes the training process of the error correction model. In order to train the error correction model, first, error correction labels of different fields can be obtained. The error correction labels are obtained according to the punctuation type, the punctuation modification operation, and the field to which the data belongs. The punctuation type distinguishes between full-width and half-width. For text data belonging to the same field, a unified symbol can be used as a sign signal, while different fields can have different symbols, which can be divided into general (G), humanities (L), medicine (M), engineering (E), and science (S).
[0065] In the labeling system and training process of this application, the punctuation characteristics and error distribution of different fields may be different. In subsequent training, the model will learn from the data to automatically judge the field and language characteristics of the input corpus, so as to adopt the correct strategy for detection and correction.
[0066] For example, in a specific example, punctuation marks need to have the following characteristics: (1) Distinguish between full-width and half-width characters, including commas, periods, exclamation marks, question marks, colons, semicolons, tildes, and hyphens, a total of 16 characters; (2) Distinguish between left and right characters, including curly brackets, solid square brackets, hollow square brackets, hexagonal brackets, angle brackets, book title marks, and single book title marks, a total of 14 characters; (3) Distinguish between full-width and half-width characters and left and right characters, including parentheses, single quotation marks, and double quotation marks, a total of 12 characters; as well as commas, ellipsis marks, dashes, separators (·), emphasis marks (.), and hyphens (-), a total of 48 common punctuation marks. These symbols are combined into a list and numbered starting from 1 to form the symbol part of the label. The modification operations include four types: insert (A), delete (D), replace (R), and retain (K). Among them, delete (N) and retain (K) do not distinguish between punctuation types, so the punctuation prefixes of these two types of operations are recorded as 0. The fields to which the data belongs can be divided into general (G), humanities (L), medicine (M), engineering (E), and science (S). According to the above definition, a punctuation correction label can be 1-AL (humanities data, insert punctuation No. 1 at the current position), 0-DG (general data, delete the punctuation at the current position), etc. Since deletion (D), replacement (R), and retention (K) are all marked at the position of punctuation marks, and insertion (A) is marked at the position of text such as Chinese characters (i.e., inserting a punctuation at the current Chinese character position), Chinese characters that do not involve punctuation modification are all recorded as N. Based on the above principles, the error correction label system contains a total of 491 labels, for example, including 48 punctuation marks * 2 types of operations (A, R) * 5 types of data, 2 types of operations (K, D) * 5 types of data and 1 Chinese character label. In one embodiment of the present application, the error correction label system will be used for training.
[0067] Furthermore, the training of the error correction model may also include a process of generating training data, wherein the model training data may be constructed based on the aforementioned error correction label system. For example, the training data may be divided into two types of data, language model training data and error correction model training data. Among them, the training data of the language model is obtained through error correction labels and masking of the acquired corpus data in various fields, for example, a masking mechanism is set according to punctuation marks. Since the language model is a model for punctuation correction tasks, it is necessary to focus on learning the usage habits of punctuation marks. Therefore, the masking probability of punctuation marks is greater than the masking probability of text such as Chinese characters. Specifically, taking the text of Chinese characters as an example, we can first collect corpus data in various fields, recorded as The training data of the language model obtained after processing is recorded as The construction rule is: for any Chinese character c, 10% is replaced by other Chinese characters and 10% is replaced by [mask]; the specific masking rule for any punctuation mark x is as follows:
[0068] (1) 30% probability remains unchanged;
[0069] (2) 20% probability of replacing with “[mask]”. Since the number of dots in a text is usually greater than that of symbols, in this operation of replacing with [mask], the number of symbols replaced is less than the number of dots replaced. For example, the ratio of replaced symbols to dots is set to 1:2, or other suitable ratios.
[0070] (3) 50% probability of replacing with other punctuation marks. In order for the model to simulate the distribution of punctuation mark errors in real scenarios, in this step of replacement operation, it is necessary to further divide the replaced punctuation marks according to their categories. At this time, the ratio of marks and periods in the replaced punctuation marks can be 1:1. Among the replaced marks, 40% are replaced with periods; among the remaining 60%, 50% are replacements between single and double quotation marks, various brackets, and single and double book title marks; 25% of the probability is to replace the above symbols with other marks; and the remaining 25% is to replace the above symbols with periods. Among the replaced periods, the distribution ratio of replaced mid-sentence punctuation marks and sentence-end punctuation marks is not interfered. However, each mid-sentence punctuation mark has a 70% probability of being replaced with other mid-sentence punctuation marks and a 30% probability of being replaced with a sentence-end punctuation mark; each sentence-end punctuation mark has a 50% probability of being replaced with other sentence-end punctuation marks and a 50% probability of being replaced with a sentence-midpoint punctuation mark. The training data of the language model is generated based on the above-mentioned masking rules, wherein the above-mentioned masking rules can be modified or changed under reasonable circumstances.
[0071] As for the training data used to train the error correction model (remember ) It can be data with punctuation errors obtained by processing the original corpus data in various different fields. The original corpus data is correct data, that is, it has no incorrect punctuation or Chinese characters, etc. The modification operations of various punctuation marks in the data with punctuation errors are evenly distributed. The punctuation mark modification operations include insertion, deletion, replacement, and retention, and can be constructed in the following exemplary manner. When constructing, it is necessary to ensure that the distribution of each error type is balanced, and the punctuation errors corresponding to the modification operations of various punctuation marks in the data with punctuation errors are evenly distributed. The punctuation mark modification operations include insertion (A), deletion (D), replacement (R), and retention (K), that is, A:R:D:K = 1:1:1:1. When constructing, the original data is considered correct data, and the constructed data is data with punctuation errors. The purpose of model training is to input data with punctuation errors and predict the correct punctuation marks. Therefore, the label needs to indicate the correct punctuation mark modification operation according to the original text (that is, the original corpus data). When constructing the training data (also called pseudo-data) of the error correction model, corresponding errors need to be introduced according to the A / R / D / K type. In one embodiment, taking the corpus data of Chinese characters as an example, the specific construction operations are as follows:
[0072] (1) The insertion operation (A) is a label for Chinese characters or punctuation marks. When constructing data for the A operation, the current punctuation mark needs to be deleted, and a label needs to be made on the character in the previous position. For example, deleting the “。” in the correct sentence “It's a nice day today.” and constructing a sentence missing a full stop, then a label needs to be made at the position of “good” as I。-A-G (taking the general field as an example, I。 is the identity (Identification, id) label of “。” in the punctuation system. In this way, when using the error correction model, the wrong sentence “It's a nice day today” can be corrected to “It's a nice day today.” according to the predicted label.
[0073] (2) The replacement operation (R) is a label for punctuation marks. Replace the punctuation mark at the current position. The specific replacement rule is generally the same as the description (3) when constructing above. For example, replacing the “,” (correct symbol) in the general text with “;” (wrong symbol), then the label at this position is I,-R-G, where I, is the id of “,” (correct symbol) in the punctuation system. When constructing, it is necessary to ensure that the distribution of each error type is balanced, and the punctuation errors corresponding to the modification operations of various punctuation marks in the data with punctuation errors are evenly distributed. The punctuation mark modification operations include insertion (A), deletion (D), replacement (R), and retention (K), that is, A:R:D:K = 1:1:1:1. When constructing, the original data is considered correct data, and the constructed data is data with punctuation errors. The purpose of model training is to input data with punctuation errors and predict the correct punctuation marks. Therefore, the label needs to indicate the correct punctuation mark modification operation according to the original text (that is, the original corpus data). When constructing the training data (also called pseudo-data) of the error correction model, corresponding errors need to be introduced according to the A / R / D / K type. In one embodiment, taking the corpus data of Chinese characters as an example, the specific construction operations are as follows:
[0074] (3) The deletion operation (D) is a label for punctuation marks. It indicates that the punctuation mark at this position needs to be deleted. When constructing data, an arbitrary punctuation mark needs to be inserted at the current position, and this punctuation mark is labeled as 0-D-G (taking the general field as an example).
[0075] (4) The retention operation (K) is a label for punctuation marks, which means that the original punctuation marks in the original corpus data are retained without modification.
[0076] Furthermore, after the above training data is constructed, the error correction model can be inspected based on the above training data. For example, the error correction model is obtained by training on the basis of the trained language model. For example, first, a multi-domain language model for punctuation proofreading can be trained based on the training data of the aforementioned language model, wherein the training process is substantially the same as the training process of BERT, and a [T-TYPE] sequence of length t (i.e., t [T-TYPE] symbols) is concatenated at the end of the sentence of the output layer of the language model to guide the next step of the error correction model to learn to distinguish data domains during training, and reserve the encoding position of the data domain vector representation for it, such as Figure 2 The following is an exemplary input of a language model.
[0077] The error correction model is trained on the basis of the trained language model. Its training process is similar to the sequence-to-sequence training method based on BERT. In addition to the sequence-to-sequence training task, an additional domain classification task is added. The error correction model also includes an output layer for classifying the domain of the text to be detected. An output layer is added, such as Figure 3 As shown, the data domain vector representation is learned through the [T-TYPE] sequence of length t, and the predicted G / L / M / E / S classification results are output, that is, the trained error correction model can also be used to classify the data domain to which the text to be detected belongs, and output the classification result of the domain type prediction. The first predicted error correction result may include the classification result of the domain to which the data of the text to be detected belongs, and also includes an error correction label prediction. The error correction label prediction includes the modification operation type predicted to be performed on each of the said positions, and the predicted corrected punctuation type corresponding to each of the said positions.
[0078] Further, in step S120, based on the modification operation type predicted to be performed at each of the positions, a detection method of the second detection to be performed at each of the positions is determined, and the detection method includes at least two detection methods.
[0079] In step S120, since the first predicted correction result is output in step S110, and the first predicted correction result can be, for example, an output result based on the aforementioned error correction label system, some subsequent detection or processing can be performed according to the error correction label system. For example, for a certain position in the text, the corresponding first predicted correction result is 1-AL (humanities data, insert punctuation mark 1 at the current position), based on which it can be obtained that the modification operation type predicted to be performed on the position is insertion, and for another position, the corresponding first predicted correction result is 0-DG (general data, delete the punctuation mark at the current position), based on which it can be obtained that the modification operation type predicted to be performed on the position is deletion, and so on. In the case where the first predicted correction result includes multiple candidate prediction results, the modification operation types corresponding to the multiple candidate prediction results may be the same, while the punctuation mark types may be different.
[0080] It is worth mentioning that when the language model is trained, the model can automatically judge the domain and language characteristics of the input corpus from the data, so that the error correction model can adopt the correct strategy for detection and correction. In some embodiments, the function of the error correction model of the present application for classifying the domain to which the data belongs can be selectively set, and the error correction model can be a neural network model. The method of the present application can also include detecting the input operation of the domain to which the data of the text to be detected input by the user belongs, and calling the neurons adapted to the domain in the error correction model for detection according to the domain to which the data belongs represented by the input operation, so as to make the output of the first predicted correction result more accurate.
[0081] In some embodiments, at least two detection methods include detection method one and detection method two, wherein detection method one includes detecting the positions among the multiple positions where the modification operation type is insertion based on an acoustic model, and detection method two includes detecting the positions among the multiple positions where the modification operation type is other operations other than insertion (for example, deletion (D), replacement (R), retention (K)) based on a preset rule base. Some details about detection method one and detection method two will be described below.
[0082] The preset rule base may be a preconfigured rule base, which may have an editable interface to enable deletion of invalid rules, overwriting of modified rules, insertion of new rules, etc., so as to adapt to rule changes and update the preset rule base when the rules change.
[0083] In some embodiments, the preset rule base can be configured based on the following methods. For example, the rule base can be constructed based on regular expressions, that is, the existing text rules are recorded using regular expressions and stored in the rule base as initialization data. The rules in this article are rules that combine punctuation marks and Chinese characters, such as:
[0084] “(?:\d{1,2}:\d{1,2}([-~]+)\d{1,2}:\d{1,2})|(?:[\d\uFF10-\uFF19]+[year, day, month]?([-~]+)[\d\uFF10-\uFF19]+[year, day, month][from within]{0,2})”
[0085] This is one of the rules for detecting the misuse of the hyphen (-) and the tilde (~). The specific text version is:
[0086] When indicating the start and end range of time, use '-' (a straight line) instead of a hyphen (-) or a tilde (~).
[0087] The rule-based punctuation prediction mainly predicts and proofreads around the official punctuation usage specifications, such as "Punctuation Usage (GB / T15834-2011)" and "National Standard for the Format of Official Documents of Party and Government Agencies (2012 Edition)". First, the usage specifications need to be edited into a vocabulary or rule table / rule base (similar to the above example) through regular expressions, and then an automatic state machine or other matching algorithm is used to match the text to be checked, so as to find the punctuation marks in the text that do not meet the specifications and correct them. In this application, corrections can be made in combination with the first prediction correction result. Since most rules only describe the misuse of punctuation, it is impossible to correct them according to the rules. The correction of these errors needs to rely on the prediction results of the model. In order to simultaneously ensure the accuracy and recall rate of misuse detection and correction, it is necessary to combine the rules and the first prediction correction result of the error correction model (see the relevant description in the subsequent step S140).
[0088] In order to update the rule base, each newly added rule has a unique number (rule_id). The number contains information such as the correct punctuation type, rule code, and rule version. The format is: T punctuation_I punctuation_RID_V, T punctuation is the punctuation type (a total of 4 categories: unpaired label SINGLE, paired label PAIR, mid-sentence punctuation MIDDLE, and end-of-sentence punctuation END), I punctuation corresponds to the label system in step 1, and is the correct punctuation that needs to be corrected after triggering this rule, RID represents the current rule digital code, and V represents the rule version (0 is the initialization version). For example (assuming that punctuation No. 1 is ","): MIDDLE-1-00001-0, if the rule is modified, it is directly located according to rule_id "MIDDLE-1-00001-0", and a new MIDDLE-1-00001-1 rule is added before this rule after modification.
[0089] Further, in step S130, in one embodiment, when the determined detection method is the detection method one, a second detection is performed based on the determined detection method to obtain a second prediction correction result for each of the positions, including: converting at least part of the above text before the position where the modification operation type is insert into a speech signal, for example, the above text can be converted into a speech signal by any suitable speech synthesis module; inputting the speech signal into an acoustic model for detection to obtain a second prediction correction result corresponding to the position where the modification operation type is insert, for example, extracting the pause duration and rhythmic features in the speech signal based on the acoustic model; based on the length of the pause duration and the rhythmic features, obtaining the second prediction correction result, the second prediction correction result includes one or more punctuation types (for example, marks, mid-sentence punctuation, and sentence-end punctuation) that can be inserted at the predicted corresponding position, and the second prediction correction result may also include the probability corresponding to each punctuation type.
[0090] In an embodiment of the present application, the acoustic model may be any suitable neural network model, which may be used to insert punctuation marks based on speech signals.
[0091] Since the second predicted correction result is obtained based on the model, in order to reduce error cascading, in an embodiment of the present application, the target correction result of the position where the modification operation type is inserted is determined by combining the first predicted correction result and the second predicted correction result based on the acoustic model. The specific details will be described in step S140 below.
[0092] Continuing in step S130, when the determined detection mode is the detection mode 2, a second detection is performed based on the determined detection mode to obtain a second predicted correction result for each position, including: modifying the position where the modification operation type is other operations except the insertion according to the first predicted correction result to obtain a modified text, for example, the operation corresponding to the current position is deletion, and its corresponding first predicted correction result includes 0-DG (general data, delete the punctuation at the current position), then the label of the current position in the modified text is deleted; matching the modified text (which can be a part of the above text modified before the position where the modification operation type is other operations except the insertion) with the rules in the preset rule library to obtain one or more rules matching the modified text, for example, using an automatic state machine or other matching algorithm to match the modified text; scoring the correctness of the modified text based on one or more rules, the second predicted correction result including the score, for example, the score can be determined by calculating the proportion of the correct rules representing the modified text in the one or more rules, the higher the score, the more accurate the correction result representing the first predicted correction result.
[0093] Further, in step S140, the first prediction correction result includes multiple candidate prediction results and a first probability corresponding to each of the candidate prediction results. When the second detection is performed in the detection mode 1 in the aforementioned step S130, that is, when the second detection is performed using the acoustic model, the second prediction correction result includes multiple candidate prediction results and a second probability corresponding to each of the candidate prediction results. The target correction result of each position is determined based on the first prediction correction result and the second prediction correction result corresponding to each of the positions (that is, determining the target correction result of the position where the modification operation type is insert), including: multiplying the first probability corresponding to each of the candidate prediction results by a first preset weight to obtain a first estimated probability corresponding to each of the candidate prediction results; multiplying the second probability corresponding to each of the candidate prediction results by a second preset weight to obtain a second estimated probability corresponding to each of the candidate prediction results; adding the first estimated probability and the second estimated probability corresponding to the candidate prediction results having the same punctuation type to obtain the prediction probability corresponding to each of the candidate prediction results, wherein the target correction result is the candidate prediction result with the highest prediction probability. By assigning weights to the first prediction correction result and the second prediction correction result respectively, the possibility of error cascading caused by the joint use of multiple models can be reduced. Optionally, the first preset weight is greater than the second preset weight, for example, the second preset weight is greater than 0 and less than 0.4. For candidate prediction results whose modification operation type is insertion, different candidate prediction results may have different types of inserted punctuation marks. The output results of the error correction model can also be verified and improved through secondary detection of the acoustic model to achieve the purpose of checking for omissions and filling in gaps, thereby making the output target error correction results more accurate.
[0094] In a specific example, the output of the trained error correction model can be recorded as The output of the acoustic model is denoted by p represents the position predicted as the A-class label, e p-n:p is a text sequence consisting of the first n words at position p, TTS is a speech synthesis module, Represents the output of the acoustic model. Finally, the predicted probability with weight is:
[0095]
[0096] Further, the first prediction correction result includes multiple candidate prediction results and a first probability corresponding to each candidate prediction result. When the second detection is performed in the detection mode 2 in the aforementioned step S130, that is, the second detection is performed with the preset rule base, the first prediction correction result and the second prediction correction result corresponding to each position are determined based on the first prediction correction result and the second prediction correction result, including: multiplying the first probability corresponding to each candidate prediction result by the third preset weight to obtain the third estimated probability corresponding to each candidate prediction result; multiplying the score corresponding to each candidate prediction result by the fourth preset weight to obtain the fourth estimated probability corresponding to each candidate prediction result; adding the first estimated probability and the second estimated probability corresponding to the candidate prediction result with the same punctuation type to obtain the prediction probability corresponding to each candidate prediction result, wherein the target correction result is the candidate prediction result with the highest prediction probability, wherein the third preset weight is greater than the fourth preset weight, wherein the fourth preset weight is greater than 0 and less than 0.4. The output result of the error correction model can also be verified and improved through the secondary detection of the preset rule base to achieve the effect of checking for omissions and filling gaps, so that the accuracy of the output target error correction result is higher.
[0097] It is worth mentioning that in the embodiment itself, the first prediction correction result includes multiple candidate prediction results and a first probability corresponding to each of the candidate prediction results. When the largest first probability among the multiple candidate prediction results is greater than or equal to the preset probability, the candidate prediction result corresponding to the largest first probability is used as the target correction result. When the largest first probability among the multiple candidate prediction results is less than the preset probability, the detection method of the second detection is the detection method 2, which can be specifically expressed by the following formula:
[0098]
[0099] label p ∈{D,R,K}
[0100] Here, e' is the text modified according to the first prediction correction result output by the error correction model, for example, the output result corresponding to the maximum first probability is used as the first prediction correction result.
[0101] Finally, for the entire text to be detected, the target correction results of multiple positions can be expressed by the following formula:
[0102]
[0103] Furthermore, in some embodiments, the method of the present application also includes: modifying the text to be detected according to the target correction result to obtain a target modified text; outputting and displaying the target modified text, thereby ultimately achieving error correction of the text to be detected, so as to save manpower and time, and with higher accuracy.
[0104] In other embodiments, the method of the present application also includes: outputting and displaying the target correction result, which can be a language description of the corresponding error correction label mentioned above, etc., so that the target correction result is output so that the user can manually make modifications based on the result without the user having to read the full text, which can also save time and manpower, and can also promptly correct obviously erroneous results based on the user's understanding, thereby improving the modification accuracy.
[0105] Based on the above description, through the punctuation misuse detection and correction method of the present application, the text to be detected can be detected through the error correction model to obtain a first predicted correction result, and the second predicted correction result can be obtained in combination with the acoustic model or the preset rule library, and the target correction result can be obtained based on the first predicted correction result, or based on the first predicted correction result and the second predicted correction result. Based on the above scheme, the punctuation of the text to be detected can be corrected according to the target correction result, and compared with the manual error correction method, it can save manpower and time, and then improve the error correction efficiency and accuracy.
[0106] The following will be combined Figure 4 A punctuation mark misuse detection and correction device 400 provided according to another aspect of the present application is described, which can be used to execute the punctuation mark misuse detection and correction method according to the embodiment of the present application described above.
[0107] like Figure 4As shown, the punctuation mark misuse detection and correction device 400 may include: a first detection module 420, a detection method determination module 440, a second detection module 450 and a target correction result determination module 460, wherein the first detection module 420 is used to input the acquired text to be detected into the trained error correction model for a first detection to obtain a first predicted correction result of multiple positions, wherein the first predicted correction result includes the modification operation type predicted to be performed on each of the positions and the predicted corrected punctuation mark type corresponding to each of the positions; the detection method determination module 440 is used to determine the detection method of the second detection to be performed on each of the positions based on the modification operation type predicted to be performed on each of the positions, and the detection method includes at least two detection methods, for example, at least two detection methods include detection method one and detection method two, wherein the detection method one includes detecting the positions whose modification operation type is insertion in the multiple positions based on an acoustic model, and the detection method two includes detecting the positions whose modification operation type is other than insertion in the multiple positions based on a preset rule base; the second detection module 450 is used to perform a second detection based on the determined detection method, To obtain the second predicted correction result for each of the positions; the target correction result determination module 460 is used to determine the target correction result for each of the positions based on the first predicted correction result and / or the second predicted correction result corresponding to each of the positions.
[0108] The following will be combined Figure 5 A punctuation mark misuse detection and correction device 500 provided according to another aspect of the present application is described, which can be used to execute the punctuation mark misuse detection and correction method according to the embodiment of the present application described above.
[0109] like Figure 5 As shown, the punctuation mark misuse detection and correction device 500 may include a memory 510 and a processor 520. The memory 510 stores a computer program executed by the processor 520. When the computer program is executed by the processor 520, the processor 520 executes the punctuation mark misuse detection and correction method 100 according to the embodiment of the present application described above. Those skilled in the art can understand the specific operation of the punctuation mark misuse detection and correction method 100 according to the embodiment of the present application in combination with the above content. For the sake of brevity, the specific details are not repeated here.
[0110] The processor 520 can be any processing device known in the art, such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor, a microcontroller, a field programmable gate array (FPGA), etc., and the present invention is not limited to this.
[0111] The memory 510 is used to store the network parameters of one or more neural networks. Exemplarily, the memory 510 may be a RAM, a ROM, an EEPROM, a flash memory or other storage technology, a CD-ROM, a digital versatile disk (DVD) or other optical disk storage device, a cassette, a magnetic tape, a magnetic disk storage device or other magnetic storage device, or any other medium that can be used to store the desired information and can be accessed by the processor 520.
[0112] In addition, according to an embodiment of the present application, a storage medium is also provided, on which program instructions are stored, and when the program instructions are executed by a computer or a processor, the corresponding steps of the punctuation mark misuse detection and correction method 100 of the embodiment of the present application are executed. The storage medium may include, for example, a memory card of a smart phone, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a USB memory, or any combination of the above storage media. The computer-readable storage medium may be any combination of one or more computer-readable storage media.
[0113] Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above example embodiments are merely exemplary and are not intended to limit the scope of the present application to this. Those of ordinary skill in the art may make various changes and modifications therein without departing from the scope and spirit of the present application. All these changes and modifications are intended to be included within the scope of the present application as required by the appended claims.
[0114] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0115] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0116] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0117] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various inventive aspects, in the description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the method of the present application should not be interpreted as reflecting the following intention: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the corresponding claims, the inventive point is that the corresponding technical problem can be solved with features less than all the features of a single disclosed embodiment. Therefore, the claims following the specific embodiment are hereby explicitly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.
[0118] It will be understood by those skilled in the art that, except for mutually exclusive features, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this specification may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature that provides the same, equivalent or similar purpose.
[0119] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the claims, any one of the claimed embodiments can be used in any combination.
[0120] It should be noted that the above embodiments illustrate rather than limit the present application, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The present application may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of means, several of these means may be embodied by the same hardware item. The words first, second, and third, etc. are used in no order. These words may be interpreted as names.
Claims
1. A method for detecting and correcting misuse of punctuation marks, characterized in that: The method comprises the following steps: Input the acquired text to be detected into the trained error correction model for a first detection to obtain first predicted correction results of multiple positions, wherein the first predicted correction results include a modification operation type predicted to be performed on each position and a predicted corrected punctuation type corresponding to each position; Based on the modification operation type predicted to be performed at each of the positions, determining a detection mode of a second detection to be performed at each of the positions, the detection mode of the second detection including a detection mode 1 and a detection mode 2, the detection mode 1 including detecting a position whose modification operation type is insertion among the multiple positions based on an acoustic model, and the detection mode 2 including detecting a position whose modification operation type is other than insertion among the multiple positions based on a preset rule base; Performing a second detection based on the determined detection method to obtain a second prediction correction result for each of the positions; A target correction result for each of the positions is determined based on the first predicted correction result and / or the second predicted correction result corresponding to each of the positions.
2. The method according to claim 1, characterized in that When the determined detection mode is the detection mode 1, performing a second detection based on the determined detection mode to obtain a second prediction correction result for each of the positions includes: Converting at least part of the preceding text before the position where the modification operation type is insert into a speech signal; The speech signal is input into the acoustic model for detection to obtain the second prediction and correction result.
3. The method according to claim 2, characterized in that The step of inputting the speech signal into the acoustic model for detection to obtain the second prediction and correction result includes: Extracting pause duration and prosodic features from the speech signal based on the acoustic model; Based on the length of the pause and the rhythmic feature, the second prediction correction result is obtained, and the second prediction correction result includes one or more punctuation mark types that can be inserted into the predicted corresponding position.
4. The method according to claim 3, characterized in that The first prediction correction result includes a plurality of candidate prediction results and a first probability corresponding to each of the candidate prediction results, the second prediction correction result includes the plurality of candidate prediction results and a second probability corresponding to each of the candidate prediction results, and determining a target correction result for each of the positions based on the first prediction correction result and the second prediction correction result corresponding to each of the positions includes: Multiplying the first probability corresponding to each of the candidate prediction results by a first preset weight to obtain a first estimated probability corresponding to each of the candidate prediction results; Multiplying the second probability corresponding to each of the candidate prediction results by a second preset weight to obtain a second estimated probability corresponding to each of the candidate prediction results; The first estimated probability and the second estimated probability corresponding to the candidate prediction results having the same punctuation mark type are added together to obtain the prediction probability corresponding to each of the candidate prediction results, wherein the target correction result is the candidate prediction result with the highest prediction probability.
5. The method according to claim 1, characterized in that When the determined detection mode is the second detection mode, performing a second detection based on the determined detection mode to obtain a second prediction correction result for each of the positions includes: Modify the position where the modification operation type is other than the insertion operation according to the first prediction correction result to obtain a modified text; Matching the modified text with the rules in the preset rule library to obtain one or more rules matching the modified text; Based on one or more rules, the correctness of the modified text is scored, and the second predicted correction result includes the score, wherein the score is determined based on the proportion of the one or more rules that characterize the modified text as correct.
6. The method according to claim 5, characterized in that The first prediction correction result includes a plurality of candidate prediction results and a first probability corresponding to each of the candidate prediction results, and determining a target correction result for each of the positions based on the first prediction correction result and the second prediction correction result corresponding to each of the positions includes: Multiplying the first probability corresponding to each of the candidate prediction results by a third preset weight to obtain a third estimated probability corresponding to each of the candidate prediction results; Multiplying the score corresponding to each of the candidate prediction results by a fourth preset weight to obtain a fourth estimated probability corresponding to each of the candidate prediction results; The first estimated probability and the second estimated probability corresponding to the candidate prediction results having the same punctuation mark type are added together to obtain the prediction probability corresponding to each of the candidate prediction results, wherein the target correction result is the candidate prediction result with the highest prediction probability.
7. A device for detecting and correcting misuse of punctuation marks, characterized in that: The device comprises: A first detection module, used for inputting the text to be detected into the trained error correction model for a first detection to obtain first predicted correction results of multiple positions, wherein the first predicted correction results include a modification operation type predicted to be performed on each position and a predicted corrected punctuation type corresponding to each position; A detection mode determination module, used to determine a detection mode of a second detection to be performed at each of the positions based on the modification operation type predicted to be performed at each of the positions, the detection modes including detection mode 1 and detection mode 2, the detection mode 1 including detecting the positions whose modification operation type is insertion among the multiple positions based on an acoustic model, and the detection mode 2 including detecting the positions whose modification operation type is other than insertion among the multiple positions based on a preset rule base; A second detection module, configured to perform a second detection based on the determined detection method to obtain a second prediction correction result for each of the positions; The target correction result determination module is used to determine the target correction result of each position based on the first predicted correction result and / or the second predicted correction result corresponding to each position.
8. A device for detecting and correcting misuse of punctuation marks, characterized in that: The device includes a memory and a processor, wherein the memory stores a computer program executed by the processor, and when the computer program is executed by the processor, the processor executes the method for detecting and correcting punctuation mark misuse as described in any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is run, it executes the method for detecting and correcting punctuation mark misuse as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Input error correction method and apparatus, and apparatus used for input error correction
CN107918496A
Input error correction method and device, electronic equipment and storage medium
CN110764647A