Text error correction method, device, electronic device and computer-readable storage medium
By performing character splitting, representation calculation and vector construction on the text, combined with similarity and prior dependency probability, the problem of low text error correction accuracy in the existing technology is solved, and more efficient and accurate text error correction is achieved. .
Patent Information
- Application Number
- CN202011435068.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-10
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-12-10
AI Technical Summary
Existing text error correction methods do not refer to contextual semantics when performing character replacement, resulting in low text error correction accuracy.
By obtaining the original text, splitting it into character sets, calculating the character representation and vector of each character, performing similarity calculations with the standard character vector set, filtering out similar vectors, and selecting similar vectors for error correction based on a priori dependency probability.
It improves the accuracy and accuracy of text error correction, takes into account the relationship between characters and context, and reduces the impact of semantics in a single character, thus improving the efficiency and accuracy of error correction.
Smart Images

Figure CN112528633B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of speech semantics technology, and in particular to a text error correction method, device, electronic device and computer-readable storage medium. Background Art
[0002] Some texts are often used in daily life, such as contract texts and order texts signed by enterprises or individuals. With the increasing frequency of text use in daily life, the correctness of the content in the text has become the focus of people's attention, thus giving rise to methods for error correction of text content.
[0003] At present, most of the methods for correcting text content are text correction methods based on rule-based general error correction libraries. This method uses pre-given standard texts or words to replace characters in the text to be corrected according to established replacement rules to achieve text correction. However, this method does not refer to the context semantics when replacing characters. Only replacing according to established rules will result in low accuracy of text correction. Summary of the invention
[0004] The present invention provides a text error correction method, device and computer-readable storage medium, the main purpose of which is to solve the problem of low accuracy of text error correction.
[0005] To achieve the above object, the present invention provides a text error correction method, comprising:
[0006] Obtaining an original text, performing character splitting on the original text, and obtaining a character set;
[0007] Calculating a character representation of each character in the character set using a representation algorithm;
[0008] Constructing a character vector for each character in the character set according to the character set and the character representation;
[0009] Obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set;
[0010] Filtering out similar vectors of the character vectors of each character in the character set from the standard character vector set according to the similarity;
[0011] The priori dependency probability of the similar vectors is calculated, and similar vectors are selected according to the prior dependency probability to perform text error correction on the original text to obtain an error-corrected text.
[0012] Optionally, the character splitting of the original text to obtain a character set includes:
[0013] Traversing the original text and inserting a separator between each character in the original text;
[0014] The original text is split according to the separator to obtain a character set.
[0015] Optionally, constructing a character vector for each character in the character set according to the character set and the character representation includes:
[0016] Convert each character in the character set into a character code to obtain a character code;
[0017] Perform an arithmetic operation on the character code and the character representation to obtain a character vector.
[0018] Optionally, respectively calculating the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set includes:
[0019] The similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set is calculated using the following similarity algorithm:
[0020]
[0021] Among them, S(X n ,Y m ) is the distance value, X n is the character vector of the nth character in the character set, Y m is the mth standard character vector in the standard character vector set.
[0022] Optionally, the step of selecting a similar vector of the character vector of each character in the character set from the standard character vector set according to the similarity comprises:
[0023] When the similarity is less than or equal to a preset similarity threshold, determining that the standard character vector is not similar to the character vector;
[0024] When the similarity is greater than the similarity threshold, it is determined that the standard character vector is similar to the character vector, and the standard character vector is used as a similarity vector of the character vector.
[0025] Optionally, the selecting a similar vector according to the prior dependency probability to perform text error correction on the original text to obtain the error-corrected text includes:
[0026] When the priori dependency probability is less than or equal to a preset probability threshold, retaining the character vector corresponding to the similarity vector;
[0027] When the priori dependency probability is greater than the probability threshold, the character vector corresponding to the similarity vector is replaced by the similarity vector to obtain the error correction text.
[0028] Optionally, obtaining the original text includes:
[0029] Query the storage address of the original text;
[0030] Detecting a storage environment of the storage address;
[0031] Compiling a text call statement by a compiler corresponding to the storage environment;
[0032] The text calling statement is executed to obtain the original text from the storage address.
[0033] In order to solve the above problem, the present invention also provides a text error correction device, the device comprising:
[0034] A character splitting module is used to obtain an original text, perform character splitting on the original text, and obtain a character set;
[0035] A characterization calculation module, used for calculating the character representation of each character in the character set by using a characterization algorithm;
[0036] A vector construction module, used for constructing a character vector of each character in the character set according to the character set and the character representation;
[0037] A similarity calculation module is used to obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set;
[0038] A vector screening module, used for screening out similar vectors of the character vectors of each character in the character set from the standard character vector set according to the similarity;
[0039] The text error correction module is used to calculate the prior dependency probability of the similar vectors, select similar vectors according to the prior dependency probability, perform text error correction on the original text, and obtain the error-corrected text.
[0040] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0041] a memory storing at least one instruction; and
[0042] The processor executes the instructions stored in the memory to implement the text error correction method described above.
[0043] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the above-mentioned text error correction method.
[0044] The embodiment of the present invention can split the original text from a long sentence into multiple characters by performing character splitting on the original text, so as to reduce the semantics contained in a single character, which is conducive to improving the efficiency of analyzing the original text, and further improving the efficiency of text error correction; the character vector of each character in the character set is constructed by using the character set and the character representation corresponding to each character in the character set, which can uniquely identify the characteristics of the character, avoid the situation that the relationship between the character and the character vector is unclear when the character vector is subsequently analyzed, and is conducive to improving the accuracy of text error correction; the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set is calculated, and the similar vector of the character vector is screened out from the standard character vector set by the similarity, which is conducive to improving the accuracy of text error correction according to the similar vector; the prior dependency probability of the similar vector is calculated, and the similar vector is selected according to the prior dependency probability to perform text error correction on the original text, and the prior dependency probability is used to take into account the relationship between the context of the character, which is conducive to improving the accuracy of text error correction. Therefore, the text error correction method, device, electronic device and computer-readable storage medium proposed by the present invention can solve the problem of low accuracy of text error correction. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A flowchart of a text error correction method provided by an embodiment of the present invention;
[0046] Figure 2 A functional module diagram of a text error correction device provided by an embodiment of the present invention;
[0047] Figure 3 A schematic diagram of the structure of an electronic device for implementing the text error correction method provided by one embodiment of the present invention.
[0048] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0050] The embodiment of the present application provides a text error correction method. The execution subject of the text error correction method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the text error correction method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0051] Reference Figure 1 FIG. 1 is a flow chart of a text error correction method provided by an embodiment of the present invention. In this embodiment, the text error correction method includes:
[0052] S1. Obtain an original text, and perform character splitting on the original text to obtain a character set.
[0053] In the embodiment of the present invention, the original text is any text with words, such as a contract text, a demand text, a product information text, etc.
[0054] In detail, obtaining the original text includes:
[0055] Query the storage address of the original text;
[0056] Detecting a storage environment of the storage address;
[0057] Compiling a text call statement by a compiler corresponding to the storage environment;
[0058] The text calling statement is executed to obtain the original text from the storage address.
[0059] Specifically, the embodiment of the present invention uses a python statement with a data query function to query the storage address of the original text; the storage environment of the storage address is determined by the environment where the storage address is located. For example, when the storage address is a java database, the storage environment of the storage address is a java environment.
[0060] Furthermore, the character splitting of the original text to obtain a character set includes:
[0061] Traversing the original text and inserting a separator between each character in the original text;
[0062] The original text is split according to the separator to obtain a character set.
[0063] In detail, the delimiter may be predefined by a user, for example, the delimiter may be predefined as “<”.
[0064] For example, there is a text: "Zhang Hua's desire to survive is very strong and he is unwilling to lose to Li Ming", then the text is traversed and a preset separator "<" is inserted between each character in the text to obtain the text after the separator is inserted: "Zhang<Hua<'s<desire<to<survive<is<strong<and<unwilling<to<lose<to<Li<Ming", and the original text is split according to the separator to obtain a character set.
[0065] The embodiment of the present invention performs character splitting on the original text, and can split the original text from a longer sentence into multiple characters to reduce the semantics contained in a single character, which is beneficial to improving the efficiency of analyzing the original text and further improving the efficiency of text error correction.
[0066] S2. Calculate the character representation of each character in the character set using a representation algorithm.
[0067] In the embodiment of the present invention, the character representation refers to an indicator that can reflect the importance of a character, for example, a frequency indicator indicating the frequency of occurrence of a character, a weight indicator indicating the weight of a character, and the like.
[0068] In the embodiment of the present invention, the step of calculating the character representation of each character in the character set by using a representation algorithm includes:
[0069] The character representation of each character in the character set is calculated using the following representation algorithm:
[0070] TD=TF i ×IDF i
[0071] Among them, TF i is the frequency of occurrence of character i in the character set, IDF i is the inverse value of the frequency with which character i appears in the character set.
[0072] S3. Construct a character vector for each character in the character set according to the character set and the character representation.
[0073] In the embodiment of the present invention, constructing a character vector of each character in the character set according to the character set and the character representation includes:
[0074] Convert each character in the character set into a character code to obtain a character code;
[0075] Perform an arithmetic operation on the character code and the character representation to obtain a character vector.
[0076] In detail, the embodiment of the present invention utilizes a preset encoder to perform encoding conversion on each character in the character set, and the encoder includes but is not limited to an ASCII (American Standard Code for Information Interchange) encoder.
[0077] The performing an arithmetic operation on the character code and the character representation specifically refers to performing an arithmetic operation on the character code corresponding to each character in the character set and the character representation corresponding to each character in the character set to obtain a character vector.
[0078] Specifically, an embodiment of the present invention can multiply and sum the character code corresponding to each character in the character set with the character representation corresponding to each character to obtain a character vector. For example, in the character set, the character code corresponding to character 1 is A, the character code corresponding to character 2 is B, and the character code corresponding to character 3 is C; the character representation corresponding to character 1 is a, the character representation corresponding to character 2 is b, and the character representation corresponding to character 3 is c, then arithmetic operations are performed on the character code corresponding to each character and the character representation corresponding to each character to obtain the character vector of character 1 is A*a, the character vector of character 2 is B*b, and the character vector of character 3 is C*c.
[0079] Since the character sets of different public opinion information contain multiple characters, and the character representations of different characters are different, the character vector of each character in the character set is constructed by using the character set and the character representation corresponding to each character in the character set. This can uniquely identify the characteristics of the character and avoid unclear relationships between characters and character vectors when analyzing the character vectors later. This is beneficial to improving the accuracy of subsequent analysis of the character vectors.
[0080] S4. Obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set.
[0081] In the embodiment of the present invention, the standard character vector set includes standard character vectors corresponding to a plurality of characters, which can be used to perform text error correction on erroneous text.
[0082] In detail, the step of obtaining a standard character vector set includes:
[0083] Obtaining data transmission parameters of a blockchain node for storing the standard character vector set;
[0084] Configure the data transmission script of the blockchain node according to the data transmission parameters;
[0085] The data transmission script is executed to obtain the standard character vector set from the blockchain node.
[0086] Specifically, an embodiment of the present invention utilizes a python statement with a parameter capture function to capture the data transmission parameters from the blockchain node, and the data transmission file for configuring the blockchain node includes configuring the transmission conditions, transmission interface, and transmission type required to obtain a standard character vector set from the blockchain node.
[0087] In an embodiment of the present invention, the standard character vector set can be stored in a pre-built blockchain node, and the efficiency of obtaining industry salary data can be improved by utilizing the high throughput of blockchain nodes for data.
[0088] Furthermore, respectively calculating the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set includes:
[0089] The similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set is calculated using the following similarity algorithm:
[0090]
[0091] Among them, S(X n ,Y m ) is the distance value, X n is the character vector of the nth character in the character set, Y m is the mth standard character vector in the standard character vector set.
[0092] S5. Filter out similar vectors of the character vector of each character in the character set from the standard character vector set according to the similarity.
[0093] In the embodiment of the present invention, the step of selecting a similar vector of the character vector of each character in the character set from the standard character vector set according to the similarity includes:
[0094] When the similarity is less than or equal to a preset similarity threshold, determining that the standard character vector is not similar to the character vector;
[0095] When the similarity is greater than the similarity threshold, it is determined that the standard character vector is similar to the character vector, and the standard character vector is used as a similarity vector of the character vector.
[0096] For example, there is a character vector α, and the standard character vector set includes standard character vectors β, γ, δ, ε, and θ. Among them, the similarity between the character vector α and the standard character vector β is 80, the similarity between the character vector α and the standard character vector γ is 70, the similarity between the character vector α and the standard character vector δ is 60, the similarity between the character vector α and the standard character vector ε is 50, and the similarity between the character vector α and the standard character vector θ is 40. When the similarity threshold is 55, the standard character vectors β, γ, and δ are determined as the similar vectors of the character vector α.
[0097] In the embodiment of the present invention, the similarity between each character vector in the character set and each standard character vector in the standard character vector set is calculated, and the similar vectors of the character vector are screened out from the standard character vector set through the similarity, which is beneficial to improving the correct rate of text error correction according to the similar vectors.
[0098] S6. Calculate the prior dependence probability of the similar vector, and select the similar vector according to the prior dependence probability to perform text error correction on the original text to obtain the corrected text.
[0099] In the embodiment of the present invention, the prior dependence probability is the probability that a character will appear when one or more pre-character of any character in the text appear. For example, there is a text "Xiaoming encounters difficulties", the prior dependence probability of the character "difficulties" refers to the probability that the character "difficulties" appears when one or more of the pre-characters "Xiaoming", "encounters", and "difficulties" of the character "difficulties" appear.
[0100] In the embodiment of the present invention, the prior dependence probability of the similar vector is calculated by substituting the similar vector into the position of the character vector corresponding to the similar vector.
[0101] Specifically, the calculation of the prior dependence probability of the similar vector includes:
[0102] The prior dependence probability of the similar vector is calculated by using the following probability algorithm:
[0103]
[0104] Where H(ρ) is the prior dependence probability of the ρ-th similar vector, ρ is the ρ-th similar vector, x i is the i-th character in the pre-characters of the ρ-th similar vector, k is the number of pre-characters of the ρ-th similar vector, and p is the probability operator.
[0105] In the embodiment of the present invention, the step of selecting the similar vector according to the prior dependence probability to perform text error correction on the original text to obtain the corrected text includes:
[0106] When the priori dependency probability is less than or equal to a preset probability threshold, retaining the character vector corresponding to the similarity vector;
[0107] When the priori dependency probability is greater than the probability threshold, the character vector corresponding to the similarity vector is replaced by the similarity vector to obtain the error correction text.
[0108] For example, there is a text "Xiao Ming encounters a difficult situation", in which the similarity vector of the character "Jing" includes the standard character vectors corresponding to "Jing", "Jing", "Jing" and "Jing", respectively. The prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 20, the prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 50, the prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 80, and the prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 55. When the preset probability threshold is 70, it is confirmed that the correct text of the character "Jing" is the character "Jing", and the character "Jing" is replaced with the character "Jing" to obtain the corrected text "Xiao Ming encounters a difficult situation".
[0109] The embodiment of the present invention can split the original text from a long sentence into multiple characters by performing character splitting on the original text, so as to reduce the semantics contained in a single character, which is conducive to improving the efficiency of analyzing the original text, and further improving the efficiency of text error correction; constructing a character vector of each character in the character set by using a character set and a character representation corresponding to each character in the character set, which can uniquely identify the characteristics of the character, avoid the situation where the relationship between the character and the character vector is unclear when the character vector is subsequently analyzed, and is conducive to improving the accuracy of text error correction; calculating the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set, and filtering out the similar vector of the character vector from the standard character vector set by the similarity, which is conducive to improving the accuracy of text error correction according to the similar vector; calculating the prior dependency probability of the similar vector, selecting the similar vector according to the prior dependency probability to perform text error correction on the original text, and taking into account the relationship between the context of the character by using the prior dependency probability, which is conducive to improving the accuracy of text error correction. Therefore, the text error correction method proposed by the present invention can solve the problem of low accuracy of text error correction.
[0110] like Figure 2 , which is a functional module diagram of a text error correction device provided by an embodiment of the present invention.
[0111] The text error correction device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the text error correction device 100 can include a character segmentation module 101, a representation calculation module 102, a vector construction module 103, a similarity calculation module 104, a vector screening module 105 and a text error correction module 106. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0112] In this embodiment, the functions of each module / unit are as follows:
[0113] The character splitting module 101 is used to obtain an original text, perform character splitting on the original text, and obtain a character set.
[0114] In the embodiment of the present invention, the original text is any text with words, such as a contract text, a demand text, a product information text, etc.
[0115] In detail, the character splitting module 101 is specifically used for:
[0116] Query the storage address of the original text;
[0117] Detecting a storage environment of the storage address;
[0118] Compiling a text call statement by a compiler corresponding to the storage environment;
[0119] Execute the text call statement to obtain the original text from the storage address;
[0120] Traversing the original text and inserting a separator between each character in the original text;
[0121] The original text is split according to the separator to obtain a character set.
[0122] Specifically, the embodiment of the present invention uses a python statement with a data query function to query the storage address of the original text; the storage environment of the storage address is determined by the environment where the storage address is located. For example, when the storage address is a java database, the storage environment of the storage address is a java environment.
[0123] In detail, the delimiter may be predefined by a user, for example, the delimiter may be predefined as “<”.
[0124] For example, there is a text: "Zhang Hua's desire to survive is very strong and he is unwilling to lose to Li Ming", then the text is traversed and a preset separator "<" is inserted between each character in the text to obtain the text after the separator is inserted: "Zhang<Hua<'s<desire<to<survive<is<strong<and<unwilling<to<lose<to<Li<Ming", and the original text is split according to the separator to obtain a character set.
[0125] The embodiment of the present invention performs character splitting on the original text, and can split the original text from a longer sentence into multiple characters to reduce the semantics contained in a single character, which is beneficial to improving the efficiency of analyzing the original text and further improving the efficiency of text error correction.
[0126] The representation calculation module 102 is used to calculate the character representation of each character in the character set by using a representation algorithm.
[0127] In the embodiment of the present invention, the character representation refers to an indicator that can reflect the importance of a character, for example, a frequency indicator indicating the frequency of occurrence of a character, a weight indicator indicating the weight of a character, and the like.
[0128] In the embodiment of the present invention, the characterization calculation module 102 is specifically used for:
[0129] The character representation of each character in the character set is calculated using the following representation algorithm:
[0130] TD=TF i ×IDF i
[0131] Among them, TF i is the frequency of occurrence of character i in the character set, IDF i is the inverse value of the frequency with which character i appears in the character set.
[0132] The vector construction module 103 is used to construct a character vector of each character in the character set according to the character set and the character representation.
[0133] In the embodiment of the present invention, the vector construction module 103 is specifically used for:
[0134] Convert each character in the character set into a character code to obtain a character code;
[0135] Perform an arithmetic operation on the character code and the character representation to obtain a character vector.
[0136] In detail, the embodiment of the present invention utilizes a preset encoder to perform encoding conversion on each character in the character set, and the encoder includes but is not limited to an ASCII (American Standard Code for Information Interchange) encoder.
[0137] The performing an arithmetic operation on the character code and the character representation specifically refers to performing an arithmetic operation on the character code corresponding to each character in the character set and the character representation corresponding to each character in the character set to obtain a character vector.
[0138] Specifically, an embodiment of the present invention can multiply and sum the character code corresponding to each character in the character set with the character representation corresponding to each character to obtain a character vector. For example, in the character set, the character code corresponding to character 1 is A, the character code corresponding to character 2 is B, and the character code corresponding to character 3 is C; the character representation corresponding to character 1 is a, the character representation corresponding to character 2 is b, and the character representation corresponding to character 3 is c, then arithmetic operations are performed on the character code corresponding to each character and the character representation corresponding to each character to obtain the character vector of character 1 is A*a, the character vector of character 2 is B*b, and the character vector of character 3 is C*c.
[0139] Since the character sets of different public opinion information contain multiple characters, and the character representations of different characters are different, the character vector of each character in the character set is constructed by using the character set and the character representation corresponding to each character in the character set. This can uniquely identify the characteristics of the character and avoid unclear relationships between characters and character vectors when analyzing the character vectors later. This is beneficial to improving the accuracy of subsequent analysis of the character vectors.
[0140] The similarity calculation module 104 is used to obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set.
[0141] In the embodiment of the present invention, the standard character vector set includes standard character vectors corresponding to a plurality of characters, which can be used to perform text error correction on erroneous text.
[0142] In detail, the similarity calculation module 104 is specifically used for:
[0143] Obtaining data transmission parameters of a blockchain node for storing the standard character vector set;
[0144] Configure the data transmission script of the blockchain node according to the data transmission parameters;
[0145] The data transmission script is executed to obtain the standard character vector set from the blockchain node.
[0146] Specifically, an embodiment of the present invention utilizes a python statement with a parameter capture function to capture the data transmission parameters from the blockchain node, and the data transmission file for configuring the blockchain node includes configuring the transmission conditions, transmission interface, and transmission type required to obtain a standard character vector set from the blockchain node.
[0147] In an embodiment of the present invention, the standard character vector set can be stored in a pre-built blockchain node, and the efficiency of obtaining industry salary data can be improved by utilizing the high throughput of blockchain nodes for data.
[0148] Furthermore, respectively calculating the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set includes:
[0149] The similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set is calculated using the following similarity algorithm:
[0150]
[0151] Among them, S(X n ,Y m ) is the distance value, X n is the character vector of the nth character in the character set, Y m is the mth standard character vector in the standard character vector set.
[0152] The vector screening module 105 is used to screen out similar vectors of the character vector of each character in the character set from the standard character vector set according to the similarity.
[0153] In the embodiment of the present invention, the vector screening module 105 is specifically used for:
[0154] When the similarity is less than or equal to a preset similarity threshold, determining that the standard character vector is not similar to the character vector;
[0155] When the similarity is greater than the similarity threshold, it is determined that the standard character vector is similar to the character vector, and the standard character vector is used as a similarity vector of the character vector.
[0156] For example, there is a character vector α, and the standard character vector set includes standard character vectors β, γ, δ, ε, and θ. Among them, the similarity between the character vector α and the standard character vector β is 80, the similarity between the character vector α and the standard character vector γ is 70, the similarity between the character vector α and the standard character vector δ is 60, the similarity between the character vector α and the standard character vector ε is 50, and the similarity between the character vector α and the standard character vector θ is 40. When the similarity threshold is 55, the standard character vectors β, γ, and δ are determined as the similar vectors of the character vector α.
[0157] In the embodiment of the present invention, the similarity between each character vector in the character set and each standard character vector in the standard character vector set is calculated, and the similar vectors of the character vector are screened out from the standard character vector set through the similarity, which is beneficial to improving the correct rate of text error correction based on the similar vectors.
[0158] The text error correction module 106 is configured to calculate the prior dependence probability of the similar vectors, and select the similar vectors according to the prior dependence probability to perform text error correction on the original text to obtain the error-corrected text.
[0159] In the embodiment of the present invention, the prior dependence probability is the probability that a character will appear when one or more pre-character(s) of any character in the text appears. For example, there is a text "Xiaoming encounters difficulties", and the prior dependence probability of the character "difficulties" refers to the probability that the character "difficulties" appears when one or more of the pre-characters "Xiaoming", "encounters" appear.
[0160] In the embodiment of the present invention, the prior dependence probability of the similar vectors is calculated by substituting the similar vectors into the positions of the character vectors corresponding to the similar vectors.
[0161] Specifically, calculating the prior dependence probability of the similar vectors includes:
[0162] Calculating the prior dependence probability of the similar vectors by using the following probability algorithm:
[0163]
[0164] where H(ρ) is the prior dependence probability of the ρ-th similar vector, ρ is the ρ-th similar vector, x i is the i-th character among the pre-characters of the ρ-th similar vector, k is the number of pre-characters of the ρ-th similar vector, and p is the probability operator.
[0165] In the embodiment of the present invention, the text error correction module 106 is specifically configured to:
[0166] Calculating a priori dependency probability of the similarity vectors;
[0167] When the priori dependency probability is less than or equal to a preset probability threshold, retaining the character vector corresponding to the similarity vector;
[0168] When the priori dependency probability is greater than the probability threshold, the character vector corresponding to the similarity vector is replaced by the similarity vector to obtain the error correction text.
[0169] For example, there is a text "Xiao Ming encounters a difficult situation", in which the similarity vector of the character "Jing" includes the standard character vectors corresponding to "Jing", "Jing", "Jing" and "Jing", respectively. The prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 20, the prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 50, the prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 80, and the prior dependency probability calculated by substituting the character "Jing" into the text position where the character "Jing" is located is 55. When the preset probability threshold is 70, it is confirmed that the correct text of the character "Jing" is the character "Jing", and the character "Jing" is replaced with the character "Jing" to obtain the corrected text "Xiao Ming encounters a difficult situation".
[0170] The embodiment of the present invention can split the original text from a long sentence into multiple characters by performing character splitting on the original text, so as to reduce the semantics contained in a single character, which is conducive to improving the efficiency of analyzing the original text, and further improving the efficiency of text error correction; constructing a character vector of each character in the character set by using a character set and a character representation corresponding to each character in the character set, which can uniquely identify the characteristics of the character, avoid the situation where the relationship between the character and the character vector is unclear when the character vector is subsequently analyzed, and is conducive to improving the accuracy of text error correction; calculating the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set, and filtering out the similar vector of the character vector from the standard character vector set by the similarity, which is conducive to improving the accuracy of text error correction based on the similar vector; calculating the prior dependency probability of the similar vector, selecting the similar vector according to the prior dependency probability to perform text error correction on the original text, and taking into account the relationship between the context of the character by using the prior dependency probability, which is conducive to improving the accuracy of text error correction. Therefore, the text error correction device proposed by the present invention can solve the problem of low accuracy of text error correction.
[0171] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing a text error correction method provided by an embodiment of the present invention.
[0172] The electronic device 1 may include a processor 10 , a memory 11 , and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a text error correction program 12 .
[0173] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device 1, such as the code of the text error correction program 12, etc., but also be used to temporarily store data that has been output or is to be output.
[0174] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as text error correction programs, etc.) stored in the memory 11, and calls data stored in the memory 11 to execute various functions of the electronic device 1 and process data.
[0175] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0176] Figure 3Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0177] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0178] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
[0179] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0180] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0181] The text error correction program 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0182] Obtaining an original text, performing character splitting on the original text, and obtaining a character set;
[0183] Calculating a character representation of each character in the character set using a representation algorithm;
[0184] Constructing a character vector for each character in the character set according to the character set and the character representation;
[0185] Obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set;
[0186] Filtering out similar vectors of the character vectors of each character in the character set from the standard character vector set according to the similarity;
[0187] The priori dependency probability of the similar vectors is calculated, and similar vectors are selected according to the prior dependency probability to perform text error correction on the original text to obtain an error-corrected text.
[0188] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0189] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0190] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0191] Obtaining an original text, performing character splitting on the original text, and obtaining a character set;
[0192] Calculating a character representation of each character in the character set using a representation algorithm;
[0193] Constructing a character vector for each character in the character set according to the character set and the character representation;
[0194] Obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set;
[0195] Filtering out similar vectors of the character vectors of each character in the character set from the standard character vector set according to the similarity;
[0196] The priori dependency probability of the similar vectors is calculated, and similar vectors are selected according to the prior dependency probability to perform text error correction on the original text to obtain an error-corrected text.
[0197] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0198] The modules described as separate components may or may not be physically separated, and the components shown as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0199] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0200] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0201] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0202] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0203] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0204] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A text error correction method, characterized in that: The method comprises: Obtaining an original text, performing character splitting on the original text, and obtaining a character set; Calculating a character representation of each character in the character set using a representation algorithm; Constructing a character vector for each character in the character set according to the character set and the character representation; Obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set; Filtering out similar vectors of the character vectors of each character in the character set from the standard character vector set according to the similarity; Calculating the prior dependency probability of the similar vectors, and selecting similar vectors according to the prior dependency probability to perform text error correction on the original text to obtain an error-corrected text; The step of constructing a character vector of each character in the character set according to the character set and the character representation includes: performing encoding conversion on each character in the character set to obtain a character code; performing arithmetic operation on the character code and the character representation to obtain a character vector; The selecting a similar vector according to the prior dependency probability to perform text correction on the original text to obtain a corrected text includes: when the prior dependency probability is less than or equal to a preset probability threshold, retaining the character vector corresponding to the similar vector; when the prior dependency probability is greater than the probability threshold, using the similar vector to replace the character vector corresponding to the similar vector to obtain the corrected text; The step of calculating the character representation of each character in the character set by using the representation algorithm includes: calculating the character representation of each character in the character set by using the following representation algorithm: in, For characters The frequency of occurrence in the character set, For characters The inverse of the frequency of occurrence in the character set.
2. The text error correction method according to claim 1, characterized in that: The character splitting of the original text to obtain a character set includes: Traversing the original text and inserting a separator between each character in the original text; The original text is split according to the separator to obtain a character set.
3. The text error correction method according to claim 1, characterized in that: The respectively calculating the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set includes: The similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set is calculated using the following similarity algorithm: in, is the distance value, The character set character vector of characters, is the first A standard character vector.
4. The text error correction method according to any one of claims 1 to 3, characterized in that: The step of selecting a similar vector of the character vector of each character in the character set from the standard character vector set according to the similarity comprises: When the similarity is less than or equal to a preset similarity threshold, determining that the standard character vector is not similar to the character vector; When the similarity is greater than the similarity threshold, it is determined that the standard character vector is similar to the character vector, and the standard character vector is used as a similarity vector of the character vector.
5. The text error correction method according to claim 1, characterized in that: The obtaining of the original text comprises: Query the storage address of the original text; Detecting a storage environment of the storage address; Compiling a text call statement by a compiler corresponding to the storage environment; The text calling statement is executed to obtain the original text from the storage address.
6. A text error correction device, used to implement the text error correction method according to any one of claims 1 to 5, characterized in that: The device comprises: A character splitting module is used to obtain an original text, perform character splitting on the original text, and obtain a character set; A characterization calculation module, used for calculating the character representation of each character in the character set by using a characterization algorithm; A vector construction module, used for constructing a character vector of each character in the character set according to the character set and the character representation; A similarity calculation module is used to obtain a standard character vector set, and respectively calculate the similarity between the character vector of each character in the character set and each standard character vector in the standard character vector set; A vector screening module, used for screening out similar vectors of the character vectors of each character in the character set from the standard character vector set according to the similarity; The text error correction module is used to calculate the prior dependency probability of the similar vectors, select similar vectors according to the prior dependency probability, perform text error correction on the original text, and obtain the error-corrected text.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the text error correction method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text error correction method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Text error correction method, device and system
CN111310440A
Text error correction method and device, electronic equipment and storage medium
CN112016304A
