Text extraction method and device, equipment and storage medium
By performing protocol parsing and image conversion on non-editable files, combined with target recognition model processing, the problem of insufficient text information extraction accuracy in the existing technology is solved, and high-accuracy extraction of complex text information is achieved.
Patent Information
- Application Number
- CN202410804966.4
- 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
When the existing technology extracts text information from non-editable files such as PDF files, especially when it contains mathematical formulas, rare characters, etc., it is not accurate enough and it is difficult to effectively extract the text information.
The target text information is obtained through protocol analysis of the file to be extracted, and the target image is obtained through image conversion. It is processed in conjunction with the target recognition model and uses multi-modal data to improve the accuracy of text information extraction.
The accuracy of text information extraction is improved, and text information containing complex display structure features can be effectively extracted.
Smart Images

Figure CN118609146A
Abstract
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] Acquire target text information corresponding to the target extraction object and a target image corresponding to the target extraction object; wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted;
[0008] Inputting the target text information and the target image into a target recognition model, and obtaining a text recognition result corresponding to the target image after being processed by the target recognition model;
[0009] The text recognition result corresponding to the target image is determined as the text extraction result of the target extraction object.
[0010] In an optional implementation manner, before inputting the target text information and the target image into a target recognition model and obtaining a text recognition result corresponding to the target image after being processed by the target recognition model, the method further includes:
[0011] Acquire display characteristic information of the target text information; wherein the display characteristic information is used to characterize display characteristics of text characters in the target text information;
[0012] Correspondingly, the target text information and the target image are input into a target recognition model, and a text recognition result of the target image is obtained after being processed by the target recognition model, including:
[0013] The target text information, the display feature information of the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained.
[0014] In an optional implementation, the display characteristic information of the target text information includes display position information and / or display attribute information of each text character in the target text information, and the display attribute information includes font type and / or font size.
[0015] In an optional implementation manner, before acquiring the target text information corresponding to the target extraction object and the target image corresponding to the target extraction object, the method further includes:
[0016] Performing protocol parsing on the file to be extracted to obtain structured description data of the file to be extracted; wherein the structured description data is used to describe the display content in the file to be extracted;
[0017] Correspondingly, the step of acquiring target text information corresponding to the target extraction object and the target image corresponding to the target extraction object includes:
[0018] The target text information corresponding to the target extraction object is obtained from the structured description data of the file to be extracted; wherein the target text information has corresponding display position information.
[0019] In an optional implementation manner, before acquiring the target text information corresponding to the target extraction object and the target image corresponding to the target extraction object, the method further includes:
[0020] Performing image conversion on the file to be extracted to obtain an image corresponding to the file to be extracted;
[0021] Correspondingly, the step of acquiring target text information corresponding to the target extraction object and the target image corresponding to the target extraction object includes:
[0022] A target image corresponding to the target extraction object is intercepted from the image corresponding to the file to be extracted; wherein the target image has corresponding display position information.
[0023] In an optional implementation, the target text information corresponding to the target extraction object and the target image corresponding to the target extraction object have the same display position information, and the display position information is used to represent the display position in the file to be extracted.
[0024] In an optional implementation manner, before inputting the target text information and the target image into a target recognition model and obtaining a text recognition result corresponding to the target image after being processed by the target recognition model, the method further includes:
[0025] Determining whether the target extraction object contains a target type text; wherein the target type text includes text having a preset display structure feature;
[0026] Correspondingly, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained, including:
[0027] If it is determined that the target extraction object contains the target type text, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained.
[0028] 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:
[0029] The PDF file is traversed line by line to determine the target extraction object in the PDF file.
[0030] In a second aspect, the present disclosure further provides a text extraction device, the device comprising:
[0031] A first determination module is used to determine a target extraction object in the file to be extracted;
[0032] A first acquisition module is used to acquire target text information corresponding to the target extraction object and a target image corresponding to the target extraction object; wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted;
[0033] A model processing module, used for inputting the target text information and the target image into a target recognition model, and obtaining a text recognition result corresponding to the target image after being processed by the target recognition model;
[0034] The second determination module is used to determine the text recognition result corresponding to the target image as the text extraction result of the target extraction object.
[0035] 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.
[0036] 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.
[0037] 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.
[0038] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:
[0039] The disclosed embodiment provides a text extraction method. Specifically, first, a target extraction object in a file to be extracted is determined, and target text information corresponding to the target extraction object and a target image corresponding to the target extraction object are obtained, wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted. Then, the target text information and the target image are input into a target recognition model. After being processed by the target recognition model, a text recognition result corresponding to the target image is obtained, and then, the text recognition result corresponding to the target image is determined as the text extraction result of the target extraction object.
[0040] The disclosed embodiment inputs the target text information and target image corresponding to the target extraction object into the target recognition model, and obtains the text extraction result of the target extraction object after being processed by the target recognition model. It can be seen that the disclosed embodiment uses the target text information and target image as multimodal data of the target recognition model, which improves the accuracy of text information extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] 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.
[0042] 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.
[0043] Figure 1 A flowchart of a text extraction method provided for some embodiments of the present disclosure;
[0044] Figure 2 A processing flow chart of a text extraction method provided in some embodiments of the present disclosure;
[0045] Figure 3 A schematic diagram of the structure of a text extraction device provided in some embodiments of the present disclosure;
[0046] Figure 4 A schematic diagram of the structure of a text extraction device provided in some embodiments of the present disclosure. DETAILED DESCRIPTION
[0047] 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.
[0048] 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.
[0049] 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.
[0050] 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.
[0051] 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.
[0052] To this end, the present disclosure provides a text extraction method. Specifically, first, a target extraction object in a file to be extracted is determined, and target text information corresponding to the target extraction object and a target image corresponding to the target extraction object are obtained, wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted. Then, the target text information and the target image are input into a target recognition model. After being processed by the target recognition model, a text recognition result corresponding to the target image is obtained, and then, the text recognition result corresponding to the target image is determined as the text extraction result of the target extraction object.
[0053] The disclosed embodiment inputs the target text information and target image corresponding to the target extraction object into the target recognition model, and obtains the text extraction result of the target extraction object after being processed by the target recognition model. It can be seen that the disclosed embodiment uses the target text information and target image as multimodal data of the target recognition model, which improves the accuracy of text information extraction.
[0054] To this end, 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:
[0055] S101: Determine the target extraction object in the file to be extracted.
[0056] 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.
[0057] 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.
[0058] 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.
[0059] S102: Acquire target text information corresponding to the target extraction object and a target image corresponding to the target extraction object.
[0060] The target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted.
[0061] In an optional implementation, after determining the target extraction object in the file to be extracted, the target extraction object in the file to be extracted can be subjected to protocol parsing to obtain structured description data of the file to be extracted, and then, based on the text extraction unit of the file to be extracted, the text characters corresponding to the text extraction unit are extracted from the structured description data, and then the text characters are concatenated to form the target text information corresponding to the target extraction object.
[0062] 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.
[0063] In addition, the structured description data corresponding to the target extraction object is used to describe the display content in the target extraction object of the file to be extracted. Specifically, the structured description data includes text information in the target extraction object and display feature information of the text information.
[0064] In the disclosed embodiment, the target text information is determined based on the text extraction unit of the file to be extracted. For example, taking a line of text as a text extraction unit as an example, the target text information is the text information corresponding to the above text extraction unit. In the disclosed embodiment, the text information and the image with the same display position information are a pair of data sets, and the target text information and the target image are a pair of data sets corresponding to the target extraction object. The target image and the target text information corresponding to the target extraction object have the same display position information, and the display position can be used to characterize the display position of the target text information corresponding to the target extraction object and the corresponding target image in the file to be extracted. Among them, the display position information of the target text information can be obtained based on the structured description data corresponding to the target extraction object. For example, taking a line of text as a text extraction unit as an example, the display position information corresponding to the text extraction unit is obtained from the structured description data corresponding to the target extraction object, that is, the display position information corresponding to the line of text is obtained from the structured description data corresponding to the target extraction object, specifically the line coordinates.
[0065] In an optional implementation, after determining the target extraction object in the file to be extracted, the file to be extracted can be converted into an image to obtain an image corresponding to the file to be extracted, and based on the text extraction object of the file to be extracted, the image corresponding to the file to be extracted can be cropped into a word strip image, and then based on the display position information of the target text information corresponding to the target extraction object, the word strip image with the same position information can be used as the target image corresponding to the target extraction object. For example, taking a line of text as a text extraction unit as an example, the image corresponding to the file to be extracted is cropped into multiple word strip images, each word strip image has corresponding display position information, that is, the display position information of the line where each word strip image is located, and since the display position information corresponding to the target text information is the same as that of the target image, the font image with the same display position information as the target text information in the multiple word strip images is used as the target image.
[0066] In another optional implementation, after obtaining the image corresponding to the file to be extracted, based on the display position information of the target text information, the display position information of the target image corresponding to the target extraction object is determined in the image corresponding to the file to be extracted, and then the target image corresponding to the target extraction object is intercepted from the image corresponding to the file to be extracted.
[0067] S103: Input the target text information and the target image into a target recognition model, and obtain a text recognition result corresponding to the target image after being processed by the target recognition model.
[0068] The target recognition model in the embodiment of the present disclosure is obtained through sample training, and the specific model training process is not repeated in the embodiment of the present disclosure.
[0069] In actual applications, since the structured description data corresponding to the target extraction object also includes display feature information of the target text information, the display feature information can be used to characterize the display features of the text characters in the target text information. Therefore, in order to improve the recognition accuracy of the target recognition model, the display feature information of the target text information can also be input into the target recognition model in the embodiment of the present disclosure.
[0070] In an optional implementation, before inputting the target text information and the target image into the target recognition model, the display feature information of the target text information is obtained from the structured description data corresponding to the target extraction object, and then the target text information, the display feature information of the target text information, and the target image are input into the target recognition model. After being processed by the target recognition model, the text recognition result of the target image is obtained.
[0071] The display feature information of the target text information may include at least one of display attribute information and display position information of each text character in the target text information in the target extraction object. The display attribute information is used to characterize the display attributes of the target text information in the target extraction object. The display attribute information may include the font size, font, and font color of the text characters; the display position information is used to characterize the display position of the target text information in the target extraction object. For example, the display position information may include the coordinate information of each text character in the corresponding target text information in the target extraction object on the current text page.
[0072] The display feature information of the target text information is obtained from the structured description data corresponding to the target extraction object. Based on the structured description data, at least one of the display attribute information and the display position information of each text character in the target text information can be extracted from the structured description data.
[0073] In the text extraction method provided by the embodiment of the present disclosure, specifically, first, a target extraction object in a file to be extracted is determined, and target text information corresponding to the target extraction object and a target image corresponding to the target extraction object are obtained, wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted, and then, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained, and then, the text recognition result corresponding to the target image is determined as the text extraction result of the target extraction object.
[0074] The disclosed embodiment inputs the target text information and target image corresponding to the target extraction object into the target recognition model, and obtains the text extraction result of the target extraction object after being processed by the target recognition model. It can be seen that the disclosed embodiment uses the target text information and target image as multimodal data of the target recognition model, which improves the accuracy of text information extraction.
[0075] In actual applications, since the structured description data corresponding to the target extraction object contains display feature information of the target text information, the display feature information can reflect whether the target text information belongs to a text with preset display structure features. Therefore, based on the display feature information of the text information in the structured description data corresponding to the target extraction object, it is possible to judge whether the target extraction object includes the target type text.
[0076] The target type text includes text with preset display structure features. The preset display structure features may include any one or more preset display structure features. Specifically, the preset display structure features 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.
[0077] 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 of the target text information in the structured description data is obtained, 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 text characters in the structured description data is not the same, it indicates that the target extraction object contains the target type text.
[0078] 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 text 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.
[0079] 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 text characters in the target text information 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.
[0080] 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 target 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 target text information 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.
[0081] The display position information may be position information of each text character in the target text information 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 text characters.
[0082] 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 type text is included in the target extraction object.
[0083] In an optional implementation, based on the above embodiment, if it is determined that the target extraction object contains target type text, the text recognition result obtained after processing by the target recognition model is used as the text recognition result corresponding to the target image.
[0084] In another optional implementation, if it is determined that the target extraction object does not contain the target type text, the file to be extracted is subjected to protocol parsing, and the obtained target text information is used as the text recognition result corresponding to the target extraction object.
[0085] In order to facilitate understanding of the above embodiments, the present embodiment will take a PDF file as the file to be extracted to specifically introduce the text extraction method provided by the present embodiment. Figure 2 , which is a processing flow chart of a text extraction method provided in an embodiment of the present disclosure.
[0086] In an optional implementation, after obtaining the PDF file and determining the target extraction object of the PDF file, a 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. Based on the structured description data, text characters of the target extraction object are obtained from the structured description data, and then the text characters are spliced into target text information corresponding to the target extraction object.
[0087] In addition, image conversion is performed on the file to be extracted to obtain an image corresponding to the file to be extracted, and then based on the target extraction object, the image corresponding to the file to be extracted is cropped into a note image, and based on the display position information of the target image pair being the same as the display position information of the target text information corresponding to the target extraction object, a note image with the same display position information as the target text information is screened out from the note image as the target image of the target extraction object.
[0088] The text extraction method provided by the embodiment of the present disclosure improves the accuracy of text information extraction by using target text information and target image as multimodal data of the target recognition model.
[0089] 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:
[0090] The first determination module 301 is used to determine the target extraction object in the file to be extracted;
[0091] The first acquisition module 302 is used to acquire target text information corresponding to the target extraction object and a target image corresponding to the target extraction object; wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted;
[0092] The model processing module 303 is used to input the target text information and the target image into the target recognition model, and obtain the text recognition result corresponding to the target image after being processed by the target recognition model;
[0093] The second determination module 304 is configured to determine the text recognition result corresponding to the target image as the text extraction result of the target extraction object.
[0094] In an optional implementation, the device further includes:
[0095] A second acquisition module is used to acquire display feature information of the target text information; wherein the display feature information is used to characterize display features of text characters in the target text information;
[0096] Accordingly, the model processing module is specifically used for:
[0097] The target text information, the display feature information of the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained.
[0098] In an optional implementation, the display characteristic information of the target text information includes display position information and / or display attribute information of each text character in the target text information, and the display attribute information includes font type and / or font size.
[0099] In an optional implementation, the device further includes:
[0100] A protocol parsing module, used for performing protocol parsing on the file to be extracted to obtain structured description data of the file to be extracted; wherein the structured description data is used to describe the display content in the file to be extracted;
[0101] Accordingly, the first acquisition module is specifically used for:
[0102] The target text information corresponding to the target extraction object is obtained from the structured description data of the file to be extracted; wherein the target text information has corresponding display position information.
[0103] In an optional implementation, the device further includes:
[0104] An image conversion module, used for performing image conversion on the file to be extracted to obtain an image corresponding to the file to be extracted;
[0105] Accordingly, the first acquisition module is specifically used for:
[0106] A target image corresponding to the target extraction object is intercepted from the image corresponding to the file to be extracted; wherein the target image has corresponding display position information.
[0107] In an optional implementation, the target text information corresponding to the target extraction object and the target image corresponding to the target extraction object have the same display position information, and the display position information is used to represent the display position in the file to be extracted.
[0108] In an optional implementation, the device further includes:
[0109] A third determination module is used to determine whether the target extraction object contains a target type text; wherein the target type text includes a text with a preset display structure feature;
[0110] Accordingly, the model processing module is specifically used for:
[0111] When it is determined that the target extraction object contains the target type text, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained.
[0112] In an optional implementation manner, the file to be extracted includes a portable document format PDF file, and the first determining module is specifically configured to:
[0113] The PDF file is traversed line by line to determine the target extraction object in the PDF file.
[0114] In the text extraction device provided by the embodiment of the present disclosure, first, a target extraction object in a file to be extracted is determined, and target text information corresponding to the target extraction object and a target image corresponding to the target extraction object are obtained, wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted. Then, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained, and then, the text recognition result corresponding to the target image is determined as the text extraction result of the target extraction object.
[0115] The disclosed embodiment inputs the target text information and target image corresponding to the target extraction object into the target recognition model, and obtains the text extraction result of the target extraction object after being processed by the target recognition model. It can be seen that the disclosed embodiment uses the target text information and target image as multimodal data of the target recognition model, which improves the accuracy of text information extraction.
[0116] 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.
[0117] 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.
[0118] In addition, the present disclosure also provides a text extraction device, see Figure 4 As shown, it may include:
[0119] 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.
[0120] 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.
[0121] 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.
[0122] 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.
[0123] 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; Acquire target text information corresponding to the target extraction object and a target image corresponding to the target extraction object; wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted; Inputting the target text information and the target image into a target recognition model, and obtaining a text recognition result corresponding to the target image after being processed by the target recognition model; The text recognition result corresponding to the target image is determined as the text extraction result of the target extraction object.
2. The method according to claim 1, characterized in that The method further includes: inputting the target text information and the target image into a target recognition model, and obtaining a text recognition result corresponding to the target image after the target recognition model processes the target text information and the target image. Acquire display characteristic information of the target text information; wherein the display characteristic information is used to characterize display characteristics of text characters in the target text information; Correspondingly, the target text information and the target image are input into a target recognition model, and a text recognition result of the target image is obtained after being processed by the target recognition model, including: The target text information, the display feature information of the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained.
3. The method according to claim 2, characterized in that The display characteristic information of the target text information includes display position information and / or display attribute information of each text character in the target text information, and the display attribute information includes font type and / or font size.
4. The method according to claim 1, characterized in that: Before acquiring the target text information corresponding to the target extraction object and the target image corresponding to the target extraction object, the method further includes: Performing protocol parsing on the file to be extracted to obtain structured description data of the file to be extracted; wherein the structured description data is used to describe the display content in the file to be extracted; Correspondingly, the step of acquiring target text information corresponding to the target extraction object and the target image corresponding to the target extraction object includes: The target text information corresponding to the target extraction object is obtained from the structured description data of the file to be extracted; wherein the target text information has corresponding display position information.
5. The method according to claim 1, characterized in that: Before acquiring the target text information corresponding to the target extraction object and the target image corresponding to the target extraction object, the method further includes: Performing image conversion on the file to be extracted to obtain an image corresponding to the file to be extracted; Correspondingly, the step of acquiring target text information corresponding to the target extraction object and the target image corresponding to the target extraction object includes: A target image corresponding to the target extraction object is intercepted from the image corresponding to the file to be extracted; wherein the target image has corresponding display position information.
6. The method according to claim 1, characterized in that The target text information corresponding to the target extraction object and the target image corresponding to the target extraction object have the same display position information, and the display position information is used to represent the display position in the file to be extracted.
7. The method according to claim 1, characterized in that The method further includes: inputting the target text information and the target image into a target recognition model, and obtaining a text recognition result corresponding to the target image after the target recognition model processes the target text information and the target image. Determining whether the target extraction object contains a target type text; wherein the target type text includes text having a preset display structure feature; Correspondingly, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained, including: If it is determined that the target extraction object contains the target type text, the target text information and the target image are input into a target recognition model, and after being processed by the target recognition model, a text recognition result corresponding to the target image is obtained.
8. 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.
9. A text extraction device, characterized in that: The device comprises: A first determination module is used to determine a target extraction object in the file to be extracted; A first acquisition module is used to acquire target text information corresponding to the target extraction object and a target image corresponding to the target extraction object; wherein the target text information is obtained by performing protocol parsing on the file to be extracted, and the target image is obtained by performing image conversion on the file to be extracted; A model processing module, used for inputting the target text information and the target image into a target recognition model, and obtaining a text recognition result corresponding to the target image after being processed by the target recognition model; The second determination module is used to determine the text recognition result corresponding to the target image as the text extraction result of the target extraction object.
10. 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 8.
11. 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 8 is implemented.
12. 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 8 is implemented.
Citation Information
Patent Citations
File information extraction method and electronic equipment
CN112906774A
Document layout recognition method and device, electronic equipment and storage medium
CN113901954A
Table information extraction method and device, electronic equipment and readable storage medium
CN116343248A
PDF (Portable Document Format) document identification method based on open source Padd framework
CN116740723A
Medical text recognition method and device, computer equipment and storage medium
CN116912847A
