Text extraction method and device

By identifying and extracting the location information of text blocks, the out-of-order problem caused by format in text extraction is solved, and the accurate extraction of document content is achieved, which is suitable for a variety of document formats.

CN118982839APending Publication Date: 2024-11-19BEIJING KINGSOFT DIGITAL ENTERTAINMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411103257.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-08-11
Filing Date
2024-08-12
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

In the process of extracting text content, especially when processing documents containing text blocks and relative coordinate relationships, the problem of text disorder is prone to occur, and it is difficult to accurately extract content such as chunking and columns.

Method used

By obtaining the document to be identified, identifying the location information of each text block, and extracting the target subtext corresponding to each text block based on this information, and finally splicing it into the correct target text, solving the text lines and lines caused by special formats. The problem of disorderly order.

Benefits of technology

It realizes accurate extraction of document content, overcomes the problem of out-of-order text, ensures the clearness and accuracy of the extraction results, and is suitable for various document formats, including PDF, DOC, DOCX, etc.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118982839A_ABST
    Figure CN118982839A_ABST
Patent Text Reader

Abstract

The invention provides a text extraction method and device.The text extraction method comprises the steps that a to-be-recognized document is obtained, and the to-be-recognized document comprises at least one text block; identifying position information of each text block in the to-be-identified document; according to the position information of each text block, extracting a target sub-text corresponding to each text block from the to-be-recognized document; and obtaining a target text corresponding to the to-be-identified document according to the target sub-text corresponding to each text block and the position information of each text block. Through the method provided by the invention, the problem of disorder between lines of the text caused by special formats and the like in the text extraction process can be effectively solved, and the content in the document can be extracted more clearly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims the priority of the Chinese patent application filed with the China Patent Office on August 11, 2023, with application number 202311015376.5 and invention name “Text Extraction Method and Device”. Technical Field

[0002] The present application relates to the field of computer technology, and more particularly to a text extraction method, a text extraction device, a computing device, and a computer-readable storage medium. Background Art

[0003] Artificial intelligence (AI) refers to the ability of engineered (i.e. designed and manufactured) systems to perceive the environment and to acquire, process, apply and represent knowledge. The development status of key technologies in the field of artificial intelligence, including machine learning, knowledge graphs, natural language processing, computer vision, human-computer interaction, biometrics, virtual reality / augmented reality and other key technologies. In recent years, the most impressive progress in the field of machine learning has appeared in the subfield of deep learning (also known as deep neural network learning). Deep learning refers to the method of creating rich hierarchical representations by training neural networks with many hidden layers. Deep learning uses simple computing units (i.e. "neurons") to form a multi-layer network. Each unit combines a set of input values ​​to produce an output value and passes the value to other neurons downstream. The neural networks in deep learning are composed of several hidden layers. Natural language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can enable effective communication between people and computers in natural language, extracts text content, and is an important branch in the field of natural language processing.

[0004] In the current text content extraction process, the text content in the document is usually extracted directly, and the document is classified, screened, and processed based on the extraction results. However, it is more difficult to extract text content that includes a combination of text blocks and relative coordinate relationships in the document. For example, if the document includes blocks, columns, and other content, disorder will occur during the recognition process. Therefore, a new text content extraction method is urgently needed to solve the problem of text disorder when extracting documents containing text block content. Summary of the invention

[0005] In view of this, the embodiment of the present application provides a text extraction method to solve the technical defects existing in the prior art. The embodiment of the present application also provides a text extraction device, a computing device, and a computer-readable storage medium.

[0006] According to a first aspect of an embodiment of the present application, a text extraction method is provided, comprising:

[0007] Acquire a document to be identified, wherein the document to be identified includes at least one text block;

[0008] Identify the position information of each text block in the document to be identified;

[0009] Extracting target subtext corresponding to each text block from the document to be recognized according to the position information of each text block;

[0010] According to the target sub-text corresponding to each text block and the position information of each text block, the target text corresponding to the document to be recognized is obtained.

[0011] According to a second aspect of an embodiment of the present application, a text extraction device is provided, comprising:

[0012] An acquisition module is configured to acquire a document to be recognized, wherein the document to be recognized includes at least one text block;

[0013] A recognition module, configured to recognize position information of each text block in the document to be recognized;

[0014] An extraction module is configured to extract a target subtext corresponding to each text block from the document to be recognized according to the position information of each text block;

[0015] The text acquisition module is configured to obtain the target text corresponding to the document to be recognized according to the target sub-text corresponding to each text block and the position information of each text block.

[0016] According to a third aspect of an embodiment of the present application, a computing device is provided, including:

[0017] Memory and processor;

[0018] The memory is used to store computer-executable instructions, and the processor implements the steps of the text extraction method when executing the computer-executable instructions.

[0019] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the computer instructions are executed by a processor, the steps of the text extraction method are implemented.

[0020] According to a fifth aspect of an embodiment of the present application, a chip is provided, which stores a computer program, and the computer program implements the steps of the text extraction method when executed by the chip.

[0021] The text extraction method provided by the present application is to obtain a document to be identified, wherein the document to be identified includes at least one text block; identify the position information of each text block in the document to be identified; extract the target subtext corresponding to each text block from the document to be identified according to the position information of each text block; obtain the target text corresponding to the document to be identified according to the target subtext corresponding to each text block and the position information of each text block. Through the method provided by the present application, the document to be identified is first divided into blocks for content, and the document to be identified is divided into multiple text blocks, and then the target subtext corresponding to each text block is identified respectively, and then each target subtext is generated into the final target text according to the position information of the text block, which can effectively solve the problem of disorder between text lines due to special formats and other reasons in the text extraction process, and extract the content in the document more clearly and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a schematic diagram of a text format in an existing document provided by an embodiment of the present application;

[0023] Figure 2 It is a structural diagram of a text extraction system provided by an embodiment of the present application;

[0024] Figure 3 is a flowchart of a text extraction method provided by an embodiment of the present application;

[0025] Figure 4 is a schematic diagram of the layout of a document to be identified provided by an embodiment of the present application;

[0026] Figure 5 It is a processing flow chart of a text extraction method applied to a resume text scenario provided by an embodiment of the present application;

[0027] Figure 6 This is a schematic diagram of the interface of a resume document provided in an embodiment of the present application;

[0028] Figure 7 is a structural schematic diagram of a text extraction device provided in one embodiment of the present application;

[0029] Figure 8 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0030] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0031] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0032] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.

[0033] First, the terms involved in one or more embodiments of the present invention are explained.

[0034] Optical Character Recognition (OCR): The process of detecting dark and light patterns to determine their shape, and then using character recognition methods to translate the shape into computer text; that is, the technology of converting text in an image into text format for further editing and processing.

[0035] JACOB: A middleware used to call COM components and Win32 libraries in applications written in Java. COM is the abbreviation of Component Object Model. COM is a specification about how to build components and how to build applications through components, and it also explains how to dynamically update components alternately. COM components are components written in COM, so they can be called by applications written in different programming languages.

[0036] Imagemgick: An image processing software that can edit and display most of the most popular image formats including JPEG, TIFF, PNM, PNG, GIF and Photo CS.

[0037] Tabula: A tool for identifying text blocks in portable documents (PDF, Portable Document Format) and obtaining the coordinates of text blocks.

[0038] Object Detection Model: A model used to find targets of interest in an image, such as objects of interest, and determine the category of the target of interest and the location information of the target of interest in the image.

[0039] In actual applications, many documents have columns, tables and other formats, such as in thesis documents and resume documents. For such documents, during the text extraction process, it is often the case that the content that should be separated into two columns is extracted into one line. See Figure 1 , Figure 1 A schematic diagram of a text format in an existing document is shown. In the process of extracting the text content of the document, the content to be extracted is "Addbcdefgdfdhig123456798 / *212", but due to the columns in the document format, it is often extracted as "Add1234bcde5679fgdf8 / *2dhig12", which leads to errors in text extraction.

[0040] Based on this, in the present application, a text extraction method is provided. The present application also relates to a text extraction device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.

[0041] See also Figure 2 , Figure 2 1 is a schematic diagram of the structure of a text extraction system provided in an embodiment of the present application. The execution subject of the text extraction system is a terminal, which can be any electronic product that can interact with a user, such as a personal computer (PC), a mobile terminal, a PPC (Pocket PC), a tablet computer, a server, etc. The server can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center, which is not limited in the present embodiment of the present application.

[0042] After the terminal receives the document to be recognized, it identifies the multiple text blocks included in the document, then performs text recognition on each text block separately, extracts the text content in each text block, and then splices the target sub-texts recognized in each text block, and finally obtains the target text extracted from the document to be recognized.

[0043] The following is combined with Figure 3 The text extraction method provided in this application is further explained in detail. Figure 3 , Figure 3 A flowchart of a text extraction method provided by an embodiment of the present application is shown, which specifically includes the following steps:

[0044] Step 302: Obtain a document to be recognized, wherein the document to be recognized includes at least one text block.

[0045] The document to be identified specifically refers to the document that needs to be identified and extracted in this application. Usually, the document to be identified usually exists in the form of a separate file, such as a paper, resume, etc. The document to be identified usually includes at least one text block. The text block specifically refers to the text format in the document to be identified. For example, in a resume document, the text block can be a personal profile, education experience, work experience, work skills, etc.; in a paper document, it usually involves formats such as tables and columns.

[0046] See also Figure 4 , Figure 4 This is a layout diagram of a document to be identified provided by an embodiment of the present application. The document to be identified takes a resume document RD1 as an example. In the resume document RD1, there are multiple text blocks, namely "text block TB1", "text block TB2", "text block TB3", "text block TB4"... and so on.

[0047] There are many ways for the text extraction system provided in the present application to obtain the document to be identified. For example, the user can use the system to download the document to be identified from a specific website, thereby obtaining the document to be identified; the user can also save the document to be identified in a specific location of the terminal, and then read the document to be identified from the specific location through the system; the user can also directly upload the document to be identified to the text extraction system.

[0048] In practical applications, the formats of each document that needs to be recognized and extracted for text are different, such as PDF (Portable DOCument Format), DOC, DOCX, WPS, TXT and other formats. In this application, preferably, documents in PDF format are used for processing, because documents in PDF format are more standardized and have more accurate coordinate information in the document. The coordinates of each object in the PDF document can be accurately obtained, which is convenient for further processing later.

[0049] Based on this, obtain the document to be identified, including:

[0050] Acquire an initial document to be identified, and determine an initial document format of the initial document to be identified;

[0051] Determining whether the initial document format is a preset document format;

[0052] If yes, determining that the initial document to be identified is the document to be identified;

[0053] If not, the initial document to be recognized is converted into a document to be recognized according to a format conversion tool.

[0054] Among them, the initial document to be identified specifically refers to the initial document obtained by the text extraction system. Taking the user uploading a document to the text extraction system as an example, the user can upload documents in DOCX format, PDF format, TXT format, etc. The initial document uploaded by the user is the initial document to be identified. After obtaining the initial document to be identified uploaded by the user, the initial document format of the initial document to be identified can be determined. For example, if the user uploads document 1 in DOC format, then the initial document to be identified is document 1, and the initial document format of the document is DOC; for another example, if the system obtains document 2 in PDF format, then the initial document to be identified is document 2, and the initial document format of the document is PDF.

[0055] After determining the initial document format of the initial document to be identified, it is necessary to further determine whether the initial document format matches the preset document format, that is, to determine whether the initial document format is the preset document format. In this application, it is preferred to perform subsequent text recognition and extraction processing on documents in PDF format. The preset document format is PDF format, which is more standardized and has more accurate coordinate information in the document. The coordinates of each object in the PDF document can be accurately obtained, which is convenient for further processing.

[0056] If the initial document to be identified uploaded by the user is in PDF format and the preset document format is PDF, it means that the initial document format matches the preset document format, and the initial document to be identified can be directly used subsequently, and the initial document to be identified is determined to be the document to be identified.

[0057] If the initial document to be identified uploaded by the user is in DOC format and the preset document format is PDF format, it means that the initial document format does not match the preset document format, and the initial document to be identified needs to be format converted to the preset document format. For example, if the initial document format is DOC format, JACOB can be used to convert the initial document to be identified in DOC format into a document to be identified in PDF format.

[0058] It should be noted that converting the initial document to be recognized into the document to be recognized only requires converting the format of the document, and the content in the document will not be changed.

[0059] In a specific implementation provided in the present application, taking the preset document format as PDF format as an example, the user uploads a document 1 in PDF format, and the text extraction system confirms that the document format of document 1 is the same as the preset document format, then the document 1 can be directly determined as the document to be identified.

[0060] In another specific implementation provided by the present application, still taking the preset document format as PDF format as an example, the user uploads a document 2 in DOCX format, and the text extraction system determines that the document format of document 2 is different from the preset document format, then it is necessary to perform text conversion on the document 2 in DOCX format, and convert the document 2 in DOCX format into a document 2 in PDF format.

[0061] Step 304: Identify the position information of each text block in the document to be identified.

[0062] After obtaining the document to be recognized, it is first necessary to recognize the information of each text box in the document to be recognized. Specifically, it is necessary to recognize the position information of each text box in the document to be recognized.

[0063] Specifically, determining the position information of each text box may include determining the coordinate information of a key point of the text box and the length and width of the text box. For example, if the key point of a text box is determined to be the upper left corner, the coordinates of the key point are (x, y), the length of the text box is a, and the width is b, then the position information of the text box can be recorded as (x, y, a, b).

[0064] In practical applications, obtaining the position information of each text block in the document to be identified requires performing document recognition processing on the document to be identified. Currently, directly identifying the document consumes a large amount of computing resources and may result in inaccurate text block recognition. In order to improve the recognition accuracy of the position information of each text block in the document to be identified, it is preferred to process the image information corresponding to the document to be identified. The technology for image processing is relatively mature and has a higher accuracy rate.

[0065] Specifically, identifying the position information of each text block in the document to be identified includes:

[0066] Converting the document to be identified into a picture to be identified;

[0067] At least one text block in the to-be-identified picture and position information of each text block are identified.

[0068] In practical applications, it is preferred to first convert the document to be identified, and convert the document to be identified into the corresponding picture to be identified. Specifically, the document to be identified can be input into the Imagemgick tool. Imagemgick is an image processing software that can edit and display most image formats such as JPEG, PNG, GIF, TIFF, etc., and can be used to convert files in non-image formats into image formats. The Imagemgick tool can convert the document to be identified into the corresponding picture to be identified. Furthermore, if the document to be identified includes multiple document pages, the picture to be identified corresponding to the number of document pages can be obtained. For example, the document to be identified has a total of 5 pages. After the document conversion, the picture to be identified corresponding to each document page to be identified can be obtained respectively, that is, 5 pictures to be identified are obtained.

[0069] After converting the document to be identified into the image to be identified, each text block in the image to be identified and the position information corresponding to each text block can be identified. Specifically, identifying at least one text block in the image to be identified and the position information of each text block includes:

[0070] Inputting the image to be identified into the target detection model;

[0071] At least one text block and position information of each text block in the image to be identified output by the target detection model are obtained.

[0072] Among them, the target detection model specifically refers to a deep learning model that identifies the target object in the image. For example, for the task of detecting pedestrians, the picture is input into the target detection model, and the target detection model can mark the pedestrians in the picture; for the text block detection task, the picture to be identified is input into the target detection model, and the target detection model can mark the text blocks in the picture to be identified, and can also output the location information of each text block.

[0073] The target detection model is generated after pre-training, and the target detection model is trained through the following steps:

[0074] Acquire a sample image to be identified, wherein the sample image to be identified includes position information of a marked text block;

[0075] Inputting the sample image to be identified into the target detection model to obtain the predicted text block position information output by the target monitoring model;

[0076] Calculating a model loss value according to the annotated text block position information and the predicted text block position information;

[0077] The model parameters of the target detection model are adjusted according to the model loss value, and the training is continued until the training stop condition is reached.

[0078] The sample to-be-recognized image specifically refers to a training sample of the target detection model, and the sample to-be-recognized image is annotated with text blocks and the position information of the annotated text blocks in each text block. The annotated text block position information is used to determine which are the text blocks in the sample to-be-recognized image.

[0079] The sample image to be identified is input into the target detection model for processing. The target detection model is used to detect whether the sample image to be identified contains a text block. After the text block is detected, the predicted text block position information corresponding to each text block is output. At this time, the target detection model is an untrained model. There will be a deviation between the predicted predicted text block position information and the actual annotated text block position information. The model parameters of the target detection model need to be adjusted. Specifically, the loss value is calculated based on the predicted text block position information and the annotated text block position information. The loss function for calculating the loss value can be a 0-1 loss function, an absolute value loss function, a square loss function, a cross entropy loss function, etc. in actual applications. In this application, the choice of loss function is not limited, and the actual application shall prevail. Here, the cross entropy loss function is taken as an example for explanation, see the following formula 1:

[0080]

[0081] Among them, C represents the model loss value Loss, x represents the sample image to be recognized, y represents the position information of the labeled text block, a represents the predicted text block position information, and n represents the total number of samples. According to the Loss value, the model parameters of the target detection model are adjusted by back propagation. Specifically, the learning rate parameter, Batch_size parameter, etc. in the target detection model can be adjusted, and the target detection model is continued to be trained with the next batch of sample data until the model training stop condition is reached.

[0082] Specifically, the model training stopping conditions include that the model loss value is less than a preset threshold and / or the training rounds reach a preset round.

[0083] In a specific implementation provided in the present application, taking the training stop condition of the model loss value being less than a preset threshold as an example, the preset threshold is 0.3. When the model loss value is less than 0.3, the target detection model training is considered to be completed.

[0084] In another specific implementation provided in the present application, taking the preset number of training rounds as the training stop condition as an example, the preset number of training rounds is 20 rounds. When the number of training rounds of sample data reaches 20 rounds, the target detection model training is considered to be completed.

[0085] In another specific implementation provided in the present application, two training stop conditions, a preset threshold and a preset training round, are set, and the loss value and the training round are monitored at the same time. When either the model loss value or the training round meets the training stop condition, the target detection model training is considered to be completed.

[0086] Step 306: extracting the target subtext corresponding to each text block from the document to be recognized according to the position information of each text block.

[0087] After each text block and the position information corresponding to each text block are identified from the document to be identified, the target subtext corresponding to each text block can be extracted from the document to be identified according to the position information of each text block.

[0088] The target sub-text specifically refers to the text information corresponding to each text block. For example, there are three text blocks in a document to be identified, namely text block 1, text block 2 and text block 3. The target sub-text 1 corresponding to text block 1 is extracted, the target sub-text 2 corresponding to text block 2 is extracted, and the target sub-text 3 corresponding to text block 3 is extracted respectively.

[0089] Specifically, the location information of the text block includes coordinate information and area information of the text block;

[0090] Extracting target subtext corresponding to each text block from the document to be recognized according to the position information of each text block includes:

[0091] Determine a target text block, and determine target coordinate information and target area information corresponding to the target text block;

[0092] The target sub-text corresponding to the target text block is extracted from the document to be recognized according to the target coordinate information and the target area information.

[0093] In practical applications, the location information of a text block usually includes the coordinate information and area information of the text block. Taking the illustration in the above embodiment as an example, the location information of a text block is (x, y, a, b), where (x, y) is the coordinate information of the text block, and a and b are the area information of the text block.

[0094] There are usually multiple text blocks in the document to be recognized. The target text block specifically refers to the text block that needs to be processed. Furthermore, the text blocks in the document to be recognized are processed separately. During the processing, the text blocks can be recognized one by one, or multiple text blocks can be processed in parallel. In this application, the processing order of the text blocks is not limited.

[0095] Here, the processing of one of the text blocks is taken as an example for explanation, and the processed text block is called the target text block. After the target text block is determined, the target coordinate information and target area information corresponding to the target text block can be determined.

[0096] After the target coordinate information and the target area information are determined, the target subtext corresponding to the target text block can be extracted from the document to be recognized based on the two pieces of information.

[0097] Specifically, extracting a target subtext corresponding to the target text block from the document to be recognized according to the target coordinate information and the target area information includes:

[0098] Determine a text area to be extracted in the document to be identified according to the target coordinate information and the target area information;

[0099] The text content in the to-be-extracted text area is extracted to obtain the target sub-text corresponding to the target text block.

[0100] Furthermore, the text area to be extracted corresponding to the target text block in the document to be identified can be determined in the document to be identified according to the target coordinate information and the target area information, and the text area to be extracted corresponds to the target text block. After the text area to be extracted is determined, the text content in the text area to be extracted can be extracted to obtain the target subtext corresponding to the target text block.

[0101] When extracting the text content in the text area to be extracted, the text content in the text area to be extracted can be identified and extracted through OCR recognition technology. OCR recognition (Optical Character Recognition) technology is a process of determining the shape by detecting dark and light patterns, and then translating the shape into computer text using character recognition methods. The text content in each text area to be extracted can be identified through ORC technology, and the target sub-text corresponding to each text area to be extracted can be generated.

[0102] In a specific implementation provided by the present application, taking text block 1 as the target text block as an example, after determining text block 1, the coordinate information and area information corresponding to the target text block 1 can be determined, and the text area 1 to be extracted corresponding to text block 1 can be further determined in the document to be recognized, and then OCR recognition is performed on the text area 1 to be extracted corresponding to text block 1 to extract the target subtext 1 in the text area 1 to be extracted. By analogy, the target subtext corresponding to each text block in the document to be recognized can be obtained.

[0103] In practical applications, with the development of computer technology, more and more tasks can be handled by artificial intelligence models. Accordingly, in another specific implementation provided by the present application, according to the position information of each text block, the target subtext corresponding to each text block is extracted from the document to be recognized, including:

[0104] Inputting the position information of each text block and the document to be identified into the document extraction model;

[0105] The target subtext corresponding to each text block output by the document extraction model is obtained.

[0106] Among them, the document extraction model specifically refers to an artificial intelligence model used to extract documents based on the location information of each text block and the document to be identified. The model can be a Transformer model or a Bert model, which is not limited in this application.

[0107] The document extraction model needs to be pre-trained and have the ability to extract the content in the document to be identified based on the document to be identified and the position information of each text block in the document to be identified. Furthermore, within the document extraction model, after receiving the document to be identified and the position information of each text block in the document to be identified, different recognition areas can be determined in the document to be identified according to the position information of each text block, and then the text content in each recognition area can be extracted respectively, so as to obtain the target sub-text corresponding to each text block.

[0108] In the process of extracting the target sub-text corresponding to each text block from the document to be identified based on the position information of each text block, a document extraction model was introduced. The accuracy and efficiency of document content extraction can be further improved through the artificial intelligence model.

[0109] Step 308: Obtain the target text corresponding to the document to be recognized according to the target sub-text corresponding to each text block and the position information of each text block.

[0110] After the above steps, the target sub-text corresponding to each text block can be obtained. Then, each target sub-text needs to be spliced ​​to obtain the target text corresponding to the document to be recognized. In actual applications, each text block is not arranged in a completely sequential order. Figure 4 As shown, the positions of different text blocks in the document to be recognized may be in a parallel relationship or a sequential relationship. Therefore, in the process of processing each target sub-text to obtain the target text corresponding to the document to be recognized, it is necessary to further refer to the position information of each text block, and match each target sub-text with the position information of each text block, so as to obtain the target text corresponding to the document to be recognized.

[0111] Specifically, obtaining the target text corresponding to the document to be recognized according to the target subtext corresponding to each text block and the position information of each text block includes:

[0112] Determine text order information according to position information of each text block;

[0113] The target sub-texts corresponding to each text block are spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

[0114] The text order information specifically refers to the text sorting order of the text blocks in the text to be recognized determined according to the position information of each text block, and is still based on Figure 4 For example, in actual application, the page includes 7 text blocks, namely 1-"text block TB1", 2-"text block TB2", 3-"text block TB3", 4-"text block TB4", 5-"text block TB5", 6-"text block TB6", 7-"text block TB7". According to the position information of each text block, further, according to the coordinate information of each text block, the text sequence information is determined as "1-2-3-4-6-5-7". Among them, 1-7 are the labels of each text block.

[0115] After the text sequence information is determined, the target sub-texts corresponding to each text block can be concatenated according to the text sequence, thereby obtaining the target text corresponding to the document to be recognized.

[0116] The target sub-texts corresponding to each text block are spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

[0117] Furthermore, in order to better restore the text layout in the document to be recognized, so that the extracted target text is closer to the content of the document to be recognized, the target subtext corresponding to each text block is spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized, including:

[0118] Fill each text block with the target sub-text corresponding to each text block;

[0119] Each text block is spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

[0120] In practical applications, the target subtext corresponding to each text block can be backfilled into the corresponding text block, and then each text block filled with the target subtext can be spliced ​​according to the order information of each text and the position information of each text block, so as to obtain the target text corresponding to the document to be recognized. At this time, each text block is recognized and obtained on the basis of the document to be recognized, and the target subtext corresponding to each text block is filled into the corresponding text block, which can effectively solve the problem of disordered text between lines in the target text. Each text block can also be traversed again to obtain the target text corresponding to each text to be recognized.

[0121] The text extraction method provided by the present application is to obtain a document to be identified, wherein the document to be identified includes at least one text block; identify the position information of each text block in the document to be identified; extract the target subtext corresponding to each text block from the document to be identified according to the position information of each text block; obtain the target text corresponding to the document to be identified according to the target subtext corresponding to each text block and the position information of each text block. Through the method provided by the present application, the document to be identified is first divided into blocks for content, and the document to be identified is divided into multiple text blocks, and then the target subtext corresponding to each text block is identified respectively, and then each target subtext is generated into the final target text according to the position information of the text block, which can effectively solve the problem of disorder between text lines due to special formats and other reasons in the text extraction process, and extract the content in the document more clearly and accurately.

[0122] Secondly, the present application mentions that the document to be identified is first divided into blocks to obtain multiple text blocks. After the target sub-text in each text block is extracted respectively, each target sub-text is backfilled to refer to the corresponding text block. This can effectively solve the problem of text disorder between lines, and can also solve the problem of text extraction disorder that often appears in documents due to settings such as left alignment and right alignment.

[0123] The following combination Figure 5 , taking the application of the text extraction method provided by the present application in extracting resume text as an example, the text extraction method is further described. Among them, Figure 5 A processing flow chart of a text extraction method applied to a resume text scenario provided by an embodiment of the present application is shown, which specifically includes the following steps:

[0124] Step 502: Obtain a resume document to be identified, wherein the resume document to be identified includes at least one text block.

[0125] In this embodiment, the user uploads a resume document 1 in DOCX format to the text extraction system, and the text extraction system obtains the resume document 1 and compares the DOCX format with the preset PDF format. After the comparison, it is determined that the resume document in DOCX format does not conform to the format of the text extraction system, and the resume document 1 in DOCX format needs to be converted to a resume document 1 in PDF format. Furthermore, when it is detected that the format of the resume document 1 is in DOCX format, the Jacob tool is called to process the resume document 1 in DOCX format through the Jacob tool, and the resume document 1 in DOCX format is converted to a resume document 1 in PDF format.

[0126] See also Figure 6 , Figure 6 FIG. 1 shows a schematic diagram of an interface of a resume document provided by an embodiment of the present application. Figure 6 As shown, the resume document includes "Title H1-Work Experience", "Text T1 describing work experience W1", "Text T2 describing work experience W1", "Text T3 describing work experience W1", "Title H2-Educational Background", "Title H3-Skill Description", "At least one line of text describing educational background E1", and "At least one line of text describing skills SK".

[0127] Step 504: Convert the resume document to be identified into a resume image to be identified.

[0128] In this embodiment, the resume document to be identified is converted into a resume image to be identified by using the Imagemgick tool. By converting the document into an image, it is convenient to identify text blocks in the image in the subsequent processing process.

[0129] Step 506: Input the resume image to be identified into the target detection model.

[0130] In this embodiment, the resume image to be identified is input into the target detection model, wherein the target monitoring model is used to detect text blocks in the image and the position information corresponding to each text block.

[0131] Step 508: Obtain at least one text block in the resume image to be identified output by the target detection model and the position information of each text block.

[0132] In this embodiment, the target detection model processes the resume image to be identified, identifies 8 text blocks in the resume image to be identified, and marks the location information of each text block.

[0133] Step 510: Determine the text area to be identified corresponding to each text block in the resume document to be identified according to the position information of each text block.

[0134] In this embodiment, after the position information of each text block is determined, the position information of each text block is mapped to the resume document to be identified, so as to determine the text area to be identified corresponding to each text block in the resume document to be identified.

[0135] Step 512: extract the text content in each text area to be recognized respectively, and obtain the target sub-text corresponding to each text block.

[0136] In this embodiment, the text content corresponding to each to-be-recognized text area is extracted respectively, and the target sub-text corresponding to each text block can be obtained. The target sub-text here specifically refers to the text information extracted from each text block.

[0137] Step 514: Fill each text block with the target subtext corresponding to each text block according to the position information corresponding to each text block.

[0138] In this embodiment, after the target sub-text corresponding to each text block is obtained, each target sub-text is backfilled into each text block according to the position information corresponding to each text block.

[0139] Step 516: traverse each text block to obtain the target text corresponding to the resume document to be identified.

[0140] In this embodiment, each text block is traversed according to the coordinate order of the text blocks, and the target sub-texts in each text block are spliced ​​to finally obtain the target text corresponding to the resume document to be identified: "Title H1-Work Experience, text T1 describing work experience W1, text T2 describing work experience W1, text T3 describing work experience W1, Title H2-Educational Background, at least one line of text describing educational background E1, Title H3-Skill Description, at least one line of text describing skills SK".

[0141] The text extraction method applied to resume text provided in the present application first divides the content of the resume document to be identified into blocks, divides the resume document to be identified into multiple text blocks, and then respectively identifies the target sub-text corresponding to each text block, and then generates the final target text for each target sub-text according to the position information of the text block. This method can effectively solve the problem of disorder between text lines due to special formats and the like that occurs during the text extraction process, and can extract the content in the document more clearly and accurately.

[0142] Secondly, the present application mentions that the document to be identified is first divided into blocks to obtain multiple text blocks. After the target sub-text in each text block is extracted respectively, each target sub-text is backfilled to refer to the corresponding text block. This can effectively solve the problem of text disorder between lines, and can also solve the problem of text extraction disorder that often appears in documents due to settings such as left alignment and right alignment.

[0143] Corresponding to the above text extraction method embodiment, the present application also provides a text extraction device embodiment, Figure 7 FIG. 1 is a schematic diagram showing the structure of a text extraction device provided by an embodiment of the present application. Figure 7 As shown, the device comprises:

[0144] The acquisition module 702 is configured to acquire a document to be recognized, wherein the document to be recognized includes at least one text block;

[0145] The recognition module 704 is configured to recognize the position information of each text block in the document to be recognized;

[0146] An extraction module 706 is configured to extract a target subtext corresponding to each text block from the document to be recognized according to the position information of each text block;

[0147] The text acquisition module 708 is configured to obtain the target text corresponding to the document to be recognized according to the target sub-text corresponding to each text block and the position information of each text block.

[0148] Optionally, the identification module 704 is further configured to:

[0149] Converting the document to be identified into a picture to be identified;

[0150] At least one text block in the to-be-identified picture and position information of each text block are identified.

[0151] Optionally, the identification module 704 is further configured to:

[0152] Inputting the image to be identified into the target detection model;

[0153] At least one text block and position information of each text block in the image to be identified output by the target detection model are obtained.

[0154] Optionally, the position information of the text block includes coordinate information and area information of the text block;

[0155] The extraction module 706 is further configured to:

[0156] Determine a target text block, and determine target coordinate information and target area information corresponding to the target text block;

[0157] The target sub-text corresponding to the target text block is extracted from the document to be recognized according to the target coordinate information and the target area information.

[0158] Optionally, the extraction module 706 is further configured to:

[0159] Determine a text area to be extracted in the document to be identified according to the target coordinate information and the target area information;

[0160] The text content in the to-be-extracted text area is extracted to obtain the target sub-text corresponding to the target text block.

[0161] Optionally, the extraction module 706 is further configured to:

[0162] Inputting the position information of each text block and the document to be identified into the document extraction model;

[0163] The target subtext corresponding to each text block output by the document extraction model is obtained.

[0164] Optionally, the text acquisition module 708 is further configured to:

[0165] Determine text order information according to position information of each text block;

[0166] The target sub-texts corresponding to each text block are spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

[0167] Optionally, the text acquisition module 708 is further configured to:

[0168] Fill each text block with the target sub-text corresponding to each text block;

[0169] Each text block is spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

[0170] Optionally, the acquisition module 702 is further configured to:

[0171] Acquire an initial document to be identified, and determine an initial document format of the initial document to be identified;

[0172] Determining whether the initial document format is a preset document format;

[0173] If yes, determining that the initial document to be identified is the document to be identified;

[0174] If not, the initial document to be recognized is converted into a document to be recognized according to a format conversion tool.

[0175] Optionally, the device further comprises a training module configured to:

[0176] Acquire a sample image to be identified, wherein the sample image to be identified includes position information of a marked text block;

[0177] Inputting the sample image to be identified into the target detection model to obtain the predicted text block position information output by the target monitoring model;

[0178] Calculating a model loss value according to the annotated text block position information and the predicted text block position information;

[0179] The model parameters of the target detection model are adjusted according to the model loss value, and the training is continued until the training stop condition is reached.

[0180] The above is a schematic scheme of a text extraction device of the present embodiment. It should be noted that the technical scheme of the text extraction device and the technical scheme of the above-mentioned text extraction method belong to the same concept. For details not described in detail in the technical scheme of the text extraction device, please refer to the description of the technical scheme of the above-mentioned text extraction method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.

[0181] Figure 8 The block diagram of a computing device according to an embodiment of the present application is shown. The components of the computing device 800 include but are not limited to a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and the database 850 is used to store data.

[0182] The computing device 800 also includes an access device 840 that enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 840 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0183] In one embodiment of the present application, the above components of the computing device 800 and Figure 8 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 8 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0184] The computing device 800 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 800 may also be a mobile or stationary server.

[0185] The processor 820 is used to execute computer executable instructions of the text extraction method.

[0186] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above text extraction method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above text extraction method.

[0187] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are used in a text extraction method when executed by a processor.

[0188] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above text extraction method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above text extraction method.

[0189] An embodiment of the present application further provides a chip storing a computer program, which implements the steps of the text extraction method when executed by the chip.

[0190] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0191] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0192] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0193] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0194] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.

Claims

1. A text extraction method, characterized in that: include: Acquire a document to be identified, wherein the document to be identified includes at least one text block; Identify the position information of each text block in the document to be identified; Extracting target subtext corresponding to each text block from the document to be recognized according to the position information of each text block; According to the target sub-text corresponding to each text block and the position information of each text block, the target text corresponding to the document to be recognized is obtained.

2. The method according to claim 1, characterized in that Identifying the position information of each text block in the document to be identified includes: Converting the document to be identified into a picture to be identified; At least one text block in the to-be-identified picture and position information of each text block are identified.

3. The method according to claim 2, characterized in that Identifying at least one text block in the to-be-identified picture and position information of each text block, including: Inputting the image to be identified into the target detection model; At least one text block and position information of each text block in the image to be identified output by the target detection model are obtained.

4. The method according to claim 1, characterized in that The location information of the text block includes the coordinate information and area information of the text block; Extracting target subtext corresponding to each text block from the document to be recognized according to the position information of each text block includes: Determine a target text block, and determine target coordinate information and target area information corresponding to the target text block; The target sub-text corresponding to the target text block is extracted from the document to be recognized according to the target coordinate information and the target area information.

5. The method according to claim 4, characterized in that Extracting a target subtext corresponding to the target text block in the document to be recognized according to the target coordinate information and the target area information includes: Determine a text area to be extracted in the document to be recognized according to the target coordinate information and the target area information; The text content in the to-be-extracted text area is extracted to obtain the target sub-text corresponding to the target text block.

6. The method according to claim 1, characterized in that Extracting target subtext corresponding to each text block from the document to be recognized according to the position information of each text block includes: Inputting the position information of each text block and the document to be identified into the document extraction model; The target subtext corresponding to each text block output by the document extraction model is obtained.

7. The method according to claim 1, characterized in that Obtaining the target text corresponding to the document to be recognized according to the target subtext corresponding to each text block and the position information of each text block, including: Determine text order information according to position information of each text block; The target sub-texts corresponding to each text block are spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

8. The method according to claim 7, characterized in that The target sub-texts corresponding to each text block are spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized, including: Fill each text block with the target sub-text corresponding to each text block; Each text block is spliced ​​according to the text sequence information to obtain the target text corresponding to the document to be recognized.

9. The method according to claim 1, characterized in that Get the document to be identified, including: Acquire an initial document to be identified, and determine an initial document format of the initial document to be identified; Determining whether the initial document format is a preset document format; If yes, determining that the initial document to be identified is the document to be identified; If not, the initial document to be recognized is converted into a document to be recognized according to a format conversion tool.

10. The method according to claim 3, characterized in that The target detection model is trained by the following steps: Acquire a sample image to be identified, wherein the sample image to be identified includes position information of a marked text block; Inputting the sample image to be identified into the target detection model to obtain the predicted text block position information output by the target monitoring model; Calculating a model loss value according to the annotated text block position information and the predicted text block position information; The model parameters of the target detection model are adjusted according to the model loss value, and the training is continued until the training stop condition is reached.

11. A text extraction device, characterized in that: include: An acquisition module is configured to acquire a document to be recognized, wherein the document to be recognized includes at least one text block; A recognition module, configured to recognize position information of each text block in the document to be recognized; An extraction module is configured to extract a target subtext corresponding to each text block from the document to be recognized according to the position information of each text block; The text acquisition module is configured to obtain the target text corresponding to the document to be recognized according to the target sub-text corresponding to each text block and the position information of each text block.

12. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the method according to any one of claims 1 to 10.

13. A computer-readable storage medium storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method described in any one of claims 1 to 10 are implemented.