Text processing method, device, electronic device and computer-readable storage medium
By vectorizing text objects and feature extraction, and text processing combined with spelling check results, the problem of difficult to take into account both the quality and efficiency of text proofreading in the prior art is solved, and efficient and accurate Chinese text proofreading is achieved.
Patent Information
- Application Number
- CN202010463654.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-27
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2040-05-27
Smart Images

Figure CN113743092B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of image processing technology, and in particular to a text processing method, device, electronic device, and computer-readable storage medium. Background Art
[0002] When people use input tools to input text, they often make input errors such as spelling errors, errors in similar characters, and errors in similar characters. The above input errors usually make the text easy to be misunderstood, which in turn affects the effect and efficiency of people's text communication. In addition, in many rigorous document scenarios, such as policies, judicial, and contract texts, the tolerance for the above input errors is almost zero. Therefore, in many cases, it is necessary to proofread the text. There are two proofreading methods in the prior art: manual proofreading and machine proofreading. Among them, the manual proofreading method has a relatively high proofreading quality, but it is time-consuming and labor-intensive, and the proofreading efficiency is low; the machine proofreading method has a fast proofreading speed, but because the Chinese text expression is very complex, many spelling errors are difficult to be accurately identified. In addition, the spelling check feature data and spelling error correction feature data used in the existing machine proofreading method are relatively independent data. No matter which data is used, it is not enough to improve the robustness of text proofreading, so the proofreading quality is low. In summary, there is an urgent need for a text processing method that can simultaneously guarantee proofreading quality and proofreading efficiency and save labor costs. Summary of the invention
[0003] Embodiments of the present disclosure provide a text processing method, device, electronic device, and computer-readable storage medium.
[0004] In a first aspect, a text processing method is provided in an embodiment of the present disclosure.
[0005] Specifically, the text processing method includes:
[0006] Acquire a text object, and perform vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object;
[0007] Performing a first feature extraction on the vectorized matrix to obtain a first feature matrix, and performing a spelling check based on the first feature matrix to obtain a spelling check probability matrix;
[0008] A second feature extraction is performed on the first feature matrix to obtain a second feature matrix, and a processing result of the text object is obtained by performing processing based on the spelling check probability matrix and the second feature matrix.
[0009] In combination with the first aspect, in a first implementation of the first aspect of the embodiment of the present disclosure, the acquiring of the text object and the vectorization processing of the text object to obtain the vectorization matrix corresponding to the text object are implemented as follows:
[0010] Get the text object;
[0011] Performing word segmentation on the text object to obtain a word set;
[0012] Vectorized matrix mapping is performed on the character set to obtain a vectorized matrix corresponding to the text object, wherein the dimension of the vectorized matrix is n*d, n is the number of characters in the character set, and d is a preset vectorized dimension.
[0013] In combination with the first aspect and the first implementation manner of the first aspect, in the second implementation manner of the first aspect of the embodiment of the present disclosure, performing first feature extraction on the vectorized matrix to obtain a first feature matrix is implemented as follows:
[0014] Determine the context feature extraction model;
[0015] The context feature extraction model is used to extract context features of the vectorized matrix to obtain a first feature matrix, wherein the dimension of the first feature matrix is n*h1, n is the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model.
[0016] In combination with the first aspect, the first implementation manner of the first aspect and the second implementation manner of the first aspect, in a third implementation manner of the first aspect of the present disclosure, performing spelling check based on the first feature matrix to obtain a spelling check probability matrix is implemented as follows:
[0017] Determine the spell-check model;
[0018] The first feature matrix is used as an input of the spelling check model for calculation to obtain a spelling check probability matrix, wherein the dimension of the spelling check probability matrix is n*r, n is the number of characters in the character set, and r is the number of spelling check result categories.
[0019] In combination with the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, and the third implementation manner of the first aspect, in a fourth implementation manner of the first aspect of the present disclosure, performing second feature extraction on the first feature matrix to obtain a second feature matrix is implemented as follows:
[0020] Determine the spelling processing feature extraction model;
[0021] The spelling processing feature extraction model is used to extract the spelling processing features of the first feature matrix to obtain a second feature matrix, wherein the dimension of the second feature matrix is n*h2, n is the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model.
[0022] In combination with the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, and the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect of the present disclosure, the processing result of obtaining the text object by performing processing based on the spelling check probability matrix and the second feature matrix is implemented as follows:
[0023] Determining a preset vocabulary and processing a candidate probability calculation model, wherein the preset vocabulary at least includes the character set;
[0024] The second feature matrix is used as an input of the processing candidate probability calculation model to calculate and obtain a processing candidate probability matrix, wherein the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary, and the dimension of the processing candidate probability matrix is n*V, where n is the number of characters in the character set, and V is the number of characters in the preset vocabulary;
[0025] A processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0026] In combination with the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, the fourth implementation manner of the first aspect, and the fifth implementation manner of the first aspect, in a sixth implementation manner of the first aspect of the present disclosure, the spelling check probability matrix includes two types of spelling check results, namely, correct and incorrect.
[0027] The process of obtaining the processing result of the text object based on the spelling check probability matrix and the processing candidate probability matrix is implemented as follows:
[0028] Establishing a position probability matrix based on the position relationship of characters between the character set and the preset vocabulary;
[0029] Multiplying the position probability matrix with the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix;
[0030] Multiplying the processing candidate probability matrix with the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix;
[0031] Adding the first text object processing probability matrix to the second text object processing probability matrix to obtain a text object processing probability matrix, wherein the row vectors of the text object processing probability matrix correspond to the processing probabilities of the characters in the preset vocabulary in sequence;
[0032] The word corresponding to the vector value with the largest probability in the row vector of the text object processing probability matrix is used as the processing result of the word at the corresponding position in the text object.
[0033] In a second aspect, a text processing device is provided in an embodiment of the present disclosure.
[0034] Specifically, the text processing device includes:
[0035] A vectorization processing module is configured to obtain a text object and perform vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object;
[0036] A spelling check module is configured to perform a first feature extraction on the vectorized matrix to obtain a first feature matrix, and perform a spelling check based on the first feature matrix to obtain a spelling check probability matrix;
[0037] The processing module is configured to perform second feature extraction on the first feature matrix to obtain a second feature matrix, and perform processing based on the spelling check probability matrix and the second feature matrix to obtain a processing result of the text object.
[0038] In combination with the second aspect, in a first implementation manner of the second aspect of the embodiment of the present disclosure, the vectorization processing module is configured as follows:
[0039] Get the text object;
[0040] Performing word segmentation on the text object to obtain a word set;
[0041] Vectorized matrix mapping is performed on the character set to obtain a vectorized matrix corresponding to the text object, wherein the dimension of the vectorized matrix is n*d, n is the number of characters in the character set, and d is a preset vectorized dimension.
[0042] In combination with the second aspect and the first implementation of the second aspect, in the second implementation of the second aspect of the embodiment of the present disclosure, the part in the spelling check module that performs first feature extraction on the vectorized matrix to obtain the first feature matrix is configured as follows:
[0043] Determine the context feature extraction model;
[0044] The context feature extraction model is used to extract context features of the vectorized matrix to obtain a first feature matrix, wherein the dimension of the first feature matrix is n*h1, n is the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model.
[0045] In combination with the second aspect, the first implementation manner of the second aspect, and the second implementation manner of the second aspect, in a third implementation manner of the second aspect of the present disclosure, the part of the spelling check module that performs spelling check based on the first feature matrix to obtain a spelling check probability matrix is configured as follows:
[0046] Determine the spell-check model;
[0047] The first feature matrix is used as an input of the spelling check model for calculation to obtain a spelling check probability matrix, wherein the dimension of the spelling check probability matrix is n*r, n is the number of characters in the character set, and r is the number of spelling check result categories.
[0048] In combination with the first implementation manner of the second aspect, the second implementation manner of the second aspect, and the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect of the present disclosure, the part of the processing module that performs second feature extraction on the first feature matrix to obtain the second feature matrix is configured as follows:
[0049] Determine the spelling processing feature extraction model;
[0050] The spelling processing feature extraction model is used to extract the spelling processing features of the first feature matrix to obtain a second feature matrix, wherein the dimension of the second feature matrix is n*h2, n is the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model.
[0051] In combination with the second aspect, the second implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, and the fourth implementation manner of the second aspect, in a fifth implementation manner of the second aspect of the present disclosure, a part of the processing module that performs processing based on the spelling check probability matrix and the second feature matrix to obtain a processing result of the text object is configured as follows:
[0052] Determining a preset vocabulary and processing a candidate probability calculation model, wherein the preset vocabulary at least includes the character set;
[0053] The second feature matrix is used as an input of the processing candidate probability calculation model to calculate and obtain a processing candidate probability matrix, wherein the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary, and the dimension of the processing candidate probability matrix is n*V, where n is the number of characters in the character set, and V is the number of characters in the preset vocabulary;
[0054] A processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0055] In combination with the second aspect, the second implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, the fourth implementation manner of the second aspect, and the fifth implementation manner of the second aspect, in a sixth implementation manner of the second aspect of the present disclosure, the spelling check probability matrix includes two types of spelling check results, namely, correct and incorrect.
[0056] The part of obtaining the processing result of the text object based on the spelling check probability matrix and the processing candidate probability matrix is configured as follows:
[0057] Establishing a position probability matrix based on the position relationship of characters between the character set and the preset vocabulary;
[0058] Multiplying the position probability matrix with the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix;
[0059] Multiplying the processing candidate probability matrix with the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix;
[0060] Adding the first text object processing probability matrix to the second text object processing probability matrix to obtain a text object processing probability matrix, wherein the row vectors of the text object processing probability matrix correspond to the processing probabilities of the characters in the preset vocabulary in sequence;
[0061] The word corresponding to the vector value with the largest probability in the row vector of the text object processing probability matrix is used as the processing result of the word at the corresponding position in the text object.
[0062] In a third aspect, an embodiment of the present disclosure provides an electronic device, including a memory and a processor, wherein the memory is used to store one or more computer instructions that support a text processing device to perform the above-mentioned text processing method, and the processor is configured to execute the computer instructions stored in the memory. The text processing device may also include a communication interface for the text processing device to communicate with other devices or a communication network.
[0063] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium for storing computer instructions used by a text processing device, which includes computer instructions involved in the text processing device for executing the above-mentioned text processing method.
[0064] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0065] The above technical solution extracts features twice for the text object to be processed, first uses the result of the first feature extraction to perform spelling check, and then combines the spelling check result and the result of the second feature extraction to perform text processing to obtain the text processing result. This technical solution uses spelling check feature data and spelling error correction feature data in combination, and can effectively improve the efficiency of text processing and save labor costs while ensuring the quality of text processing and improving the robustness of text processing.
[0066] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the embodiments of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Other features, purposes and advantages of the embodiments of the present disclosure will become more apparent through the following detailed description of non-limiting embodiments in conjunction with the accompanying drawings. In the accompanying drawings:
[0068] Figure 1 A flowchart showing a text processing method according to an embodiment of the present disclosure is shown;
[0069] Figure 2 An overall flow chart of a text processing method according to an embodiment of the present disclosure is shown;
[0070] Figure 3 A structural block diagram of a text processing device according to an embodiment of the present disclosure is shown;
[0071] Figure 4 It is a structural diagram of a computer system suitable for implementing a text processing method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0072] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, parts not related to the description of the exemplary embodiments are omitted in the accompanying drawings.
[0073] In the embodiments of the present disclosure, it should be understood that terms such as "including" or "having" are intended to indicate the existence of features, numbers, steps, behaviors, components, parts, or a combination thereof disclosed in this specification, and are not intended to exclude the possibility of one or more other features, numbers, steps, behaviors, components, parts, or a combination thereof existing or being added.
[0074] It should also be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0075] The technical solution provided by the embodiment of the present disclosure performs two feature extractions on the text object to be processed, first uses the result obtained by the first feature extraction to perform spelling check, and then combines the spelling check result and the result obtained by the second feature extraction to perform text processing to obtain the text processing result. The technical solution uses spelling check feature data and spelling error correction feature data in combination, and can effectively improve the efficiency of text processing and save labor costs while ensuring the quality of text processing and improving the robustness of text processing.
[0076] Figure 1 A flowchart of a text processing method according to an embodiment of the present disclosure is shown, which is applicable to a text processing server, such as Figure 1 As shown, the text processing method includes the following steps S101-S103:
[0077] In step S101, a text object is obtained, and vectorization processing is performed on the text object to obtain a vectorization matrix corresponding to the text object;
[0078] In step S102, a first feature extraction is performed on the vectorized matrix to obtain a first feature matrix, and a spelling check is performed based on the first feature matrix to obtain a spelling check probability matrix;
[0079] In step S103, a second feature extraction is performed on the first feature matrix to obtain a second feature matrix, and processing is performed based on the spelling check probability matrix and the second feature matrix to obtain a processing result of the text object.
[0080] As mentioned above, when people use input tools to input text, they often make input errors such as spelling errors, errors in similar characters, and errors in similar characters. The above input errors usually make the text easy to be misunderstood, which in turn affects the effect and efficiency of people's text communication. In addition, in many rigorous document scenarios, such as policies, judicial, and contract texts, the tolerance for the above input errors is almost zero. Therefore, in many cases, it is necessary to proofread the text. There are two proofreading methods in the prior art: manual proofreading and machine proofreading. Among them, the manual proofreading method has a relatively high proofreading quality, but it is time-consuming and labor-intensive, and the proofreading efficiency is low; the machine proofreading method has a fast proofreading speed, but because the Chinese text expression is very complex, many spelling errors are difficult to be accurately identified. In addition, the spelling check feature data and spelling error correction feature data used in the existing machine proofreading method are relatively independent data. No matter which data is used, it is not enough to improve the robustness of text proofreading, so the proofreading quality is low. In summary, there is an urgent need for a text processing method that can simultaneously guarantee proofreading quality and proofreading efficiency and save labor costs.
[0081] In view of the above problems, in this embodiment, a text processing method is proposed, which performs two feature extractions on the text object to be processed, first uses the result obtained by the first feature extraction to perform spelling check, and then combines the spelling check result and the result obtained by the second feature extraction to perform text processing to obtain the text processing result. This technical solution uses spelling check feature data and spelling error correction feature data in combination, and can effectively improve the efficiency of text processing and save labor costs while ensuring the quality of text processing and improving the robustness of text processing.
[0082] In one embodiment of the present disclosure, the text object refers to text that may contain spelling errors and needs to be checked and proofread, especially Chinese text. The text object can be the currently input text or the text obtained from other text sources.
[0083] In one embodiment of the present disclosure, the vectorization processing refers to the process of converting a non-vector into a vector, for example, a text can be converted into a vectorized matrix by using a vectorized matrix mapping method.
[0084] In one embodiment of the present disclosure, the first feature refers to a feature subsequently used for spell checking, and the second feature refers to a feature subsequently used for text processing, wherein both the first feature and the second feature can be taken as context features, and of course other text features can also be used. The present disclosure does not specifically limit the specific forms of expression of the first feature and the second feature.
[0085] In one embodiment of the present disclosure, the step S101, i.e., obtaining a text object and performing vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object, can be implemented as follows:
[0086] Get the text object;
[0087] Performing word segmentation on the text object to obtain a word set;
[0088] Vectorized matrix mapping is performed on the character set to obtain a vectorized matrix corresponding to the text object, wherein the dimension of the vectorized matrix can be expressed as n*d, where n is the number of characters in the character set and d is a preset vectorized dimension.
[0089] In order to more conveniently perform effective spelling check and accurate text proofreading on the text object, in this embodiment, it is necessary to perform vectorization processing on the text object to convert it into a vector form.
[0090] First, the acquired text object is segmented into characters to obtain a character set. In the prior art, spelling and proofreading for Western European languages such as English are relatively mature, and they are mainly based on word granularity for text checking and proofreading. There is a big difference between Chinese and Western European languages such as English. There is no word segmentation in Chinese text, so text with spelling errors can easily lead to word segmentation errors in the word segmentation system, making the accumulation of errors more serious. Therefore, when performing spelling check on Chinese text, it is necessary to be based on word granularity, that is, it is necessary to first segment the text object into characters to obtain a character set consisting of segmented characters and corresponding to the text object.
[0091] Then, vectorization matrix mapping is performed on the character set, that is, each part in the character set is mapped into a vector representation through a vectorization matrix, and a vectorization matrix corresponding to the text object is obtained, that is, the vectorization result of the text object, wherein the dimension of the vectorization matrix can be n*d, n is the number of characters in the character set, and d is a preset vectorization dimension, which can be determined according to the needs of the actual application and the scale of the character set, and the present disclosure does not make any specific limitation on it.
[0092] For example, if a text object is "I was shocked at 11 o'clock and ate KFC", we can first perform character segmentation on it to obtain the segmentation result: "I|was|surprised|at|11|o'clock|,|eat|KFC", and then get a character set composed of 8 character units: {I, shocked, at, 11, o'clock,,, eat, KFC}, and then each part of the character set is mapped to a vector representation through a vectorization matrix, and an 8*d-dimensional vectorization matrix corresponding to the text object can be obtained.
[0093] In one embodiment of the present disclosure, the step of performing first feature extraction on the vectorized matrix to obtain the first feature matrix in step S102 may be implemented as follows:
[0094] Determine the context feature extraction model;
[0095] The context feature extraction model is used to extract context features of the vectorized matrix to obtain a first feature matrix, wherein the dimension of the first feature matrix is n*h1, n is the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model.
[0096] In this embodiment, the first feature is taken as a context feature. Therefore, when obtaining the first feature matrix, a context feature extraction model is first determined; then the context feature extraction model is used to extract the context features of the vectorized matrix, and finally the first feature matrix is obtained, wherein the dimension of the first feature matrix can be expressed as n*h1, n is still the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model. Similar to d, h1 can also be determined according to the needs of the actual application and the scale of the character set, and the present disclosure does not make any specific limitation on it.
[0097] In one embodiment of the present disclosure, the context feature extraction model can be a bidirectional long short-term memory network (BiLSTM).
[0098] In one embodiment of the present disclosure, the step of performing spelling check based on the first feature matrix to obtain a spelling check probability matrix in step S102 may be implemented as follows:
[0099] Determine the spell-check model;
[0100] The first feature matrix is used as an input of the spelling check model for calculation to obtain a spelling check probability matrix, wherein the dimension of the spelling check probability matrix is n*r, n is the number of characters in the character set, and r is the number of spelling check result categories.
[0101] In this embodiment, the first feature matrix is used to perform spelling check. First, a spelling check model is determined. Then, the first feature matrix is used as the input of the spelling check model and input into the spelling check model for calculation to obtain a spelling check probability matrix, wherein the dimension of the spelling check probability matrix is n*r, where n is still the number of characters in the character set, and r is the number of spelling check result categories. For example, if the spelling check results are divided into two categories: correct spelling check and incorrect spelling check, that is, r=2, then the matrix elements of a row in the spelling check probability matrix represent the probability of a certain character in the character set being spelled correctly or incorrectly, and the matrix elements of the first column in the spelling check probability matrix represent the probability of each character in the character set being spelled correctly, and the matrix elements of the second column represent the probability of each character in the character set being spelled incorrectly.
[0102] In one embodiment of the present disclosure, the spelling check model can be a computational model composed of a feedforward neural network and a softmax function.
[0103] In one embodiment of the present disclosure, the context feature extraction model and the spelling check model may be trained using a back propagation algorithm based on the output of the spelling check model: the spelling check probability matrix, so as to achieve a more optimized result and obtain a target spelling check probability matrix.
[0104] In one embodiment of the present disclosure, the step of extracting the second feature from the first feature matrix to obtain the second feature matrix in step S103 may be implemented as follows:
[0105] Determine the spelling processing feature extraction model;
[0106] The spelling processing feature extraction model is used to extract the spelling processing features of the first feature matrix to obtain a second feature matrix, wherein the dimension of the second feature matrix is n*h2, n is the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model.
[0107] In this embodiment, the second feature is obtained based on the first feature. Similar to the first feature, the second feature can also be taken as a context feature. Therefore, when obtaining the second feature matrix, it is necessary to first determine a spelling processing feature extraction model, that is, the second feature extraction model; then use the spelling processing feature extraction model to extract the spelling processing features based on the first feature matrix, and finally obtain the second feature matrix, wherein the dimension of the second feature matrix can be expressed as n*h2, n is still the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model. Similar to d and h1, h2 can also be determined according to the needs of the actual application and the scale of the character set, and the present disclosure does not make specific limitations on it.
[0108] In one embodiment of the present disclosure, the spelling processing feature extraction model can also be taken as a bidirectional long short-term memory network (BiLSTM). The combination of the first feature extraction model and the spelling processing feature extraction model is equivalent to adding a spelling processing feature extraction model to the output of the first feature extraction model to realize secondary feature extraction.
[0109] In one embodiment of the present disclosure, the step of performing processing based on the spelling check probability matrix and the second feature matrix to obtain the processing result of the text object in step S103 may be implemented as follows:
[0110] Determining a preset vocabulary and processing a candidate probability calculation model, wherein the preset vocabulary at least includes the character set;
[0111] The second feature matrix is used as an input of the processing candidate probability calculation model to calculate and obtain a processing candidate probability matrix, wherein the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary, and the dimension of the processing candidate probability matrix is n*V, where n is the number of characters in the character set, and V is the number of characters in the preset vocabulary;
[0112] A processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0113] In order to improve the quality of text processing and enhance the robustness of text processing, in this embodiment, spelling check feature data and spelling error correction feature data are used in combination to perform processing operations. Specifically, a preset word list and a processing candidate probability calculation model are first determined, wherein the preset word list is a pre-set word list that at least includes the character set, such as a relatively complete word list that includes both characters that may appear as wrong characters and characters that may appear as correct characters, or a word set obtained based on historical correction data, etc.; then the second feature matrix is used as the input of the processing candidate probability calculation model and input into the processing candidate probability calculation model for calculation to obtain a processing candidate probability matrix, wherein the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset word list, and therefore, the dimension of the processing candidate probability matrix is n*V, where n is still the number of characters in the character set, and V is the number of characters in the preset word list; finally, the processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0114] In one embodiment of the present disclosure, the candidate processing probability calculation model can be a calculation model composed of a forward neural network and a softmax function.
[0115] In one embodiment of the present disclosure, based on the output of the processing candidate probability calculation model: the processing candidate probability matrix, the back propagation algorithm can be used to train the context feature extraction model, the spelling check model, the spelling processing feature extraction model and the processing candidate probability calculation model to make them more optimized and obtain the target processing candidate probability matrix.
[0116] In one embodiment of the present disclosure, the spelling check probability matrix includes two types of spelling check results: correct and incorrect;
[0117] In this embodiment, the step of obtaining the processing result of the text object based on the spelling check probability matrix and the processing candidate probability matrix can be implemented as follows:
[0118] Establishing a position probability matrix based on the position relationship of characters between the character set and the preset vocabulary;
[0119] Multiplying the position probability matrix with the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix;
[0120] Multiplying the processing candidate probability matrix with the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix;
[0121] Adding the first text object processing probability matrix to the second text object processing probability matrix to obtain a text object processing probability matrix, wherein the row vectors of the text object processing probability matrix correspond to the processing probabilities of the characters in the preset vocabulary in sequence;
[0122] The word corresponding to the vector value with the largest probability in the row vector of the text object processing probability matrix is used as the processing result of the word at the corresponding position in the text object.
[0123] As mentioned above, the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary. In this embodiment, a position probability matrix O is first established based on the position relationship of the characters between the character set and the preset vocabulary. The position probability matrix is used to represent the existence probability of the characters in the character set at the corresponding positions in the preset vocabulary. For example, in the matrix elements of a row of the position probability matrix, except for the characters corresponding to the row in the character set, the probability value at the corresponding position in the preset vocabulary is 1, and all other places are 0. Therefore, the dimension of the position probability matrix is n*V, where n is still the number of characters in the character set, and V is the number of characters in the preset vocabulary. When the spelling check probability matrix includes both correct and incorrect spelling check results, in order to To obtain the correction result of the text object, first, the position probability matrix is multiplied by the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix; then, the processing candidate probability matrix is multiplied by the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix; the first text object processing probability matrix is added to the second text object processing probability matrix to obtain a text object processing probability matrix P, wherein the row vectors of the text object processing probability matrix P correspond to the processing probabilities of the characters in the preset vocabulary in sequence; finally, the character corresponding to the vector value with the largest probability in the row vectors of the text object processing probability matrix is used as the processing result of the character at the corresponding position in the text object.
[0124] Figure 2 The overall flow chart of the text processing method according to one embodiment of the present disclosure is shown as follows: Figure 2As shown, firstly, a text object to be processed is obtained, and then vectorized to obtain a vectorized matrix corresponding to the text object; a preset context feature extraction model is used to extract context features of the vectorized matrix to obtain a first feature matrix; the first feature matrix is used as an input of a preset spelling check model to perform spelling check to obtain a spelling check probability matrix, i.e., a spelling check result; spelling processing feature extraction is performed on the first feature matrix to obtain a second feature matrix, and the second feature matrix is used as an input of a preset processing candidate probability calculation model to perform calculation to obtain a processing candidate probability matrix; finally, the processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0125] The technical solution of the present disclosure is explained and illustrated below by taking a specific example.
[0126] Suppose the input text object is "平果" (Pingguo), and the vocabulary V only includes three characters: 苹 (ping), 平 (ping), and 果 (guo), with a size of 3. First, segment the text object by characters, and the segmentation result is: "平|果" (ping|guo). Then, a character set consisting of 2 character units is obtained: [平, 果] (ping, guo). Map this character set to a vectorized matrix. Since n = 2 and assuming the vectorization dimension d is 1, a vectorized matrix of n*d = 2*1 corresponding to the text object "平果" (Pingguo) can be obtained: [[平], [果]] ([[ping], [guo]]); Use a bidirectional long short-term memory network (BiLSTM) as the context feature extraction model to extract the context features of the vectorized matrix, and a first feature matrix is obtained. Then, use the first feature matrix as the input of a spelling check model composed of a forward neural network and a softmax function for spelling check. If the spelling check result has two categories: spelling check correct and spelling check wrong, that is, r = 2, a spelling check probability matrix of n*r = 2*2 can be obtained: [[0.1, 0.9], [0.95, 0.05]], where the probability values in the first row of the spelling check probability matrix [0.1, 0.9] indicate that the probability of the character "平" (ping) being spelled correctly is 0.1, and the probability of being spelled wrong is 0.9. The probability values in the second row [0.95, 0.05] indicate that the probability of the character "果" (guo) being spelled correctly is 0.95, and the probability of being spelled wrong is 0.05. That is, the probability values in the first column of the spelling check probability matrix [0.1, 0.95] correspond to the probability p_c of the characters "平" (ping) and "果" (guo) being spelled correctly, and the probability values in the second column [0.9, 0.05] correspond to the probability p_w of the characters "平" (ping) and "果" (guo) being spelled wrong; Extract spelling processing features from the first feature matrix to obtain a second feature matrix. Use the second feature matrix as the input of a processing candidate probability calculation model composed of a forward neural network and a softmax function for calculation, and a processing candidate probability matrix of n*V = 2*3 is obtained: C = [[0.9, 0.1, 0.0], [0.1, 0.1, 0.8]]. The probability values in the first row of the processing candidate probability matrix C [0.9, 0.1, 0.0] indicate that the processing candidate probabilities of the character "平" (ping) in the vocabulary V are [苹 = 0.9, 平 = 0.1, 果 = 0.0], and the probability values in the second row [0.1, 0.1, 0.8] indicate that the processing candidate probabilities of the character "果" (guo) in the vocabulary V are [苹 = 0.1, 平 = 0.1, 果 = 0.8]; Establish a position probability matrix O based on the position relationship of characters between the character set [Ping, Guo] and the preset word list [Ping, Ping, Guo]: [[0, 1, 0], [0, 0, 1]]. The probability values [0, 1, 0] in the first row of the position probability matrix O indicate that the existence probabilities of the character "Ping" in the word list V at different positions are [0, 1, 0], and the probability values [0, 0, 1] in the second row indicate that the existence probabilities of the character "Guo" in the word list V at different positions are [0, 0, 1]. That is, the character "Ping" exists at the second position of the word list V, and the character "Guo" exists at the third position of the word list V. Then, the text object processing probability matrix P for representing the processing result of the text object can be calculated using the following formula:.
[0127] P = O * p_c + C * p_w
[0128] = [[0, 1, 0], [0, 0, 1]] * [0.1, 0.95] + [[0.9, 0.1, 0.0], [0.1, 0.1, 0.8]] * [0.9, 0.05]
[0129] = [[0, 1 * 0.1, 0], [0, 0, 1 * 0.95]] + [[0.9 * 0.9, 0.1 * 0.9, 0.0], [0.1 * 0.05, 0.1 * 0.05, 0.8 * 0.05]]
[0130] = [[0, 0.1, 0], [0, 0, 0.95]] + [[0.81, 0.09, 0.0], [0.005, 0.005, 0.04]]
[0131] = [[0.81, 0.19, 0], [0.005, 0.005, 0.99]].
[0132] The character "Ping" corresponding to the vector value 0.81 with the largest probability in the first row vector of the text object processing probability matrix P and the character "Guo" corresponding to the vector value 0.99 with the largest probability in the second row vector are the processing results of the characters "Ping" and "Guo" at the corresponding positions in the text object. That is, the processing result of the text object "Pingguo" is "Pingguo".
[0133] The above technical solution can be used in many scenarios, such as:
[0134] 1. Document checking and proofreading. For a document that has been published, is about to be published, or has just been completed, in order to avoid text input and usage errors, the above-mentioned solution can be used to check and proofread it, thereby improving the writing quality of the document. At the same time, the cost of manual checking and proofreading can be greatly saved. Specifically, the document is first vectorized to obtain a vectorized matrix corresponding to it, and then a first feature extraction is performed on the vectorized matrix to obtain a first feature matrix. A spelling check is performed based on the first feature matrix to obtain a spelling check probability matrix. A second feature extraction is performed on the first feature matrix to obtain a second feature matrix. Finally, the inspection result of the document can be obtained by combining the spelling check probability matrix and the second feature matrix. Furthermore, the document can be proofread and corrected according to the inspection result.
[0135] 2. In the field of education, automatic checking of homework and automatic correction of essays can be realized. In this scenario, the vocabulary can be determined according to the correct homework content. When the vocabulary content is determined, the technical solution described above can be used to effectively and automatically check and proofread students' homework and essays. This can greatly reduce the workload of teachers, while ensuring the accuracy of checking and proofreading homework and essays.
[0136] 3. Provide text processing services. For example, the text processing interface can be provided through cloud servers and other media, so that many users only need to request to call the text processing interface and input the text object to be processed to immediately obtain text checking, proofreading and other processing results without the need for users to spend time and manpower on the development of related technologies, which saves users' time and manpower costs. Especially for users who lack R&D capabilities, the text processing service can provide them with great convenience.
[0137] The technical solution of the present disclosure can also be applied to many other application scenarios. The above are only illustrative examples and descriptions and should not be understood as limitations on the technical solution of the present disclosure.
[0138] The following are embodiments of the apparatus of the present disclosure, which can be used to execute embodiments of the method of the present disclosure.
[0139] Figure 3 FIG. 1 shows a structural block diagram of a text processing device according to an embodiment of the present disclosure. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both, and can be implemented as a text processing server. Figure 3 As shown, the text processing device includes:
[0140] The vectorization processing module 301 is configured to obtain a text object and perform vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object;
[0141] A spelling check module 302 is configured to perform a first feature extraction on the vectorized matrix to obtain a first feature matrix, and perform a spelling check based on the first feature matrix to obtain a spelling check probability matrix;
[0142] The processing module 303 is configured to perform second feature extraction on the first feature matrix to obtain a second feature matrix, and perform processing based on the spelling check probability matrix and the second feature matrix to obtain a processing result of the text object.
[0143] As mentioned above, when people use input tools to input text, they often make input errors such as spelling errors, errors in similar characters, and errors in similar characters. The above input errors usually make the text easy to be misunderstood, which in turn affects the effect and efficiency of people's text communication. In addition, in many rigorous document scenarios, such as policies, judicial, and contract texts, the tolerance for the above input errors is almost zero. Therefore, in many cases, it is necessary to proofread the text. There are two proofreading methods in the prior art: manual proofreading and machine proofreading. Among them, the manual proofreading method has a relatively high proofreading quality, but it is time-consuming and labor-intensive, and the proofreading efficiency is low; the machine proofreading method has a fast proofreading speed, but because the Chinese text expression is very complex, many spelling errors are difficult to be accurately identified. In addition, the spelling check feature data and spelling error correction feature data used in the existing machine proofreading method are relatively independent data. No matter which data is used, it is not enough to improve the robustness of text proofreading, so the proofreading quality is low. In summary, there is an urgent need for a text processing method that can simultaneously guarantee proofreading quality and proofreading efficiency and save labor costs.
[0144] In view of the above problems, in this embodiment, a text processing device is proposed, which performs two feature extractions on the text object to be processed, first uses the result obtained by the first feature extraction to perform spelling check, and then combines the spelling check result and the result obtained by the second feature extraction to perform text processing to obtain the text processing result. This technical solution uses spelling check feature data and spelling error correction feature data in combination, and can effectively improve the efficiency of text processing and save labor costs while ensuring the quality of text processing and improving the robustness of text processing.
[0145] In one embodiment of the present disclosure, the text object refers to text that may contain spelling errors and needs to be checked and proofread, especially Chinese text. The text object can be the currently input text or the text obtained from other text sources.
[0146] In one embodiment of the present disclosure, the vectorization processing refers to the process of converting a non-vector into a vector, for example, a text can be converted into a vectorized matrix by using a vectorized matrix mapping method.
[0147] In one embodiment of the present disclosure, the first feature refers to a feature subsequently used for spell checking, and the second feature refers to a feature subsequently used for text processing, wherein both the first feature and the second feature can be taken as context features, and of course other text features can also be used. The present disclosure does not specifically limit the specific forms of expression of the first feature and the second feature.
[0148] In one embodiment of the present disclosure, the vectorization processing module 301 may be configured as follows:
[0149] Get the text object;
[0150] Performing word segmentation on the text object to obtain a word set;
[0151] Vectorized matrix mapping is performed on the character set to obtain a vectorized matrix corresponding to the text object, wherein the dimension of the vectorized matrix can be expressed as n*d, where n is the number of characters in the character set and d is a preset vectorized dimension.
[0152] In order to more conveniently perform effective spelling check and accurate text proofreading on the text object, in this embodiment, it is necessary to perform vectorization processing on the text object to convert it into a vector form.
[0153] First, the acquired text object is segmented into characters to obtain a character set. In the prior art, spelling and proofreading for Western European languages such as English are relatively mature, and they are mainly based on word granularity for text checking and proofreading. There is a big difference between Chinese and Western European languages such as English. There is no word segmentation in Chinese text, so text with spelling errors can easily lead to word segmentation errors in the word segmentation system, making the accumulation of errors more serious. Therefore, when performing spelling check on Chinese text, it is necessary to be based on word granularity, that is, it is necessary to first segment the text object into characters to obtain a character set consisting of segmented characters and corresponding to the text object.
[0154] Then, vectorization matrix mapping is performed on the character set, that is, each part in the character set is mapped into a vector representation through a vectorization matrix, and a vectorization matrix corresponding to the text object is obtained, that is, the vectorization result of the text object, wherein the dimension of the vectorization matrix can be n*d, n is the number of characters in the character set, and d is a preset vectorization dimension, which can be determined according to the needs of the actual application and the scale of the character set, and the present disclosure does not make any specific limitation on it.
[0155] For example, if a text object is "I was shocked at 11 o'clock and ate KFC", we can first perform character segmentation on it to obtain the segmentation result: "I|was|surprised|at|11|o'clock|,|eat|KFC", and then get a character set composed of 8 character units: {I, shocked, at, 11, o'clock,,, eat, KFC}, and then each part of the character set is mapped to a vector representation through a vectorization matrix, and an 8*d-dimensional vectorization matrix corresponding to the text object can be obtained.
[0156] In one embodiment of the present disclosure, the part of the spelling check module 302 that performs first feature extraction on the vectorized matrix to obtain the first feature matrix may be configured as follows:
[0157] Determine the context feature extraction model;
[0158] The context feature extraction model is used to extract context features of the vectorized matrix to obtain a first feature matrix, wherein the dimension of the first feature matrix is n*h1, n is the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model.
[0159] In this embodiment, the first feature is taken as a context feature. Therefore, when obtaining the first feature matrix, a context feature extraction model is first determined; then the context feature extraction model is used to extract the context features of the vectorized matrix, and finally the first feature matrix is obtained, wherein the dimension of the first feature matrix can be expressed as n*h1, n is still the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model. Similar to d, h1 can also be determined according to the needs of the actual application and the scale of the character set, and the present disclosure does not make any specific limitation on it.
[0160] In one embodiment of the present disclosure, the context feature extraction model can be a bidirectional long short-term memory network (BiLSTM).
[0161] In one embodiment of the present disclosure, the part of the spelling check module 302 that performs spelling check based on the first feature matrix to obtain the spelling check probability matrix may be configured as follows:
[0162] Determine the spell-check model;
[0163] The first feature matrix is used as an input of the spelling check model for calculation to obtain a spelling check probability matrix, wherein the dimension of the spelling check probability matrix is n*r, n is the number of characters in the character set, and r is the number of spelling check result categories.
[0164] In this embodiment, the first feature matrix is used to perform spelling check. First, a spelling check model is determined. Then, the first feature matrix is used as the input of the spelling check model and input into the spelling check model for calculation to obtain a spelling check probability matrix, wherein the dimension of the spelling check probability matrix is n*r, where n is still the number of characters in the character set, and r is the number of spelling check result categories. For example, if the spelling check results are divided into two categories: correct spelling check and incorrect spelling check, that is, r=2, then the matrix elements of a row in the spelling check probability matrix represent the probability of a certain character in the character set being spelled correctly or incorrectly, and the matrix elements of the first column in the spelling check probability matrix represent the probability of each character in the character set being spelled correctly, and the matrix elements of the second column represent the probability of each character in the character set being spelled incorrectly.
[0165] In one embodiment of the present disclosure, the spelling check model can be a computational model composed of a feedforward neural network and a softmax function.
[0166] In one embodiment of the present disclosure, the spelling check model can also use a back propagation algorithm to train the context feature extraction model and the spelling check model based on the output of the spelling check model: the spelling check probability matrix, so as to make them more optimized and obtain a target spelling check probability matrix.
[0167] In one embodiment of the present disclosure, the part of the processing module 303 that performs second feature extraction on the first feature matrix to obtain the second feature matrix may be configured as follows:
[0168] Determine the spelling processing feature extraction model;
[0169] The spelling processing feature extraction model is used to extract the spelling processing features of the first feature matrix to obtain a second feature matrix, wherein the dimension of the second feature matrix is n*h2, n is the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model.
[0170] In this embodiment, the second feature is obtained based on the first feature. Similar to the first feature, the second feature can also be taken as a context feature. Therefore, when obtaining the second feature matrix, it is necessary to first determine a spelling processing feature extraction model, that is, the second feature extraction model; then use the spelling processing feature extraction model to extract the spelling processing features based on the first feature matrix, and finally obtain the second feature matrix, wherein the dimension of the second feature matrix can be expressed as n*h2, n is still the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model. Similar to d and h1, h2 can also be determined according to the needs of the actual application and the scale of the character set, and the present disclosure does not make specific limitations on it.
[0171] In one embodiment of the present disclosure, the spelling processing feature extraction model can also be taken as a bidirectional long short-term memory network (BiLSTM). The combination of the first feature extraction model and the spelling processing feature extraction model is equivalent to adding a spelling processing feature extraction model to the output of the first feature extraction model to realize secondary feature extraction.
[0172] In one embodiment of the present disclosure, the part of the processing module 303 that performs processing based on the spelling check probability matrix and the second feature matrix to obtain the processing result of the text object can be configured as follows:
[0173] Determining a preset vocabulary and processing a candidate probability calculation model, wherein the preset vocabulary at least includes the character set;
[0174] The second feature matrix is used as an input of the processing candidate probability calculation model to calculate and obtain a processing candidate probability matrix, wherein the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary, and the dimension of the processing candidate probability matrix is n*V, where n is the number of characters in the character set, and V is the number of characters in the preset vocabulary;
[0175] A processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0176] In order to improve the quality of text processing and enhance the robustness of text processing, in this embodiment, spelling check feature data and spelling error correction feature data are used in combination to perform processing operations. Specifically, a preset word list and a processing candidate probability calculation model are first determined, wherein the preset word list is a pre-set word list that at least includes the character set, such as a relatively complete word list that includes both characters that may appear as wrong characters and characters that may appear as correct characters, or a word set obtained based on historical correction data, etc.; then the second feature matrix is used as the input of the processing candidate probability calculation model and input into the processing candidate probability calculation model for calculation to obtain a processing candidate probability matrix, wherein the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset word list, and therefore, the dimension of the processing candidate probability matrix is n*V, where n is still the number of characters in the character set, and V is the number of characters in the preset word list; finally, the processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix.
[0177] In one embodiment of the present disclosure, the candidate processing probability calculation model can be a calculation model composed of a forward neural network and a softmax function.
[0178] In one embodiment of the present disclosure, the processing candidate probability calculation model can also be based on the output of the processing candidate probability calculation model: the processing candidate probability matrix, and use the back propagation algorithm to train the context feature extraction model, the spelling check model, the spelling processing feature extraction model and the processing candidate probability calculation model to make them more optimized and obtain the target processing candidate probability matrix.
[0179] In one embodiment of the present disclosure, the spelling check probability matrix includes two types of spelling check results: correct and incorrect;
[0180] In this embodiment, the part of obtaining the processing result of the text object based on the spelling check probability matrix and the processing candidate probability matrix can be configured as follows:
[0181] Establishing a position probability matrix based on the position relationship of characters between the character set and the preset vocabulary;
[0182] Multiplying the position probability matrix with the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix;
[0183] Multiplying the processing candidate probability matrix with the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix;
[0184] Adding the first text object processing probability matrix to the second text object processing probability matrix to obtain a text object processing probability matrix, wherein the row vectors of the text object processing probability matrix correspond to the processing probabilities of the characters in the preset vocabulary in sequence;
[0185] The word corresponding to the vector value with the largest probability in the row vector of the text object processing probability matrix is used as the processing result of the word at the corresponding position in the text object.
[0186] As mentioned above, the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary. In this embodiment, a position probability matrix O is first established based on the position relationship of the characters between the character set and the preset vocabulary. The position probability matrix is used to represent the existence probability of the characters in the character set at the corresponding positions in the preset vocabulary. For example, in the matrix elements of a row of the position probability matrix, except for the characters corresponding to the row in the character set, the probability value at the corresponding position in the preset vocabulary is 1, and all other places are 0. Therefore, the dimension of the position probability matrix is n*V, where n is still the number of characters in the character set, and V is the number of characters in the preset vocabulary. When the spelling check probability matrix includes both correct and incorrect spelling check results, in order to To obtain the correction result of the text object, first, the position probability matrix is multiplied by the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix; then, the processing candidate probability matrix is multiplied by the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix; the first text object processing probability matrix is added to the second text object processing probability matrix to obtain a text object processing probability matrix P, wherein the row vectors of the text object processing probability matrix P correspond to the processing probabilities of the characters in the preset vocabulary in sequence; finally, the character corresponding to the vector value with the largest probability in the row vectors of the text object processing probability matrix is used as the processing result of the character at the corresponding position in the text object.
[0187] The present disclosure also discloses an electronic device, which includes a memory and a processor; wherein:
[0188] The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement any of the above method steps.
[0189] Figure 4 A schematic diagram of the structure of a computer system suitable for implementing the text processing method according to an embodiment of the present disclosure.
[0190] like Figure 4As shown, the computer system 400 includes a processing unit 401, which can perform various processes in the above-mentioned embodiments according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the system 400 are also stored. The processing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0191] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. The drive 410 is also connected to the I / O interface 405 as needed. Removable media 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., are installed on the drive 410 as needed, so that the computer program read therefrom is installed into the storage section 408 as needed. Among them, the processing unit 401 can be implemented as a processing unit such as a CPU, a GPU, a TPU, an FPGA, an NPU, etc.
[0192] In particular, according to an embodiment of the present disclosure, the method described above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program tangibly contained on a readable medium thereof, and the computer program includes a program code for executing the text processing method. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 409, and / or installed from the removable medium 411.
[0193] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the road map or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions characterized in the box can also occur in an order different from the order characterized in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0194] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The units or modules described may also be set in a processor, and the names of these units or modules do not constitute limitations on the units or modules themselves in some cases.
[0195] As another aspect, the embodiments of the present disclosure further provide a computer-readable storage medium, which may be a computer-readable storage medium included in the device described in the above-mentioned embodiment; or a computer-readable storage medium that exists independently and is not assembled into the device. The computer-readable storage medium stores one or more programs, and the programs are used by one or more processors to execute the methods described in the embodiments of the present disclosure.
[0196] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure.
Claims
1. A text processing method, comprising: Acquire a text object, and perform vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object; Performing a first feature extraction on the vectorized matrix to obtain a first feature matrix, and performing a spell check based on the first feature matrix to obtain a spell check probability matrix, wherein the spell check probability matrix includes probabilities of spell check results of different categories; A second feature extraction is performed on the first feature matrix to obtain a second feature matrix, and a processing result of the text object is obtained based on the spelling check probability matrix and the processing candidate probability matrix, wherein the processing candidate probability matrix is determined based on the second feature matrix, and the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary.
2. According to the method of claim 1, the acquiring of the text object and performing vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object is implemented as follows: Get the text object; Performing word segmentation on the text object to obtain a word set; Perform vectorization matrix mapping on the character set to obtain a vectorization matrix corresponding to the text object, wherein: The dimension of the vectorization matrix is n*d, where n is the number of characters in the character set and d is the preset vectorization dimension.
3. According to the method of claim 2, the first feature extraction is performed on the vectorized matrix to obtain the first feature matrix, which is implemented as follows: Determine the context feature extraction model; The context feature extraction model is used to extract the context features of the vectorized matrix to obtain a first feature matrix, wherein: The dimension of the first feature matrix is n*h1, where n is the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model.
4. The method according to claim 2 or 3, wherein performing spell checking based on the first feature matrix to obtain a spell checking probability matrix is implemented as follows: Determine the spell-check model; The first feature matrix is used as the input of the spelling check model to calculate and obtain a spelling check probability matrix, wherein: The dimension of the spelling check probability matrix is n*r, where n is the number of characters in the character set and r is the number of spelling check result categories.
5. The method according to claim 2 or 3, wherein the step of extracting the second feature from the first feature matrix to obtain the second feature matrix is implemented as follows: Determine the spelling processing feature extraction model; The spelling processing feature extraction model is used to extract the spelling processing features of the first feature matrix to obtain a second feature matrix, wherein: The dimension of the second feature matrix is n*h2, where n is the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model.
6. The method according to claim 2 or 3, wherein the processing candidate probability matrix is determined based on the second feature matrix and is implemented as follows: Determine the preset vocabulary and process candidate probability calculation model, wherein: The preset vocabulary at least includes the character set; The second feature matrix is used as the input of the processing candidate probability calculation model to calculate and obtain the processing candidate probability matrix, wherein the dimension of the processing candidate probability matrix is n*V, n is the number of characters in the character set, and V is the number of characters in the preset vocabulary.
7. The method according to claim 6, wherein the spelling check probability matrix includes two types of spelling check results: correct and incorrect; The process of obtaining the processing result of the text object based on the spelling check probability matrix and the processing candidate probability matrix is implemented as follows: Establishing a position probability matrix based on the position relationship of characters between the character set and the preset vocabulary; Multiplying the position probability matrix with the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix; Multiplying the processing candidate probability matrix with the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix; The first text object processing probability matrix is added to the second text object processing probability matrix to obtain a text object processing probability matrix, wherein: The row vectors of the text object processing probability matrix respectively correspond to the processing probabilities of the characters in the preset vocabulary in sequence; The word corresponding to the vector value with the largest probability in the row vector of the text object processing probability matrix is used as the processing result of the word at the corresponding position in the text object.
8. A text processing device, comprising: A vectorization processing module is configured to obtain a text object and perform vectorization processing on the text object to obtain a vectorization matrix corresponding to the text object; A spelling check module is configured to perform a first feature extraction on the vectorized matrix to obtain a first feature matrix, and perform a spelling check based on the first feature matrix to obtain a spelling check probability matrix, wherein the spelling check probability matrix contains probabilities of spelling check results of different categories; A processing module is configured to perform a second feature extraction on the first feature matrix to obtain a second feature matrix, and obtain a processing result of the text object based on the spelling check probability matrix and a processing candidate probability matrix, wherein the processing candidate probability matrix is determined based on the second feature matrix, and the processing candidate probability matrix is used to represent the corresponding correction candidate probabilities of the characters in the character set in the preset vocabulary.
9. The apparatus according to claim 8, wherein the vectorization processing module is configured to: Get the text object; Performing word segmentation on the text object to obtain a word set; Perform vectorization matrix mapping on the character set to obtain a vectorization matrix corresponding to the text object, wherein: The dimension of the vectorization matrix is n*d, where n is the number of characters in the character set and d is the preset vectorization dimension.
10. The apparatus according to claim 9, wherein the part of the spelling check module that extracts the first feature from the vectorized matrix to obtain the first feature matrix is configured as follows: Determine the context feature extraction model; The context feature extraction model is used to extract the context features of the vectorized matrix to obtain a first feature matrix, wherein: The dimension of the first feature matrix is n*h1, where n is the number of characters in the character set, and h1 is the preset output dimension of the context feature extraction model.
11. The apparatus according to claim 9 or 10, wherein the part of the spelling check module that performs spelling check based on the first feature matrix to obtain a spelling check probability matrix is configured as follows: Determine the spell-check model; The first feature matrix is used as the input of the spelling check model to calculate and obtain a spelling check probability matrix, wherein: The dimension of the spelling check probability matrix is n*r, where n is the number of characters in the character set and r is the number of spelling check result categories.
12. The apparatus according to claim 9 or 10, wherein the part of the processing module that extracts the second feature from the first feature matrix to obtain the second feature matrix is configured as follows: Determine the spelling processing feature extraction model; The spelling processing feature extraction model is used to extract the spelling processing features of the first feature matrix to obtain a second feature matrix, wherein: The dimension of the second feature matrix is n*h2, where n is the number of characters in the character set, and h2 is the preset output dimension of the spelling processing feature extraction model.
13. The apparatus according to claim 9 or 10, wherein when the processing module determines the processing candidate probability matrix based on the second feature matrix, the processing module is configured to: Determine the preset vocabulary and process candidate probability calculation model, wherein: The preset vocabulary at least includes the character set; The second feature matrix is used as the input of the processing candidate probability calculation model to calculate and obtain the processing candidate probability matrix, wherein the dimension of the processing candidate probability matrix is n*V, n is the number of characters in the character set, and V is the number of characters in the preset vocabulary.
14. The device according to claim 13, wherein the spelling check probability matrix includes two types of spelling check results: correct and incorrect; The part of obtaining the processing result of the text object based on the spelling check probability matrix and the processing candidate probability matrix is configured as follows: Establishing a position probability matrix based on the position relationship of characters between the character set and the preset vocabulary; Multiplying the position probability matrix with the probability vector corresponding to the correct spelling check result in the spelling check probability matrix to obtain a first text object processing probability matrix; Multiplying the processing candidate probability matrix with the probability vector corresponding to the incorrect spelling check result in the spelling check probability matrix to obtain a second text object processing probability matrix; The first text object processing probability matrix is added to the second text object processing probability matrix to obtain a text object processing probability matrix, wherein: The row vectors of the text object processing probability matrix respectively correspond to the processing probabilities of the characters in the preset vocabulary in sequence; The word corresponding to the vector value with the largest probability in the row vector of the text object processing probability matrix is used as the processing result of the word at the corresponding position in the text object.
15. An electronic device comprising a memory and a processor; wherein: The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps described in any one of claims 1-7.
16. A computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions, when executed by a processor, implement the method steps described in any one of claims 1 to 7.
Citation Information
Patent Citations
Text spelling error correction method and system, computer device and storage medium
CN108491392A