Optical Character Recognition-Based Attachment Classification Method, Device, Equipment and Medium
The text information in electronic attachments is extracted through optical character recognition technology and the classifier is configured using this information, which solves the problem of unclear attachment classification and improves classification accuracy and query efficiency.
Patent Information
- Application Number
- CN202111437898.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2041-11-30
AI Technical Summary
In the prior art, the classification of electronic accessories is unclear, resulting in extremely low efficiency of users when querying.
The text information in the attachment of the picture is extracted through optical character recognition technology, and the extracted attachment keywords and paragraphs and table labels are used to configure and adjust the classifier to achieve accurate classification of the attachment.
Improve the classification accuracy of scanned attachments with optical character recognition and enhance the efficiency of users inquiring attachments.
Smart Images

Figure CN114153972B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent decision-making, and particularly to an attachment classification method, device, electronic device and computer-readable storage medium based on optical character recognition. Background Art
[0002] With the popularization of computer technology, the original paper-based attachment records have gradually been replaced by electronic attachments. Electronic attachments are widely used in all walks of life due to their advantages of high efficiency and convenience.
[0003] Currently, most of the records of electronic attachments are stored in the form of pictures, such as contract agreements, form lists, invoice documents, etc., and are not marked according to the category or content of the attachments. In most cases, users only know the specific picture content and category of the attachment after opening it. This unclear way of classifying and storing attachments makes the query efficiency of users extremely low. Summary of the Invention
[0004] The present invention provides an attachment classification method, device and computer-readable storage medium based on optical character recognition, and its main purpose is to solve the problem of unclear classification of attachments scanned by optical character recognition.
[0005] To achieve the above object, an attachment classification method based on optical character recognition provided by the present invention includes:
[0006] Obtaining a text attachment set generated by optical character recognition of a picture set to be classified;
[0007] Selecting one text attachment from the text attachment set one by one, and extracting the true category pre-labeled for the text attachment and all attachment keywords, paragraph tags and table tags in the text attachment;
[0008] Combining the extracted attachment keywords in the text attachment to obtain a training keyword set for the text attachment, and calculating the ratio of the number of paragraph tags to the number of table tags to obtain a training label ratio;
[0009] Configuring a pre-constructed original attachment classifier by using the training keyword set and the training label ratio;
[0010] Classifying and predicting the text attachment by using the original attachment classifier to obtain the attachment category and corresponding score of the text attachment;
[0011] Judging whether the score is less than a preset prediction threshold;
[0012] When the score is less than a preset prediction threshold, use the score to perform gradient adjustment on the original attachment classifier, and return to the step of classifying and predicting the text attachment using the original attachment classifier to obtain the attachment category and the corresponding score of the text attachment;
[0013] When the score is greater than or equal to the preset prediction threshold, compare the predicted attachment category with the true category of the text attachment to obtain a prediction result of correct or incorrect prediction;
[0014] Summarize the prediction results of all text attachments in the text attachment set to obtain the prediction accuracy rate;
[0015] Determine whether the prediction accuracy rate is greater than or equal to a preset training threshold;
[0016] If the prediction accuracy rate is less than the training threshold, return to the step of configuring the pre-constructed original attachment classifier using the training keyword set and the training label ratio until the prediction accuracy rate is greater than or equal to the training threshold, then stop the iterative training to obtain the standard attachment classifier;
[0017] Receive the attachment to be classified, and classify the attachment to be classified using the standard attachment classifier to obtain the classification result of the attachment to be classified.
[0018] Optionally, the step of classifying and predicting the text attachment using the original attachment classifier to obtain the attachment category and the corresponding score of the text attachment includes:
[0019] Score the text attachment under each attachment category in the pre-constructed attachment category score table according to each training keyword in the training keyword set to obtain a keyword score set;
[0020] Score the text attachment under each attachment category in the attachment category score table according to the training label ratio to obtain a label ratio score set;
[0021] Construct a comprehensive score of the text attachment under each attachment category in the attachment category score table according to the keyword score set and the label ratio score set to obtain a comprehensive score set;
[0022] Query the attachment category corresponding to the highest comprehensive score in the comprehensive score set, and use the attachment category corresponding to the highest comprehensive score and the highest comprehensive score as the attachment category and the corresponding score of the text attachment.
[0023] Optionally, constructing a comprehensive score for each attachment category of the text attachment in the attachment category score table according to the keyword score set and the tag ratio score set to obtain a comprehensive score set, including:
[0024] Overlaying the scores in the keyword score set under the same attachment category to obtain the scores of the training keyword set under each attachment category;
[0025] Using a pre-constructed first normalization formula to normalize the scores of the training keyword set under each attachment category to obtain a keyword normalized score set;
[0026] Using a pre-constructed second normalization formula to normalize the scores in the tag ratio score set to obtain a tag ratio normalized score set;
[0027] Correspondingly overlaying the scores in the keyword normalized score set and the tag ratio normalized score set under the same attachment category to obtain the comprehensive score set.
[0028] Optionally, extracting the pre-annotated true category of the text attachment and all attachment keywords, paragraph tags, and table tags in the text attachment, including:
[0029] Extracting the preset attachment number of the text attachment, and querying the pre-annotated true category of the text attachment in a pre-constructed training attachment category table;
[0030] Converting the text attachment into html format to obtain an html attachment;
[0031] Extracting all attachment keywords in the html attachment according to a pre-constructed attachment keyword set;
[0032] Extracting all paragraph tags in the html attachment according to a preset attachment paragraph tag set;
[0033] Extracting all table tags in the html attachment according to a preset attachment table tag set.
[0034] Optionally, extracting all attachment keywords in the html attachment according to a pre-constructed attachment keyword set, including:
[0035] Performing word segmentation on the content in the html attachment to obtain a set of words to be matched;
[0036] Extracting the words that exist simultaneously in the set of words to be matched and the attachment keyword set, and using the simultaneously existing words as the attachment keywords.
[0037] Optionally, the step of using the score to perform gradient adjustment on the original attachment classifier and returning to the above step of using the original attachment classifier to classify and predict the text attachment to obtain the attachment category and the corresponding score of the text attachment includes:
[0038] Calculate the difference between the score and the prediction threshold to obtain a prediction residual;
[0039] Set the adjustment gradient for adjusting the keyword scoring set and the label ratio scoring set according to the magnitude of the prediction residual;
[0040] According to the adjustment gradient, adjust the scores under each attachment category in the keyword scoring set and the label ratio scoring set, and predict the attachment category and the corresponding score of the text attachment according to the adjusted keyword scoring set and label ratio scoring set.
[0041] Optionally, the step of receiving the attachment to be classified and using the standard attachment classifier to classify the attachment to be classified to obtain the classification result of the attachment to be classified includes:
[0042] Extract all attachment keywords, paragraph labels, and table labels in the attachment to be classified;
[0043] According to all the attachment keywords, paragraph labels, and table labels in the attachment to be classified, use the standard attachment classifier to classify the attachment to be classified to obtain the classification result of the attachment to be classified.
[0044] To solve the above problems, the present invention also provides an attachment classification device based on optical character recognition, and the device includes:
[0045] A sample data extraction module, configured to obtain a text attachment set generated by performing optical character recognition on a set of pictures to be classified, and select one text attachment from the text attachment set one by one, extract the true category pre-labeled for the text attachment, all attachment keywords, paragraph labels, and table labels in the text attachment, combine the extracted attachment keywords in the text attachment to obtain a training keyword set for the text attachment, and calculate the ratio of the number of paragraph labels to the number of table labels to obtain a training label ratio;
[0046] A classifier prediction module, configured to configure a pre-constructed original attachment classifier by using the training keyword set and the training label ratio, and use the original attachment classifier to classify and predict the text attachment to obtain the attachment category and the corresponding score of the text attachment;
[0047] A classification result judgment module, configured to determine whether the score is less than a preset prediction threshold, and when the score is less than the preset prediction threshold, perform gradient adjustment on the original attachment classifier using the score, and return to the step of classifying and predicting the text attachment using the original attachment classifier to obtain the attachment category and the corresponding score of the text attachment;
[0048] A classifier effect judgment module, configured to compare the predicted attachment category with the true category of the text attachment to obtain a prediction result of correct or incorrect prediction when the score is greater than or equal to the preset prediction threshold, and summarize the prediction results of all text attachments in the text attachment set to obtain a prediction accuracy rate, and determine whether the prediction accuracy rate is greater than or equal to a preset training threshold, and if the prediction accuracy rate is less than the training threshold, return to the process of configuring the pre-constructed original attachment classifier using the training keyword set and the training label ratio until the prediction accuracy rate is greater than or equal to the training threshold, and then stop the iterative training to obtain a standard attachment classifier;
[0049] A classifier recognition module, configured to receive an attachment to be classified and classify the attachment to be classified using the standard attachment classifier to obtain a classification result of the attachment to be classified.
[0050] To solve the above problems, the present invention also provides an electronic device, which includes:
[0051] At least one processor; and,
[0052] A memory communicatively connected to the at least one processor; wherein,
[0053] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned attachment classification method based on optical character recognition.
[0054] To solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the above-mentioned attachment classification method based on optical character recognition.
[0055] In an embodiment of the present invention, the attachment keyword and the training label ratio of the text attachment obtained by performing optical character recognition on the picture attachment are extracted. The attachment keyword and the training label ratio can represent all the feature information in a picture attachment. Using the training keyword set and the training label ratio to train the attachment classifier can make the attachment classifier more accurate. In addition, according to the scores of each attachment category predicted by the attachment classifier and the prediction accuracy rate of the attachment classifier, the attachment classifier is trained with two evaluation criteria, further improving the classification accuracy of the attachment classifier. Therefore, the attachment classification method, device, electronic device, and computer-readable storage medium based on optical character recognition proposed by the present invention can improve the classification accuracy of the attachments scanned by optical character recognition. Description of the Drawings
[0056] Figure 1 It is a schematic flowchart of the attachment classification method based on optical character recognition provided by an embodiment of the present invention;
[0057] Figure 2 It is a schematic flowchart of a step in the attachment classification method based on optical character recognition provided by an embodiment of the present invention;
[0058] Figure 3 It is a schematic flowchart of a step in the attachment classification method based on optical character recognition provided by an embodiment of the present invention;
[0059] Figure 4 It is a functional module diagram of the attachment classification device based on optical character recognition provided by an embodiment of the present invention;
[0060] Figure 5 It is a schematic structural diagram of an electronic device for implementing the attachment classification method based on optical character recognition provided by an embodiment of the present invention.
[0061] The realization, functional characteristics, and advantages of the object of the present invention will be further described in conjunction with the embodiments with reference to the drawings. Detailed Embodiments
[0062] 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.
[0063] An embodiment of the present application provides an attachment classification method based on optical character recognition. The execution subject of the attachment classification method based on optical character recognition includes, but is not limited to, at least one of electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided in the embodiment of the present application. In other words, the attachment classification method based on optical character recognition can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to: a single server, a server cluster, a cloud server, or a cloud server cluster, etc. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.
[0064] Referring to Figure 1 As shown, it is a schematic flowchart of an attachment classification method based on optical character recognition provided by an embodiment of the present invention. In this embodiment, the attachment classification method based on optical character recognition includes:
[0065] S1. Obtain a text attachment set generated by optical character recognition of a picture set to be classified.
[0066] In an embodiment of the present invention, the picture set to be classified can be business attachments stored on a website. For example: contract picture attachments, lease item list picture attachments, invoice picture attachments, etc. regarding the actual financing business between users registered on the China Registration and Clearing Corporation website. These attachments are all required to be scanned and uploaded. Further, in an embodiment of the present invention, a text attachment set corresponding to the picture set to be classified is obtained through optical character recognition technology (Optical Character Recognition, abbreviated as OCR).
[0067] Specifically, the picture set to be classified includes all types of attachment categories in a certain field. For example: in the field of actual financing business, the attachment categories include: pure text type, pure table type, composite type, invoice type, etc. Among them, the pure text type can be a contract agreement with basically no tables, the pure table type can be a table list with basically no text, the composite type is composed of half table and half pure text, and the invoice type can be a general VAT invoice and a special invoice, etc. Particularly, when an attachment is particularly blurred or cannot be opened, the attachment can be classified as an abnormal type.
[0068] S2. Select one text attachment from the text attachment set one by one, and extract the true category pre-labeled for the text attachment and all attachment keywords, paragraph tags, and table tags in the text attachment.
[0069] In the embodiments of the present invention, the attachment keywords are characteristic words with relatively high occurrence frequencies in each preset attachment category. For example, in a contract agreement of the pure text type, words such as "contract", "agreement", and "seal" can be used as attachment keywords; in a list of the pure table type, words such as "list" can be used as attachment keywords; in an attachment of the invoice type, words such as "special VAT invoice", "ordinary VAT invoice", "invoice copy", "deduction copy", "taxpayer identification number", and "issuer" can be used as attachment keywords.
[0070] In the embodiments of the present invention, possibility scores are calculated for each attachment category based on each attachment keyword in the text attachment. The higher the score for a certain attachment category, the greater the possibility that the text attachment belongs to that attachment category. Finally, the attachment category of the text attachment is predicted by comprehensively considering all the attachment keywords in the text attachment.
[0071] In the embodiments of the present invention, the paragraph tags refer to the paragraph tags in a file attachment in html format. For example: 、 etc. The table tags refer to the table tags in the text attachment in html format. For example: 、 、 etc.;
[0072] In the embodiment of the present invention, extracting the pre-labeled true category of the text attachment and all attachment keywords, paragraph tags, and table tags in the text attachment includes:
[0073] Extracting the preset attachment number of the text attachment, and querying the pre-labeled true category of the text attachment in the pre-constructed training attachment category table according to the attachment number;
[0074] Converting the text attachment into html format to obtain an html attachment;
[0075] Extracting all attachment keywords in the html attachment according to the pre-constructed attachment keyword set;
[0076] Extracting all paragraph tags in the html attachment according to the preset attachment paragraph tag set;
[0077] Extracting all table tags in the html attachment according to the preset attachment table tag set.
[0078] In the embodiment of the present invention, the training attachment category table refers to a pre-constructed query table for querying the true category of each text attachment in the text attachment set, wherein the training attachment category table is established according to the corresponding relationship between the preset attachment number of each text attachment and the true category of the text attachment.
[0079] In the embodiment of the present invention, extracting all attachment keywords in the html attachment according to the pre-constructed attachment keyword set includes:
[0080] Performing word segmentation on the content in the html attachment to obtain a set of words to be matched;
[0081] Extracting the words that exist simultaneously in the set of words to be matched and the attachment keyword set, and using the simultaneously existing words as the attachment keywords.
[0082] In the embodiment of the present invention, the jieba word segmentation tool or other word segmentation tools can be used to perform word segmentation on the html attachment.
[0083] Specifically, in the embodiment of the present invention, after word segmentation is completed, each attachment keyword in the attachment keyword set can be extracted and matched with each word to be matched in the set of words to be matched. When the matching is successful, it indicates that the word to be matched is an attachment keyword.
[0084] S3. Combine each attachment keyword extracted from the text attachment to obtain the training keyword set of the text attachment, and calculate the ratio of the number of the paragraph tags to the number of the table tags to obtain the training label ratio.
[0085] In the embodiments of the present invention, since the frequency of a certain attachment keyword appearing in the attachments of each attachment category and the ratio of the paragraph tags to the table tags are different, all the attachment keywords in the extracted text attachment and the ratio of the paragraph tags to the table tags can be used as the attachment category features of the text attachment, and the training label ratio is obtained by counting the number of the paragraph tags and the number of the table tags, providing data features for the subsequent classifier categorization process.
[0086] S4. Configure the pre-constructed original attachment classifier by using the training keyword set and the training label ratio.
[0087] In the embodiments of the present invention, the original attachment classifier can receive the scores given by the user to the text attachment under each attachment category according to each training keyword in the training keyword set and the training label ratio. When the score of a certain attachment category is the highest and greater than a preset threshold, the corresponding attachment category is used as the predicted attachment category.
[0088] S5. Classify and predict the text attachment by using the original attachment classifier to obtain the attachment category of the text attachment and the corresponding score.
[0089] Specifically, as Figure 2 shown, in the embodiments of the present invention, the step of classifying and predicting the text attachment by using the original attachment classifier to obtain the attachment category of the text attachment and the corresponding score includes:
[0090] S51. Score the text attachment under each attachment category in the pre-constructed attachment category score table according to each training keyword in the training keyword set to obtain a keyword score set;
[0091] S52. Score the text attachment under each attachment category in the attachment category score table according to the training label ratio to obtain a label ratio score set;
[0092] S53. Construct a comprehensive score of the text attachment under each attachment category in the attachment category score table according to the keyword score set and the label ratio score set to obtain a comprehensive score set;
[0093] S54. Query the attachment category corresponding to the highest comprehensive score in the comprehensive score set, and use the attachment category corresponding to the highest comprehensive score and the highest comprehensive score as the attachment category and the corresponding score of the text attachment.
[0094] Among them, the attachment category score table refers to a pre-constructed score table containing all preset attachment categories, such as: pure text category, pure table category, composite category, invoice category, etc. The attachment category can be placed in the first horizontal column of the attachment category score table. The keyword score set contains the scores of each training keyword in the training keyword set under all attachment categories in the attachment category score table. For example: when the training keyword is "contract", the score under the attachment category of the pure text category can be 0.70, the score under the attachment category of the pure table category can be 0.60, the score under the attachment category of the composite category can be 0.65, and the score under the attachment category of the invoice category can be 0.30.
[0095] In addition, the label ratio score set contains the scores of the training label ratio under all attachment categories in the attachment category score table. For example: when the training label ratio is 7:3, the score under the attachment category of the pure text category can be 0.30, the score under the attachment category of the pure table category can be 0.10, the score under the attachment category of the composite category can be 0.70, and the score under the attachment category of the invoice category can be 0.20.
[0096] Furthermore, the comprehensive score set refers to the score set obtained by integrating the scores of the keyword score set and the label ratio score set for the same attachment category to obtain the comprehensive score of the same attachment category, and then according to the comprehensive scores of all attachment categories.
[0097] Specifically, as Figure 3 shown, in the embodiment of the present invention, constructing the comprehensive score of the text attachment under each attachment category in the attachment category score table according to the keyword score set and the label ratio score set to obtain the comprehensive score set includes:
[0098] S531. Stack the scores in the keyword score set under the same attachment category to obtain the scores of the training keyword set under each attachment category;
[0099] S532. Use a pre-constructed first normalization formula to normalize the scores of the training keyword set under each attachment category to obtain a keyword normalized score set;
[0100] S533. Use a pre-constructed second normalization formula to normalize the scores in the label ratio score set to obtain a label ratio normalized score set;
[0101] S534. Corresponding to and superimposing the scores in the keyword normalization score set and the label ratio normalization score set under the same attachment category to obtain the comprehensive score set.
[0102] In the embodiment of the present invention, the first normalization formula is as follows:
[0103]
[0104] Among them, G 词集 refers to the score of the training keyword set under a certain attachment category after normalization of all scores of the training keyword set under the attachment category, and Q 词集 refers to the preset keyword normalization weight, which can be 0.5, and P 词集评分 refers to the superimposed scores of all training keywords in the training keyword set under a certain attachment category, and S 训练词数 refers to the number of training keywords in the training keyword set.
[0105] Furthermore, the second normalization formula is as follows:
[0106] G 标签 = Q 标签 * P 标签评分
[0107] Among them, G 标签 refers to the score of the label ratio score set under a certain attachment category after normalization, and Q 标签 refers to the preset label ratio normalization weight, which can be 0.5, and P 标签评分 refers to the score of the label ratio score set under a certain attachment category.
[0108] S6. Determine whether the score is less than a preset prediction threshold;
[0109] When the score is less than the preset prediction threshold, S7. Use the score to perform gradient adjustment on the original attachment classifier and return to S4 above.
[0110] In the embodiment of the present invention, the prediction threshold can be 0.7. When a certain highest comprehensive score is greater than or equal to 0.7, the highest comprehensive score is used as the score predicted for the text attachment.
[0111] Specifically, in the embodiment of the present invention, the step of using the score to perform gradient adjustment on the original attachment classifier and returning to the step of classifying and predicting the text attachment using the original attachment classifier to obtain the attachment category and the corresponding score of the text attachment includes:
[0112] Calculate the difference between the score and the prediction threshold to obtain a prediction residual;
[0113] Set an adjustment gradient for adjusting the keyword score set and the tag ratio score set according to the magnitude of the prediction residual;
[0114] Adjust the scores under each attachment category in the keyword score set and the tag ratio score set according to the adjustment gradient, and predict the attachment category and the corresponding score of the text attachment according to the adjusted keyword score set and tag ratio score set.
[0115] In an embodiment of the present invention, according to a preset adjustment strategy, when the highest comprehensive score is less than 0.7, it is necessary to set the adjustment gradient magnitude of the scores in each attachment category in the keyword score set and the tag ratio score set according to the magnitude of the prediction residual.
[0116] When the score is greater than or equal to a preset prediction threshold, in S8, compare the predicted attachment category with the true category of the text attachment to obtain a prediction result of correct prediction or wrong prediction.
[0117] In an embodiment of the present invention, by comparing the attachment category predicted for the text attachment with the pre-extracted true category, when the two are the same, it indicates a correct prediction, and when the two are different, it indicates a wrong prediction.
[0118] S9. Aggregate the prediction results of all text attachments in the text attachment set to obtain a prediction accuracy rate.
[0119] In an embodiment of the present invention, according to the ratio of correct predictions and wrong predictions in the prediction results of all text attachments in the text attachment set, obtain the prediction accuracy rate, and the prediction effect can be obtained according to the prediction accuracy rate.
[0120] S10. Determine whether the prediction accuracy rate is greater than or equal to a preset training threshold.
[0121] If the prediction accuracy rate is less than the training threshold, return to S4 above until the prediction accuracy rate is greater than or equal to the training threshold, then execute S11, stop the iterative training, and obtain a standard attachment classifier.
[0122] In an embodiment of the present invention, the training threshold is set to 0.85. When the prediction accuracy rate is less than the training threshold, it indicates that the scores in the keyword score and the tag ratio score set are inaccurate, and the scores need to be re-evaluated to obtain the prediction accuracy rate again until the prediction accuracy rate is greater than or equal to the preset training threshold, which indicates a relatively high scoring accuracy.
[0123] S12. Receive the attachment to be classified, and classify the attachment to be classified by using the standard attachment classifier to obtain the classification result of the attachment to be classified.
[0124] Specifically, in the embodiment of the present invention, the receiving the attachment to be classified, classifying the attachment to be classified by using the standard attachment classifier, and obtaining the classification result of the attachment to be classified includes
[0125] Extract all attachment keywords, paragraph tags, and table tags in the attachment to be classified;
[0126] According to all the attachment keywords, paragraph tags, and table tags in the attachment to be classified, classify the attachment to be classified by using the standard attachment classifier to obtain the classification result of the attachment to be classified.
[0127] In the embodiment of the present invention, after obtaining the standard attachment classifier, the attachment keywords of the picture attachments in the pre-constructed set of pictures to be classified can be extracted one by one, and the ratio of the number of paragraph tags to the number of table tags can be obtained. According to the attachment keywords of the attachment to be classified and the number of paragraph tags and table tags of the attachment, as the attachment features of the attachment to be classified, the standard attachment classifier can classify according to the attachment features to obtain the classification result.
[0128] As Figure 4 shown, it is a functional module diagram of an attachment classification device based on optical character recognition provided by an embodiment of the present invention.
[0129] The attachment classification device 100 based on optical character recognition according to the present invention can be installed in an electronic device. According to the functions implemented, the attachment classification device 100 based on optical character recognition can include a sample data extraction module 101, a classifier prediction module 102, a classification result judgment module 103, a classifier effect judgment module 104, and a classifier recognition module 105. The modules in the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by a processor of an electronic device and can complete fixed functions, and are stored in the memory of the electronic device.
[0130] In this embodiment, the functions of each module / unit are as follows:
[0131] The sample data extraction module 101 is used to obtain a set of text attachments generated by optical character recognition of a picture set to be classified, select one text attachment from the set of text attachments one by one, extract the true category pre-labeled for the text attachment, all attachment keywords, paragraph tags, and table tags in the text attachment, combine the extracted attachment keywords in the text attachment to obtain a training keyword set for the text attachment, and calculate the ratio of the number of paragraph tags to the number of table tags to obtain a training label ratio.
[0132] The classifier prediction module 102 is used to configure a pre-constructed original attachment classifier using the training keyword set and the training label ratio, and classify and predict the text attachment using the original attachment classifier to obtain the attachment category and corresponding score of the text attachment.
[0133] The classification result judgment module 103 is used to judge whether the score is less than a preset prediction threshold, and when the score is less than the preset prediction threshold, perform gradient adjustment on the original attachment classifier using the score, and return to the above step of classifying and predicting the text attachment using the original attachment classifier to obtain the attachment category and corresponding score of the text attachment.
[0134] The classifier effect judgment module 104 is used to, when the score is greater than or equal to the preset prediction threshold, compare the predicted attachment category with the true category of the text attachment to obtain a prediction result of correct or incorrect prediction, summarize the prediction results of all text attachments in the set of text attachments to obtain a prediction accuracy rate, judge whether the prediction accuracy rate is greater than or equal to a preset training threshold, and if the prediction accuracy rate is less than the training threshold, return to the above process of configuring the pre-constructed original attachment classifier using the training keyword set and the training label ratio until the prediction accuracy rate is greater than or equal to the training threshold, and then stop the iterative training to obtain a standard attachment classifier.
[0135] The classifier recognition module 105 is used to receive an attachment to be classified and classify the attachment to be classified using the standard attachment classifier to obtain the classification result of the attachment to be classified.
[0136] Specifically, each module in the attachment classification device 100 based on optical character recognition in the embodiment of the present invention uses the same technical means as those in the above Figures 1 to 3 attachment classification method based on optical character recognition and can produce the same technical effects, which will not be elaborated here.
[0137] Such as Figure 5 As shown, it is a schematic structural diagram of an electronic device for implementing an accessory classification method based on optical character recognition according to an embodiment of the present invention.
[0138] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13. It may also include a computer program stored in the memory 11 and executable on the processor 10, such as an accessory classification program based on optical character recognition.
[0139] Among them, the processor 10 may be composed of integrated circuits in some embodiments. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple packaged integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control core (Control Unit) of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. By running or executing programs or modules stored in the memory 11 (such as executing an accessory classification program based on optical character recognition, etc.), and by calling data stored in the memory 11, it performs various functions of the electronic device and processes data.
[0140] The memory 11 includes at least one type of readable storage medium. The readable storage medium includes flash memory, mobile hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), magnetic memories, magnetic disks, optical discs, etc. The memory 11 may be an internal storage unit of the electronic device in some embodiments, such as the mobile hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 11 may include both an internal storage unit and an external storage device of the electronic device. The memory 11 can not only be used to store application software installed on the electronic device and various types of data, such as the code of an accessory classification program based on optical character recognition, etc., but also be used to temporarily store data that has been output or will be output.
[0141] The communication bus 12 can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to implement connection communication between the memory 11, at least one processor 10, and the like.
[0142] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user 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.), and is generally used to establish a communication connection between this electronic device and other electronic devices. The user interface can be a display, an input unit (such as a keyboard), and optionally, the user interface can also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) toucher, etc. Among them, the display can also be appropriately referred to as a display screen or a display unit, and is used to display the information processed in the electronic device and to display a visual user interface.
[0143] Figure 5 Only the electronic device with components is shown. Those skilled in the art can understand that Figure 5 the shown structure does not constitute a limitation on the electronic device 1, and it may include fewer or more components than shown, or combine certain components, or have a different component layout.
[0144] For example, although not shown, the electronic device may further include a power source (such as a battery) for powering each component. Preferably, the power source can be logically connected to the at least one processor 10 through a power management device, so as to implement functions such as charge management, discharge management, and power consumption management through the power management device. The power source may further include any components such as one or more DC or AC power sources, a recharge device, a power failure detection circuit, a power converter or an inverter, and a power status indicator. The electronic device may further include various sensors, a Bluetooth module, a Wi-Fi module, etc., which will not be elaborated here.
[0145] It should be understood that the above embodiments are only for illustration purposes and are not limited by this structure in the scope of the patent application.
[0146] The accessory classification program based on optical character recognition stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve the following:
[0147] Obtain the text accessory set generated by optical character recognition of the picture set to be classified;
[0148] Select one text accessory from the text accessory set one by one, and extract the true category pre-labeled for the text accessory, as well as all accessory keywords, paragraph tags, and table tags in the text accessory;
[0149] Combine the various accessory keywords extracted from the text accessory to obtain the training keyword set for the text accessory, and calculate the ratio of the number of paragraph tags to the number of table tags to obtain the training label ratio;
[0150] Configure the pre-constructed original accessory classifier using the training keyword set and the training label ratio;
[0151] Use the original accessory classifier to perform classification prediction on the text accessory to obtain the accessory category and the corresponding score of the text accessory;
[0152] Determine whether the score is less than a preset prediction threshold;
[0153] When the score is less than the preset prediction threshold, use the score to perform gradient adjustment on the original accessory classifier, and return to the above step of using the original accessory classifier to perform classification prediction on the text accessory to obtain the accessory category and the corresponding score of the text accessory;
[0154] When the score is greater than or equal to the preset prediction threshold, compare the predicted accessory category with the true category of the text accessory to obtain a prediction result of correct or incorrect prediction;
[0155] Summarize the prediction results of all text accessories in the text accessory set to obtain the prediction accuracy rate;
[0156] Determine whether the prediction accuracy rate is greater than or equal to a preset training threshold;
[0157] If the prediction accuracy rate is less than the training threshold, return to the above process of configuring the pre-constructed original accessory classifier using the training keyword set and the training label ratio, and stop the iterative training until the prediction accuracy rate is greater than or equal to the training threshold to obtain a standard accessory classifier;
[0158] Receive the accessory to be classified, and use the standard accessory classifier to classify the accessory to be classified to obtain the classification result of the accessory to be classified.
[0159] Specifically, for the specific implementation method of the above instructions by the processor 10, reference may be made to the description of the relevant steps in the corresponding embodiments of the accompanying drawings, which will not be elaborated herein.
[0160] Furthermore, if the modules / units integrated in the electronic device 1 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory).
[0161] The present invention also provides a computer-readable storage medium, where the readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, it can implement:
[0162] Obtain a set of text attachments generated by performing optical character recognition on a set of pictures to be classified;
[0163] Select one text attachment from the set of text attachments one by one, and extract the true category pre-labeled for the text attachment and all attachment keywords, paragraph tags, and table tags in the text attachment;
[0164] Combine the various attachment keywords extracted from the text attachment to obtain a training keyword set for the text attachment, and calculate the ratio of the number of paragraph tags to the number of table tags to obtain a training label ratio;
[0165] Configure a pre-constructed original attachment classifier using the training keyword set and the training label ratio;
[0166] Use the original attachment classifier to perform classification prediction on the text attachment to obtain the attachment category of the text attachment and the corresponding score;
[0167] Determine whether the score is less than a preset prediction threshold;
[0168] When the score is less than the preset prediction threshold, use the score to perform gradient adjustment on the original attachment classifier, and return to the above step of using the original attachment classifier to perform classification prediction on the text attachment to obtain the attachment category of the text attachment and the corresponding score;
[0169] When the score is greater than or equal to a preset prediction threshold, compare the predicted attachment category with the true category of the text attachment to obtain a prediction result of correct or incorrect prediction;
[0170] Summarize the prediction results of all text attachments in the text attachment set to obtain a prediction accuracy rate;
[0171] Determine whether the prediction accuracy rate is greater than or equal to a preset training threshold;
[0172] If the prediction accuracy rate is less than the training threshold, return the process of configuring the pre-constructed original attachment classifier using the training keyword set and the training label ratio as described above. Stop the iterative training until the prediction accuracy rate is greater than or equal to the training threshold to obtain a standard attachment classifier;
[0173] Receive the attachment to be classified, and classify the attachment to be classified using the standard attachment classifier to obtain the classification result of the attachment to be classified.
[0174] In 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 merely illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation.
[0175] 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 can be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0176] In addition, in each embodiment of the present invention, the functional modules can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a hardware plus software functional module.
[0177] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and can be implemented in other specific forms without departing from the spirit or basic characteristics of the present invention.
[0178] Therefore, in all aspects, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Thus, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be encompassed by the present invention. Any reference signs in the claims should not be construed as limiting the claims involved.
[0179] The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, in essence, is a decentralized database, a series of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer, etc.
[0180] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results.
[0181] In addition, it is obvious that the word "including" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices stated in the system claims can also be implemented by one unit or device through software or hardware. Words such as first, second, etc. are used to denote names and do not denote any particular order.
[0182] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not restrictive. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. An accessory classification method based on optical character recognition, characterized in that, the method includes: Obtaining a set of text accessories generated by optical character recognition of a set of pictures to be classified; Selecting one text accessory from the set of text accessories one by one, and extracting the true category pre-labeled for the text accessory and all accessory keywords, paragraph labels, and table labels in the text accessory; Combining each accessory keyword extracted from the text accessory to obtain a training keyword set for the text accessory, and calculating the ratio of the number of paragraph labels to the number of table labels to obtain a training label ratio; Configuring a pre-constructed original accessory classifier using the training keyword set and the training label ratio; Using the original accessory classifier to perform classification prediction on the text accessory to obtain the accessory category and corresponding score of the text accessory; Judging whether the score is less than a preset prediction threshold; When the score is less than the preset prediction threshold, using the score to perform gradient adjustment on the original accessory classifier, and returning to the above step of using the original accessory classifier to perform classification prediction on the text accessory to obtain the accessory category and corresponding score of the text accessory; When the score is greater than or equal to the preset prediction threshold, comparing the predicted accessory category with the true category of the text accessory to obtain a prediction result of correct or incorrect prediction; Summarizing the prediction results of all text accessories in the set of text accessories to obtain a prediction accuracy rate; Judging whether the prediction accuracy rate is greater than or equal to a preset training threshold; If the prediction accuracy rate is less than the training threshold, return to the above step of configuring the pre-constructed original accessory classifier using the training keyword set and the training label ratio until the prediction accuracy rate is greater than or equal to the training threshold to obtain a standard accessory classifier; Receiving an accessory to be classified, and using the standard accessory classifier to classify the accessory to be classified to obtain a classification result of the accessory to be classified.
2. The accessory classification method based on optical character recognition according to claim 1, characterized in that, the step of using the original accessory classifier to perform classification prediction on the text accessory to obtain the accessory category and corresponding score of the text accessory includes: Scoring the text accessory under each accessory category in a pre-constructed accessory category scoring table according to each training keyword in the training keyword set to obtain a keyword scoring set; Scoring the text accessory under each accessory category in the accessory category scoring table according to the training label ratio to obtain a label ratio scoring set; Constructing a comprehensive score of the text accessory under each accessory category in the accessory category scoring table according to the keyword scoring set and the label ratio scoring set to obtain a comprehensive scoring set; Querying the accessory category corresponding to the highest comprehensive score in the comprehensive scoring set, and using the accessory category corresponding to the highest comprehensive score and the highest comprehensive score as the accessory category and corresponding score of the text accessory.
3. The method for classifying attachments based on optical character recognition according to claim 2, characterized in that, constructing a comprehensive score for each attachment category of the text attachment in the attachment category score table according to the keyword score set and the label ratio score set, to obtain a comprehensive score set, including: superposing the scores in the same attachment category in the keyword score set to obtain the score of the training keyword set in each attachment category; using a pre-constructed first normalization formula to perform normalization processing on the scores of the training keyword set in each attachment category to obtain a keyword normalized score set; using a pre-constructed second normalization formula to perform normalization processing on the scores in the label ratio score set to obtain a label ratio normalized score set; correspondingly superposing the scores in the same attachment category in the keyword normalized score set and the label ratio normalized score set to obtain the comprehensive score set.
4. The method for classifying attachments based on optical character recognition according to claim 1, characterized in that, extracting the true category pre-labeled for the text attachment and all attachment keywords, paragraph labels and table labels in the text attachment, including: extracting the preset attachment number of the text attachment, and querying the true category pre-labeled for the text attachment in a pre-constructed training attachment category table according to the attachment number; converting the text attachment into html format to obtain an html attachment; extracting all attachment keywords in the html attachment according to a pre-constructed attachment keyword set; extracting all paragraph labels in the html attachment according to a preset attachment paragraph label set; extracting all table labels in the html attachment according to a preset attachment table label set.
5. The method for classifying attachments based on optical character recognition according to claim 4, characterized in that, extracting all attachment keywords in the html attachment according to a pre-constructed attachment keyword set, including: performing word segmentation processing on the content in the html attachment to obtain a set of words to be matched; extracting the words that simultaneously exist in the set of words to be matched and the attachment keyword set, and using the simultaneously existing words as the attachment keywords.
6. The method for classifying attachments based on optical character recognition according to claim 1, characterized in that, using the score to perform gradient adjustment on the original attachment classifier, and returning to the step of using the original attachment classifier to perform classification prediction on the text attachment to obtain the attachment category and the corresponding score of the text attachment, including: calculating the difference between the score and the prediction threshold to obtain a prediction residual; setting an adjustment gradient for adjusting the keyword score set and the label ratio score set according to the magnitude of the prediction residual; adjusting the scores of each attachment category in the keyword score set and the label ratio score set according to the adjustment gradient, and predicting the attachment category and the corresponding score of the text attachment according to the adjusted keyword score set and label ratio score set.
7. The method for classifying attachments based on optical character recognition according to any one of claims 1-6, characterized in that, receiving the attachment to be classified, and classifying the attachment to be classified by using the standard attachment classifier to obtain the classification result of the attachment to be classified, including: extracting all attachment keywords, paragraph labels and table labels in the attachment to be classified; classifying the attachment to be classified by using the standard attachment classifier according to all the attachment keywords, paragraph labels and table labels in the attachment to be classified to obtain the classification result of the attachment to be classified.
8. An attachment classification device based on optical character recognition, characterized in that, the device includes: a sample data extraction module, configured to obtain a set of text attachments generated by optical character recognition of a set of pictures to be classified, and select one text attachment from the set of text attachments one by one, extract the true category pre-labeled for the text attachment and all attachment keywords, paragraph labels and table labels in the text attachment, and combine the extracted attachment keywords in the text attachment to obtain a training keyword set for the text attachment, and calculate a ratio of the number of the paragraph labels to the number of the table labels to obtain a training label ratio; a classifier prediction module, configured to configure a pre-constructed original attachment classifier by using the training keyword set and the training label ratio, and classify and predict the text attachment by using the original attachment classifier to obtain the attachment category and the corresponding score of the text attachment; a classification result judgment module, configured to judge whether the score is less than a preset prediction threshold, and when the score is less than the preset prediction threshold, perform gradient adjustment on the original attachment classifier by using the score, and return to the above step of classifying and predicting the text attachment by using the original attachment classifier to obtain the attachment category and the corresponding score of the text attachment; a classifier effect judgment module, configured to, when the score is greater than or equal to the preset prediction threshold, compare the predicted attachment category with the true category of the text attachment to obtain a prediction result of correct or incorrect prediction, and summarize the prediction results of all the text attachments in the set of text attachments to obtain a prediction accuracy rate, and judge whether the prediction accuracy rate is greater than or equal to a preset training threshold, and if the prediction accuracy rate is less than the training threshold, return to the above process of configuring the pre-constructed original attachment classifier by using the training keyword set and the training label ratio until the prediction accuracy rate is greater than or equal to the training threshold to obtain a standard attachment classifier; a classifier recognition module, configured to receive an attachment to be classified, and classify the attachment to be classified by using the standard attachment classifier to obtain the classification result of the attachment to be classified.
9. An electronic device, characterized in that, the electronic device includes: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the optical character recognition-based attachment classification method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein, when the computer program is executed by a processor, it implements the optical character recognition-based attachment classification method according to any one of claims 1 to 7.
Citation Information
Patent Citations
File storage method and device based on RPA and AI, equipment and medium
CN111752900A
Text classification method and device, electronic equipment and readable storage medium
CN113157927A