Method and apparatus for obtaining information
By correcting the word close-up by text matching and similarity calculation model for text information to be processed, the accuracy problem caused by interference factors in text recognition is solved, and a higher accuracy of text information acquisition is achieved.
Patent Information
- Application Number
- CN201910575809.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-28
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2039-06-28
AI Technical Summary
In the process of text recognition, the prior art is susceptible to interference from factors such as light, image color and uneven placement of printed materials, resulting in low recognition accuracy and difficult to effectively correct the error of similar characters.
By matching the text information to be processed, filter out the entries to be corrected, query the benchmark entries to build a text group, and use the text similarity calculation model to calculate the similarity. When the similarity is greater than the set threshold, replace the entries to be corrected with the benchmark entries to be corrected, improve the accuracy of the text information.
Through the shape-close word correction technology, the accuracy of obtaining target text information is improved and the accuracy of text recognition is improved.
Smart Images

Figure CN110287910B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of data processing technology, and more particularly to a method and device for acquiring information. Background Art
[0002] Text is an important medium for people to communicate in daily life. Text is widely found on the Internet, in images, and in printed materials. Text can effectively convey information to users. In order to facilitate information processing, users can directly receive the information to be processed, or extract the information to be processed from images or printed materials through a variety of text recognition methods. Summary of the invention
[0003] The embodiments of the present disclosure provide a method and a device for acquiring information.
[0004] In a first aspect, an embodiment of the present disclosure provides a method for acquiring information, the method comprising: performing text matching on text information to be processed, and selecting a to-be-corrected term from the text information to be processed; querying a reference term corresponding to the term to be corrected, and forming at least one text group with the difference characters in the term to be corrected and the reference term, wherein the reference term and the term to be corrected contain the same number of characters, and the reference term and the term to be corrected contain the same characters, and the same characters are in the same position in the reference term and the term to be corrected, and the two characters contained in the text group are in the same corresponding position in the term to be corrected and the reference term, respectively; for a text group in the at least one text group, introducing the text group into a text similarity calculation model to obtain the similarity of the text group, wherein the text similarity calculation model is used to calculate whether the characters in the text group are similar characters, and obtain the similarity of the characters in the text group; in response to the similarity being greater than a set threshold, replacing the term to be corrected in the text information to be processed with the reference term, and obtaining target text information corresponding to the text information to be processed.
[0005] In some embodiments, the above-mentioned text similarity calculation model is trained by the following steps: obtaining multiple text groups including sample texts and the sample similarities corresponding to each of the above-mentioned multiple text groups, wherein the above-mentioned text groups include a sample text and a comparison text, the comparison text is a similar character of the sample text or a negative sample text other than the sample text and the sample similar character, and the above-mentioned sample similarity is used to characterize the degree of similarity in glyphs between the sample text and the comparison text; taking each of the above-mentioned multiple text groups as input and taking the sample similarity corresponding to each of the above-mentioned multiple text groups as output, and training to obtain the above-mentioned text similarity calculation model.
[0006] In some embodiments, training the text similarity calculation model by using each of the multiple text groups as an input and using the sample similarity corresponding to each of the multiple text groups as an output includes: performing the following training steps: inputting each of the multiple text groups into an initial text similarity calculation model to obtain the predicted similarity corresponding to each of the multiple text groups; comparing the predicted similarity corresponding to each of the multiple text groups with the sample similarity corresponding to this text group to obtain the prediction accuracy rate of the initial text similarity calculation model; determining whether the prediction accuracy rate is greater than a preset accuracy rate threshold; and if it is greater than the preset accuracy rate threshold, using the initial text similarity calculation model as the trained text similarity calculation model.
[0007] In some embodiments, training the text similarity calculation model by using each of the multiple text groups as an input and using the sample similarity corresponding to each of the multiple text groups as an output includes: in response to being not greater than the preset accuracy rate threshold, adjusting the parameters of the initial text similarity calculation model and continuing to perform the above training steps.
[0008] In some embodiments, the sample similarity is obtained through the following steps: encoding the sample text and the comparison text respectively by using a set glyph encoding to obtain a first sample text vector of the sample text and a second sample text vector of the comparison text, where the set glyph encoding includes at least one of the following: stroke encoding, Wubi encoding, Cangjie encoding, and four-corner encoding; and calculating the cosine distance between the first sample text vector and the second sample text vector to obtain the sample similarity.
[0009] In some embodiments, adjusting the parameters of the initial text similarity calculation model includes: marking the sample similarity of a text group formed by a sample text and a similar-form character of the sample text as a first sample similarity, and marking the sample similarity of a text group formed by a sample text and a negative sample text as a second sample similarity; calculating a first similarity difference between the first sample similarity and a predicted first similarity, and a second similarity difference between the second sample similarity and a predicted second similarity; and in response to the sum of the corresponding first similarity difference and second similarity difference being less than or equal to a set threshold, using the parameters of the current initial text similarity calculation model as the adjusted parameters.
[0010] Second aspect, embodiments of the present disclosure provide a device for obtaining information. The device includes: a to-be-corrected entry obtaining unit configured to perform text matching on the to-be-processed text information and screen out to-be-corrected entries from the to-be-processed text information; a text group constructing unit configured to query a reference entry corresponding to the to-be-corrected entry and form at least one text group with the different characters in the to-be-corrected entry and the reference entry. Wherein, the reference entry and the to-be-corrected entry contain the same number of characters, and the reference entry and the to-be-corrected entry contain the same characters, and the same characters are in the same positions in the reference entry and the to-be-corrected entry. The two characters included in the text group are in the same corresponding positions in the to-be-corrected entry and the reference entry respectively; a similarity obtaining unit configured to import the text group into a text similarity calculation model for the text group in the at least one text group to obtain the similarity of the text group. Wherein, the text similarity calculation model is used to calculate whether the characters in the text group are similar in shape to obtain the similarity of the characters in the text group; a target text information obtaining unit configured to replace the to-be-corrected entry in the to-be-processed text information with the reference entry in response to the similarity being greater than a set threshold to obtain target text information corresponding to the to-be-processed text information.
[0011] In some embodiments, the device further includes a text similarity calculation model training unit configured to train a text similarity calculation model. The text similarity calculation model training unit includes: a sample obtaining subunit configured to obtain a plurality of text groups including sample characters and sample similarities corresponding to each of the plurality of text groups. Wherein, the text group includes a sample character and a comparison character, and the comparison character is a similar-shaped character of the sample character or a negative sample character other than the sample character and the sample similar-shaped character. The sample similarity is used to characterize the degree of similarity in shape between the sample character and the comparison character; a text similarity calculation model training subunit configured to use each of the plurality of text groups as an input and the sample similarity corresponding to each of the plurality of text groups as an output to train the text similarity calculation model.
[0012] In some embodiments, the above-mentioned text similarity calculation model training subunit includes: a text similarity calculation model training module, configured to input each of the above-mentioned multiple text groups into an initial text similarity calculation model, obtain the predicted similarity corresponding to each of the above-mentioned multiple text groups, compare the predicted similarity corresponding to each of the above-mentioned multiple text groups with the sample similarity corresponding to this text group, obtain the prediction accuracy rate of the above-mentioned initial text similarity calculation model, determine whether the above-mentioned prediction accuracy rate is greater than a preset accuracy rate threshold, and if it is greater than the above-mentioned preset accuracy rate threshold, use the above-mentioned initial text similarity calculation model as the trained text similarity calculation model.
[0013] In some embodiments, the above-mentioned text similarity calculation model training subunit includes: a parameter adjustment module, in response to being not greater than the above-mentioned preset accuracy rate threshold, configured to adjust the parameters of the above-mentioned initial text similarity calculation model and return to the text similarity calculation model training module.
[0014] In some embodiments, the above-mentioned device includes a sample similarity calculation unit, configured to calculate sample similarity. The above-mentioned sample similarity calculation unit includes: a sample text vector encoding subunit, configured to encode sample text and comparison text respectively through a set glyph encoding to obtain a first sample text vector of the above-mentioned sample text and a second sample text vector of the above-mentioned comparison text, where the above-mentioned set glyph encoding includes at least one of the following: stroke encoding, Wubi encoding, Cangjie encoding, and four-corner encoding; a sample similarity calculation subunit, configured to calculate the cosine distance between the above-mentioned first sample text vector and the second sample text vector to obtain the sample similarity.
[0015] In some embodiments, the above-mentioned parameter adjustment module includes: a sample similarity marking sub-module, configured to mark the sample similarity of a text group composed of a sample text and a similar-form character of the sample text as a first sample similarity, and mark the sample similarity of a text group composed of a sample text and a negative sample text as a second sample similarity; a similarity difference calculation sub-module, configured to calculate a first similarity difference between the above-mentioned first sample similarity and a predicted first similarity, and a second similarity difference between the above-mentioned second sample similarity and a predicted second similarity; a parameter setting sub-module, in response to the sum of the above-mentioned first similarity difference and the second similarity difference being less than or equal to a set threshold, configured to use the parameters of the current above-mentioned initial text similarity calculation model as the adjusted parameters.
[0016] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a memory having one or more programs stored thereon, and when the above-mentioned one or more programs are executed by the above-mentioned one or more processors, enabling the above-mentioned one or more processors to execute the method for obtaining information in the first aspect.
[0017] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, characterized in that when the program is executed by a processor, it implements the method for obtaining information in the first aspect above.
[0018] The method and apparatus for obtaining information provided by the embodiments of the present disclosure first perform text matching on the text information to be processed, and screen out the entries to be corrected from the text information to be processed; then, query the reference entries corresponding to the entries to be corrected, and form at least one text group from the different characters in the entries to be corrected and the reference entries; then, import the text group into a text similarity calculation model to obtain the similarity of the text group; finally, when the similarity is greater than a set threshold, replace the entries to be corrected in the text information to be processed with the reference entries to obtain the target text information corresponding to the text information to be processed. The technical solution of the present application corrects the text to be processed through similar-shaped characters, improving the accuracy of obtaining the target text information. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Other features, objects, and advantages of the present disclosure will become more apparent by reading the detailed description of the non-limiting embodiments with reference to the following drawings:
[0020] Figure 1 is an exemplary system architecture diagram to which an embodiment of the present disclosure can be applied;
[0021] Figure 2 is a flowchart of an embodiment of the method for obtaining information according to the present disclosure;
[0022] Figure 3 is a schematic diagram of an application scenario of the method for obtaining information according to the present disclosure;
[0023] Figure 4 is a flowchart of an embodiment of the method for training a text similarity calculation model according to the present disclosure;
[0024] Figure 5 is a schematic structural diagram of an embodiment of the apparatus for obtaining information according to the present disclosure;
[0025] Figure 6 is a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] The present disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention, rather than limiting the invention. Additionally, it should be noted that for ease of description, only the parts related to the relevant invention are shown in the drawings.
[0027] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The present disclosure will be described in detail below with reference to the drawings and embodiments.
[0028] Figure 1 An exemplary system architecture 100 for a method of obtaining information or a device for obtaining information to which the embodiments of the present disclosure can be applied is shown.
[0029] As Figure 1 shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0030] Users can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various data processing applications may be installed on the terminal devices 101, 102, 103, such as image acquisition applications, image information extraction applications, character recognition applications, text editing applications, etc.
[0031] The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices with a display screen and supporting information editing, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, and desktop computers, etc. When the terminal devices 101, 102, 103 are software, they may be installed in the above-listed electronic devices. It may be implemented as multiple software or software modules (e.g., for providing distributed services), or it may be implemented as a single software or software module, and no specific limitation is made here.
[0032] The server 105 may be a server that provides various services, such as a server for processing the text information to be processed sent by the terminal devices 101, 102, 103. The server may analyze and process data such as the received text information to be processed, and feedback the processing result (e.g., the target text information) to the terminal device.
[0033] It should be noted that the method for obtaining information provided by the embodiments of the present disclosure can be executed independently by the terminal devices 101, 102, and 103, or can also be jointly executed by the terminal devices 101, 102, 103 and the server 105. Correspondingly, the device for obtaining information can be set in the terminal devices 101, 102, 103, or can also be set in the server 105.
[0034] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or can also be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, used to provide distributed services), or can also be implemented as a single software or software module, which is not specifically limited herein.
[0035] It should be understood that Figure 1 the numbers of the terminal devices, the network, and the server in
[0036] Continue to refer to Figure 2 , which shows a process 200 of an embodiment of the method for obtaining information according to the present disclosure. The method for obtaining information includes the following steps:
[0037] Step 201, perform text matching on the text information to be processed, and screen out the entries to be corrected from the above text information to be processed.
[0038] In this embodiment, the execution subject of the method for obtaining information (such as Figure 1 the terminal devices 101, 102, 103 and / or the server 105 shown) can receive the text information to be processed through a wired connection method or a wireless connection method. Among them, the text information to be processed can be information obtained by performing optical character recognition (OCR) on an image or other information such as network information obtained by other means. It should be noted that the above wireless connection methods can include but are not limited to 3G / 4G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (Ultra Wideband) connections, and other currently known or future-developed wireless connection methods.
[0039] In practice, when obtaining text through methods such as text recognition, it will be interfered by various factors such as light, image color, and uneven placement of printed matter, resulting in low recognition accuracy of the text.
[0040] To this end, after receiving the text information to be processed, the execution subject may first perform text matching on the text information to be processed through a variety of text matching methods in order to improve the accuracy of the text information to be processed, so as to screen out the entries to be corrected from the above text information to be processed. Among them, the text matching method can be to match the text contained in the text information to be processed through commonly used entries, idioms, professional terms, etc. When there are words in the text information to be processed that cannot be matched by the text matching method, these words can be marked as entries to be corrected. Generally, the entries to be corrected can be considered as entries that may contain text errors. For example, when an image is processed by optical character recognition to extract text in the image, it is easy to obtain entries to be corrected.
[0041] Step 202, searching for a reference entry corresponding to the entry to be modified, and forming at least one character group with different characters in the entry to be modified and the reference entry.
[0042] The execution subject searches for the reference entry corresponding to the entry to be revised through the above-mentioned commonly used entries, idioms, professional terms, etc. Among them, the above-mentioned reference entry can contain the same number of characters as the above-mentioned entry to be revised, and the reference entry and the entry to be revised contain the same characters, and the same characters are in the same position in the reference entry and the entry to be revised. For example, the entry to be revised can be: "Ling-rolled coil", and the corresponding reference entry can be: "Cold-rolled coil". Among them, "Ling-rolled coil" and "Cold-rolled coil" contain the same number of characters "rolled coil", and "Ling-rolled coil" and "Cold-rolled coil" contain the same characters, and the same characters are in the same position in "Ling-rolled coil" and "Cold-rolled coil" (both are the second and third characters).
[0043] Afterwards, the execution entity may form at least one character group with the different characters in the above-mentioned entry to be modified and the reference entry. The two characters included in the above-mentioned character group are in the same corresponding positions in the above-mentioned entry to be modified and the reference entry. Taking the above-mentioned "玲轧卷" and "冷轧卷" as examples, the corresponding character group is: "玲,冷".
[0044] Step 203 , for a text group in the at least one text group, the text group is introduced into a text similarity calculation model to obtain the similarity of the text group.
[0045] After obtaining the character group, the execution subject can import the character group into the character similarity calculation model to obtain the similarity of the character group. The character similarity calculation model can be used to calculate whether the characters in the character group are similar characters to obtain the similarity of the characters in the character group.
[0046] In some optional implementations of this embodiment, the above text similarity calculation model is trained by the following steps:
[0047] In the first step, obtain multiple text groups containing sample texts and the sample similarity corresponding to each of the multiple text groups.
[0048] The execution entity can pre-obtain multiple text groups containing sample texts, and each text group has a corresponding sample similarity. Among them, the above text group can contain a sample text and a comparison text, and the comparison text is a character with a similar shape to the sample text or a negative sample text other than the sample text and the sample character with a similar shape. The above sample similarity is used to characterize the degree of glyph similarity between the sample text and the comparison text.
[0049] In the second step, use each of the multiple text groups as an input and the sample similarity corresponding to each of the multiple text groups as an output to train the above text similarity calculation model.
[0050] The execution entity can train the text similarity calculation model through various networks (such as a convolutional neural network, a deep learning network, etc.). The execution entity can use the text group as the network input and the sample similarity corresponding to the text group as the network output to train the above text similarity calculation model.
[0051] Step 204, in response to the similarity being greater than the set threshold, replace the to-be-corrected entry in the above to-be-processed text information with the above reference entry to obtain the target text information corresponding to the to-be-processed text information.
[0052] When the similarity of the text group is greater than the set threshold, it indicates that the text in the to-be-corrected entry corresponding to the text group is incorrect. At this time, the execution entity can replace the to-be-corrected entry in the to-be-processed text information with the reference entry to obtain the target text information corresponding to the to-be-processed text information. In this way, the to-be-processed text information is corrected through the reference entry, improving the accuracy of obtaining the target text information.
[0053] Continue to refer to Figure 3 , Figure 3 which is a schematic diagram of an application scenario of the method for obtaining information according to this embodiment. In the Figure 3 application scenario, the terminal device 102 can obtain the to-be-processed text information from the image in various ways: "Border Collie, originally from the Scottish border, is a Co11ie type of sheepdog, with a strong herding instinct, intelligent by nature, good at observing words and expressions, able to accurately understand the instructions of the owner, and can drive the sheep to move or rotate by means of eye contact. It has been used as a sheepdog for many years and ranks first in the world dog breed intelligence ranking." After the terminal device 102 performs text matching on the to-be-processed text information, it is found that " Tongli Co11ie"middle" 11 " is not the English "l" but the number "1"; and there is no " Tongli Therefore, the terminal device 102 can process the word " Co11ie "and" Tongli Shepherd" is marked as a term to be revised. Then, the terminal device 102 finds the corresponding " Co11ie The base term for " Collie ";" Tongli The base entry for "Shepherd Dog" is " Collie Shepherd dog", and then construct the character groups: "Collie, Collie" and "Tong, Ke"; then, the two character groups are respectively poured into the character similarity calculation model, and the obtained similarities can be 95% and 90% respectively. Therefore, it can be determined that the characters in the character groups are similar characters. Finally, the terminal device 102 replaces the to-be-processed text information with the reference entry to obtain the target text information.
[0054] The method provided by the above embodiment of the present disclosure first performs text matching on the text information to be processed, and selects the term to be corrected from the above text information to be processed; then, the reference term corresponding to the above term to be corrected is queried, and the difference characters in the above term to be corrected and the reference term form at least one text group; then, the above text group is introduced into the text similarity calculation model to obtain the similarity of the above text group; finally, when the similarity is greater than the set threshold, the term to be corrected in the above text information to be processed is replaced with the reference term to obtain the target text information corresponding to the above text information to be processed. The technical solution of the present application improves the accuracy of obtaining the target text information by correcting the text to be processed by similar characters.
[0055] Further references Figure 4 , which shows a process 400 of an embodiment of a text similarity calculation model training method. The process 400 of the text similarity calculation model training method includes the following steps:
[0056] Step 401 : obtaining a plurality of text groups including sample texts and a sample similarity corresponding to each of the plurality of text groups.
[0057] In this embodiment, the execution subject of the text similarity calculation model training method (for example Figure 1 The server 105 shown in the figure can obtain multiple text groups containing sample texts and the sample similarity corresponding to each of the multiple text groups.
[0058] In some optional implementations of this embodiment, the sample similarity is obtained by the following steps:
[0059] First step, encode the sample text and the comparison text respectively by setting the glyph code to obtain the first sample text vector and the second sample text vector of the above sample text and comparison text.
[0060] Among them, the above-mentioned set font code includes at least one of the following: stroke code, Wubi code, Cangjie code, and Sijiao code. Each font code has corresponding characters and / or numbers. The execution subject can encode the sample text and the comparison text according to the font code. What is obtained is the first sample text vector corresponding to the sample text and the second sample text vector corresponding to the comparison text. The more types of font codes used, the more complex the first sample text vector and the second sample text vector obtained, and the higher the accuracy of the text described by the font. When encoding is performed by a font code, the vector corresponding to the font code can be directly used as the first sample text vector and the second sample text vector of the corresponding sample text and the comparison text; when encoding is performed by multiple font codes, the encoding can be performed according to the order of the set font codes. For example, the stroke code is set as the first code, the Wubi code is set as the second code, the Cangjie code is set as the third code, and the Sijiao code is set as the fourth code. Then, in the order from the first code to the fourth code, the vectors corresponding to each font code are combined to obtain the first sample text vector and the second sample text vector. For example, the sample character is: "奔", and the corresponding stroke code is: "13412132"; the Wubi code is: "DFAJ"; the Cangjie code is: "KJT";... When only one glyph code is needed to form a vector, the vector of the sample character "奔" can be "13412132", "DFAJ" or "KJT", or "13412132", "DFAJ" or "KJT" can be converted into a vector of a corresponding set dimension. When multiple glyph codes are needed to form a vector, the vector of the sample character "奔" can be a vector composed of "13412132", "DFAJ" and / or "KJT", or "13412132", "DFAJ" and / or "KJT" can be converted into a vector of a corresponding set dimension. It should be noted that in the process of converting the glyph code into a vector, each code contained in the glyph code corresponds to a vector. For example: when the stroke code is "13412132", "1", "2", "3" and "4" correspond to a vector representing the corresponding stroke, and then similar characters can be judged by strokes. Similarly, the "D", "F", "A", "J" and "K", "J", "T" contained in the Wubi code "DFAJ" and the Cangjie code "KJT" correspond to their own vectors. Moreover, the same code has different corresponding vectors in different glyph codes. For example, the Wubi code "DFAJ" contains "J", and the Cangjie code "KJT" also contains "J". However, the two "J"s use different vectors to distinguish the glyph codes. It should be noted that the vector of each stroke in the glyph code, the vector of the Wubi character, and the vector of the Cangjie character can be obtained through model learning.The glyph encodings used for the first sample text vector and the second sample text vector should be the same. When multiple glyph encodings are used, the order of the vectors corresponding to the glyph encodings should also be the same. In this way, each character can have a vector corresponding to its glyph, improving the recognition accuracy of similar-looking characters.
[0061] In the second step, calculate the cosine distance between the above-mentioned first sample text vector and the second sample text vector to obtain the sample similarity.
[0062] The execution entity can calculate the cosine distance between the above-mentioned first sample text vector and the second sample text vector to obtain the sample similarity. The execution entity can also process the first sample text vector and the second sample text vector in other ways (such as solving the second norm, etc.) to obtain the sample similarity.
[0063] Step 402: Input each of the above-mentioned multiple text groups into the initial text similarity calculation model to obtain the predicted similarity corresponding to each of the above-mentioned multiple text groups.
[0064] In this embodiment, based on the multiple text groups obtained in step 401, the execution entity can input each of the above-mentioned multiple text groups into the initial text similarity calculation model, thereby obtaining the predicted similarity corresponding to each of the above-mentioned multiple text groups. Here, the execution entity can input each text group from the input side of the initial text similarity calculation model, successively process it through the parameters of each layer in the initial text similarity calculation model, and output it from the output side of the initial text similarity calculation model. The information output from the output side is the predicted similarity corresponding to this text group. Among them, the initial text similarity calculation model can be an untrained model (such as a deep learning model, etc.) or an incompletely trained model, and each layer is set with initialization parameters, and the initialization parameters can be continuously adjusted during the training process of the model.
[0065] Step 403: Compare the predicted similarity corresponding to each of the above-mentioned multiple text groups with the sample similarity corresponding to this text group to obtain the prediction accuracy of the above-mentioned initial text similarity calculation model.
[0066] Based on the predicted similarity corresponding to each of the multiple text groups obtained in step 402, the execution entity can compare the predicted similarity corresponding to each of the multiple text groups with the sample similarity corresponding to that text group, so as to obtain the prediction accuracy of the initial text similarity calculation model. Specifically, if the predicted similarity corresponding to a text group is the same as or close to the sample similarity corresponding to that text group, the initial text similarity calculation model predicts correctly; if the predicted similarity corresponding to a text group is different from or not close to the sample similarity corresponding to that text group, the initial text similarity calculation model predicts incorrectly. Here, the execution entity can calculate the ratio of the number of correct predictions to the total number of samples, and use this ratio as the prediction accuracy of the initial text similarity calculation model.
[0067] Step 404, determine whether the above prediction accuracy is greater than a preset accuracy threshold.
[0068] Based on the prediction accuracy of the initial text similarity calculation model obtained in step 403, the execution entity can compare the prediction accuracy of the initial text similarity calculation model with the preset accuracy threshold. If it is greater than the preset accuracy threshold, execute step 405; if it is not greater than the preset accuracy threshold, execute step 406.
[0069] Step 405, use the above initial text similarity calculation model as the trained text similarity calculation model.
[0070] In this embodiment, when the prediction accuracy of the initial text similarity calculation model is greater than the preset accuracy threshold, it indicates that the initial text similarity calculation model is trained. At this time, the execution entity can use the initial text similarity calculation model as the trained text similarity calculation model.
[0071] Step 406, adjust the parameters of the above initial text similarity calculation model.
[0072] In this embodiment, when the prediction accuracy of the initial text similarity calculation model is not greater than the preset accuracy threshold, the execution entity can adjust the parameters of the initial text similarity calculation model and return to execute step 402 until a text similarity calculation model that can represent the similarity of the glyph similarity between the sample text and the comparison text is trained.
[0073] In some optional implementation manners of this embodiment, the above adjustment of the parameters of the initial text similarity calculation model may include the following steps:
[0074] In the first step, mark the sample similarity of the text group composed of the sample text and the characters similar in form to the sample text as the first sample similarity, and mark the sample similarity of the text group composed of the sample text and the negative sample text as the second sample similarity.
[0075] To adjust the parameters of the above initial text similarity calculation model, the executing entity can mark the sample similarity of the text group composed of the sample text and the characters similar in form to the sample text as the first sample similarity, and mark the sample similarity of the text group composed of the sample text and the negative sample text as the second sample similarity. Generally, the value range of similarity can be between 0 and 1. The larger the value of similarity, the more likely the two characters corresponding to the similarity are characters similar in form; correspondingly, the smaller the value of similarity, the more likely the two characters corresponding to the similarity are non-characters similar in form. Generally, the value of the first sample similarity can be much larger than that of the second sample similarity.
[0076] In the second step, calculate the first similarity difference between the above first sample similarity and the predicted first similarity, and the second similarity difference between the above second sample similarity and the predicted second similarity.
[0077] The executing entity can import the text group containing the sample text and the characters similar in form, and the text group containing the sample text and the negative sample text corresponding to the same sample text into the initial text similarity calculation model to obtain the predicted first similarity corresponding to the first sample similarity and the predicted second similarity corresponding to the second sample similarity. Then, calculate the first similarity difference between the above first sample similarity and the predicted first similarity, and the second similarity difference between the above second sample similarity and the predicted second similarity. The first sample similarity and the second sample similarity are fixed values, while the predicted first similarity and the predicted second similarity are the values predicted by the initial text similarity calculation model. Generally, the predicted first similarity is not exactly the same as the first sample similarity, and the predicted second similarity is not exactly the same as the second sample similarity. That is, the first similarity difference and the second similarity difference can respectively represent the accuracy of the initial text similarity calculation model in identifying characters similar in form and the accuracy of identifying non-characters similar in form.
[0078] In the third step, in response to the sum of the above first similarity difference and the second similarity difference being less than or equal to the set threshold, use the parameters of the current initial text similarity calculation model as the adjusted parameters.
[0079] When the sum of the above first similarity difference and the second similarity difference is less than or equal to the set threshold, it means that the current initial text similarity calculation model can accurately identify characters similar in form and accurately distinguish non-characters similar in form. The executing entity can use the parameters of the current initial text similarity calculation model as the adjusted parameters.
[0080] The execution entity can also use the parameters when the difference between the predicted first similarity and the predicted second similarity is greater than the set threshold as the adjusted parameters. Which specific method to use depends on the actual needs.
[0081] For further reference Figure 5 , as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for obtaining information. This device embodiment corresponds to Figure 2 the method embodiment shown, and this device can be specifically applied to various electronic devices.
[0082] As Figure 5 shown, the device 500 for obtaining information in this embodiment may include: a to-be-corrected entry obtaining unit 501, a character group constructing unit 502, a similarity obtaining unit 503, and a target character information obtaining unit 504. Among them, the to-be-corrected entry obtaining unit 501 is configured to perform character matching on the to-be-processed character information, and screen out the to-be-corrected entries from the to-be-processed character information; the character group constructing unit 502 is configured to query the reference entries corresponding to the to-be-corrected entries, and form at least one character group from the different characters in the to-be-corrected entries and the reference entries. Among them, the reference entries and the to-be-corrected entries contain the same number of characters, and the reference entries and the to-be-corrected entries contain the same characters, and the same characters are in the same positions in the reference entries and the to-be-corrected entries. The two characters included in the character group are in the corresponding positions in the to-be-corrected entry and the reference entry respectively; the similarity obtaining unit 503 is configured to import the character group into a character similarity calculation model for the character group among the at least one character group to obtain the similarity of the character group. Among them, the character similarity calculation model is used to calculate whether the characters in the character group are similar in form to obtain the similarity of the characters in the character group; the target character information obtaining unit 504 is configured to replace the to-be-corrected entry in the to-be-processed character information with the reference entry in response to the similarity being greater than the set threshold to obtain the target character information corresponding to the to-be-processed character information.
[0083] In some alternative implementation manners of this embodiment, the above-mentioned device 500 for obtaining information may further include a text similarity calculation model training unit (not shown in the figure), which is configured to train a text similarity calculation model. The above-mentioned text similarity calculation model training unit may include: a sample acquisition subunit (not shown in the figure) and a text similarity calculation model training subunit (not shown in the figure). The sample acquisition subunit is configured to obtain a plurality of text groups including sample texts and sample similarities corresponding to each of the plurality of text groups. Among them, the above-mentioned text group includes a sample text and a comparison text, and the comparison text is a similar-looking character of the sample text or a negative sample text other than the sample text and the similar-looking sample characters. The above-mentioned sample similarity is used to characterize the glyph similarity degree between the sample text and the comparison text; the text similarity calculation model training subunit is configured to use each of the plurality of text groups as an input and the sample similarity corresponding to each of the plurality of text groups as an output to train the above-mentioned text similarity calculation model.
[0084] In some alternative implementation manners of this embodiment, the above-mentioned text similarity calculation model training subunit may include: a text similarity calculation model training module (not shown in the figure), which is configured to input each of the plurality of text groups into an initial text similarity calculation model to obtain the predicted similarity corresponding to each of the plurality of text groups, compare the predicted similarity corresponding to each of the plurality of text groups with the sample similarity corresponding to this text group to obtain the prediction accuracy rate of the above-mentioned initial text similarity calculation model, determine whether the above-mentioned prediction accuracy rate is greater than a preset accuracy rate threshold. If it is greater than the above-mentioned preset accuracy rate threshold, then use the above-mentioned initial text similarity calculation model as the trained text similarity calculation model.
[0085] In some alternative implementation manners of this embodiment, the above-mentioned text similarity calculation model training subunit may include: a parameter adjustment module (not shown in the figure), in response to being not greater than the above-mentioned preset accuracy rate threshold, which is configured to adjust the parameters of the above-mentioned initial text similarity calculation model and return to the text similarity calculation model training module.
[0086] In some alternative implementations of this embodiment, the device 500 for obtaining information may include a sample similarity calculation unit (not shown in the figure), which is configured to calculate the sample similarity. The sample similarity calculation unit may include: a sample text vector encoding subunit (not shown in the figure) and a sample similarity calculation subunit (not shown in the figure). Among them, the sample text vector encoding subunit is configured to encode the sample text and the comparison text respectively through a set glyph encoding to obtain a first sample text vector of the sample text and a second sample text vector of the comparison text. Among them, the set glyph encoding includes at least one of the following: stroke encoding, Wubi encoding, Cangjie encoding, and four-corner encoding; the sample similarity calculation subunit is configured to calculate the cosine distance between the first sample text vector and the second sample text vector to obtain the sample similarity.
[0087] In some alternative implementations of this embodiment, the parameter adjustment module may include: a sample similarity marking sub-module (not shown in the figure), a similarity difference calculation sub-module (not shown in the figure), and a parameter setting sub-module (not shown in the figure). Among them, the sample similarity marking sub-module is configured to mark the sample similarity of the text group composed of the sample text and the similar-shaped characters of the sample text as the first sample similarity, and mark the sample similarity of the text group composed of the sample text and the negative sample text as the second sample similarity; the similarity difference calculation sub-module is configured to calculate a first similarity difference between the first sample similarity and the predicted first similarity, and a second similarity difference between the second sample similarity and the predicted second similarity; the parameter setting sub-module, in response to the sum of the corresponding first similarity difference and the second similarity difference being less than or equal to a set threshold, is configured to use the parameters of the current initial text similarity calculation model as the adjusted parameters.
[0088] This embodiment also provides an electronic device, including: one or more processors; a memory, on which one or more programs are stored. When the one or more programs are executed by the one or more processors, the one or more processors are caused to execute the above method for obtaining information.
[0089] This embodiment also provides a computer-readable medium, on which a computer program is stored. When the program is executed by a processor, it implements the above method for obtaining information.
[0090] Next, refer to Figure 6 , which shows a schematic structural diagram of a computer system 600 of an electronic device (for example, Figure 1 the server 105 in Figure 6 suitable for implementing the embodiments of the present disclosure. The electronic device shown is only an example and should not impose any limitations on the functions and usage scopes of the embodiments of the present disclosure.
[0091] As shown Figure 6 in FIG. 600, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which may perform various appropriate actions and processes according to a program stored in the read-only memory (ROM) 602 or a program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0092] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6 FIG. 600 shows an electronic device 600 having various devices, it should be understood that it is not required to implement or include all the shown devices. More or fewer devices may be alternatively implemented or included. Figure 6 Each block shown in FIG. 600 may represent a device or, as required, multiple devices.
[0093] Specifically, according to an embodiment of the present disclosure, the process described above with reference to the flowchart may 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 carried on a computer-readable medium, and the computer program includes program codes for performing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are performed.
[0094] It should be noted that the computer-readable medium in the embodiments of the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0095] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: performs text matching on the text information to be processed and selects the term to be corrected from the text information to be processed; queries the reference term corresponding to the term to be corrected, and forms at least one text group with the difference characters in the term to be corrected and the reference term, wherein the reference term and the term to be corrected contain the same number of characters, and the reference term and the term to be corrected contain the same characters, and the same characters are in the same position in the reference term and the term to be corrected, and the two characters contained in the text group are in the same corresponding position in the term to be corrected and the reference term respectively; for the text group in the at least one text group, introduce the text group into a text similarity calculation model to obtain the similarity of the text group, wherein the text similarity calculation model is used to calculate whether the characters in the text group are similar characters, and obtain the similarity of the characters in the text group; in response to the similarity being greater than a set threshold, replace the term to be corrected in the text information to be processed with the reference term to obtain the target text information corresponding to the text information to be processed.
[0096] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in an order different from that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0098] The units involved in the embodiments described in the present disclosure can be implemented in software or in hardware. The described units can also be provided in a processor. For example, it can be described as: a processor includes a unit for obtaining a term to be corrected, a unit for constructing a text group, a unit for obtaining a similarity, and a unit for obtaining target text information. Among them, the names of these units do not constitute a limitation on the unit itself in some cases. For example, the unit for obtaining target text information can also be described as "a unit for correcting the text information to be processed by a reference term".
[0099] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles applied. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, a technical solution formed by mutually replacing the above features with (but not limited to) technical features having similar functions disclosed in the present disclosure.
Claims
1. A method for obtaining information, comprising: matching the entries in the text information to be processed with common entries, idiomatic expressions, and technical terms, screening out the entries to be corrected with text errors from the text information to be processed, and screening out the reference entries corresponding to the entries to be corrected from the common entries, the idiomatic expressions, and the technical terms, wherein the reference entries and the entries to be corrected contain the same number of characters, and the reference entries and the entries to be corrected contain the same characters, and the same characters are in the same positions in the reference entries and the entries to be corrected; forming at least one character group from the different characters in the entry to be corrected and the reference entry, wherein the two characters included in the character group are in the same corresponding positions in the entry to be corrected and the reference entry respectively; for the character group in the at least one character group, inputting the character group into a text similarity calculation model to obtain the similarity of the character group; wherein, the steps of training the text similarity calculation model include: obtaining a plurality of character groups containing sample characters, and encoding one sample character and one comparison character included in each of the character groups respectively through the sorting of the set glyph encoding to obtain a first sample character vector and a second sample character vector of the sample character and the comparison character, the comparison character being a character similar in form to the sample character or a negative sample character other than the sample character and the sample character similar in form, and the glyph encoding including at least one of stroke encoding, Wubi encoding, Cangjie encoding, and four-corner encoding; calculating the cosine distance between the first sample character vector and the second sample character vector to obtain the sample similarity corresponding to the corresponding character group; using each of the character groups as an input and the sample similarity corresponding to each of the character groups as an output to train the text similarity calculation model; in response to the similarity being greater than a set threshold, replacing the entry to be corrected in the text information to be processed with the reference entry to obtain the target text information corresponding to the text information to be processed.
2. The method according to claim 1, wherein The sample similarity is used to characterize the glyph similarity degree between the sample character and the comparison character.
3. The method according to claim 1, wherein The training the text similarity calculation model by using each of the character groups as an input and the sample similarity corresponding to each of the character groups as an output includes: performing the following training steps: inputting each of the plurality of character groups into an initial text similarity calculation model to obtain the predicted similarity corresponding to each of the plurality of character groups, comparing the predicted similarity corresponding to each of the plurality of character groups with the sample similarity corresponding to the character group to obtain the prediction accuracy rate of the initial text similarity calculation model, determining whether the prediction accuracy rate is greater than a preset accuracy rate threshold, and if it is greater than the preset accuracy rate threshold, using the initial text similarity calculation model as the trained text similarity calculation model.
4. The method according to claim 3, wherein, The training the text similarity calculation model by using each of the character groups as an input and the sample similarity corresponding to each of the character groups as an output includes: In response to being not greater than the preset accuracy threshold, adjust the parameters of the initial text similarity calculation model, and continue to execute the training step.
5. The method according to claim 4, wherein, The adjusting the parameters of the initial text similarity calculation model includes: Mark the sample similarity of the text group composed of the sample text and the similar-looking characters of the sample text as the first sample similarity, and mark the sample similarity of the text group composed of the sample text and the negative sample text as the second sample similarity; Calculate the first similarity difference between the first sample similarity and the predicted first similarity, and the second similarity difference between the second sample similarity and the predicted second similarity; In response to the sum of the corresponding first similarity difference and second similarity difference being less than or equal to the set threshold, use the parameters of the current initial text similarity calculation model as the adjusted parameters.
6. A device for obtaining information, comprising: A to-be-corrected entry acquisition unit configured to perform text matching on the entries in the to-be-processed text information with common entries, idiomatic expressions, and technical terms, screen out the to-be-corrected entries with text errors from the to-be-processed text information, and screen out the reference entries corresponding to the to-be-corrected entries from the common entries, the idiomatic expressions, and the technical terms, wherein the reference entries and the to-be-corrected entries contain the same number of characters, and the reference entries and the to-be-corrected entries contain the same characters, and the same characters are in the same positions in the reference entries and the to-be-corrected entries; A text group construction unit configured to form at least one text group from the different characters in the to-be-corrected entry and the reference entry, and the two characters included in the text group are in the same corresponding positions in the to-be-corrected entry and the reference entry respectively; A similarity acquisition unit configured to import the text group into a text similarity calculation model for each text group in the at least one text group to obtain the similarity of the text group; A target text information acquisition unit configured to replace the to-be-corrected entry in the to-be-processed text information with the reference entry to obtain the target text information corresponding to the to-be-processed text information in response to the similarity being greater than the set threshold; A text similarity calculation model training unit is configured to train a text similarity calculation model. The text similarity calculation model training unit includes: a sample acquisition sub-unit configured to acquire a plurality of text groups including sample texts, and encode a sample text and a comparison text included in each of the text groups respectively through the sorting of a set glyph encoding to obtain a first sample text vector and a second sample text vector of the sample text and the comparison text, where the comparison text is a similar-looking character of the sample text or a negative sample text other than the sample text and the sample similar-looking characters, and the glyph encoding includes at least one of stroke encoding, Wubi encoding, Cangjie encoding, and four-corner encoding; calculate the cosine distance between the first sample text vector and the second sample text vector to obtain a sample similarity corresponding to the corresponding text group; a text similarity calculation model training sub-unit configured to use each of the text groups as an input and the sample similarity corresponding to each of the text groups as an output to train and obtain the text similarity calculation model.
7. The apparatus according to claim 6, wherein The sample similarity is used to represent the glyph similarity degree between the sample text and the comparison text.
8. The apparatus according to claim 6, wherein The text similarity calculation model training sub-unit includes: A text similarity calculation model training module configured to input each of the text groups in the plurality of text groups into an initial text similarity calculation model to obtain a predicted similarity corresponding to each of the text groups in the plurality of text groups, compare the predicted similarity corresponding to each of the text groups in the plurality of text groups with the sample similarity corresponding to the text group to obtain the prediction accuracy rate of the initial text similarity calculation model, determine whether the prediction accuracy rate is greater than a preset accuracy rate threshold, and if it is greater than the preset accuracy rate threshold, use the initial text similarity calculation model as the trained text similarity calculation model.
9. The apparatus according to claim 8, wherein The text similarity calculation model training sub-unit includes: A parameter adjustment module, in response to being not greater than the preset accuracy rate threshold, is configured to adjust the parameters of the initial text similarity calculation model and return to the text similarity calculation model training module.
10. The device according to claim 9, wherein, The parameter adjustment module includes: A sample similarity marking sub-module configured to mark the sample similarity of the text group composed of the sample text and the similar-looking characters of the sample text as a sample first similarity, and mark the sample similarity of the text group composed of the sample text and the negative sample text as a sample second similarity; A similarity difference calculation sub-module configured to calculate a first similarity difference between the sample first similarity and the predicted first similarity, and a second similarity difference between the sample second similarity and the predicted second similarity; A parameter setting sub-module, in response to the sum of the corresponding first similarity difference and the second similarity difference being less than or equal to a set threshold, is configured to use the parameters of the current initial text similarity calculation model as the adjusted parameters.
11. An electronic device includes: One or more processors; A memory on which one or more programs are stored, When the one or more programs are executed by the one or more processors, the one or more processors are caused to execute the method according to any one of claims 1 to 5.
12. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Character recognition correction method and a terminal
CN106940798A
Character recognition error correction method, error correction system and computer device
CN107633250A
Semantic matching method and device and storage medium
CN109918663A