Text error correction method, device, computer equipment and storage medium based on character existence index
By using a method based on character presence indicators, combined with the text error correction model and fragment library frequency analysis, the problem of miscorrection caused by insufficient learning of low-frequency word fragments by the text error correction model is solved, and more accurate text error correction is achieved.
Patent Information
- Application Number
- CN202410994288.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-23
Smart Images

Figure CN118536495B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of text detection, and in particular to a text error correction method, device, computer equipment and storage medium based on character existence indicators. Background Art
[0002] Chinese text spelling correction refers to the process of detecting and correcting characters with similar pronunciations and shapes in Chinese texts to improve the accuracy, fluency and readability of the text. Generally, a text correction model based on deep learning can be used to detect text and implement text correction. The input of the text correction model is the sentence to be corrected, and the output is the correction result of each character in the sentence. If there is no error, a special character is output. However, due to the limitations of the training samples of the text correction model, the learning of low-frequency word fragments is insufficient, which easily leads to miscorrection, that is, correcting the correct text content to the wrong text content, making the accuracy of text correction impossible to guarantee. Summary of the invention
[0003] The embodiments of the present disclosure at least provide a text error correction method, apparatus, computer equipment and storage medium based on character existence indicators.
[0004] In a first aspect, an embodiment of the present disclosure provides a text error correction method based on a character existence indicator, comprising:
[0005] Obtain the text data to be detected;
[0006] Using a text error correction model, detecting whether there is a character to be corrected in the text data, and if so, determining a target character corresponding to the character to be corrected and an error correction probability of the target character;
[0007] When the error correction probability is less than or equal to a probability threshold, based on the position of the character to be corrected in the text data and a preset segment length, determining at least one first text segment including the character to be corrected from the text data; and replacing the character to be corrected in each of the first text segments with the target character to generate a second text segment;
[0008] Determining a first frequency of the first text segment existing in a pre-built segment library, and determining a second frequency of the second text segment existing in the segment library;
[0009] Based on the first frequency and the second frequency, it is determined whether the current detection satisfies a character replacement condition, and if so, the to-be-corrected character in the text data is replaced with the target character.
[0010] In an optional implementation manner, determining whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency includes:
[0011] It is determined whether the ratio of the second frequency to the first frequency is greater than a first ratio threshold, and if not, it is determined that the current detection satisfies a character replacement condition.
[0012] In an optional implementation manner, determining whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency includes:
[0013] Based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment, determining a first existence index of the first text segment; and based on the second frequency of the second text segment and the position information of the target character in the second text segment, determining a second existence index of the second text segment; wherein the existence index is used to characterize the strength of the existence of the text segment in the segment library;
[0014] Based on the first existence index and the second existence index, it is determined whether this detection satisfies a character replacement condition.
[0015] In an optional implementation manner, determining whether the current detection satisfies a character replacement condition based on the first existence index and the second existence index includes:
[0016] Determine whether the ratio of the second existence index to the first existence index is greater than a second ratio threshold, and if not, determine that the current detection satisfies a character replacement condition.
[0017] In an optional implementation manner, determining the first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment includes:
[0018] Determining a position measurement index of the character to be corrected based on the position information of the character to be corrected in the first text segment, wherein the position measurement index is used to characterize the degree of centering of the character to be corrected in the first text segment;
[0019] Based on the position measurement index of the to-be-corrected character and the first frequency of the first text segment, a first existence index corresponding to the first text segment is determined.
[0020] In an optional implementation manner, when there are multiple first text segments and multiple second text segments, the method further includes:
[0021] Averaging the first existence indexes corresponding to the plurality of first text segments to obtain a first index average value; and averaging the second existence indexes corresponding to the plurality of second text segments to obtain a second index average value;
[0022] The determining whether the current detection satisfies a character replacement condition based on the first existence index and the second existence index includes:
[0023] Based on the first index average value and the second index average value, it is determined whether the current detection satisfies the character replacement condition.
[0024] In an optional embodiment, the fragment library is constructed according to the following steps:
[0025] Get corpus data;
[0026] Extracting a plurality of preset text segments from the corpus data based on the preset segment length;
[0027] Determining the frequency of each of the predetermined text segments;
[0028] The segment library is constructed based on the multiple preset text segments and the frequency of each of the preset text segments.
[0029] In an optional implementation manner, determining the frequency of each of the preset text segments includes:
[0030] Determining the number of occurrences of each of the preset text segments in the corpus data;
[0031] Performing a logarithmic operation on the inverse of the number of occurrences of each of the preset text segments to obtain an operation value of the preset text segment, and summing the operation values of multiple preset text segments to obtain an operation sum value;
[0032] For each of the preset text segments, a division operation is performed on the operation value of the preset text segment and the operation sum value to generate the frequency of the preset text segment.
[0033] In an optional implementation manner, after determining the frequency of each of the preset text segments, the method includes:
[0034] Determine whether the preset text segment exists in the constructed knowledge graph;
[0035] If it exists, the frequency of the preset text segment is adjusted upward to obtain the adjusted frequency of the preset text segment, wherein the adjusted frequency is used to construct the segment library.
[0036] In a second aspect, the present disclosure also provides a text error correction device based on character existence indicators, including:
[0037] An acquisition module, used for acquiring text data to be detected;
[0038] A detection module, used to detect whether there is a character to be corrected in the text data by using a text error correction model, and if so, determine a target character corresponding to the character to be corrected and an error correction probability of the target character;
[0039] A generating module, configured to determine, when the error correction probability is less than a probability threshold, at least one first text segment including the character to be corrected from the text data based on the position of the character to be corrected in the text data and a preset segment length; and replace the character to be corrected in each of the first text segments with the target character to generate a second text segment;
[0040] a first determination module, configured to determine a first frequency of the first text segment existing in a pre-built segment library, and to determine a second frequency of the second text segment existing in the segment library;
[0041] The second determination module is used to determine whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency, and if so, replace the to-be-corrected character in the text data with the target character.
[0042] In an optional implementation manner, the second determination module, when determining whether the current detection satisfies the character replacement condition based on the first frequency and the second frequency, is configured to:
[0043] It is determined whether the ratio of the second frequency to the first frequency is greater than a first ratio threshold, and if not, it is determined that the current detection satisfies a character replacement condition.
[0044] In an optional implementation manner, the second determination module, when determining whether the current detection satisfies the character replacement condition based on the first frequency and the second frequency, is configured to:
[0045] Based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment, determining a first existence index of the first text segment; and based on the second frequency of the second text segment and the position information of the target character in the second text segment, determining a second existence index of the second text segment; wherein the existence index is used to characterize the strength of the existence of the text segment in the segment library;
[0046] Based on the first existence index and the second existence index, it is determined whether this detection satisfies a character replacement condition.
[0047] In an optional implementation manner, the second determination module, when determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index, is configured to:
[0048] Determine whether the ratio of the second existence index to the first existence index is greater than a second ratio threshold, and if not, determine that the current detection satisfies a character replacement condition.
[0049] In an optional implementation manner, the second determination module, when determining the first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment, is configured to:
[0050] Determining a position measurement index of the character to be corrected based on the position information of the character to be corrected in the first text segment, wherein the position measurement index is used to characterize the degree of centering of the character to be corrected in the first text segment;
[0051] Based on the position measurement index of the to-be-corrected character and the first frequency of the first text segment, a first existence index corresponding to the first text segment is determined.
[0052] In an optional implementation manner, when there are multiple first text segments and multiple second text segments, the second determining module is further configured to:
[0053] Averaging the first existence indexes corresponding to the plurality of first text segments to obtain a first index average value; and averaging the second existence indexes corresponding to the plurality of second text segments to obtain a second index average value;
[0054] The second determination module, when determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index, is used to:
[0055] Based on the first index average value and the second index average value, it is determined whether the current detection satisfies the character replacement condition.
[0056] In an optional embodiment, it further comprises a construction module for constructing the fragment library according to the following steps:
[0057] Get corpus data;
[0058] Extracting a plurality of preset text segments from the corpus data based on the preset segment length;
[0059] Determining the frequency of each of the predetermined text segments;
[0060] The segment library is constructed based on the multiple preset text segments and the frequency of each of the preset text segments.
[0061] In an optional implementation manner, the construction module, when determining the frequency of each of the preset text segments, is used to:
[0062] Determining the number of occurrences of each of the preset text segments in the corpus data;
[0063] Performing a logarithmic operation on the inverse of the number of occurrences of each of the preset text segments to obtain an operation value of the preset text segment, and summing the operation values of multiple preset text segments to obtain an operation sum value;
[0064] For each of the preset text segments, a division operation is performed on the operation value of the preset text segment and the operation sum value to generate the frequency of the preset text segment.
[0065] In an optional implementation manner, after determining the frequency of each of the preset text segments, the construction module is further configured to:
[0066] Determine whether the preset text segment exists in the constructed knowledge graph;
[0067] If it exists, the frequency of the preset text segment is adjusted upward to obtain the adjusted frequency of the preset text segment, wherein the adjusted frequency is used to construct the segment library.
[0068] In a third aspect, an optional implementation of the present disclosure further provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the machine-readable instructions perform the steps of the above-mentioned first aspect, or any possible implementation of the first aspect.
[0069] In a fourth aspect, an optional implementation of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are executed.
[0070] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present disclosure.
[0071] The present application provides a text error correction method, device, computer equipment and storage medium based on character existence index, which uses a text error correction model to detect whether there is a character to be corrected in the text data. If so, the target character corresponding to the character to be corrected and the error correction probability of the target character are determined. When the error correction probability is less than the probability threshold, it means that the accuracy of this error correction is low. In this case, it can be further determined whether to replace the character to be corrected with the target character to alleviate the miscorrection and ensure the accuracy of text error correction.
[0072] And when the error correction probability is less than the probability threshold, the present application determines at least one first text segment including the character to be corrected from the text data based on the position of the character to be corrected in the text data and the preset segment length; and replaces the character to be corrected in each first text segment with the target character to generate a second text segment. Determine the first frequency of the first text segment in the pre-constructed segment library, and determine the second frequency of the second text segment in the segment library, wherein the first frequency can characterize the high and low number of occurrences of the first text segment in the segment library, and the second frequency can characterize the high and low number of occurrences of the second text segment in the segment library, so the first frequency and the second frequency can reflect the difference in the number of occurrences of the first text segment and the second text segment in the segment library. Then, based on the first frequency and the second frequency, determine whether this detection meets the character replacement condition. For example, if the difference between the first frequency and the second frequency is small, it means that the difference in the number of occurrences of the first text segment and the second text segment in the segment library is small, and this error correction does not belong to the situation of correcting the low-frequency segment to the high-frequency segment, and the probability of miscorrection is low. In this case, it can be determined that this detection meets the character replacement condition. If the second frequency is much greater than the first frequency, it means that the frequency of the second text segment in the segment library is much higher than that of the first text segment. This error correction is a case of correcting a low-frequency segment to a high-frequency segment. The probability of miscorrection is high. In this case, it can be determined that this detection does not meet the character replacement condition. When the character replacement condition is met, the character to be corrected in the text data is replaced with the target character to alleviate the miscorrection problem caused by correcting low-frequency words to high-frequency words, and ensure the accuracy of text error correction.
[0073] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0075] Figure 1 A flowchart of a text error correction method based on character existence indicators provided by some embodiments of the present disclosure is shown;
[0076] Figure 2 A flowchart of a text error correction method based on character existence indicators provided by some embodiments of the present disclosure is shown;
[0077] Figure 3 A schematic diagram of the structure of a text error correction device based on character existence indicators provided by some embodiments of the present disclosure is shown;
[0078] Figure 4 A schematic diagram of a computer device provided by some embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0079] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure claimed for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0080] In the related art, a text error correction model based on deep learning is used to detect text and implement text error correction. For example, a large number of training samples can be used to train the Transformer model to be trained to obtain an end-to-end text error correction model. The input of the text error correction model is the sentence to be corrected, and the output is the error correction result of each character in the sentence. If there is no error, a special character is output. However, due to the limitations of the training samples of the text error correction model, the learning of low-frequency word fragments is insufficient, which is easy to cause miscorrection, that is, correcting the correct text content to incorrect text content, making the accuracy of text error correction impossible to guarantee.
[0081] Based on the above research, this application provides a text error correction method based on character existence index, which uses a text error correction model to detect whether there is a character to be corrected in the text data. If so, the target character corresponding to the character to be corrected and the error correction probability of the target character are determined. When the error correction probability is less than the probability threshold, it means that the accuracy of this error correction is low. In this case, it can be further determined whether to replace the character to be corrected with the target character to alleviate the miscorrection and ensure the accuracy of text error correction.
[0082] And when the error correction probability is less than the probability threshold, the present application determines at least one first text segment including the character to be corrected from the text data based on the position of the character to be corrected in the text data and the preset segment length; and replaces the character to be corrected in each first text segment with the target character to generate a second text segment. Determine the first frequency of the first text segment in the pre-constructed segment library, and determine the second frequency of the second text segment in the segment library, wherein the first frequency can characterize the high and low number of occurrences of the first text segment in the segment library, and the second frequency can characterize the high and low number of occurrences of the second text segment in the segment library, so the first frequency and the second frequency can reflect the difference in the number of occurrences of the first text segment and the second text segment in the segment library. Then, based on the first frequency and the second frequency, determine whether this detection meets the character replacement condition. For example, if the difference between the first frequency and the second frequency is small, it means that the difference in the number of occurrences of the first text segment and the second text segment in the segment library is small, and this error correction does not belong to the situation of correcting the low-frequency segment to the high-frequency segment, and the probability of miscorrection is low. In this case, it can be determined that this detection meets the character replacement condition. If the second frequency is much greater than the first frequency, it means that the frequency of the second text segment in the segment library is much higher than that of the first text segment. This error correction is a case of correcting a low-frequency segment to a high-frequency segment. The probability of miscorrection is high. In this case, it can be determined that this detection does not meet the character replacement condition. When the character replacement condition is met, the character to be corrected in the text data is replaced with the target character to alleviate the miscorrection problem caused by correcting low-frequency words to high-frequency words, and ensure the accuracy of text error correction.
[0083] The above contents are all the results obtained by the inventor after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.
[0084] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0085] To facilitate understanding of this embodiment, a text error correction method based on character existence indicators disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the text error correction method based on character existence indicators provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the text error correction method based on character existence indicators can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0086] The text error correction method based on character existence index provided by the embodiment of the present disclosure is described below by taking the execution subject as a terminal device as an example.
[0087] See also Figure 1 As shown, it is a flowchart of a text error correction method based on character existence index provided by an embodiment of the present disclosure, and the method includes steps S101 to S105, wherein:
[0088] S101: Acquire text data to be detected.
[0089] The text data to be detected can be text data input by a user in an input interface, or can be text data obtained from a target storage location. The text data to be detected can be any text data containing Chinese characters to be detected.
[0090] S102: Using a text error correction model, detect whether there is a character to be corrected in the text data; if so, determine a target character corresponding to the character to be corrected and an error correction probability of the target character.
[0091] The model structure of the text error correction model can be set as needed. For example, the text error correction model can be a text error correction model based on the bidirectional encoder representations from transformers (Bert) architecture, or a text error correction model based on the convolutional neural network (CNN) architecture, or a text error correction model based on the recurrent neural network (RNN) architecture, etc.
[0092] Exemplarily, the text error correction model can be constructed using a sequence-to-sequence (seq2seq) model structure. During the training process, the training sample is input into the constructed model to be trained to obtain the detection result of each character in the training sample. For example, if the detection result of the character includes a special mark, namely $KEEP, it means that the character does not need to be corrected; if the character does not need to be corrected, the detection result of the character includes the corrected character and the error correction probability. Then, a loss function such as a cross entropy loss function is used to determine the loss value based on the detection results of the characters in the training sample, and the model parameters of the model to be trained are adjusted using the loss value until the training cutoff condition is met to obtain a text error correction model, wherein the training cutoff condition may be that the number of training times is greater than the number threshold, or the loss value converges, or the detection accuracy of the model is greater than the accuracy threshold, etc.
[0093] By using the text error correction model to detect the text data, the detection result of each character in the text data can be obtained. If the detection result of the character is a special mark, the character does not need to be corrected. If the detection result of the character is not a special character, the character is the character to be corrected, and the target character corresponding to the character to be corrected and the error correction probability of the target character are determined. Among them, the target character corresponding to the character to be corrected and the error correction probability of the target character are obtained by the text error correction model detection.
[0094] When there are multiple characters to be corrected detected in the text data, it can be determined whether to perform character replacement for each character to be corrected using the process from S103 to S105 .
[0095] S103. When the error correction probability is less than a probability threshold, based on the position of the character to be corrected in the text data and a preset segment length, determine at least one first text segment including the character to be corrected from the text data; and replace the character to be corrected in each of the first text segments with the target character to generate a second text segment.
[0096] If the error correction probability is greater than or equal to the probability threshold, it indicates that the accuracy of this error correction is relatively high and the possibility of mis-correction is relatively low. Therefore, the character to be corrected in the text data can be directly replaced with the target character.
[0097] When the error correction probability is less than the probability threshold, it indicates that the accuracy of this error correction is relatively low and the possibility of mis-correction is relatively high. It is necessary to further determine whether the character replacement condition is met.
[0098] Specifically, when the error correction probability is less than the probability threshold, based on the position of the character to be corrected in the text data, at least one first text segment including the character to be corrected is determined from the text data according to the preset segment length. For example, a first text segment centered on the character to be corrected can be determined, or all first text segments including the character to be corrected can also be determined.
[0099] For example, if the preset segment length is 4, the text data is "How to achieve digital intelligence empowerment for high-quality development", the character to be corrected is "智" (intelligence), and the target character is "字" (character), then the first text segment centered on the character to be corrected is: 现数智赋 (realize digital empowerment), 数智赋能 (digital intelligence empowerment). If the preset segment length is 3, the first text segment centered on the character to be corrected is: 数智赋 (digital intelligence empowerment).
[0100] Another example, if the preset segment length is 4, the text data is "How to achieve digital intelligence empowerment for high-quality development", the character to be corrected is "智" (intelligence), and the target character is "字" (character), then all first text segments including the character to be corrected can include: 实现数智 (achieve digital intelligence), 现数智赋 (realize digital empowerment), 数智赋能 (digital intelligence empowerment), 智赋能高 (intelligence empowerment for high-quality). And the character to be corrected in each first text segment can be replaced with the target character to generate a second text segment, and the second text segment can include: 实现数字 (achieve digital), 现数字赋 (realize digital empowerment), 数字赋能 (digital empowerment), 字赋能高 (character empowerment for high-quality).
[0101] Another example, if the preset segment length is 4, the text data is "The development prospect of digital intelligence empowerment", the character to be corrected is "智" (intelligence), and the target character is "字" (character), then the determined first text segments can include: 数智赋能 (digital intelligence empowerment), 智赋能的 (intelligence empowerment of); the second text segments can include: 数字赋能 (digital empowerment), 字赋能的 (character empowerment of).
[0102] S104. Determine the first frequency of the existence of the first text segment in the pre-constructed segment library, and determine the second frequency of the existence of the second text segment in the segment library.
[0103] During implementation, a fragment library can be pre-constructed, in which a plurality of preset text fragments and the frequency of each preset text fragment are stored. Therefore, the first frequency of the first text fragment and the second frequency of the second text fragment can be determined from the fragment library. The frequency of the preset text fragment can be the statistical number of occurrences, or the number obtained after normalizing the number of occurrences. In this case, the first frequency can be regarded as an existence indicator of the character to be corrected, and the second frequency can be regarded as an existence indicator of the target character, so that it can be determined whether to perform text error correction based on the existence indicators of the character to be corrected and the target character in the future.
[0104] S105 . Determine whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency. If so, replace the to-be-corrected character in the text data with the target character.
[0105] For example, the difference between the second frequency and the first frequency can be determined to determine whether the difference is greater than the set first difference threshold. If so, it indicates that the number of occurrences of the second text segment is much greater than that of the first text segment, that is, in the segment library, relative to the second text segment, the first text segment is a low-frequency segment. This error correction process is a case of correcting a low-frequency segment into a high-frequency segment, and the possibility of miscorrection is high. Therefore, this detection does not meet the character replacement conditions, and the character to be corrected in the text data is not replaced with the target character.
[0106] On the contrary, if the difference is less than or equal to the set first difference threshold, it means that the number of occurrences of the second text segment is not much greater than that of the first text segment. This error correction process does not belong to the case of correcting a low-frequency segment into a high-frequency segment, and the possibility of miscorrection is low. Therefore, it is determined that this detection meets the character replacement conditions, and the character to be corrected in the text data is replaced with the target character.
[0107] In an optional implementation, determining whether this detection satisfies a character replacement condition is performed based on the first frequency and the second frequency, including: determining whether a ratio of the second frequency to the first frequency is greater than a first ratio threshold; if not, determining that this detection satisfies a character replacement condition.
[0108] The ratio between the second frequency and the first frequency can be determined, that is, the ratio obtained by dividing the second frequency by the first frequency. It is determined whether the ratio of the second frequency to the first frequency is greater than the first ratio threshold. If so, it indicates that the second text segment is a high-frequency segment relative to the first text segment in the segment library, and this error correction process is a case of correcting a low-frequency segment to a high-frequency segment, and the possibility of miscorrection is high. Therefore, it is determined that this detection does not meet the character replacement condition, and the character to be corrected in the text data is not replaced with the target character.
[0109] Conversely, if the ratio of the second frequency to the first frequency is less than or equal to the first ratio threshold, it is determined that the current error correction process does not belong to the situation of correcting a low-frequency segment to a high-frequency segment, and the possibility of mis-correction is small. Therefore, it is determined that the current detection meets the character replacement condition, and the character to be corrected in the text data is replaced with the target character.
[0110] Through the above process, it can be determined whether the second text segment belongs to a high-frequency segment relative to the first text segment in the segment library, and based on this judgment result, it can be determined whether the current detection corrects a low-frequency segment to a high-frequency segment, and further, it can be more accurately determined whether the current detection meets the character replacement condition.
[0111] In an optional implementation manner, determining whether the current detection meets the character replacement condition based on the first frequency and the second frequency may further include:
[0112] Step a1: Determine the first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment; and determine the second existence index of the second text segment based on the second frequency of the second text segment and the position information of the target character in the second text segment; wherein, the existence index is used to represent the strength of the existence of the text segment in the segment library;
[0113] Step a2: Determine whether the current detection meets the character replacement condition based on the first existence index and the second existence index.
[0114] In step a1, determine the position information of the character to be corrected in the first text segment. For example, if the character to be corrected is "智" and the first text segment is "现数智赋", the position information of the character to be corrected can be 3; for another example, if the first text segment is "数智赋能", the position information of the character to be corrected can be 2. Then, according to the first frequency of the first text segment and the position information of the character to be corrected in the text segment, determine the first existence index of the first text segment. Similarly, the second existence index can be determined. Among them, the existence index is used to represent the strength of the existence of the text segment in the segment library. The larger the existence index, the stronger the existence degree of the text segment in the segment library, and the higher the occurrence frequency of this text segment. In this case, the first existence index can be regarded as the existence index of the character to be corrected, and the second existence index can be regarded as the existence index of the target character, so as to determine whether to perform text error correction based on the existence indexes of the character to be corrected and the target character in the subsequent process.
[0115] Optionally, based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment, a first existence index of the first text segment is determined, including: determining a position measurement index of the character to be corrected based on the position information of the character to be corrected in the first text segment, wherein the position measurement index is used to characterize the degree of centering of the character to be corrected in the first text segment; and determining a first existence index corresponding to the first text segment based on the position measurement index of the character to be corrected and the first frequency of the first text segment.
[0116] During implementation, the first text segment can be determined according to the following formula (1): The first existence index :
[0117] , (1)
[0118] in, For the first text segment The first frequency, The character to be corrected is in the first text segment The location information of N is the preset segment length. The value of the first text fragment The position measurement indicator. is a parameter used to prevent division by zero errors, such as It can be set to 0.1, or 0.01, etc. The scaling factor is set, such as The value of can be 2, 3, etc.
[0119] In the above formula, The smaller the value of , the more centered the character is in the first text segment, the more balanced the context information of the character to be corrected is, and the stronger the existence of the first text segment is.
[0120] The second existence index of the second text segment can be determined based on the above formula (1), which will not be described in detail here.
[0121] Here, the first existence index corresponding to the first text segment can be determined more accurately through the position information of the character to be corrected in the text segment and the first frequency of the first text segment, so as to achieve more accurate judgment of miscorrection.
[0122] In step a2, the difference between the first existence index and the second existence index can be determined. If the difference is greater than the set second difference threshold, it is determined that the current detection does not meet the character replacement condition. On the contrary, if the difference is less than or equal to the second difference threshold, it is determined that the current detection meets the character replacement condition.
[0123] Optionally, based on the first existence index and the second existence index, determining whether this detection satisfies a character replacement condition includes: determining whether a ratio of the second existence index to the first existence index is greater than a second ratio threshold; if not, determining that this detection satisfies the character replacement condition.
[0124] During implementation, the ratio of the second existence index to the first existence index can be determined. If the ratio is greater than the second ratio threshold, it indicates that the second text segment is a high-frequency segment relative to the first text segment in the segment library, and this error correction process is a case of correcting a low-frequency segment into a high-frequency segment. The possibility of miscorrection is high, so it is determined that this detection does not meet the character replacement conditions, and the character to be corrected in the text data is not replaced with the target character.
[0125] On the contrary, if the ratio of the second existence index to the first existence index is less than or equal to the second ratio threshold, it is determined that the error correction process does not belong to the case of correcting a low-frequency segment into a high-frequency segment, and the possibility of miscorrection is small. Therefore, it is determined that this detection meets the character replacement conditions, and the characters to be corrected in the text data are replaced with the target characters.
[0126] When there are multiple first text segments and multiple second text segments, the method further includes: averaging the first existence indexes corresponding to the multiple first text segments to obtain a first index average value; and averaging the second existence indexes corresponding to the multiple second text segments to obtain a second index average value.
[0127] The determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index includes: determining whether the current detection satisfies the character replacement condition based on the first index average value and the second index average value.
[0128] After determining a plurality of first text segments and a plurality of second text segments, a first frequency of each first text segment can be determined, and a first existence index of the first text segment can be determined based on the first frequency of the first text segment and position information of the character to be corrected in the first text segment. The first existence indexes corresponding to the plurality of first text segments are averaged to obtain a first index average value.
[0129] Similarly, for each second text segment, the second frequency of the second text segment is determined, and based on the second frequency of the second text segment and the position information of the target character in the second text segment, the second existence index of the second text segment is determined. The second existence indexes corresponding to the plurality of second text segments are averaged to obtain a second index average value.
[0130] Determine whether the ratio of the second index average value to the first index average value is greater than a second ratio threshold value. If not, determine that this detection satisfies the character replacement condition; if so, determine that this detection does not satisfy the character replacement condition.
[0131] See also Figure 2 As shown, Figure 2 middle is the error correction probability, is the first exponential average, is the second exponential average, theta1 is the probability threshold, theta2 is the second ratio threshold, where theta1 and theta2 are two hyperparameter values, and the optimal value can be determined by the grid search GridSearch method. Figure 2 It can be seen that in the error correction probability When the probability is greater than theta1, the error correction result of Bert (i.e., text error correction model) can be directly accepted, that is, the characters to be corrected in the text data are replaced with the target characters. When it is less than or equal to the probability threshold theta1, determine the first exponential average and the second exponential mean If the second exponential mean With the first index average If the ratio between the two is greater than the second ratio threshold theta2, the Bert error correction result is accepted; otherwise, if the second exponential average With the first index average If the ratio between them is less than or equal to the second ratio threshold theta2, the Bert error correction result is rejected, that is, the characters to be corrected in the text data are not replaced with the target characters.
[0132] In an optional implementation, the fragment library can be constructed according to the following steps:
[0133] Step b1, obtaining corpus data;
[0134] Step b2: extracting a plurality of preset text segments from the corpus data based on the preset segment length;
[0135] Step b3, determining the frequency of each of the preset text segments;
[0136] Step b4: constructing the segment library based on the multiple preset text segments and the frequency of each preset text segment.
[0137] The corpus data may be a large amount of Chinese text data obtained for various application scenarios, which is not specifically limited here.
[0138] According to the preset segment length, a plurality of preset text segments are extracted from the corpus data, wherein the length of the preset text segment is the preset segment length. For example, if the preset segment length is 4, and the corpus data includes the following content: "I like quiet days", the selected preset text segments include: I like peace, like quiet, like quiet, quiet days, and quiet days.
[0139] Through the above process, a large number of preset text segments can be extracted from the corpus data, and the frequency of each preset text segment extracted can be counted. For example, the number of occurrences of each preset text segment can be determined, and the number of occurrences can be determined as the frequency of the preset text segment. Assuming that "like quiet" is extracted 1000 times, the frequency of "like quiet" can be 1000.
[0140] After determining the number of occurrences of the preset text segment, the preset text segment can also be screened, for example, the preset text segment whose number of occurrences is less than a number threshold can be screened out, wherein the number threshold can be set as needed, for example, the number threshold can be 5, 6, etc. Among them, when the number of occurrences of the preset text segment is small, the probability that the preset text segment belongs to a messy text segment is high, so the preset text segment can be screened out to alleviate the interference of the messy text segment on error correction.
[0141] Optionally, determining the frequency of each of the preset text fragments includes: determining the number of occurrences of each of the preset text fragments in the corpus data; performing a logarithmic operation on the inverse of the frequency of occurrence of each of the preset text fragments to obtain an operation value of the preset text fragment, and summing the operation values of multiple preset text fragments to obtain an operation sum value; for each of the preset text fragments, dividing the operation value of the preset text fragment by the operation sum value to generate the frequency of the preset text fragment.
[0142] The frequency of the preset text segment is determined according to the following formula (2):
[0143] , (2)
[0144] in is the number of occurrences of the preset text segment j, is the number of occurrences of the preset text segment i, is the frequency of the preset text segment i, The operation and value of multiple preset text segments are obtained, where j is 1, 2, ..., m, m is the total number of preset text segments, and i is a positive integer less than or equal to m.
[0145] Through the above process, the frequency of preset text segments with lower occurrence times can be amplified, thereby achieving the highlighting effect of preset text segments with lower occurrence times, so that the first existence index of the first text segment and the second existence index of the second text segment can be determined more accurately subsequently.
[0146] After the frequency of each preset text segment is determined, a segment library may be constructed based on the plurality of preset text segments and the frequency of each preset text segment.
[0147] In an optional implementation, after determining the frequency of each of the preset text fragments, the method includes: determining whether the preset text fragment exists in the constructed knowledge graph; if so, adjusting the frequency of the preset text fragment upward to obtain the adjusted frequency of the preset text fragment, wherein the adjusted frequency is used to construct the fragment library.
[0148] The knowledge graph includes multiple entities, each of which is accurate information. Therefore, the knowledge graph can be used to adjust the frequency of the preset text fragments to increase the accuracy of the frequency of the preset text fragments.
[0149] During implementation, it is determined whether there is a preset text segment in the constructed knowledge graph. If so, it means that the preset text segment is real and accurate entity information, and the presence of the preset text segment can be enhanced, so the frequency of the preset text segment can be adjusted upward, and the adjustment value can be set as needed. Alternatively, when it is determined that there is a preset text segment in the knowledge graph, it is determined whether the frequency of the preset text segment is less than the preset frequency. If so, the frequency of the preset text segment can be adjusted to the preset frequency.
[0150] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0151] Based on the same inventive concept, the embodiment of the present disclosure also provides a text correction device based on character existence indicators corresponding to the text correction method based on character existence indicators. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned text correction method based on character existence indicators in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0152] Reference Figure 3As shown, it is a structural schematic diagram of a text error correction device based on character existence index provided by an embodiment of the present disclosure, the device includes: an acquisition module 301, a detection module 302, a generation module 303, a first determination module 304, a second determination module 305, and a construction module 306; wherein,
[0153] An acquisition module 301 is used to acquire text data to be detected;
[0154] The detection module 302 is used to detect whether there is a character to be corrected in the text data by using a text error correction model, and if so, determine a target character corresponding to the character to be corrected and an error correction probability of the target character;
[0155] A generating module 303 is configured to determine at least one first text segment including the character to be corrected from the text data based on the position of the character to be corrected in the text data and a preset segment length when the error correction probability is less than a probability threshold; and replace the character to be corrected in each of the first text segments with the target character to generate a second text segment;
[0156] A first determination module 304, configured to determine a first frequency of the first text segment existing in a pre-built segment library, and to determine a second frequency of the second text segment existing in the segment library;
[0157] The second determination module 305 is used to determine whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency, and if so, replace the to-be-corrected character in the text data with the target character.
[0158] In an optional implementation manner, the second determination module 305, when determining whether the current detection satisfies the character replacement condition based on the first frequency and the second frequency, is configured to:
[0159] It is determined whether the ratio of the second frequency to the first frequency is greater than a first ratio threshold, and if not, it is determined that the current detection satisfies a character replacement condition.
[0160] In an optional implementation manner, the second determination module 305, when determining whether the current detection satisfies the character replacement condition based on the first frequency and the second frequency, is configured to:
[0161] Determine a first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment; and determine a second existence index of the second text segment based on the second frequency of the second text segment and the position information of the target character in the second text segment; wherein the existence index is used to characterize the strength of the existence of the text segment in the segment library;
[0162] Based on the first existence index and the second existence index, it is determined whether this detection satisfies a character replacement condition.
[0163] In an optional implementation manner, the second determination module 305, when determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index, is configured to:
[0164] Determine whether the ratio of the second existence index to the first existence index is greater than a second ratio threshold, and if not, determine that the current detection satisfies a character replacement condition.
[0165] In an optional implementation manner, the second determination module 305, when determining the first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment, is configured to:
[0166] Determining a position measurement index of the character to be corrected based on the position information of the character to be corrected in the first text segment, wherein the position measurement index is used to characterize the degree of centering of the character to be corrected in the first text segment;
[0167] Based on the position measurement index of the to-be-corrected character and the first frequency of the first text segment, a first existence index corresponding to the first text segment is determined.
[0168] In an optional implementation manner, when there are multiple first text segments and multiple second text segments, the second determining module 305 is further configured to:
[0169] Averaging the first existence indexes corresponding to the plurality of first text segments to obtain a first index average value; and averaging the second existence indexes corresponding to the plurality of second text segments to obtain a second index average value;
[0170] The second determination module 305, when determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index, is used to:
[0171] Based on the first index average value and the second index average value, it is determined whether the current detection satisfies the character replacement condition.
[0172] In an optional embodiment, the method further comprises a construction module 306, which is used to construct the fragment library according to the following steps:
[0173] Get corpus data;
[0174] Extracting a plurality of preset text segments from the corpus data based on the preset segment length;
[0175] Determining the frequency of each of the predetermined text segments;
[0176] The segment library is constructed based on the multiple preset text segments and the frequency of each of the preset text segments.
[0177] In an optional implementation, the construction module 306, when determining the frequency of each of the preset text segments, is used to:
[0178] Determining the number of occurrences of each of the preset text segments in the corpus data;
[0179] Performing a logarithmic operation on the inverse of the number of occurrences of each of the preset text segments to obtain an operation value of the preset text segment, and summing the operation values of multiple preset text segments to obtain an operation sum value;
[0180] For each of the preset text segments, a division operation is performed on the operation value of the preset text segment and the operation sum value to generate the frequency of the preset text segment.
[0181] In an optional implementation, after determining the frequency of each of the preset text segments, the construction module 306 is further configured to:
[0182] Determine whether the preset text segment exists in the constructed knowledge graph;
[0183] If it exists, the frequency of the preset text segment is adjusted upward to obtain the adjusted frequency of the preset text segment, wherein the adjusted frequency is used to construct the segment library.
[0184] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0185] The present disclosure also provides a computer device, such as Figure 4 FIG. 1 is a schematic diagram of a computer device structure provided in an embodiment of the present disclosure, including:
[0186] A processor 41 and a memory 42; the memory 42 stores machine-readable instructions executable by the processor 41, and the processor 41 is used to execute the machine-readable instructions stored in the memory 42. When the machine-readable instructions are executed by the processor 41, the processor 41 performs the following steps:
[0187] Obtain the text data to be detected;
[0188] Using a text error correction model, detecting whether there is a character to be corrected in the text data, and if so, determining a target character corresponding to the character to be corrected and an error correction probability of the target character;
[0189] When the error correction probability is less than or equal to a probability threshold, based on the position of the character to be corrected in the text data and a preset segment length, determining at least one first text segment including the character to be corrected from the text data; and replacing the character to be corrected in each of the first text segments with the target character to generate a second text segment;
[0190] Determining a first frequency of the first text segment existing in a pre-built segment library, and determining a second frequency of the second text segment existing in the segment library;
[0191] Based on the first frequency and the second frequency, it is determined whether the current detection satisfies a character replacement condition, and if so, the to-be-corrected character in the text data is replaced with the target character.
[0192] The above-mentioned memory 42 includes internal memory 421 and external memory 422; the memory 421 here is also called internal memory, which is used to temporarily store the calculation data in the processor 41 and the data exchanged with the external memory 422 such as the hard disk. The processor 41 exchanges data with the external memory 422 through the internal memory 421.
[0193] The specific execution process of the above instructions can refer to the steps of the text error correction method based on character existence index described in the embodiment of the present disclosure, which will not be repeated here.
[0194] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the text error correction method based on character existence index described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0195] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the text error correction method based on character existence indicators described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0196] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0197] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0198] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0199] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0200] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0201] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A text error correction method based on character existence index, characterized in that: include: Get the text data to be detected; Using a text error correction model, detecting whether there is a character to be corrected in the text data, and if so, determining a target character corresponding to the character to be corrected and an error correction probability of the target character; When the error correction probability is less than or equal to a probability threshold, based on the position of the character to be corrected in the text data and a preset segment length, determining at least one first text segment including the character to be corrected from the text data; and replacing the character to be corrected in each of the first text segments with the target character to generate a second text segment; Determining a first frequency of the first text segment existing in a pre-built segment library, and determining a second frequency of the second text segment existing in the segment library; Based on the first frequency and the second frequency, determining whether the current detection satisfies a character replacement condition, and if so, replacing the to-be-corrected character in the text data with the target character; The determining whether the current detection satisfies the character replacement condition based on the first frequency and the second frequency includes: determining a first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment; and determining a second existence index of the second text segment based on the second frequency of the second text segment and the position information of the target character in the second text segment; wherein the existence index is used to characterize the strength of the text segment in the segment library; determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index; The first text segment is determined according to the following formula The first existence index : ; For the first text segment The first frequency, The character to be corrected in the first text segment , N is the preset segment length, is a parameter used to prevent division by zero errors, The scaling factor to set.
2. The method according to claim 1, characterized in that The determining whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency includes: It is determined whether the ratio of the second frequency to the first frequency is greater than a first ratio threshold, and if not, it is determined that the current detection satisfies a character replacement condition.
3. The method according to claim 1, characterized in that The determining whether the current detection satisfies a character replacement condition based on the first existence index and the second existence index includes: Determine whether the ratio of the second existence index to the first existence index is greater than a second ratio threshold, and if not, determine that the current detection satisfies a character replacement condition.
4. The method according to claim 1, characterized in that: The determining, based on the first frequency of the first text segment and the position information of the to-be-corrected character in the first text segment, a first existence index of the first text segment includes: Based on the position information of the character to be corrected in the first text segment, determining a position measurement index of the character to be corrected, wherein the position measurement index is used to characterize the degree of centering of the character to be corrected in the first text segment, The value of is a position measure of the first text segment; Based on the position measurement index of the to-be-corrected character and the first frequency of the first text segment, a first existence index corresponding to the first text segment is determined.
5. The method according to claim 1, characterized in that When there are multiple first text segments and multiple second text segments, the method further includes: Averaging the first existence indexes corresponding to the plurality of first text segments to obtain a first index average value; and averaging the second existence indexes corresponding to the plurality of second text segments to obtain a second index average value; The determining whether the current detection satisfies a character replacement condition based on the first existence index and the second existence index includes: Based on the first index average value and the second index average value, it is determined whether the current detection satisfies the character replacement condition.
6. The method according to any one of claims 1 to 5, characterized in that: The fragment library was constructed according to the following steps: Get corpus data; Extracting a plurality of preset text segments from the corpus data based on the preset segment length; Determining the frequency of each of the predetermined text segments; The segment library is constructed based on the multiple preset text segments and the frequency of each of the preset text segments.
7. The method according to claim 6, characterized in that The determining the frequency of each of the preset text segments includes: Determining the number of occurrences of each of the preset text segments in the corpus data; Performing a logarithmic operation on the inverse of the number of occurrences of each of the preset text segments to obtain an operation value of the preset text segment, and summing the operation values of multiple preset text segments to obtain an operation sum value; For each of the preset text segments, a division operation is performed on the operation value of the preset text segment and the operation sum value to generate the frequency of the preset text segment.
8. The method according to claim 6, characterized in that After determining the frequency of each of the preset text segments, the method includes: Determine whether the preset text segment exists in the constructed knowledge graph; If it exists, the frequency of the preset text segment is adjusted upward to obtain the adjusted frequency of the preset text segment, wherein the adjusted frequency is used to construct the segment library.
9. A text error correction device based on character existence index, characterized in that: include: An acquisition module, used for acquiring text data to be detected; A detection module, used to detect whether there is a character to be corrected in the text data by using a text error correction model, and if so, determine a target character corresponding to the character to be corrected and an error correction probability of the target character; A generating module, configured to determine, when the error correction probability is less than a probability threshold, at least one first text segment including the character to be corrected from the text data based on the position of the character to be corrected in the text data and a preset segment length; and replace the character to be corrected in each of the first text segments with the target character to generate a second text segment; a first determination module, configured to determine a first frequency of the first text segment existing in a pre-built segment library, and to determine a second frequency of the second text segment existing in the segment library; A second determination module is used to determine whether the current detection satisfies a character replacement condition based on the first frequency and the second frequency, and if so, replace the to-be-corrected character in the text data with the target character; The determining whether the current detection satisfies the character replacement condition based on the first frequency and the second frequency includes: determining a first existence index of the first text segment based on the first frequency of the first text segment and the position information of the character to be corrected in the first text segment; and determining a second existence index of the second text segment based on the second frequency of the second text segment and the position information of the target character in the second text segment; wherein the existence index is used to characterize the strength of the text segment in the segment library; determining whether the current detection satisfies the character replacement condition based on the first existence index and the second existence index; The first text segment is determined according to the following formula The first existence index : ; For the first text segment The first frequency, The character to be corrected in the first text segment , N is the preset segment length, is a parameter used to prevent division by zero errors, The scaling factor to set.
10. A computer device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor executes the steps of the text error correction method based on character existence indicators as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program. When the computer program is executed by a computer device, the computer device executes the steps of the text error correction method based on character existence indicators as described in any one of claims 1 to 8.
