Intelligent text error correction method, device, electronic device and readable storage medium
By performing unsupervised training on unlabeled text sets and supervised training on labeled text sets, combined with text masking operations, the robustness and error correction effect of the text correction model are improved, solving the problems of high resource consumption and poor robustness in existing technologies. In particular, it achieves efficient text correction in the medical field.
Patent Information
- Application Number
- CN202010329725.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-23
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-04-23
AI Technical Summary
Existing text correction technologies in the medical field suffer from high resource consumption and poor robustness. In particular, traditional models are not performing well, and deep learning models require a large corpus during the training phase, resulting in high resource consumption.
Unsupervised training of a pre-built original text correction model is performed using an unlabeled text set, combined with supervised training using a labeled text set. Text masking operations and deep learning models are then used to improve the error correction effect.
Without excessive consumption of human and computer resources, it significantly improves the accuracy and efficiency of text correction, especially in the medical field, where it can effectively correct word usage errors.
Smart Images

Figure CN111626047B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, electronic device and readable storage medium for intelligent text error correction. Background Art
[0002] Text error correction has broad application prospects, such as intelligent error correction and prompts for cumbersome texts in the medical field, speeding up the work efficiency of prescription printers, correcting spelled texts during office chats, preventing low-level errors, etc.
[0003] There are two main technologies for text correction: 1. Traditional text correction models using distance calculation methods; 2. Deep learning text correction models trained using large corpora. Both methods can correct text errors to a certain extent, but deep learning text correction models require a large corpus during the training phase. Whether it is corpus collection, cleaning, or subsequent training processes, it consumes a lot of manpower and computer resources. Traditional text correction models have poor robustness and are not ideal for certain scenarios, especially for texts in the medical field. Summary of the invention
[0004] The present invention provides an intelligent text error correction method, device, electronic device and computer-readable storage medium, the main purpose of which is to solve the problem of improving the text error correction effect without excessively consuming human and computer resources.
[0005] To achieve the above object, the present invention provides an intelligent text error correction method, comprising:
[0006] The pre-built original text error correction model is trained unsupervised using the unlabeled text set to obtain a primary text error correction model.
[0007] Using the labeled text set to perform supervised training on the primary text error correction model to obtain a standard text error correction model;
[0008] Acquire the text to be corrected, perform a text masking operation on the text to be corrected to obtain one or more groups of masked texts, input the masked texts into the standard text correction model, and obtain a predicted text and a predicted probability value of the predicted text;
[0009] When the predicted text is different from the text to be corrected and the predicted probability value is greater than the preset probability value, text correction is performed on the text to be corrected according to the predicted text.
[0010] Optionally, the unsupervised training of the pre-built original text error correction model using the unlabeled text set to obtain the primary text error correction model includes:
[0011] According to a pre-built text vector conversion method, the unlabeled text set is converted into a text vector set;
[0012] Performing position annotation on the unlabeled text set to obtain a text position set;
[0013] According to the text vector conversion method, the text position set is converted into a position vector set;
[0014] The position vector set and the text vector set are input into the original text error correction model for unsupervised training until the number of training times of the unsupervised training meets the preset training requirements, and the training is exited to obtain a primary text error correction model.
[0015] Optionally, converting the unlabeled text set into a text vector set according to a pre-built text vector conversion method includes:
[0016] The unlabeled text set is converted into a text vector set using the following conversion method:
[0017]
[0018] Wherein, ω represents the path value of the text decision tree based on the text vector conversion method, j represents the index of the unlabeled text set, and is a positive integer, ζ(ω,j) represents the text vector of the jth unlabeled text in the unlabeled text set under the path ω, represents the Huffman code corresponding to the jth node in the path ω, where ω is a positive integer, θ is the iteration factor of the text vector conversion method, σ represents the sigmoid function, and X ω is the unlabeled text set.
[0019] Optionally, the step of inputting the position vector set and the text vector set into the original text error correction model for unsupervised training includes:
[0020] The text vector set is divided into multiple groups of word vector sets based on vector data;
[0021] Divide the text vector set into multiple groups of paragraph vector sets by dividing the text vector set into units based on the behavior of the vector;
[0022] The weight relationship between each group of the word vector sets, each group of the paragraph vector sets and the position vector sets is calculated, and the internal parameters of the original text error correction model are updated according to the weight relationship.
[0023] Optionally, the calculating the weight relationship between each group of the word vector sets, each group of the paragraph vector sets and the position vector sets includes:
[0024] Select any one of the word vector set, the paragraph vector set, and the position vector set in sequence as a target vector;
[0025] Performing the text masking operation on the target vector to obtain a masking vector;
[0026] The weights of the masking vector and other vectors in the word vector set, the paragraph vector set, and the position vector set are calculated to obtain a weight set, and the weight set is weightedly fused to obtain the weight relationship.
[0027] Optionally, the supervised training of the primary text error correction model using the labeled text set to obtain a standard text error correction model includes:
[0028] Extracting labels of the labeled text from the labeled text set to obtain a true label set;
[0029] According to the text vector conversion method, the marked text set is converted into a marked text vector set;
[0030] Inputting the labeled text vector set into the primary text error correction model for supervised training to obtain a predicted label set;
[0031] If the error range between the predicted label set and the true label set is greater than the preset error, continue the supervised training until the error range between the predicted label set and the true label set is less than the preset error, exit the supervised training, and obtain the standard text error correction model.
[0032] Optionally, the method further includes:
[0033] When the predicted text is the same as the text to be corrected, re-receiving the text to be corrected;
[0034] When the predicted text is different from the text to be corrected, and the predicted probability value is less than a preset probability value, the text to be corrected is received again.
[0035] In order to solve the above problems, the present invention also provides an intelligent text error correction device, the device comprising:
[0036] The unsupervised training module is used to calculate the label of the current information set according to the correspondence between the historical information set and the historical label set to obtain the current label set;
[0037] A supervised training module, used for performing label adjustment on the current label set according to a preset adjustment factor to obtain a standard label set;
[0038] A predictive text module, used for extracting label features from the standard label set to obtain a feature extraction set according to a convolutional neural network feature extraction technique;
[0039] The text error correction module is used to use the feature extraction set as the input value of the trained classification neural network to perform classification prediction to obtain information classification results.
[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] A processor executes instructions stored in the memory to implement any one of the intelligent text error correction methods described above.
[0043] In order to solve the above problems, 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 any one of the intelligent text correction methods described above.
[0044] The present invention uses an unlabeled text set to perform unsupervised training and supervised training on a pre-constructed original text correction model, and predicts text through text masking operations and trained models. Since unsupervised training does not require a large amount of manual and computer resources for marking and cleaning, and the pre-constructed original text correction model is based on deep learning, the text correction ability is strong for certain specific scenarios. Therefore, the intelligent text correction method, device, electronic device and computer-readable storage medium proposed by the present invention can solve the problem of improving the text correction effect without excessively consuming manual and computer resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic diagram of a flow chart of an intelligent text error correction method provided by an embodiment of the present invention;
[0046] Figure 2 A detailed flowchart of step S1 in the intelligent text error correction method provided by one embodiment of the present invention;
[0047] Figure 3 A detailed flow chart of step S2 in the intelligent text error correction method provided by one embodiment of the present invention;
[0048] Figure 4 A schematic diagram of a module of an intelligent text error correction method provided by an embodiment of the present invention;
[0049] Figure 5 A schematic diagram of the internal structure of an electronic device for an intelligent text error correction method provided by an embodiment of the present invention;
[0050] 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
[0051] 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.
[0052] The present invention provides an intelligent text error correction method. Figure 1 FIG. 1 is a flow chart of an intelligent text error correction method provided by an embodiment of the present invention. The method can be executed by a device, and the device can be implemented by software and / or hardware.
[0053] In this embodiment, the intelligent text error correction method includes:
[0054] S1. Use the unlabeled text set to perform unsupervised training on the pre-built original text error correction model to obtain a primary text error correction model.
[0055] Text error correction has a wide range of application scenarios, especially in the medical field. Due to the complex wording, many medical books and prescriptions have wording errors. For example, patient Zhang Qiang suffers from seborrheic dermatitis, and the doctor prescribes compound ketoconazole hair lotion. The prescription printer mistakenly prints compound ketoconazole hair lotion as compound tongconazole hair lotion. In this case, the technical solution of the present invention can be used for intelligent error correction.
[0056] The unlabeled text set is a text set without adding labels. For example, the above-mentioned compound ketoconazole hair lotion and compound tongconazole hair lotion are actually unlabeled texts. It can be simply understood that compound ketoconazole hair lotion is the correct writing form, while compound tongconazole hair lotion is the wrong writing form, but no label is given whether it is written correctly.
[0057] For details, the S1 can be found in Figure 2 The detailed flow chart of the steps includes:
[0058] S11, converting the unlabeled text set into a text vector set according to a pre-built text vector conversion method;
[0059] S12, performing position marking on the unlabeled text set to obtain a text position set, and converting the text position set into a position vector set according to the text vector conversion method;
[0060] S13, inputting the position vector set and the text vector set into the original text error correction model for unsupervised training, until the number of training times of the unsupervised training meets the preset training requirement, and then exiting the training to obtain a primary text error correction model.
[0061] Furthermore, the text vector conversion method may adopt one-hot word vector conversion, Word2Vec word vector conversion, etc.
[0062] The preferred embodiment of the present invention adopts Word2Vec word vector conversion, and the Word2Vec word vector conversion includes:
[0063] The unlabeled text set or the text position set is converted into a vector in the following manner:
[0064]
[0065] Wherein, ω represents the decision tree path value on which the Word2Vec word vector conversion depends, j represents the index of the unlabeled text set and is a positive integer, ζ(ω,j) represents the text vector of the jth unlabeled text in the unlabeled text set or the position vector of the jth text position in the text position set under the path ω, represents the Huffman code corresponding to the jth node in the path ω, where ω is a positive integer, θ is the iteration factor of the Word2Vec word vector conversion, σ represents the sigmoid function, and X ω is the unlabeled text set or the text position set.
[0066] For example, the original correct compound ketoconazole hair lotion is transformed into a text vector and a position vector after the above vector conversion. The text vector is [1.6, 1.23, 6.91, 9.4, 12.7, 0.3, 17.03, 2.81, 1.04], and the position vector is [0.11, 1.09, 3.59, 0.4, 0.75, 2.1, 5.1, 2.09, 3.77]
[0067] Preferably, the original text error correction model is improved based on the BERT model (Bidirectional Encoder Representations from Transformer, BERT for short).
[0068] In detail, the position vector set and the text vector set are input into the original text error correction model for unsupervised training, including: dividing the text vector set into multiple groups of word vector sets based on the data in the vector set, dividing the text vector set into multiple groups of paragraph vector sets based on behavior, calculating the weight relationship between each group of the word vector set, each group of the paragraph vector set and the position vector set, and updating the internal parameters of the original text error correction model according to the weight relationship.
[0069] For example, the text vector of the compound ketoconazole hair lotion is [1.6, 1.23, 6.91, 9.4, 12.7, 0.3, 17.03, 2.81, 1.04], and the position vector is [0.11, 1.09, 3.59, 0.4, 0.75, 2.1, 5.1, 2.09, 3.77]. If the text vector is divided into data units, multiple groups of word vector sets in the form of [0.75, 2.1], [1.6, 2.81, 1.04], [0.3, 17.03, 2.81, 1.04] can be obtained. If the text vector of the compound ketoconazole hair lotion is multi-line, for example, the expression is Then we divide the paragraph vectors into two groups: [1.6, 1.23] and [6.91, 9.4] by row.
[0070] Furthermore, the calculation of the weight relationship between each group of the word vector sets, each group of the paragraph vector sets and the position vector sets includes: randomly selecting a vector in any one of the word vector sets, the paragraph vector sets and the position vector sets as a target vector, performing a text masking operation on the target vector to obtain a masked vector, calculating the weight of the masked vector and the vectors in each vector set to obtain a weight set, and weighted fusion of the weight sets to obtain the weight relationship.
[0071] For example, the compound ketoconazole hair lotion has a word vector [0.3, 17.03, 2.81, 1.04] selected as the target vector. The text masking operation is to mask any data. For example, [0.3, 17.03, 2.81, 1.04] is transformed into [0.3, **, 2.81, **] by text masking operation. Then, the weight set is obtained by calculating the weights of [0.3, **, 2.81, **] and other word vectors, paragraph vectors, and position vectors.
[0072] In detail, the weights of the shielding vector and the vectors in each vector set may be calculated using a similarity calculation method, and the similarity calculation method may use the currently disclosed cosine calculation method, Euclidean distance method, and the like.
[0073] The weighted fusion can adopt a fusion method in the form of Gaussian distribution, a linear method (such as a linear function), or a nonlinear method (such as a quadratic function). For example, the weight set is [0.101, 3.091, 2.057, 0.4, 0.756, 2.71, 5.103]. A linear function is used for fusion to obtain the k value and b value of the linear function, and then the k value and b value are used as internal parameters of the original text error correction model.
[0074] S2. Use the labeled text set to perform supervised training on the primary text error correction model to obtain a standard text error correction model.
[0075] The labeled text set corresponds to the unlabeled text set. The labeled text set is a text set with added labels. As described in S1, compound ketoconazole hair lotion, compound tongconazole hair lotion, etc. can be unlabeled texts. Even if compound tongconazole hair lotion is written in an incorrect way, in the labeled text set, compound ketoconazole hair lotion is added with a correctly written label, and incorrectly written texts are generally not used.
[0076] The supervised training is basically the same as the unsupervised training. For details, the supervised training of the primary text error correction model using the labeled text set to obtain the standard text error correction model can be found in Figure 3 The detailed process diagram of step S2 is shown in FIG. 1 , including:
[0077] S21, extracting labels of the marked text from the marked text set to obtain a true label set;
[0078] S22, converting the marked text set into a marked text vector set according to the text vector conversion method;
[0079] S23, inputting the labeled text vector set into the primary text error correction model for supervised training to obtain a predicted label set;
[0080] S24. Determine whether the error range between the predicted label set and the true label set is greater than a preset error. If the error range between the predicted label set and the true label set is greater than the preset error, continue the supervised training until the error range between the predicted label set and the true label set is less than the preset error, then exit the supervised training to obtain a standard text error correction model.
[0081] S3. Obtain the text to be corrected, perform a text masking operation on the text to be corrected to obtain one or more groups of masked texts, and input the masked texts into the standard text correction model to obtain predicted texts and predicted probability values of the predicted texts.
[0082] If the above-mentioned prescription printer mistakenly prints compound ketoconazole hair lotion as compound tongconazole hair lotion, then compound tongconazole hair lotion is the text to be corrected. If the text masking operation is performed on "compound tongconazole hair lotion", masked texts such as "compound ** ketoconazole hair lotion", "* tongconazole* hair lotion", and "compound tongconazole hair lotion**" can be obtained.
[0083] In detail, the masked text is input into the standard text error correction model to obtain the predicted text and the predicted probability value of the predicted text, including: according to the text vector conversion method, the masked text is converted into a masked vector, and the masked vector is input into the standard text error correction model to obtain the predicted text and the predicted probability value of the predicted text.
[0084] S4. Determine whether the predicted text is the same as the text to be corrected.
[0085] For example, when predicting "compound ketoconazole hair lotion" as mentioned above, the predicted text obtained is "compound ketoconazole hair lotion", then it is determined whether the predicted text "compound ketoconazole hair lotion" is the same as the text to be corrected "compound ketoconazole hair lotion".
[0086] S5. If the predicted text is the same as the text to be corrected, there is no need to perform text correction on the text to be corrected and the text to be corrected is received again.
[0087] If the above-mentioned predicted text "Compound Tongkangazole Hair Lotion" is the same as the text to be corrected "Compound Tongkangazole Hair Lotion", it proves that the error of the prescription printer was not found.
[0088] S6. If the predicted text is different from the text to be corrected, determine whether the predicted probability value is greater than a preset probability value. If the predicted probability value is less than the preset probability value, there is no need to perform text correction on the text to be corrected and the text to be corrected is received again.
[0089] If the above-mentioned predicted text "compound ketoconazole hair lotion" is different from the text to be corrected "compound ketoconazole hair lotion", and the prediction probability of the predicted text "compound ketoconazole hair lotion" is 97%.
[0090] If the preset probability value is 99%, the present invention considers that the predicted text accuracy does not meet the requirement, and thus does not perform text correction on the text to be corrected.
[0091] S7: If the predicted probability value is greater than the preset probability value, perform text correction on the text to be corrected according to the predicted text.
[0092] If the preset probability value is 96%, the predicted text "compound ketoconazole hair lotion" is used to replace the text to be corrected "compound ketoconazole hair lotion" to complete the text correction.
[0093] It should be emphasized that in order to further ensure the privacy and security of the above data, the above texts and text sets can also be stored in a blockchain node.
[0094] This solution can be applied to smart healthcare, smart education and other sub-fields in the smart city field, thereby promoting the construction of smart cities.
[0095] like Figure 4 The figure shows a functional module diagram of the intelligent text error correction device of the present invention.
[0096] The intelligent text error correction device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the intelligent text error correction device can include an unsupervised training module 101, a supervised training module 102, a predictive text module 103 and a text error correction module 104. The module described in 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.
[0097] In this embodiment, the functions of each module / unit are as follows:
[0098] The unsupervised training module 101 is used to perform label calculation on the current information set to obtain the current label set according to the correspondence between the historical information set and the historical label set;
[0099] The supervised training module 102 is used to perform label adjustment on the current label set according to a preset adjustment factor to obtain a standard label set;
[0100] The predicted text module 103 is used to extract label features from the standard label set to obtain a feature extraction set according to a convolutional neural network feature extraction technology;
[0101] The text error correction module 104 is used to use the feature extraction set as the input value of the trained classification neural network to perform classification prediction to obtain information classification results.
[0102] like Figure 5 The figure is a schematic diagram of the structure of an electronic device for realizing the intelligent text error correction method of the present invention.
[0103] 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 an intelligent text error correction program 12 .
[0104] Wherein, 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 intelligent text error correction code, etc., but also be used to temporarily store data that has been output or is to be output.
[0105] 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 stored in the memory 11 (for example, executing intelligent text error correction, etc.), and calls data stored in the memory 11 to execute various functions of the electronic device 1 and process data.
[0106] 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.
[0107] Figure 5 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 5The 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.
[0108] 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.
[0109] 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.
[0110] 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.
[0111] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0112] The intelligent text error correction 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions, and when running in the processor 10, it can achieve:
[0113] The pre-built original text correction model is trained in an unsupervised manner using an unlabeled text set to obtain a primary text correction model.
[0114] The primary text error correction model is supervised and trained using a labeled text set to obtain a standard text error correction model.
[0115] The text to be corrected is obtained, a text masking operation is performed on the text to be corrected to obtain one or more groups of masked texts, and the masked texts are input into the standard text correction model to obtain predicted texts and predicted probability values of the predicted texts.
[0116] When the predicted text is different from the text to be corrected and the predicted probability value is greater than the preset probability value, text correction is performed on the text to be corrected according to the predicted text.
[0117] Specifically, the processor 10 implements the above instructions as follows:
[0118] Step 1: Use the unlabeled text set to perform unsupervised training on the pre-built original text error correction model to obtain a primary text error correction model.
[0119] Text error correction has a wide range of application scenarios, especially in the medical field. Due to the complex wording, many medical books and prescriptions have wording errors. For example, patient Zhang Qiang suffers from seborrheic dermatitis, and the doctor prescribes compound ketoconazole hair lotion. The prescription printer mistakenly prints compound ketoconazole hair lotion as compound tongconazole hair lotion. In this case, the technical solution of the present invention can be used for intelligent error correction.
[0120] The unlabeled text set is a text set without adding labels. For example, the above-mentioned compound ketoconazole hair lotion and compound tongconazole hair lotion are actually unlabeled texts. It can be simply understood that compound ketoconazole hair lotion is the correct writing form, while compound tongconazole hair lotion is the wrong writing form, but no label is given whether it is written correctly.
[0121] In detail, the step 1 includes:
[0122] According to a pre-built text vector conversion method, the unlabeled text set is converted into a text vector set;
[0123] Performing position annotation on the unlabeled text set to obtain a text position set, and converting the text position set into a position vector set according to the text vector conversion method;
[0124] The position vector set and the text vector set are input into the original text error correction model for unsupervised training until the number of training times of the unsupervised training meets the preset training requirements, and the training is exited to obtain a primary text error correction model.
[0125] Furthermore, the text vector conversion method may adopt one-hot word vector conversion, Word2Vec word vector conversion, etc.
[0126] The preferred embodiment of the present invention adopts Word2Vec word vector conversion, and the Word2Vec word vector conversion includes:
[0127] The unlabeled text set or the text position set is converted into a vector in the following manner:
[0128]
[0129] Wherein, ω represents the decision tree path value on which the Word2Vec word vector conversion depends, j represents the index of the unlabeled text set and is a positive integer, ζ(ω,j) represents the text vector of the jth unlabeled text in the unlabeled text set or the position vector of the jth text position in the text position set under the path ω, represents the Huffman code corresponding to the jth node in the path ω, where ω is a positive integer, θ is the iteration factor of the Word2Vec word vector conversion, σ represents the sigmoid function, and X ω is the unlabeled text set or the text position set.
[0130] For example, the original correct compound ketoconazole hair lotion is transformed into a text vector and a position vector after the above vector conversion. The text vector is [1.6, 1.23, 6.91, 9.4, 12.7, 0.3, 17.03, 2.81, 1.04], and the position vector is [0.11, 1.09, 3.59, 0.4, 0.75, 2.1, 5.1, 2.09, 3.77]
[0131] Preferably, the original text error correction model is improved based on the BERT model (Bidirectional Encoder Representations from Transformer, BERT for short).
[0132] In detail, the position vector set and the text vector set are input into the original text error correction model for unsupervised training, including: dividing the text vector set into multiple groups of word vector sets based on the data in the vector set, dividing the text vector set into multiple groups of paragraph vector sets based on behavior, calculating the weight relationship between each group of the word vector set, each group of the paragraph vector set and the position vector set, and updating the internal parameters of the original text error correction model according to the weight relationship.
[0133] For example, the text vector of the compound ketoconazole hair lotion is [1.6, 1.23, 6.91, 9.4, 12.7, 0.3, 17.03, 2.81, 1.04], and the position vector is [0.11, 1.09, 3.59, 0.4, 0.75, 2.1, 5.1, 2.09, 3.77]. If the text vector is divided into data units, multiple groups of word vector sets in the form of [0.75, 2.1], [1.6, 2.81, 1.04], [0.3, 17.03, 2.81, 1.04] can be obtained. If the text vector of the compound ketoconazole hair lotion is multi-line, for example, the expression is Then we divide the paragraph vectors into two groups: [1.6, 1.23] and [6.91, 9.4] by row.
[0134] Furthermore, the calculation of the weight relationship between each group of the word vector sets, each group of the paragraph vector sets and the position vector sets includes: randomly selecting a vector in any one of the word vector sets, the paragraph vector sets and the position vector sets as a target vector, performing a text masking operation on the target vector to obtain a masked vector, calculating the weight of the masked vector and the vectors in each vector set to obtain a weight set, and weighted fusion of the weight sets to obtain the weight relationship.
[0135] For example, the compound ketoconazole hair lotion has a word vector [0.3, 17.03, 2.81, 1.04] selected as the target vector. The text masking operation is to mask any data. For example, [0.3, 17.03, 2.81, 1.04] is transformed into [0.3, **, 2.81, **] by text masking operation. Then, the weight set is obtained by calculating the weights of [0.3, **, 2.81, **] and other word vectors, paragraph vectors, and position vectors.
[0136] In detail, the weights of the shielding vector and the vectors in each vector set may be calculated using a similarity calculation method, and the similarity calculation method may use the currently disclosed cosine calculation method, Euclidean distance method, and the like.
[0137] The weighted fusion can adopt a fusion method in the form of Gaussian distribution, a linear method (such as a linear function), or a nonlinear method (such as a quadratic function). For example, the weight set is [0.101, 3.091, 2.057, 0.4, 0.756, 2.71, 5.103]. A linear function is used for fusion to obtain the k value and b value of the linear function, and then the k value and b value are used as internal parameters of the original text error correction model.
[0138] Step 2: Use the labeled text set to supervise the primary text error correction model to obtain a standard text error correction model.
[0139] The marked text set corresponds to the unmarked text set. The marked text set is a text set with added labels. As described in step one, compound ketoconazole hair lotion, compound tongconazole hair lotion, etc. can be unmarked texts. Even if compound tongconazole hair lotion is written in an incorrect way, in the marked text set, compound ketoconazole hair lotion is added with a correctly written label, and incorrectly written texts are generally not used.
[0140] The supervised training is basically the same as the unsupervised training. Specifically, the supervised training of the primary text error correction model using the labeled text set to obtain the standard text error correction model includes:
[0141] Extracting labels of the labeled text from the labeled text set to obtain a true label set;
[0142] According to the text vector conversion method, the marked text set is converted into a marked text vector set;
[0143] Inputting the labeled text vector set into the primary text error correction model for supervised training to obtain a predicted label set;
[0144] Determine whether the error range between the predicted label set and the true label set is greater than a preset error. If the error range between the predicted label set and the true label set is greater than the preset error, continue the supervised training until the error range between the predicted label set and the true label set is less than the preset error, then exit the supervised training to obtain a standard text error correction model.
[0145] Step three: obtain the text to be corrected, perform a text masking operation on the text to be corrected to obtain one or more groups of masked texts, and input the masked texts into the standard text correction model to obtain predicted texts and predicted probability values of the predicted texts.
[0146] If the above-mentioned prescription printer mistakenly prints compound ketoconazole hair lotion as compound tongconazole hair lotion, then compound tongconazole hair lotion is the text to be corrected. If the text masking operation is performed on "compound tongconazole hair lotion", masked texts such as "compound ** ketoconazole hair lotion", "* tongconazole* hair lotion", and "compound tongconazole hair lotion**" can be obtained.
[0147] In detail, the masked text is input into the standard text error correction model to obtain the predicted text and the predicted probability value of the predicted text, including: according to the text vector conversion method, the masked text is converted into a masked vector, and the masked vector is input into the standard text error correction model to obtain the predicted text and the predicted probability value of the predicted text.
[0148] Step 4: Determine whether the predicted text is the same as the text to be corrected.
[0149] For example, when predicting "compound ketoconazole hair lotion" as mentioned above, the predicted text obtained is "compound ketoconazole hair lotion", then it is determined whether the predicted text "compound ketoconazole hair lotion" is the same as the text to be corrected "compound ketoconazole hair lotion".
[0150] Step 5: If the predicted text is the same as the text to be corrected, there is no need to perform text correction on the text to be corrected and the text to be corrected is received again.
[0151] If the above-mentioned predicted text "Compound Tongkangazole Hair Lotion" is the same as the text to be corrected "Compound Tongkangazole Hair Lotion", it proves that the error of the prescription printer was not found.
[0152] Step 6: If the predicted text is different from the text to be corrected, determine whether the predicted probability value is greater than a preset probability value. If the predicted probability value is less than the preset probability value, there is no need to perform text correction on the text to be corrected and the text to be corrected is received again.
[0153] If the above-mentioned predicted text "compound ketoconazole hair lotion" is different from the text to be corrected "compound ketoconazole hair lotion", and the prediction probability of the predicted text "compound ketoconazole hair lotion" is 97%.
[0154] If the preset probability value is 99%, the present invention considers that the predicted text accuracy does not meet the requirement, and thus does not perform text correction on the text to be corrected.
[0155] Step 7: If the predicted probability value is greater than the preset probability value, perform text correction on the text to be corrected according to the predicted text.
[0156] If the preset probability value is 96%, the predicted text "compound ketoconazole hair lotion" is used to replace the text to be corrected "compound ketoconazole hair lotion" to complete the text correction.
[0157] 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 non-volatile computer-readable storage medium. The computer-readable medium may 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).
[0158] 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 schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0159] 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.
[0160] 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.
[0161] 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.
[0162] 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.
[0163] 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.
[0164] 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. An intelligent text error correction method, characterized in that: The method comprises: The pre-built original text error correction model is trained unsupervised using the unlabeled text set to obtain a primary text error correction model. Using the labeled text set to perform supervised training on the primary text error correction model to obtain a standard text error correction model; Acquire the text to be corrected, perform a text masking operation on the text to be corrected to obtain one or more groups of masked texts, input the masked texts into the standard text correction model, and obtain a predicted text and a predicted probability value of the predicted text; When the predicted text is different from the text to be corrected and the predicted probability value is greater than a preset probability value, performing text correction on the text to be corrected according to the predicted text; The method of using an unlabeled text set to perform unsupervised training on a pre-constructed original text error correction model to obtain a primary text error correction model includes: converting the unlabeled text set into a text vector set according to a pre-constructed text vector conversion method; annotating the positions of the unlabeled text set to obtain a text position set; converting the text position set into a position vector set according to the text vector conversion method; inputting the position vector set and the text vector set into the original text error correction model for unsupervised training until the number of training times of the unsupervised training meets the preset training requirements, and then exiting the training to obtain the primary text error correction model. The converting the unlabeled text set into a text vector set according to the pre-constructed text vector conversion method includes: converting the unlabeled text set into a text vector set using the following conversion method: in, represents the path value of the text decision tree based on the text vector conversion method, represents the index of the unlabeled text in the unlabeled text set and is a positive integer. Indicates that the path Next, the unlabeled text set text vectors of unlabeled text, Indicates that the path Neidi The Huffman code corresponding to the unlabeled text, path is a positive integer, is the iteration factor of the text-to-vector conversion method, represents the sigmoid function, is the unlabeled text set; The inputting of the position vector set and the text vector set into the original text error correction model for unsupervised training includes: dividing the text vector set into multiple groups of word vector sets based on vector data; dividing the text vector set into multiple groups of paragraph vector sets based on vector behavior; calculating the weight relationship between each group of the word vector set, each group of the paragraph vector set and the position vector set, and updating the internal parameters of the original text error correction model according to the weight relationship.
2. The intelligent text error correction method according to claim 1, characterized in that: The calculating of the weight relationship between each group of the word vector set, each group of the paragraph vector set and the position vector set includes: Select any one of the word vector set, the paragraph vector set, and the position vector set in sequence as a target vector; Performing the text masking operation on the target vector to obtain a masking vector; The weights of the masking vector and other vectors in the word vector set, the paragraph vector set, and the position vector set are calculated to obtain a weight set, and the weight set is weightedly fused to obtain the weight relationship.
3. The intelligent text error correction method according to any one of claims 1 to 2, characterized in that: The method of using the labeled text set to supervise the primary text error correction model to obtain a standard text error correction model includes: Extracting labels of the labeled text from the labeled text set to obtain a true label set; According to the text vector conversion method, the marked text set is converted into a marked text vector set; Inputting the labeled text vector set into the primary text error correction model for supervised training to obtain a predicted label set; If the error range between the predicted label set and the true label set is greater than the preset error, continue the supervised training until the error range between the predicted label set and the true label set is less than the preset error, exit the supervised training, and obtain the standard text error correction model.
4. The intelligent text error correction method according to any one of claims 1 to 2, characterized in that: The method further includes: When the predicted text is the same as the text to be corrected, re-receiving the text to be corrected; or, When the predicted text is different from the text to be corrected, and the predicted probability value is less than a preset probability value, the text to be corrected is received again.
5. 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 intelligent text correction method as described in any one of claims 1 to 4.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the intelligent text error correction method as claimed in any one of claims 1 to 4 is implemented.
