PDF file conversion method, device, electronic device and computer-readable medium

By identifying and aggregating PDF files, extracting numbers and titles, and forming hierarchical text, the problem of inability to retrieve PDF files and lack of context in the prior art is solved, and the efficiency of information retrieval is improved.

CN113486148BActive Publication Date: 2024-12-27CHINA CONSTRUCTION BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110769021.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-07
Publication Date
2024-12-27
Estimated Expiration
2041-07-07

AI Technical Summary

Technical Problem

The prior art cannot directly search text in PDF files, and cannot understand the hierarchical structure of the file, resulting in a lack of context in the search results, which weakens the efficiency of information retrieval.

Method used

By identifying PDF files, outputting pixel coordinates and contents of text blocks, aggregating them to form paragraphs, and extracting numbers and titles from paragraphs to form text content with hierarchical structures, and using OCR and NLP technologies to convert them into structured and hierarchical text.

Benefits of technology

It realizes a complete understanding of PDF file content and obtains context, significantly improving the effectiveness of text retrieval and information utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113486148B_ABST
    Figure CN113486148B_ABST
Patent Text Reader

Abstract

The present invention discloses a PDF file conversion method, device, electronic device and computer-readable medium, and relates to the field of natural language processing technology. A specific implementation of the method includes: performing text recognition on a PDF file, thereby outputting the pixel coordinates and text content of each text block; aggregating the text blocks according to the pixel coordinates and text content of each text block to form each paragraph; extracting numbers and titles corresponding to the numbers from each paragraph; and forming text content with a hierarchical structure according to each paragraph and its corresponding numbers and titles corresponding to the numbers. This implementation can solve the technical problems of being unable to know the hierarchical structure of a file and the lack of context in the search results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a PDF file conversion method, device, electronic device and computer-readable medium. Background Art

[0002] Currently, OCR is usually used to recognize the page content of a PDF file from an image into text, and then the text content containing the keyword is retrieved through keywords.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] 1) The content of the PDF file is in the form of a photocopy, and the text in the file cannot be directly searched;

[0005] 2) The hierarchical structure of the file cannot be known, and the search results are text fragments. The content of the fragments is not complete text information. The complete content and context cannot be quickly obtained, which greatly weakens the efficiency of information retrieval. Summary of the invention

[0006] In view of this, the embodiments of the present invention provide a PDF file conversion method, device, electronic device and computer-readable medium to solve the technical problems of being unable to obtain the hierarchical structure of the file and lacking context in the retrieval results.

[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for converting a PDF file is provided, comprising:

[0008] Perform text recognition on PDF files to output the pixel coordinates and text content of each text block;

[0009] Aggregating the text blocks according to the pixel coordinates and text contents of the text blocks to form paragraphs;

[0010] Extracting numbers and titles corresponding to the numbers from each of the paragraphs;

[0011] According to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, text content with a hierarchical structure is formed.

[0012] Optionally, perform text recognition on the PDF file to output the pixel coordinates and text content of each text block, including:

[0013] Convert PDF files into multiple continuous image files in units of pages;

[0014] Perform text recognition on the image file, thereby outputting the pixel coordinates and text content of each text block in the image file.

[0015] Optionally, the text blocks are aggregated according to the pixel coordinates and text contents of the text blocks to form paragraphs, including:

[0016] Vectorizing the text content of each text block to obtain a vector of each text block;

[0017] For any text block, the vector and pixel coordinates of the text block are input into the text classification model, and whether the text block belongs to the previous paragraph or the next paragraph is output, thereby forming each paragraph.

[0018] Optionally, extracting numbers and titles corresponding to the numbers from the respective paragraphs includes:

[0019] The numbers and the titles corresponding to the numbers are extracted from the paragraphs through the trained Bi-LSTM-CRF model.

[0020] Optionally, according to the paragraphs and their corresponding numbers and titles corresponding to the numbers, text content with a hierarchical structure is formed, including:

[0021] Vectorizing the text content of each paragraph to obtain a vector of each paragraph;

[0022] For any paragraph, the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, the number extracted from the paragraph and the title corresponding to the number are input into the text classification model, and the output is whether the paragraph belongs to the previous level or the next level, thereby forming text content with a hierarchical structure.

[0023] Optionally, after forming text content with a hierarchical structure according to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, the method further includes:

[0024] The number and the title and text content corresponding to the number are imported into a full-text search engine.

[0025] Optionally, after importing the number and the title and text content corresponding to the number into a full-text search engine, the method further includes:

[0026] According to the target level and / or keyword input by the user, searching for search results corresponding to the target level and / or the keyword through the full-text search engine;

[0027] In response to the user clicking on any one of the search results, the hierarchical structure, the text content corresponding to the any one of the search results, and the location area of ​​the text content corresponding to the any one of the search results in the PDF file are displayed.

[0028] In addition, according to another aspect of the embodiment of the present invention, a PDF file conversion device is provided, comprising:

[0029] The recognition module is used to perform text recognition on PDF files, thereby outputting the pixel coordinates of each text block and the text content;

[0030] An aggregation module, used for aggregating the text blocks according to the pixel coordinates and text contents of the text blocks to form paragraphs;

[0031] An extraction module, used for extracting numbers and titles corresponding to the numbers from the respective paragraphs;

[0032] The conversion module is used to form text content with a hierarchical structure according to the paragraphs and their corresponding numbers and the titles corresponding to the numbers.

[0033] Optionally, the identification module is further used for:

[0034] Convert PDF files into multiple continuous image files in units of pages;

[0035] Perform text recognition on the image file, thereby outputting the pixel coordinates and text content of each text block in the image file.

[0036] Optionally, the aggregation module is further used for:

[0037] Vectorizing the text content of each text block to obtain a vector of each text block;

[0038] For any text block, the vector and pixel coordinates of the text block are input into the text classification model, and whether the text block belongs to the previous paragraph or the next paragraph is output, thereby forming each paragraph.

[0039] Optionally, the extraction module is further used for:

[0040] The numbers and the titles corresponding to the numbers are extracted from the paragraphs through the trained Bi-LSTM-CRF model.

[0041] Optionally, the conversion module is further used for:

[0042] Vectorizing the text content of each paragraph to obtain a vector of each paragraph;

[0043] For any paragraph, the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, the number extracted from the paragraph and the title corresponding to the number are input into the text classification model, and the output is whether the paragraph belongs to the previous level or the next level, thereby forming text content with a hierarchical structure.

[0044] Optionally, a retrieval module is further included, for:

[0045] After forming text content with a hierarchical structure according to the paragraphs, their corresponding numbers and the titles corresponding to the numbers, the numbers, the titles corresponding to the numbers and the text content are imported into a full-text search engine.

[0046] Optionally, the retrieval module is further used to:

[0047] After the number and the title and text content corresponding to the number are imported into a full-text search engine, the search results corresponding to the target level and / or the keyword are retrieved through the full-text search engine according to the target level and / or keyword input by the user;

[0048] In response to the user clicking on any one of the search results, the hierarchical structure, the text content corresponding to the any one of the search results, and the location area of ​​the text content corresponding to the any one of the search results in the PDF file are displayed.

[0049] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:

[0050] one or more processors;

[0051] a storage device for storing one or more programs,

[0052] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.

[0053] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0054] One embodiment of the above invention has the following advantages or beneficial effects: because the technical means of extracting numbers and titles corresponding to the numbers from each paragraph and forming text content with a hierarchical structure according to each paragraph and its corresponding number and title corresponding to the number is adopted, the technical problems of the inability to know the hierarchical structure of the file and the lack of context in the search results in the prior art are overcome. The embodiment of the present invention comprehensively uses OCR and NLP technologies to convert PDF files into structured and hierarchical text content based on the content of the text and the relative position information of the text, so that users can fully know the text content and context in the file, greatly improving the effect of text retrieval and the efficiency of information utilization.

[0055] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0057] Figure 1 is a schematic diagram of the main process of the PDF file conversion method according to an embodiment of the present invention;

[0058] Figure 2 is a schematic diagram of a text recognition result according to an embodiment of the present invention;

[0059] Figure 3 It is a schematic diagram of the main process of a method for converting a PDF file according to a reference embodiment of the present invention;

[0060] Figure 4 is a schematic diagram of the main process of a method for converting a PDF file according to another reference embodiment of the present invention;

[0061] Figure 5 is a schematic diagram of retrieving search results through a full-text search engine according to an embodiment of the present invention;

[0062] Figure 6 is a schematic diagram of a detail page according to an embodiment of the present invention;

[0063] Figure 7 is a schematic diagram of main modules of a PDF file conversion device according to an embodiment of the present invention;

[0064] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0065] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0067] Figure 1 Schematic diagram of the main process of the method for converting a PDF file according to an embodiment of the present invention. Figure 1 As shown, the PDF file conversion method may include:

[0068] Step 101 , performing text recognition on a PDF file, thereby outputting the pixel coordinates and text content of each text block.

[0069] First, the PDF file to be converted is subjected to text recognition, for example, OCR is used to perform text recognition on each page of the PDF file, so as to obtain the pixel coordinates of each text block and the text content in each text block.

[0070] Optionally, step 101 may include: converting a PDF file into a plurality of continuous image files in units of pages; performing text recognition on the image files, thereby outputting pixel coordinates and text content of each text block in the image file. Generally speaking, the content of a PDF file is in the form of a photocopy, and text in the file cannot be directly retrieved. Therefore, it is necessary to convert a PDF file into a plurality of continuous image files in units of pages, for example, a 60-page PDF file is converted into 60 continuous jpg image files; then performing OCR recognition on the image files, thereby outputting pixel coordinates of each text block and text content in each text block.

[0071] like Figure 2 As shown, the pixel coordinates are based on the upper left corner of the image as the coordinate origin (0, 0). The text block can be uniquely located by the pixel coordinates of the four corners, and can reflect the relative position relationship between adjacent text blocks. It should be noted that Figure 2 The upper part is a real example of text recognition, and the lower part is a detailed display of the recognition result. Text is the text content, type refers to printed / handwritten text, score is the confidence (the system's score for the recognition result, generally between 0 and 1000 points, the higher the score, the higher the possibility of correct recognition), and coords are the pixel coordinates of the four corners.

[0072] Step 102, aggregating the text blocks according to the pixel coordinates and text contents of the text blocks to form paragraphs.

[0073] In this step, the text blocks are aggregated according to the recognition result in step 101 (ie, the pixel coordinates and text content of each text block), and it is determined whether each text block belongs to the same paragraph, so that each file block is aggregated into each paragraph.

[0074] Optionally, step 102 may include: vectorizing the text content of each text block to obtain the vector of each text block; for any text block, inputting the vector and pixel coordinates of the text block into the text classification model, and outputting whether the text block belongs to the previous paragraph or the next paragraph, thereby forming each paragraph. Specifically, the BERT algorithm may be used to vectorize (word embedding) the text content of each text block to obtain the text meaning of each text block; then the vector of the text block and the pixel coordinates of the text block are used as inputs to the text classification model, and the text classification model outputs whether the text block belongs to the previous paragraph or the next paragraph, thereby forming each paragraph according to the output results of the text classification model.

[0075] It should be noted that the text classification model needs to be supervised in advance. Specifically, a large number of input and output samples are manually annotated to build a text classification model and perform training. The training result is a model file, which functions to realize paragraphing of new text blocks that are not manually annotated. Optionally, the text classification model is a Transformer-CRF model, through which each text block can be accurately aggregated into paragraphs.

[0076] Step 103: extract numbers and titles corresponding to the numbers from the paragraphs.

[0077] Generally speaking, each paragraph will contain a number. Some paragraphs will contain numbers and corresponding titles, and some paragraphs will have neither numbers nor titles. Therefore, the numbers and corresponding titles can be extracted from each paragraph through a pre-trained extraction model. These numbers and corresponding titles are used to form a hierarchical structure (similar to a tree-level directory).

[0078] Optionally, step 103 may include: extracting numbers and titles corresponding to the numbers from the paragraphs through a trained Bi-LSTM-CRF model. It should be noted that the Bi-LSTM-CRF model needs to be supervised in advance. Specifically, the numbers and titles corresponding to the numbers in a large number of paragraphs are manually annotated, and a Bi-LSTM-CRF model is constructed and trained. The function of the model is to extract numbers and titles corresponding to the numbers from the paragraphs.

[0079] Optionally, the number can be numbers, English letters or Roman numerals, etc., which are not limited in the embodiments of the present invention. It should be noted that the same number may appear repeatedly, for example, a number such as "(a)" may appear repeatedly at different levels, so the hierarchical structure cannot be simply obtained by the number, and the title corresponding to the number must be combined.

[0080] Step 104: forming text content with a hierarchical structure according to the paragraphs, their corresponding numbers and the titles corresponding to the numbers.

[0081] Each level may include one paragraph or multiple paragraphs. In order to display the complete hierarchical structure, the embodiment of the present invention aggregates the paragraphs according to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, thereby forming text content with a hierarchical structure. Therefore, the text content of each level includes at least one paragraph.

[0082] Optionally, step 104 may include: vectorizing the text content of each paragraph to obtain the vector of each paragraph; for any paragraph, inputting the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, and the number extracted from the paragraph and the title corresponding to the number into a text classification model, and outputting whether the paragraph belongs to the previous level or the next level, thereby forming text content with a hierarchical structure.

[0083] Specifically, the BERT algorithm can be used to vectorize (word embedding) the text content of each paragraph to obtain the text meaning of each paragraph; then the paragraph vector, the paragraph pixel coordinates (the pixel coordinates of the outermost text block in the paragraph), the number extracted from the paragraph and the title corresponding to the number (this item is empty for some paragraphs) are used as the input of the text classification model, and the text classification model outputs whether the paragraph belongs to the previous level or the next level, thereby forming a hierarchical text content according to the output result of the text classification model.

[0084] It should be noted that the text classification model needs to be supervised in advance. Specifically, a large number of input and output samples are manually annotated to build a text classification model and perform training. The training result is a model file, which is used to structure and hierarchize new paragraphs that are not manually annotated. Optionally, the text classification model is a Transformer-CRF model, through which each paragraph can be accurately aggregated into a hierarchy.

[0085] At this point, a PDF file is converted into structured and hierarchical text content, and the smallest granularity is the text content at the smallest level.

[0086] According to the various embodiments described above, it can be seen that the embodiments of the present invention, by extracting numbers and titles corresponding to the numbers from each paragraph, and forming text content with a hierarchical structure according to each paragraph and its corresponding number and title corresponding to the number, solves the technical problems in the prior art that the hierarchical structure of the file cannot be known and the search results lack context. The embodiments of the present invention comprehensively use OCR and NLP technologies to convert PDF files into structured and hierarchical text content based on the content of the text and the relative position information of the text, so that users can fully understand the text content and context in the file, greatly improving the effect of text retrieval and information utilization efficiency.

[0087] Figure 3 FIG. 1 is a schematic diagram of the main flow of a method for converting a PDF file according to a reference embodiment of the present invention. As another embodiment of the present invention, Figure 3 As shown, the PDF file conversion method may include:

[0088] Step 301, converting a PDF file into a plurality of continuous image files in units of pages.

[0089] Receive an uploaded PDF file and convert it into multiple continuous image files in units of pages.

[0090] Step 302, performing text recognition on the image file, thereby outputting the pixel coordinates and text content of each text block in the image file.

[0091] After converting the PDF file into multiple continuous image files, the image files are subjected to OCR recognition to output the pixel coordinates of each text block and the text content in each text block. The pixel coordinates are based on the upper left corner of the image as the coordinate origin (0, 0). The text block can be uniquely located by the pixel coordinates of the four corners, and the relative position relationship between adjacent text blocks can be reflected.

[0092] Step 303, vectorizing the text content of each text block to obtain a vector of each text block.

[0093] The BERT algorithm can be used to vectorize the text content of each text block to obtain the text meaning of each text block.

[0094] Step 304: for any text block, the vector and pixel coordinates of the text block are input into the text classification model, and output whether the text block belongs to the previous paragraph or the next paragraph, thereby forming each paragraph.

[0095] The text classification model needs to be supervised in advance, and the training process is not described in detail. In the embodiment of the present invention, the vector and pixel coordinates of the text block are used to determine whether the text block belongs to the previous paragraph or the next paragraph, so that the text blocks can be accurately aggregated to form each paragraph. Optionally, the text classification model is a Transformer-CRF model, through which each text block can be accurately aggregated into paragraphs.

[0096] Step 305: extract numbers and titles corresponding to the numbers from each paragraph using the trained Bi-LSTM-CRF model.

[0097] A pre-trained extraction model (such as a Bi-LSTM-CRF model) can be used to extract numbers and titles corresponding to the numbers from each paragraph, and these numbers and titles corresponding to the numbers are used to form a hierarchical structure. If the PDF file is a legal document, then the clause numbers and the clause titles corresponding to the clause numbers can be extracted from each paragraph.

[0098] It should be noted that some paragraphs have neither clause numbers nor clause titles, some paragraphs have only clause numbers, and some paragraphs have both clause numbers and clause titles. The Bi-LSTM-CRF model can accurately extract the clause numbers and the titles corresponding to the clause numbers, or the clause numbers, from each paragraph. Optionally, the clause numbers can be numbers, English letters, or Roman numerals, etc., which are not limited in the embodiments of the present invention. The Bi-LSTM-CRF model needs to be supervised in advance, and the training process will not be repeated.

[0099] Step 306: vectorize the text content of each paragraph to obtain a vector of each paragraph.

[0100] Optionally, the BERT algorithm may be used to vectorize the text content of each paragraph, thereby obtaining the text meaning of each paragraph.

[0101] Step 307, for any paragraph, the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, the number extracted from the paragraph and the title corresponding to the number are input into the text classification model, and whether the paragraph belongs to the previous level or the next level is output, thereby forming text content with a hierarchical structure.

[0102] The text classification model needs to be supervised in advance, and the training process will not be described in detail. The embodiment of the present invention determines whether a paragraph belongs to the previous level or the next level through the vector of the paragraph, the pixel coordinates of the paragraph, the number extracted from the paragraph, and the title corresponding to the number, so that the paragraphs can be accurately aggregated to form text content with a hierarchical structure. Optionally, the text classification model is a Transformer-CRF model, through which each paragraph can be accurately aggregated into a level.

[0103] In addition, the specific implementation content of the PDF file conversion method in a reference embodiment of the present invention has been described in detail in the PDF file conversion method described above, so the repeated content will not be described again here.

[0104] Figure 4 Schematic diagram of the main process of the PDF file conversion method according to another reference embodiment of the present invention. As another embodiment of the present invention, Figure 4 As shown, the PDF file conversion method may include:

[0105] Step 401 , performing text recognition on a PDF file, thereby outputting the pixel coordinates and text content of each text block.

[0106] Receive the uploaded PDF file and perform text recognition on the PDF file, such as using OCR to perform text recognition on each page of the PDF file, so as to obtain the pixel coordinates of each text block and the text content in each text block. Generally speaking, the content of the PDF file is in the form of a photocopy, and the text in the file cannot be directly retrieved. Therefore, it is necessary to convert the PDF file into multiple continuous image files in units of pages, and then perform OCR recognition on the image files to output the pixel coordinates of each text block and the text content in each text block.

[0107] Step 402, aggregating the text blocks according to the pixel coordinates and text contents of the text blocks to form paragraphs.

[0108] In this step, the text blocks are aggregated according to the recognition result in step 401 (ie, the pixel coordinates and text content of each text block), and it is determined whether each text block belongs to the same paragraph, so that each file block is aggregated into each paragraph.

[0109] Step 403: extract numbers and titles corresponding to the numbers from the paragraphs.

[0110] Usually, each paragraph will contain a number. Some paragraphs will contain numbers and corresponding titles, and some paragraphs will have neither numbers nor titles. Therefore, the numbers and corresponding titles can be extracted from each paragraph through a pre-trained extraction model. These numbers and corresponding titles are used to form a hierarchical structure.

[0111] Step 404: forming text content with a hierarchical structure according to the paragraphs and their corresponding numbers and the titles corresponding to the numbers.

[0112] Each level may include one paragraph or multiple paragraphs. In order to display the complete hierarchical structure, the embodiment of the present invention aggregates the paragraphs according to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, thereby forming text content with a hierarchical structure. Therefore, the text content of each level includes at least one paragraph.

[0113] Step 405: import the number and the title and text content corresponding to the number into a full-text search engine.

[0114] Import all the numbers, titles and text contents in the PDF file into the full-text search engine. If the PDF file is a legal document, import the clause numbers, clause titles and clause contents into the full-text search engine (such as the ElasticSearch full-text search engine).

[0115] Step 406: According to the target level and / or keyword input by the user, the full-text search engine is used to search for search results corresponding to the target level and / or the keyword.

[0116] Users can search text content through the full-text search engine. For example, users can enter the target level, keyword or title, etc., and retrieve the corresponding search results through the full-text search engine. Figure 5 As shown in the figure, taking legal documents as an example, users can enter the level and keywords of legal clauses, and the output search results are a list of legal clauses with the selected level of granularity and keywords, and the order is based on the order of the clauses in the original text. Furthermore, filter fields can be added, such as time, country, etc., to improve the accuracy of the search.

[0117] Step 407 , in response to the user clicking on any one of the search results, displaying the hierarchical structure, the text content corresponding to the any one of the search results, and the location area of ​​the text content corresponding to the any one of the search results in the PDF file.

[0118] Select Figure 5 After selecting a term in the list shown in the figure, the details page pops up, such as Figure 6As shown, on the left side of the details page is a hierarchical directory (including clause numbers and clause titles), on the upper right side is the clause content, and below is the corresponding location area in the PDF file.

[0119] The present invention makes comprehensive use of OCR and NLP technologies to convert PDF files into structured and hierarchical text content based on the content of the text and the relative position information of the text. The search results are presented in terms rather than general text fragments. Moreover, the structured and hierarchical information is displayed in an intuitive and flexible manner, so that users can know the complete content of the terms and the context, which greatly improves the effect of legal text retrieval and the efficiency of information utilization.

[0120] In addition, the specific implementation content of the PDF file conversion method in another reference embodiment of the present invention has been described in detail in the PDF file conversion method described above, so the repeated content will not be described again here.

[0121] Figure 7 Schematic diagram of main modules of a PDF file conversion device according to an embodiment of the present invention. Figure 7 As shown, the PDF file conversion device 700 includes a recognition module 701, an aggregation module 702, an extraction module 703 and a conversion module 704; wherein the recognition module 701 is used to perform text recognition on the PDF file, thereby outputting the pixel coordinates and text content of each text block; the aggregation module 702 is used to aggregate the text blocks according to the pixel coordinates and text content of each text block to form each paragraph; the extraction module 703 is used to extract the number and the title corresponding to the number from the each paragraph; the conversion module 704 is used to form a text content with a hierarchical structure according to the each paragraph and its corresponding number and the title corresponding to the number.

[0122] Optionally, the identification module 701 is further used for:

[0123] Convert PDF files into multiple continuous image files in units of pages;

[0124] Perform text recognition on the image file, thereby outputting the pixel coordinates and text content of each text block in the image file.

[0125] Optionally, the aggregation module 702 is further configured to:

[0126] Vectorizing the text content of each text block to obtain a vector of each text block;

[0127] For any text block, the vector and pixel coordinates of the text block are input into the text classification model, and whether the text block belongs to the previous paragraph or the next paragraph is output, thereby forming each paragraph.

[0128] Optionally, the extraction module 703 is further used for:

[0129] The numbers and the titles corresponding to the numbers are extracted from the paragraphs through the trained Bi-LSTM-CRF model.

[0130] Optionally, the conversion module 704 is further configured to:

[0131] Vectorizing the text content of each paragraph to obtain a vector of each paragraph;

[0132] For any paragraph, the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, the number extracted from the paragraph and the title corresponding to the number are input into the text classification model, and the output is whether the paragraph belongs to the previous level or the next level, thereby forming text content with a hierarchical structure.

[0133] Optionally, a retrieval module is further included, for:

[0134] After forming text content with a hierarchical structure according to the paragraphs, their corresponding numbers and the titles corresponding to the numbers, the numbers, the titles corresponding to the numbers and the text content are imported into a full-text search engine.

[0135] Optionally, the retrieval module is further used to:

[0136] After the number and the title and text content corresponding to the number are imported into a full-text search engine, the search results corresponding to the target level and / or the keyword are retrieved through the full-text search engine according to the target level and / or keyword input by the user;

[0137] In response to the user clicking on any one of the search results, the hierarchical structure, the text content corresponding to the any one of the search results, and the location area of ​​the text content corresponding to the any one of the search results in the PDF file are displayed.

[0138] According to the various embodiments described above, it can be seen that the embodiments of the present invention, by extracting numbers and titles corresponding to the numbers from each paragraph, and forming text content with a hierarchical structure according to each paragraph and its corresponding number and title corresponding to the number, solves the technical problems in the prior art that the hierarchical structure of the file cannot be known and the search results lack context. The embodiments of the present invention comprehensively use OCR and NLP technologies to convert PDF files into structured and hierarchical text content based on the content of the text and the relative position information of the text, so that users can fully understand the text content and context in the file, greatly improving the effect of text retrieval and information utilization efficiency.

[0139] It should be noted that the specific implementation content of the PDF file conversion device of the present invention has been described in detail in the PDF file conversion method described above, so the repeated content will not be described again here.

[0140] Figure 8 An exemplary system architecture 800 is shown to which the PDF file conversion method or PDF file conversion device according to the embodiment of the present invention can be applied.

[0141] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0142] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0143] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0144] The server 805 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The backend management server may analyze and process the received data such as the item information query request, and feed back the processing results to the terminal device.

[0145] It should be noted that the PDF file conversion method provided in the embodiment of the present invention is generally executed by the server 805, and accordingly, the PDF file conversion device is generally set in the server 805. The PDF file conversion method provided in the embodiment of the present invention can also be executed by the terminal devices 801, 802, and 803, and accordingly, the PDF file conversion device can be set in the terminal devices 801, 802, and 803.

[0146] It should be understood that Figure 8The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0147] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0148] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0149] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0150] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.

[0151] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0152] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0153] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an identification module, an aggregation module, an extraction module and a conversion module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.

[0154] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: performing text recognition on a PDF file, thereby outputting the pixel coordinates and text content of each text block; according to the pixel coordinates and text content of each text block, aggregating the text blocks to form each paragraph; extracting numbers and titles corresponding to the numbers from each paragraph; and forming text content with a hierarchical structure according to each paragraph and its corresponding numbers and titles corresponding to the numbers.

[0155] According to the technical solution of the embodiment of the present invention, because the technical means of extracting numbers and titles corresponding to the numbers from each paragraph, and forming text content with a hierarchical structure according to each paragraph and its corresponding number and title corresponding to the number is adopted, the technical problems of the inability to know the hierarchical structure of the file and the lack of context in the search results in the prior art are overcome. The embodiment of the present invention comprehensively uses OCR and NLP technologies, and converts PDF files into structured and hierarchical text content based on the content of the text and the relative position information of the text, so that users can fully know the text content and context in the file, greatly improving the effect of text retrieval and information utilization efficiency.

[0156] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for converting a PDF file, characterized in that: include: Perform text recognition on PDF files to output the pixel coordinates and text content of each text block; Aggregating the text blocks according to the pixel coordinates and text contents of the text blocks to form paragraphs; Extracting numbers and titles corresponding to the numbers from each of the paragraphs; According to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, a text content with a hierarchical structure is formed; According to the pixel coordinates and text contents of the text blocks, the text blocks are aggregated to form paragraphs, including: Vectorizing the text content of each text block to obtain a vector of each text block; For any text block, the vector and pixel coordinates of the text block are input into the text classification model, and output whether the text block belongs to the previous paragraph or the next paragraph, thereby forming each paragraph; According to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, a text content with a hierarchical structure is formed, including: Vectorizing the text content of each paragraph to obtain a vector of each paragraph; For any paragraph, the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, the number extracted from the paragraph and the title corresponding to the number are input into the text classification model, and the output is whether the paragraph belongs to the previous level or the next level, thereby forming text content with a hierarchical structure.

2. The method according to claim 1, characterized in that Perform text recognition on PDF files to output the pixel coordinates and text content of each text block, including: Convert PDF files into multiple continuous image files in units of pages; Perform text recognition on the image file to output the pixel coordinates and text content of each text block in the image file.

3. The method according to claim 1, characterized in that Extracting numbers and titles corresponding to the numbers from each of the paragraphs, including: The numbers and the titles corresponding to the numbers are extracted from the paragraphs through the trained Bi-LSTM-CRF model.

4. The method according to claim 1, characterized in that After forming text content with a hierarchical structure according to the paragraphs and their corresponding numbers and the titles corresponding to the numbers, the following is further included: The number and the title and text content corresponding to the number are imported into a full-text search engine.

5. The method according to claim 4, characterized in that After importing the number and the title and text content corresponding to the number into the full-text search engine, the method further includes: According to the target level and / or keyword input by the user, searching for search results corresponding to the target level and / or the keyword through the full-text search engine; In response to the user clicking on any one of the search results, the hierarchical structure, the text content corresponding to the any one of the search results, and the location area of ​​the text content corresponding to the any one of the search results in the PDF file are displayed.

6. A PDF file conversion device, characterized in that: include: The recognition module is used to perform text recognition on PDF files, thereby outputting the pixel coordinates of each text block and the text content; An aggregation module, used for aggregating the text blocks according to the pixel coordinates and text contents of the text blocks to form paragraphs; An extraction module, used for extracting numbers and titles corresponding to the numbers from the respective paragraphs; A conversion module, used for forming text content with a hierarchical structure according to the paragraphs and their corresponding numbers and titles corresponding to the numbers; The aggregation module is also used to: Vectorizing the text content of each text block to obtain a vector of each text block; For any text block, the vector and pixel coordinates of the text block are input into the text classification model, and output whether the text block belongs to the previous paragraph or the next paragraph, thereby forming each paragraph; The conversion module is also used for: Vectorizing the text content of each paragraph to obtain a vector of each paragraph; For any paragraph, the vector of the paragraph, the pixel coordinates of the outermost text block in the paragraph, the number extracted from the paragraph and the title corresponding to the number are input into the text classification model, and the output is whether the paragraph belongs to the previous level or the next level, thereby forming text content with a hierarchical structure.

7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.