Text extraction method and device, equipment and storage medium

By combining the text recognition results of protocol parsing and target recognition models in non-editable files to determine display characteristics and confidence, the problem of insufficient text extraction accuracy in the prior art is solved and the accuracy of text information extraction is improved.

CN118609145APending Publication Date: 2024-09-06BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410804953.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

When the existing technology extracts text information from non-editable files such as PDF files, especially when it contains text with complex display structures such as mathematical formulas and rare characters, the accuracy is insufficient and it is difficult to effectively extract text information.

Method used

By determining the target extraction object in the file to be extracted, the candidate text extraction results are obtained, combined with the text recognition results of the protocol analysis and target recognition model, to determine whether the target type text is included, and the final text extraction is determined based on the display feature information and confidence threshold result.

Benefits of technology

The accuracy of text information extraction is improved, especially when processing text with preset display structure characteristics, and complex text such as algorithmic formulas can be more accurately extracted.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118609145A
    Figure CN118609145A
Patent Text Reader

Abstract

The invention provides a text extraction method and device, equipment and a storage medium, and the method comprises the steps: determining a target extraction object in a to-be-extracted file, then obtaining a candidate text extraction result of the target extraction object, and if the target extraction object contains a target type text, obtaining a candidate text extraction result of the target extraction object; and if yes, outputting the second text extraction result as a text extraction result of the target extraction object. According to the embodiment of the invention, after the candidate text extraction result of the target extraction object is obtained, the text extraction result of the target extraction object is determined on the basis of the candidate text extraction result by judging whether the target extraction object contains the target type text or not. According to the embodiment of the invention, the text recognition result of the target recognition model is adopted as the text extraction result for the target type text, and the target recognition model can more accurately extract the text with the preset display structure characteristics, such as an algorithm formula, so that the text extraction efficiency is improved. According to the text extraction method provided by the embodiment of the invention, the accuracy of text information extraction can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, and in particular to a text extraction method, device, equipment and storage medium. Background Art

[0002] Text extraction is a technology that extracts text information from non-editable files (such as PDF files).

[0003] Since the formats of text information in uneditable files are diverse, for example, they may include mathematical formulas, rare characters, uncommon fonts, etc., therefore, how to more accurately extract the text information contained in uneditable files has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] In order to solve the above technical problems, the embodiments of the present disclosure provide a text extraction method, device, equipment and storage medium.

[0005] In a first aspect, the present disclosure provides a text extraction method, the method comprising:

[0006] Determine the target extraction object in the file to be extracted;

[0007] Obtain candidate text extraction results for the target extraction object; wherein the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model;

[0008] If it is determined that the target extraction object contains a target type text, the second text extraction result is output as the text extraction result of the target extraction object; wherein the target type text includes text with preset display structure features.

[0009] In an optional implementation manner, the method further includes:

[0010] If it is determined that the target extraction object does not contain the target type text, the first text extraction result is output as the text extraction result of the target extraction object.

[0011] In an optional implementation manner, before obtaining the candidate text extraction result of the target extraction object, the method further includes:

[0012] Performing protocol parsing on the target extraction object to obtain structured description data corresponding to the target extraction object; wherein the structured description data includes text information in the target extraction object and display feature information of the text information, and the structured description data is used to determine the first text extraction result;

[0013] Correspondingly, if it is determined that the target extraction object contains a target type of text, before outputting the second text extraction result as the text extraction result of the target extraction object, the method further includes:

[0014] According to the display characteristic information of the text information in the structured description data, it is determined whether the target extraction object contains target type text.

[0015] In an optional implementation, the display characteristic information includes display attribute information and / or display position information of each text character in the text information, and the display attribute information includes font type and / or font size; and determining whether the target extraction object contains target type text according to the display characteristic information of the text information in the structured description data includes:

[0016] Determining whether display attribute information corresponding to different characters in the structured description data is the same;

[0017] and / or,

[0018] Determine whether the display position information corresponding to different characters in the structured description data conforms to a preset display position rule.

[0019] In an optional implementation manner, before obtaining the candidate text extraction result of the target extraction object, the method further includes:

[0020] Acquire an image corresponding to the target extraction object, and input the image into a trained target recognition model, and output a text recognition result after being processed by the target recognition model; wherein the text recognition result is used to determine the second text extraction result;

[0021] Correspondingly, if it is determined that the target extraction object contains a target type of text, before outputting the second text extraction result as the text extraction result of the target extraction object, the method further includes:

[0022] According to the text features included in the text recognition result, it is determined whether the target extraction object includes a target type of text.

[0023] In an optional implementation manner, determining whether the target extraction object contains target type text according to the text features contained in the text recognition result includes:

[0024] Determine whether the text recognition result contains the text with the preset display structure feature.

[0025] In an optional implementation, the second text extraction result has a corresponding confidence level, the confidence level is obtained by performing text recognition on the target extraction object using the target recognition model, and the confidence level is used to characterize the credibility of the second text extraction result;

[0026] If it is determined that the target extraction object contains a target type of text, outputting the second text extraction result as the text extraction result of the target extraction object includes:

[0027] If it is determined that the target extraction object contains target type text, determining whether the confidence corresponding to the second text extraction result is less than a preset confidence threshold;

[0028] If it is determined that the confidence corresponding to the second text extraction result is not less than the preset confidence threshold, the second text extraction result is output as the text extraction result of the target extraction object.

[0029] In an optional implementation manner, the method further includes:

[0030] If it is determined that the confidence corresponding to the second text extraction result is less than the preset confidence threshold, the first text extraction result is output as the text extraction result of the target extraction object.

[0031] In an optional implementation manner, the file to be extracted includes a portable document format PDF file, and determining the target extraction object in the file to be extracted includes:

[0032] The PDF file is traversed line by line to determine the target extraction object in the PDF file.

[0033] In a second aspect, the present disclosure further provides a text extraction device, the device comprising:

[0034] The first determination model is used to determine the target extraction object in the file to be extracted;

[0035] A first acquisition model is used to acquire candidate text extraction results of the target extraction object; wherein the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model;

[0036] The second determination model is used to output the second text extraction result as the text extraction result of the target extraction object when determining that the target extraction object contains a target type text; wherein the target type text includes text with preset display structure features.

[0037] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the above method.

[0038] In a fourth aspect, the present disclosure provides a text extraction device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.

[0039] In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program / instructions, and the computer program / instructions implement the above method when executed by a processor.

[0040] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:

[0041] The disclosed embodiment provides a text extraction method. Specifically, first, a target extraction object in a file to be extracted is determined, and then, candidate text extraction results of the target extraction object are obtained, wherein the candidate text extraction results include a first text extraction result and a second text extraction result, wherein the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model, and if it is determined that the target extraction object contains a target type text, the second text extraction result is output as the text extraction result of the target extraction object, wherein the target type text includes text with preset display structure features.

[0042] After obtaining the candidate text extraction results of the target extraction object, the disclosed embodiment determines the text extraction result of the target extraction object based on the candidate text extraction results by judging whether the target extraction object contains the target type text. The disclosed embodiment uses the text recognition result of the target recognition model as the text extraction result for the target type text. Since the target recognition model can more accurately extract texts with preset display structure features such as algorithm formulas, the text extraction method provided by the disclosed embodiment can improve the accuracy of text information extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] Figure 1 A flowchart of a text extraction method provided for some embodiments of the present disclosure;

[0046] Figure 2 A processing flow chart of a text extraction method provided in some embodiments of the present disclosure;

[0047] Figure 3 A schematic diagram of the structure of a text extraction device provided in some embodiments of the present disclosure;

[0048] Figure 4 A schematic diagram of the structure of a text extraction device provided in some embodiments of the present disclosure. DETAILED DESCRIPTION

[0049] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0050] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0051] Portable Document Format (PDF) files have the advantages of cross-platform, multimedia integration, and security. PDF has become one of the most widely used electronic document formats. With the widespread use of PDF documents, a large amount of valuable data is presented in the form of PDF files. Therefore, how to extract text information from PDF files is a problem that has received widespread attention and research.

[0052] In practical applications, PDF parsing tools can be used to extract text from PDF files. PDF parsing tools are a method of performing protocol parsing on PDF files to obtain text extraction results. This text extraction method is suitable for parsing PDF files that only contain text content and has characteristics such as high confidence.

[0053] However, for PDF files containing display structure features, such as mathematical formulas, chemical equations, etc., there is a problem of insufficient accuracy because PDF parsing tools can only extract the text content therein.

[0054] To this end, an embodiment of the present disclosure provides a text extraction method. Specifically, first, a target extraction object in a file to be extracted is determined, and then, candidate text extraction results of the target extraction object are obtained, wherein the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model. If it is determined that the target extraction object contains a target type text, the second text extraction result is output as the text extraction result of the target extraction object, wherein the target type text includes text with preset display structure features.

[0055] After obtaining the candidate text extraction results of the target extraction object, the embodiment of the present disclosure determines the text extraction result of the target extraction object based on the candidate text extraction results by judging whether the target extraction object contains the target type text. The embodiment of the present disclosure uses the text recognition result of the target recognition model as the text extraction result for the target type text. Since the target recognition model can more accurately extract texts with preset display structure features such as algorithm formulas, the text extraction method provided by the embodiment of the present disclosure can improve the accuracy of text information extraction.

[0056] Specifically, the present disclosure provides a text extraction method, referring to Figure 1 , is a flowchart of a text extraction method provided by an embodiment of the present disclosure, specifically comprising:

[0057] S101: Determine the target extraction object in the file to be extracted.

[0058] In the disclosed embodiment, the file to be extracted may be a target type file, which generally has the characteristic that the text information contained in the file cannot be directly edited. Specifically, the file to be extracted may include a portable document format PDF file or the like.

[0059] The target extraction object may be an object in the file to be extracted that needs to undergo text extraction. Specifically, the target extraction object may be a line or multiple lines, a paragraph or multiple paragraphs, etc. in the file to be extracted. That is to say, the disclosed embodiment may use a line as a text extraction unit in the file to be extracted, and divide the file to be extracted according to lines to obtain the target extraction object in the file to be extracted. It is worth noting that the disclosed embodiment may also use a paragraph as a text extraction unit in the file to be extracted, and divide the file to be extracted according to paragraphs to obtain the target extraction object in the file to be extracted. The disclosed embodiment does not limit how to divide the file to be extracted to obtain the target extraction object.

[0060] In an optional implementation, assuming that the file to be extracted is a PDF file, if a line is a text extraction unit of the PDF file, each line in the PDF file can be determined as an extraction object by traversing the PDF file line by line, wherein the target extraction object in the embodiment of the present disclosure can be the extraction object corresponding to any line in the PDF file.

[0061] S102: Obtain the candidate text extraction result of the target extraction object.

[0062] Among them, the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model.

[0063] In the disclosed embodiment, the candidate text extraction result is obtained by performing text extraction on the target extraction object.

[0064] In an optional implementation, after determining the target extraction object in the file to be extracted, the target extraction object is subjected to protocol parsing, and then, structured description data corresponding to the target extraction object is obtained, and the first text extraction result of the target extraction object is obtained through the text information contained in the structured description data.

[0065] Specifically, the protocol of the target extraction object can be parsed by using parsing tools, and the corresponding parsing tools can be used for the files to be extracted of different file types. Assuming that the file to be extracted is a PDF file, the PDF parsing tool can be used to perform protocol parsing based on the file protocol that the PDF file depends on. The structured description data corresponding to the target extraction object refers to the file parsing result obtained by performing protocol parsing on the target extraction object. Specifically, the structured description data describes the file parsing result according to a preset data format.

[0066] In addition, the structured description data corresponding to the target extraction object includes the text information in the target extraction object and the display feature information of the text information. That is to say, the structured description data corresponding to the target extraction object is obtained, and then the text information in the target extraction object and the display feature information of the text information can be extracted from the structured description data.

[0067] The display characteristic information of the text information in the target extraction object may include at least one of display attribute information and display position information of the text information. The display attribute information may include font type, font size, font color, etc., and the display attribute information is used to characterize the display attribute of the text information in the target extraction object; the display position information is used to characterize the display position of the text in the target extraction object, and specifically, for example, the display position information may include the coordinate information of each text character in the target extraction object on the current text page.

[0068] In another optional implementation, after determining the target extraction object in the file to be extracted, an image (such as a screenshot) corresponding to the target extraction object is obtained, and the image is input into the target recognition model. After being processed by the target recognition model, the text recognition result corresponding to the target extraction object is output, and the text recognition result is then determined as the second text extraction result of the target extraction object. Among them, the text recognition result can be directly used as the second text extraction result of the target extraction object, and the text recognition result can also be post-processed to obtain the second text extraction result of the target extraction object. The target recognition model in the disclosed embodiment is obtained through sample training, and the specific model training process is not repeated in the disclosed embodiment.

[0069] The image corresponding to the target extraction object can be obtained by image conversion or the like. Specifically, firstly, the current document page of the file to be extracted is converted to obtain the image corresponding to the current document page. Then, based on the target extraction object of the file to be extracted, a screenshot is taken of the image corresponding to the current document page to obtain the image corresponding to the target extraction object. The embodiments of the present disclosure do not impose any limitation on this.

[0070] S103: If it is determined that the target extraction object contains target type text, output the second text extraction result as the text extraction result of the target extraction object.

[0071] Wherein, the target type text includes text with preset display structure features.

[0072] In the disclosed embodiment, the preset display structure feature may include any one or more preset display structure features. Specifically, the preset display structure feature may include relatively complex display structures such as formula structures and chemical equation structures. When extracting text with preset display structure features, it is necessary not only to consider the accuracy of the content contained in the text, but also to consider the structural features of the text, such as complex expressions such as superscripts and subscripts, matrices, etc. contained in the formula structure.

[0073] In an embodiment of the present disclosure, after obtaining the candidate text extraction results of the target extraction object, it is determined whether the target extraction object contains the target type text. If it is determined that the target extraction object contains the target type text, since the text recognition result obtained by using the target recognition model can more accurately extract the target type text, the embodiment of the present disclosure outputs the second text extraction result in the candidate extraction results as the text extraction result of the target extraction object.

[0074] In an optional implementation, it is possible to determine whether the target extraction object contains target type text based on the structured description data corresponding to the target extraction object. Specifically, since the display feature information of the text information can reflect whether the text information belongs to text with preset display structure features, it is possible to determine whether the target extraction object includes target type text based on the display feature information of the text information in the structured description data corresponding to the target extraction object.

[0075] The display characteristic information of the text information in the structured description data may include display attribute information. In an optional implementation, it is possible to determine whether the target extraction object contains the target type text based on the display attribute information of the text information in the structured description data. Specifically, after obtaining the structured description data corresponding to the target extraction object, the display attribute information corresponding to the text characters in the structured description data is traversed to obtain, and then it is determined whether the display attribute information corresponding to different text characters is the same. If it is determined that the display attribute information corresponding to different characters in the structured description data is not the same, it indicates that the target extraction object contains the target type text.

[0076] The display attribute information includes at least one of a font type and a font size. Based on the structured description data, it is determined whether the display attribute information corresponding to different characters is the same. Specifically, it can be determined whether the font types and font sizes corresponding to different text characters in the structured description data are consistent. When it is determined that at least one of the display attribute information between different text characters is inconsistent, it can be determined that the target extraction object contains the target type of text.

[0077] For example, suppose the target extraction object contains "F i=LayerNorm(VP i +SP i +P i )", obtain the structured description data corresponding to the target extraction object through protocol parsing, and determine whether the font types corresponding to different characters in the structured description data are consistent, or whether the font sizes are consistent. If it is determined that the font size corresponding to the character "F" in the structured description data is not consistent with the font size corresponding to the character "i", it can be determined that the target extraction object contains the target type text.

[0078] On the basis of the above content, it is also possible to determine whether the target extraction object includes the target type text based on the display position information of the text information in the structured description data corresponding to the target extraction object. Specifically, after obtaining the structured description data corresponding to the target extraction object, the display position information corresponding to the text characters in the structured description data is obtained, and then it is determined whether the display position information corresponding to the adjacent text characters meets the preset display position rules. If the display position information corresponding to the adjacent text characters in the structured description data does not meet the preset display position rules, it indicates that the target extraction object contains the target type text.

[0079] The display position information may be position information of each text character in the structured description data corresponding to the target extraction object, such as coordinate information, etc. The preset display position rule may be a pre-set rule for determining the display position of the text character.

[0080] Specifically, the preset display position rule may include whether the vertical coordinates of the center point coordinates of the text box where the text characters are located are the same. For example, taking a line of text as a text extraction unit, assuming that the target extraction object contains "F i =LayerNorm(VP i +SP i +P i )", "F" and "i" are two adjacent text characters, assuming that the ordinate of the upper left corner of the text character "F" is a, the ordinate of the lower right corner is b, and the ordinate in the center point coordinates is (a+b) / 2, the ordinate of the upper left corner of the text character "i" is c, the ordinate of the lower right corner is d, and the ordinate in the center point coordinates is (c+d) / 2. If it is determined that the ordinates in the center point coordinates of the text boxes where the text characters "F" and "i" are respectively located are different, it can be concluded that the display position information corresponding to the text characters "F" and "i" respectively does not conform to the preset display position rules, and it is further concluded that the target extraction object contains the target type text.

[0081] In another optional implementation, whether the target extraction object contains the target type text can also be judged based on the text recognition result output by the target recognition model. Since the text features contained in the text recognition result can reflect the type of text contained in the target extraction object, the embodiment of the present disclosure can judge whether the text recognition result contains text with preset display structure features based on the acquired text recognition result. If it is determined that the text recognition result includes text with preset display structure features, it is determined that the target extraction object contains the target type text.

[0082] Based on the above judgment of whether the target extraction object contains the target type text, the embodiment of the present disclosure can also combine the above two judgment methods to determine whether the target extraction object contains the target type text, and then determine the text extraction result of the target extraction object to further improve the accuracy of the text extraction result.

[0083] In an optional implementation, the structured description data corresponding to the target extraction object can be used to obtain display attribute information and display position information corresponding to the text characters in the structured description data, and determine whether the display attribute information corresponding to different text characters is the same, and whether the display position information complies with preset display position rules, so as to determine a first judgment result.

[0084] In addition, by judging whether the text recognition result contains text with preset display structure features, a second judgment result is determined. The first judgment result and the second judgment result are respectively used to determine whether the target extraction object contains target type text.

[0085] In an application scenario, if the first judgment result is the same as the second judgment result, the text extraction result of the target extraction object can be determined based on the first judgment result or the second judgment result.

[0086] In another application scenario, if the first judgment result is different from the second judgment result, at this time, when the first judgment result is different from the second judgment result, in order to improve the accuracy of text information extraction, the text extraction result of the target extraction object can be determined based on the judgment result containing the target type text. In other words, the second text extraction result identified by the target recognition model is output as the text extraction result of the target extraction object.

[0087] After obtaining the candidate text extraction results of the target extraction object, the embodiment of the present disclosure determines the text extraction result of the target extraction object based on the candidate text extraction results by judging whether the target extraction object contains the target type text. The embodiment of the present disclosure uses the text recognition result of the target recognition model as the text extraction result for the target type text. Since the target recognition model can more accurately extract texts with preset display structure features such as algorithm formulas, the text extraction method provided by the embodiment of the present disclosure can improve the accuracy of text information extraction.

[0088] In practical applications, the target recognition model is used to perform text recognition to obtain the second text extraction result of the target extraction object. The target recognition model not only outputs the text recognition result, but also outputs the confidence level corresponding to the text recognition result for the target extraction object, which is used to characterize the credibility of the text recognition result. The higher the confidence level, the higher the credibility of the text recognition result, and the more accurately it can reflect the text information corresponding to the target extraction object. Therefore, after determining that the target extraction object contains the target type text, the embodiment of the present disclosure can also determine the credibility of the second text extraction result based on the confidence level corresponding to the second text extraction result, thereby determining whether to output the second text extraction result as the text extraction result of the target extraction object.

[0089] Specifically, it is determined whether the confidence corresponding to the second extracted text result is less than a preset confidence threshold. If not, the second text extraction result is output as the text extraction result of the target extraction object; wherein the preset confidence threshold may be a preset confidence threshold, which is used to determine whether to use the second text extraction result as the text extraction result. If the confidence corresponding to the second extracted text result is less than the preset confidence threshold, it means that the second extracted text result is less credible and cannot be used as the text extraction result of the target extraction object.

[0090] In an optional implementation, if the confidence level is less than a preset confidence threshold, the second text extraction result may not be used as the text extraction result of the target extraction object, but the first text extraction result obtained through protocol parsing may be output as the text extraction result of the target extraction object, thereby ensuring the accuracy of the text extraction result.

[0091] In addition, before determining the target extraction object of the file to be extracted, the file type of the file to be extracted can be determined based on the file application scenario to determine the method to be used for text extraction of the file to be extracted. For example, assuming that the file to be extracted is applied to a literary application scenario, it can be determined that the file to be extracted is a literary type file, and it can be determined that the file to be extracted does not contain the target type text. Assuming that the file to be extracted is applied to a mathematical application scenario, it can be determined that the file to be extracted is a mathematical type file, and it can be determined that the file to be extracted contains the target type text.

[0092] In an optional implementation, after obtaining the file to be extracted, if the file type of the file to be extracted is determined based on the file application scenario of the file to be extracted, and then it is determined that the file to be extracted does not contain the target type of text, the file to be extracted can be parsed by protocol to obtain the text extraction result of the file to be extracted. If the file type of the file to be extracted is determined based on the file application scenario of the file to be extracted, and then it is determined that the file to be extracted contains the target type of text, the text extraction method provided in the embodiment of the present disclosure is used to perform text extraction. The specific text extraction method is understood with reference to the above embodiment and will not be repeated here.

[0093] In order to facilitate understanding of the text extraction method provided by the embodiment of the present disclosure, the present embodiment will specifically introduce the text extraction method of the present disclosure using a PDF file as the file to be extracted. Figure 2 , which is a processing flow chart of a text extraction method provided in an embodiment of the present disclosure.

[0094] First, after obtaining the PDF file, determine the file type of the PDF file according to the file application scenario of the PDF file, and then determine whether the PDF file contains the target type of text based on the file type. If it is determined that the PDF file does not contain the target type of text, the protocol of the file to be extracted can be parsed to obtain the text extraction result of the file to be extracted; Figure 2 As shown in branch B.

[0095] In another application scenario, if it is determined that the PDF file contains target type text, such as Figure 2 As shown in branch A in the PDF file, after determining the target extraction object in the PDF file, the PDF parsing tool is used to perform protocol parsing on the target extraction object to obtain structured description data corresponding to the target extraction object, and based on the structured description data, a first text extraction result is obtained.

[0096] Also, perform image conversion on the PDF file to obtain the corresponding image, based on the target extraction object of the PDF file, take a screenshot of the image corresponding to the PDF file, obtain the image corresponding to the target extraction object, and input the image corresponding to the target extraction object into the target recognition model. After being processed by the target recognition model, output the text recognition result, and then obtain the second text extraction result of the target extraction object.

[0097] In an optional implementation, based on the structured description data corresponding to the target extraction object, the display attribute information corresponding to the text characters in the structured description data and the display position information are obtained to determine whether the target extraction object includes the target type text. If it is determined that the display attribute information of the target extraction object is the same, or the display position information meets the preset display position rule, it is determined that the target extraction object does not include the target type text, and the first text extraction result is output as the text extraction result of the target extraction object;

[0098] If it is determined that the display attribute information of the target extraction object is not the same, or the display position information does not conform to the preset display position rule, the target extraction object is determined to include the target type text, and on this basis, based on the confidence corresponding to the second text extraction result, it is determined whether the confidence is less than the preset confidence threshold, and if it is determined that the confidence corresponding to the second text extraction result is not less than the preset confidence threshold, the second text extraction result is output as the text extraction result of the target extraction object. If it is determined that the confidence corresponding to the second text extraction result is less than the preset confidence threshold, the first text extraction result is determined as the text extraction result of the target extraction object.

[0099] In another optional implementation, it is determined whether the target extraction object contains the target type text based on the text recognition result output by the target recognition model. Specifically, based on the acquired text recognition result, it is determined whether the text recognition result contains text with preset display structure features. If it is determined that the text recognition result includes text with preset display structure features, it is determined that the target extraction object contains the target type text. On this basis, based on the confidence corresponding to the second text extraction result, it is determined whether the confidence is less than a preset confidence threshold. If it is determined that the confidence corresponding to the second text extraction result is not less than the preset confidence threshold, the second text extraction result is output as the text extraction result of the target extraction object. If it is determined that the confidence corresponding to the second text extraction result is less than the preset confidence threshold, the first text extraction result is determined as the text extraction result of the target extraction object.

[0100] In another optional implementation, based on the structured description data corresponding to the target extraction object, the display attribute information and display position information corresponding to the text characters in the structured description data are obtained, and it is determined whether the display attribute information corresponding to different text characters is the same, and whether the display position information complies with the preset display position rules, so as to determine the first judgment result. In addition, the second judgment result is determined by determining whether the text recognition result output by the target recognition model contains text with preset display structure features. If the first judgment result is the same as the second judgment result, the text extraction result of the target extraction object can be determined based on the first judgment result or the second judgment result; if the first judgment result is different from the second judgment result, at this time, when the first judgment result is different from the second judgment result, the text extraction result of the target extraction object can be determined based on the second judgment result.

[0101] Based on the above method embodiment, the present disclosure further provides a text extraction device. Reference 3 is a structural diagram of a text extraction device provided by an embodiment of the present disclosure, and the device includes:

[0102] The first determination model 301 is used to determine the target extraction object in the file to be extracted;

[0103] A first acquisition model 302 is used to acquire candidate text extraction results of the target extraction object; wherein the candidate text extraction results include a first text extraction result and a second text extraction result, wherein the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model;

[0104] The second determination model 303 is used to output the second text extraction result as the text extraction result of the target extraction object when it is determined that the target extraction object contains a target type text; wherein the target type text includes text with preset display structure features.

[0105] In an optional implementation, the device further includes:

[0106] The third determination model is used to output the first text extraction result as the text extraction result of the target extraction object when it is determined that the target extraction object does not contain the target type text.

[0107] In an optional implementation, the device further includes:

[0108] A protocol parsing model, used to perform protocol parsing on the target extraction object to obtain structured description data corresponding to the target extraction object; wherein the structured description data includes text information in the target extraction object and display feature information of the text information, and the structured description data is used to determine the first text extraction result;

[0109] Accordingly, the device further comprises:

[0110] The fourth determination model is used to determine whether the target extraction object contains target type text according to the display feature information of the text information in the structured description data.

[0111] In an optional implementation manner, the display characteristic information includes display attribute information and / or display position information of each text character in the text information, and the display attribute information includes font type and / or font size; the fourth determination model includes:

[0112] A first determination sub-model is used to determine whether the display attribute information corresponding to different characters in the structured description data is the same;

[0113] and / or,

[0114] The second determination sub-model is used to determine whether the display position information corresponding to different characters in the structured description data conforms to a preset display position rule.

[0115] In an optional implementation, the device further includes:

[0116] Obtaining an output model, used to obtain an image corresponding to the target extraction object, and inputting the image into a trained target recognition model, and outputting a text recognition result after being processed by the target recognition model; wherein the text recognition result is used to determine the second text extraction result;

[0117] Accordingly, the device further comprises:

[0118] The fifth determination model is used to determine whether the target extraction object contains target type text according to the text features contained in the text recognition result.

[0119] In an optional implementation manner, the fifth determination model is specifically used to:

[0120] Determine whether the text recognition result contains the text with the preset display structure feature.

[0121] In an optional implementation, the second text extraction result has a corresponding confidence level, the confidence level is obtained by performing text recognition on the target extraction object using the target recognition model, and the confidence level is used to characterize the credibility of the second text extraction result;

[0122] The second determination model comprises:

[0123] A third determination sub-model is used to determine whether the confidence corresponding to the second text extraction result is less than a preset confidence threshold when determining that the target extraction object contains a target type of text;

[0124] The fourth determination sub-model is used to output the second text extraction result as the text extraction result of the target extraction object when determining that the confidence corresponding to the second text extraction result is not less than the preset confidence threshold.

[0125] In an optional implementation, the device further includes:

[0126] The sixth determination model is used to output the first text extraction result as the text extraction result of the target extraction object when determining that the confidence corresponding to the second text extraction result is less than the preset confidence threshold.

[0127] In an optional implementation manner, the file to be extracted includes a portable document format PDF file, and the first determination model is specifically used to:

[0128] The PDF file is traversed line by line to determine the target extraction object in the PDF file.

[0129] In the text extraction method device provided by the embodiment of the present disclosure, specifically, first, a target extraction object in the file to be extracted is determined, and then, candidate text extraction results of the target extraction object are obtained, wherein the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model, and if it is determined that the target extraction object contains a target type text, the second text extraction result is output as the text extraction result of the target extraction object, wherein the target type text includes text with preset display structure features.

[0130] After obtaining the candidate text extraction results of the target extraction object, the embodiment of the present disclosure determines the text extraction result of the target extraction object based on the candidate text extraction results by judging whether the target extraction object contains the target type text. The embodiment of the present disclosure uses the text recognition result of the target recognition model as the text extraction result for the target type text. Since the target recognition model can more accurately extract texts with preset display structure features such as algorithm formulas, the text extraction method provided by the embodiment of the present disclosure can improve the accuracy of text information extraction.

[0131] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure further provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the text extraction method described in the embodiments of the present disclosure.

[0132] The embodiment of the present disclosure further provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the text extraction method described in the embodiment of the present disclosure is implemented.

[0133] In addition, the present disclosure also provides a text extraction device, see Figure 4 As shown, it may include:

[0134] Processor 401, memory 402, input device 403 and output device 404. The number of processors 401 in the text extraction device can be one or more. Figure 4 In some embodiments of the present disclosure, the processor 401, the memory 402, the input device 403 and the output device 404 may be connected via a bus or other means, wherein: Figure 4 The example of connecting through bus is taken in the following.

[0135] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing of the text extraction device by running the software programs and modules stored in the memory 402. The memory 402 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc. In addition, the memory 402 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The input device 403 can be used to receive input digital or character information, and generate signal input related to user settings and function control of the text extraction device.

[0136] Specifically in this embodiment, the processor 401 will load the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 will run the applications stored in the memory 402, thereby realizing the various functions of the above-mentioned text extraction device.

[0137] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0138] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A text extraction method, characterized in that: The method comprises: Determine the target extraction object in the file to be extracted; Obtain candidate text extraction results for the target extraction object; wherein the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model; If it is determined that the target extraction object contains a target type text, the second text extraction result is output as the text extraction result of the target extraction object; wherein the target type text includes text with preset display structure features.

2. The method according to claim 1, characterized in that The method further comprises: If it is determined that the target extraction object does not contain the target type text, the first text extraction result is output as the text extraction result of the target extraction object.

3. The method according to claim 1, characterized in that Before obtaining the candidate text extraction result of the target extraction object, the method further includes: Performing protocol parsing on the target extraction object to obtain structured description data corresponding to the target extraction object; wherein the structured description data includes text information in the target extraction object and display feature information of the text information, and the structured description data is used to determine the first text extraction result; Correspondingly, if it is determined that the target extraction object contains a target type of text, before outputting the second text extraction result as the text extraction result of the target extraction object, the method further includes: According to the display characteristic information of the text information in the structured description data, it is determined whether the target extraction object contains target type text.

4. The method according to claim 3, characterized in that The display characteristic information includes display attribute information and / or display position information of each text character in the text information, and the display attribute information includes font type and / or font size; determining whether the target extraction object contains target type text according to the display characteristic information of the text information in the structured description data includes: Determining whether display attribute information corresponding to different characters in the structured description data is the same; and / or, Determine whether the display position information corresponding to different characters in the structured description data conforms to a preset display position rule.

5. The method according to claim 1, characterized in that: Before obtaining the candidate text extraction result of the target extraction object, the method further includes: Acquire an image corresponding to the target extraction object, and input the image into a trained target recognition model, and output a text recognition result after being processed by the target recognition model; wherein the text recognition result is used to determine the second text extraction result; Correspondingly, if it is determined that the target extraction object contains a target type of text, before outputting the second text extraction result as the text extraction result of the target extraction object, the method further includes: According to the text features included in the text recognition result, it is determined whether the target extraction object includes a target type of text.

6. The method according to claim 5, characterized in that The determining, based on the text features included in the text recognition result, whether the target extraction object includes a target type of text includes: Determine whether the text recognition result contains the text with the preset display structure feature.

7. The method according to claim 1, characterized in that The second text extraction result has a corresponding confidence level, the confidence level is obtained by performing text recognition on the target extraction object using the target recognition model, and the confidence level is used to characterize the credibility of the second text extraction result; If it is determined that the target extraction object contains a target type of text, outputting the second text extraction result as the text extraction result of the target extraction object includes: If it is determined that the target extraction object contains target type text, determining whether the confidence corresponding to the second text extraction result is less than a preset confidence threshold; If it is determined that the confidence corresponding to the second text extraction result is not less than the preset confidence threshold, the second text extraction result is output as the text extraction result of the target extraction object.

8. The method according to claim 7, characterized in that The method further comprises: If it is determined that the confidence corresponding to the second text extraction result is less than the preset confidence threshold, the first text extraction result is output as the text extraction result of the target extraction object.

9. The method according to claim 1, characterized in that: The file to be extracted includes a PDF file in portable document format, and determining a target extraction object in the file to be extracted includes: The PDF file is traversed line by line to determine the target extraction object in the PDF file.

10. A text extraction device, characterized in that: The device comprises: The first determination model is used to determine the target extraction object in the file to be extracted; A first acquisition model is used to acquire candidate text extraction results of the target extraction object; wherein the candidate text extraction results include a first text extraction result and a second text extraction result, the first text extraction result is obtained by performing protocol parsing on the target extraction object, and the second text extraction result is obtained by performing text recognition on the target extraction object using a target recognition model; The second determination model is used to output the second text extraction result as the text extraction result of the target extraction object when determining that the target extraction object contains a target type text; wherein the target type text includes text with preset display structure features.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 9.

12. A text extraction device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.

13. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Mathematical formula automatic identification method and device, and model training method and device

    CN110705459A

  • Method and device for OCR recognition and picture extraction based on deep learning and union set algorithm, electronic equipment and storage medium

    CN112149523A

  • Element information extraction method and device based on text recognition, equipment and medium

    CN113536771A

  • Method and device for extracting formula from document and electronic equipment

    CN113920523A

  • Character recognition method and device, electronic equipment and computer readable storage medium

    CN114612910A