PDF document content processing method, device, equipment, storage medium and program product
By combining language and visual models to determine page type and extract directory structure from PDF documents, and performing title matching based on semantic and text similarity, the problem of inaccurate chapter division in PDF documents is solved, achieving high-precision structured representation and semantic restoration.
Patent Information
- Application Number
- CN202511468366.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2045-10-15
AI Technical Summary
Existing technologies for processing PDF document content suffer from inaccurate chapter division, contextual fragmentation, and semantic mismatch, especially in textbooks, regulations, or multi-level technical reports, where complex numbering systems and nested directories are difficult to map stably.
By combining language and visual models to determine the page type of PDF documents, constructing a table of contents tree, and matching the table of contents titles with the main text titles based on semantic and textual similarity, the content data is accurately mapped.
It improves the accuracy of PDF document recognition, ensures the accuracy of matching table of contents titles with body text titles, obtains structured document representation results, and enhances semantic restoration and structure quality, which facilitates subsequent retrieval, display or knowledge extraction.
Smart Images

Figure CN120930593B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of document structured processing, and particularly relates to a PDF document content processing method and device, equipment, a storage medium and a computer program product. BACKGROUND
[0002] With the extensive digitization of literature materials such as teaching materials, academic papers, legal documents and enterprise reports, PDF has become one of the most commonly used electronic document formats. PDF can completely retain the layout and style, but it lacks structured information, which brings great difficulties to content analysis, knowledge extraction and semantic retrieval, especially in application scenarios that require high-precision chapter division and semantic restoration.
[0003] The structured processing of PDF documents mainly relies on page number ranges, fixed separators or text length-based segmentation methods. Some improved schemes attempt to introduce a table of contents page for assistance, but most of them remain at the level of hard rule processing such as page number positioning, and lack in-depth analysis of the directory level semantics and accurate attribution of the main text content. These methods often result in inaccurate chapter division, fragmented context and semantic mismatch. In particular, in teaching materials, regulations or multi-level technical reports, the complex numbering system and nested directories are difficult to be stably mapped, resulting in the loss of document semantic hierarchy. Therefore, there is an urgent need for a high-precision structured method that integrates directory structure analysis, title alignment, semantic division and content mapping to improve the effect of PDF document semantic restoration and structure recovery. SUMMARY
[0004] The main purpose of the present application is to provide a PDF document content processing method, device, equipment, storage medium and computer program product, aiming to solve the technical problem of inaccurate chapter division in PDF document content processing in related technologies.
[0005] To achieve the above-mentioned purpose, the present application provides a PDF document content processing method, which comprises the following steps:
[0006] acquiring a PDF document, wherein the PDF document comprises at least one page;
[0007] preprocessing the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document; the to-be-processed data set comprises title data and / or content data;
[0008] determining the page type of each page of the PDF document based on all to-be-processed data sets and images of each page of the PDF document; the page type comprises a table of contents page and / or a non-table of contents page;
[0009] Based on the image of each directory page and the corresponding to-be-processed data set, the hierarchical relationship of each title data in the directory page is extracted, and a directory tree is constructed, wherein the node structure of the directory tree corresponds to the hierarchical relationship of the title data in the directory page;
[0010] Based on the semantic similarity and the text similarity between the title data of the directory page and the title data of the non-directory page, the title data of the directory page and the title data of the non-directory page are matched, and according to the matching result, the content data is filled into each title node of the directory tree, and the structured representation result of the PDF document is obtained.
[0011] In an embodiment, based on all to-be-processed data sets and images of pages of the PDF document, the step of determining the page type of each page of the PDF document comprises:
[0012] The to-be-processed data sets are sorted according to the page numbers, for each to-be-processed data set, the to-be-processed data set and the two to-be-processed data sets before and after the to-be-processed data set are taken as a to-be-recognized data group, and input to a language-based page recognition model to obtain the first page type of the current page in the to-be-recognized data group; wherein the to-be-processed data set is marked as the current page, the to-be-processed data set before the to-be-processed data set is marked as the previous page, and the to-be-processed data set after the to-be-processed data set is marked as the next page;
[0013] After all the pages of the PDF document are converted into images, the images are input to a visual-based page recognition model to obtain the second page type of all the to-be-recognized images;
[0014] Based on the first page type and the second page type, the page type of each page of the PDF document is determined.
[0015] In an embodiment, based on the first page type and the second page type, the step of determining the page type of each page of the PDF document comprises:
[0016] Based on the first page type, a first directory page number sequence is determined, and based on the second page type, a second directory page number sequence is determined;
[0017] The union of the first directory page number sequence and the second directory page number sequence is taken, and the longest continuous page number sequence in the union is taken as a first candidate page number sequence;
[0018] The intersection of the first directory page number sequence and the second directory page number sequence is taken to obtain a first page number intersection sequence, and the first page number intersection sequence is continuously extracted to obtain at least one second candidate page number sequence;
[0019] For each second candidate page number sequence, the intersection of the second candidate page number sequence and the first page number intersection sequence is taken to obtain a second page number intersection sequence;
[0020] selecting, from all the second candidate page number sequences, a second candidate page number sequence meeting preset requirements as the table of contents page number range of the PDF document; the intersection density is determined based on a ratio of a sequence length of the second page number intersection sequence and a sequence length of the second candidate page number sequence; the preset requirements include that the intersection density is greater than a preset threshold and the sequence length is a maximum value among all the second candidate page number sequences;
[0021] If no second candidate page number sequence meets the preset requirements, the first candidate page number sequence is taken as the table of contents page number range of the PDF document.
[0022] In an embodiment, based on the image of each table of contents page and the to-be-processed data set corresponding to the table of contents page, the step of extracting the hierarchical relationship of each title data in the table of contents page and constructing the table of contents tree includes:
[0023] For each to-be-processed data set corresponding to a table of contents page, the to-be-processed data set is input into a language-based table of contents structure extraction model to obtain a first table of contents hierarchical extraction result of the table of contents page;
[0024] For each table of contents page of a PDF document, the table of contents page of the PDF document is converted into a picture and input into a visual-based table of contents structure extraction model to obtain a second table of contents hierarchical extraction result of the table of contents page;
[0025] Based on the first table of contents hierarchical extraction result and the second table of contents hierarchical extraction result of the table of contents page, a table of contents tree is constructed.
[0026] In an embodiment, the step of matching the title data of the table of contents page and the title data of the non-table of contents page based on the semantic similarity and the text similarity between the title data of the table of contents page and the title data of the non-table of contents page includes:
[0027] The title data of all the table of contents pages and the title data of all the non-table of contents pages are obtained, and a table of contents title list and a text title list are constructed respectively;
[0028] Based on the order of the title data in the table of contents title list, the table of contents title list is sequentially forward traversed, and for the table of contents title data traversed in the table of contents title list, the table of contents title data is sequentially strongly matched with the text title data after the last matched text title data in the text title list until the first text title data meeting the strong matching condition is found or the text title data meeting the strong matching condition is not found; the strong matching condition is determined based on the semantic similarity between the table of contents title data and the text title data, the text similarity between the table of contents title data and the text title data, and a strong matching similarity threshold value;
[0029] After traversing all the directory title data, if there is directory title data that does not match the body title data, the directory title data that does not match the body title data is weakly matched with the unmatched body title data based on a weak matching condition; the weak matching condition is determined based on semantic similarity between the directory title data and the body title data, text similarity between the directory title data and the body title data, and a weak matching similarity threshold value.
[0030] A title data matching table is obtained; each directory title data value in the title data matching table corresponds to at most one body title data, and each body title data appears only once.
[0031] In an embodiment, according to the matching result, the step of filling the content data corresponding to each title node of the directory tree to obtain the structured representation result of the PDF document includes:
[0032] The position information of each body title data in the title data matching table in the to-be-processed data set is determined.
[0033] Based on the position information and the matching relationship between the body title data and the directory title data, the content data is filled corresponding to each title node of the directory tree to obtain the structured representation result of the PDF document.
[0034] In a second aspect, to achieve the above object, the present application further provides a PDF document content processing device, the device comprising:
[0035] An acquisition module is configured to acquire a PDF document, the PDF document comprising at least one page;
[0036] A preprocessing module is configured to preprocess the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document; the to-be-processed data set comprises title data and / or content data;
[0037] A classification module is configured to determine a page type of each page of the PDF document based on images of all the to-be-processed data sets and the pages of the PDF document; the page type comprises a directory page and / or a non-directory page;
[0038] A directory tree construction module is configured to extract a hierarchical structure relationship of each title data in a directory page based on the to-be-processed data set corresponding to the directory page and the image of the directory page, and construct a directory tree; a node structure of the directory tree corresponds to the hierarchical structure of the title data in the directory page.
[0039] The matching module is configured to match the title data of the directory page and the title data of the non-directory page based on semantic similarity and text similarity between the title data of the directory page and the title data of the non-directory page, and fill the content data under each title node of the directory tree according to a matching result, to obtain a structured representation result of the PDF document.
[0040] In a third aspect, to achieve the above object, the present application further provides a PDF document content processing device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the PDF document content processing method.
[0041] In a fourth aspect, to achieve the above object, the present application further provides a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the PDF document content processing method.
[0042] In a fifth aspect, to achieve the above object, the present application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps of the PDF document content processing method.
[0043] The one or more technical solutions provided by the present application have at least the following technical effects:
[0044] The present application combines text recognition and image recognition to determine the page type of a PDF document, extract the directory structure and match the title, so as to accurately correspond the directory page title and the non-directory page title, improve the accuracy of PDF document recognition, and reduce the possibility of problems such as inaccurate chapter division, context fragmentation and semantic mismatch; the multi-layer matching based on semantic similarity and text similarity can ensure the matching accuracy of the directory title and the text title, accurately map the content data to the directory tree node, obtain a structured document representation result, effectively improve the semantic restoration degree and the structured quality of the PDF document, and facilitate subsequent operations such as retrieval, display or knowledge extraction. BRIEF DESCRIPTION OF DRAWINGS
[0045] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the specification.
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the accompanying drawings needed to be used in the embodiments or related art description will be briefly introduced. Obviously, those skilled in the art can obtain other drawings according to these drawings without any creative effort.
[0047] Figure 1 A flowchart of a PDF document content processing method in the embodiments of the present application is shown.
[0048] Figure 2 A module connection diagram of a PDF document content processing device is shown.
[0049] Figure 3 A structure diagram of a PDF document content processing device is shown.
[0050] The purposes, functional features and advantages of the present application will be further explained in combination with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0051] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application, and are not used to limit the present application.
[0052] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and specific embodiments.
[0053] The main solution of the embodiments of the present application is: by preprocessing the PDF document, combining language and visual models to recognize and fuse the page type, directory structure and title content, first constructing a directory tree corresponding to the directory page level, then realizing accurate matching of directory title and body title based on semantic similarity and text similarity, and filling the body content to the corresponding directory node, so as to obtain a structured PDF document representation with complete semantics and clear hierarchy.
[0054] Specifically, the embodiments of the present application provide a PDF document content processing method, referring to Figure 1 , Figure 1 A flowchart of the first embodiment of the PDF document content processing method of the present application is shown.
[0055] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a PDF document content processing device, etc. capable of realizing the above functions. The present embodiment and the following embodiments will be described taking the PDF document content processing device as an example.
[0056] In the present embodiment, the PDF document content processing method comprises steps S10-S50:
[0057] Step S10, acquiring a PDF document.
[0058] Step S20, pre-processing the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document. The to-be-processed data set includes title data and / or content data.
[0059] It should be noted that the PDF document includes at least one page, and step S20 is to pre-process each page of the PDF document to obtain a corresponding to-be-processed data set, that is, one page corresponds to one to-be-processed data set. The title data can be a title item in a table of contents page or a title item in a non-table of contents page, and the content data represents that the data is a non-title item. Exemplarily, the to-be-processed data set can use a flag bit to mark the data belonging to the title item, so as to distinguish the title data and the text data.
[0060] In a feasible implementation, step S20 can include steps A10-A20.
[0061] Step A10, using a PDF parsing tool to perform parsing processing on the PDF document to obtain an analyzable to-be-processed object set; each object element in the to-be-processed object set includes text information, type marking and page number information.
[0062] Step A20, merging object elements with the same page number information into one to-be-processed data set.
[0063] In an example, the currently open source PDF parsing tool (for example, the open source framework MinerU) can be used to perform parsing processing on the PDF document to obtain a to-be-processed object set in a json format, which is represented as:
[0064]
[0065]
[0066]
[0067] In the object element, text is text information, which represents the text content of the object element, " is type marking, ":1 indicates that the object element belongs to a title level, and does not contain " indicates that the object element does not belong to the title level, is page number information, which represents the page number of the PDF document where the object element is located.
[0068] Further, object elements with the same are merged to form a to-be-processed data set.
[0069] Step S30, determining the page type of each page of the PDF document based on all the to-be-processed data sets and the images of the pages of the PDF document; the page type includes a table of contents page and / or a non-table of contents page.
[0070] It should be noted that this step is to identify the page type of each page of the processed PDF document, because in the main steps of this embodiment, the title data of the table of contents page and the non-table of contents page need to be matched. Therefore, the effect is best when processing a PDF document containing a table of contents page, and it can be understood that the processed PDF document can also not contain a table of contents page, which does not affect the implementation of this step.
[0071] Specifically, this step identifies the page type of each page of the PDF document in combination with the to-be-processed data set corresponding to each page of the PDF document and the image of each page. In a feasible implementation manner, step S30 can include steps B10-B30.
[0072] Step B10, sorting the to-be-processed data sets according to the page number, for each to-be-processed data set, taking the to-be-processed data set and the previous and subsequent to-be-processed data sets of the to-be-processed data set as a to-be-identified data group, inputting the to-be-identified data group into a language-based page identification model, and obtaining a first page type of the current page in the to-be-identified data group.
[0073] Among them, the to-be-processed data set is marked as the current page, the previous to-be-processed data set of the to-be-processed data set is marked as the previous page, and the subsequent to-be-processed data set of the to-be-processed data set is marked as the next page.
[0074] Step B20, after converting all the pages of the PDF document into images, inputting the images into a visual page identification model, and obtaining a second page type of all the to-be-identified images.
[0075] Step B30, determining the page type of each page of the PDF document based on the first page type and the second page type.
[0076] Among them, step B30 includes steps B31-B36.
[0077] Step B31, determining a first table of contents page number sequence based on the first page type and determining a second table of contents page number sequence based on the second page type.
[0078] Step B32, taking the union of the first table of contents page number sequence and the second table of contents page number sequence, and taking the longest continuous page number sequence in the union as a first candidate page number sequence.
[0079] Step B33, taking the intersection of the first table of contents page number sequence and the second table of contents page number sequence to obtain a first page number intersection sequence, and performing continuous interval extraction on the first page number intersection sequence to obtain at least one second candidate page number sequence.
[0080] Step B34, for each second candidate page number sequence, taking the intersection of the second candidate page number sequence and the first page number intersection sequence to obtain a second page number intersection sequence.
[0081] Step B35, selecting a second candidate page number sequence meeting preset requirements from all second candidate page number sequences as the directory page page number range of the PDF document; the intersection density is determined based on the ratio of the sequence length of the second page number intersection sequence and the sequence length of the second candidate page number sequence; the preset requirements include that the intersection density is greater than a preset threshold and the sequence length is the maximum value among all second candidate page number sequences.
[0082] Step B36, if no second candidate page number sequence meets the preset requirements, taking the first candidate page number sequence as the directory page page number range of the PDF document.
[0083] Specifically, in order to realize accurate recognition of the page type of the PDF document, the embodiment performs page type recognition based on the text data of the to-be-processed data set through the language-based page recognition model, and then performs page type recognition through the visual-based page recognition model, and finally determines the page type of each page of the PDF document according to the recognition results of the visual-based page recognition model and the language-based page recognition model through a fusion algorithm. It should be noted that the input of the language-based page recognition model is the to-be-processed data set corresponding to the current page, the previous page and the next page, and the output is the page type recognition result (first page type) of the current page and the confidence. The input of the visual-based page recognition model is the picture of any to-be-processed data set, and the output is the page type recognition result (second page type) of the to-be-processed data set and the confidence. The language-based page recognition model can be a general large language model (LLM, Large Language Model), and the visual-based page recognition model can be a general visual language model (VLM, Vison Language Model). The output of the confidence is helpful to avoid the occurrence of model hallucination.
[0084] Exemplarily, all to-be-processed data sets in the to-be-processed data set are sorted according to the page number information Step B34, for each second candidate page number sequence, taking the intersection of the second candidate page number sequence and the first page number intersection sequence to obtain a second page number intersection sequence.
[0085]
[0086] Wherein, represents the to-be-processed data set of the current page, represents the to-be-processed data set of the previous page of the current page, The next page pending data set represents the current page, type represents the page type of the current page, and score represents the confidence score of the language class page recognition model (first confidence information).
[0087] Subsequently, each page of the PDF document is converted into an image, combined with the prompt word, and sequentially input into the visual class page recognition model to recognize the page type of each page to obtain a second page type. For ease of understanding, it can be represented as:
[0088]
[0089] wherein, represents the image of the current page, type represents the page type of the page, and score represents the confidence score of the visual class page recognition model (second confidence score).
[0090] Subsequently, according to the first page type and the second page type, the page type of each page is determined. Specifically, according to the first page type, the page number of the table of contents page in the PDF document is determined as the first table of contents page number sequence LLM_pages, and according to the second page type, the page number of the table of contents page in the PDF document is determined as the second table of contents page number sequence VLM_pages. The first table of contents page number sequence and the second table of contents page number sequence are merged as merge_pages, and the longest continuous page number sequence in the merge set is taken as the first candidate page number sequence r_longest.
[0091] Subsequently, the first table of contents page number sequence LLM_pages and the second table of contents page number sequence VLM_pages are taken as the first intersection sequence , and the first intersection sequence is subjected to continuous interval extraction (in this example, if the page number interval gap between two adjacent page numbers in the page number sequence does not exceed 1, it is considered that the two page numbers are continuous), and at least one second candidate page number sequence r is obtained.
[0092] For each second candidate page number sequence r, the second candidate page number sequence and the first page number intersection sequence are taken as the second page number intersection sequence, and according to the sequence length of the second page number intersection sequence and the sequence length of the second candidate page number sequence, the intersection density ratio of the second candidate page number sequence is determined. For ease of understanding, the calculation method of the intersection density ratio is as follows:
[0093]
[0094] wherein, represents the sequence length of the second page number intersection sequence, a sequence length of the second candidate page number sequence r.
[0095] According to the intersection density and the sequence length of each second candidate page number sequence r, a second candidate page number sequence r that meets the condition is determined from all the second candidate page number sequences as the directory page number range of the pdf document. The judgment condition is that the intersection density of the second candidate page number sequence r is greater than a preset threshold and the sequence length is the longest among all the second candidate page number sequences r.
[0096] If there is no second candidate page number sequence r that meets the requirement, the first candidate page number sequence is taken as the directory page number range of the pdf document.
[0097] It can be understood that the language class model (based on text sequence features) and the visual class model (based on page image features) are used simultaneously to preliminarily identify the PDF page type, and the results of the two are combined through the intersection density, which avoids misjudgment of a single model, improves the accuracy of the directory page identification, and further ensures that the identified directory page number range is continuous, reasonable, and consistent with the actual structure of the document, so as to correctly divide the directory page and the non-directory page.
[0098] In step S40, the hierarchical structure relationship of each title data in the directory page is extracted based on the image of the directory page and the corresponding to-be-processed data set of the directory page, and a directory tree is constructed.
[0099] It should be noted that the node structure of the directory tree corresponds to the hierarchical structure of the title data in the directory page.
[0100] Exemplarily, the directory tree adopts a tree hierarchical structure, takes the whole PDF document as a root node, and connects each directory title as a child node level by level, the parent-child relationship between the nodes corresponds to the hierarchical relationship of the directory titles; the title nodes at the same level exist as sibling nodes side by side, and the title nodes at different levels are expanded level by level according to the hierarchical relationship, thereby forming a tree structure that gradually progresses from a general title to a chapter, then to a section, an item, and the like, which can completely reflect the hierarchy and organization logic of the directory in the PDF document.
[0101] The directory tree construction in the related art is usually constructed according to the indentation, numbering and other characteristics of the title nodes at different levels. In order to construct more accurately, the embodiment provides a construction method based on the text information and image information of each directory page. In a feasible implementation manner, step S40 includes steps C10-C30.
[0102] In step C10, for each to-be-processed data set corresponding to a directory page, the to-be-processed data set is input into a language class directory structure extraction model to obtain a first directory hierarchical extraction result of the directory page.
[0103] Step C20, for the table of contents page of each PDF document, convert the table of contents page of the PDF document into a picture input into a visual category directory structure extraction model to obtain a second directory level extraction result of the table of contents page.
[0104] Step C30, based on the first directory level extraction result and the second directory level extraction result of the table of contents page, construct the directory tree.
[0105] It should be noted that the language category directory structure extraction model can be a general large language model (LLM, Large Language Model), and the visual category directory structure extraction model can be a general visual language model (VLM, Vison Language Model).
[0106] Exemplarily, first, it is judged whether the title data in the to-be-processed data set exists certain directory rules such as “Chapter 1”, “Section 1”, “Module 1” and the like. If yes, the to-be-processed data set is textually segmented according to the directory rules, and then input into the language category directory structure extraction model to extract the hierarchical structure relationship in each segmented part in cooperation with the prompt word. If no, the to-be-processed data set is directly input into the language category directory structure extraction model in cooperation with the prompt word for extraction to obtain the first directory level extraction result.
[0107] The table of contents page of the pdf document is converted into a picture page and sent into the visual category directory structure extraction model, and the hierarchical structure relationship of each title in the directory is extracted in cooperation with the prompt word to obtain the second directory level extraction result.
[0108] Finally, based on the first directory level extraction result and the second directory level extraction result of the table of contents page, the directory tree is constructed. In this example, the way to construct the directory tree can be that the first directory level extraction result and the second directory level extraction result are combined with the prompt word and input into the language large model again to realize fusion processing of the first directory level extraction result and the second directory level extraction result, prevent information loss, obtain the final directory level structure, and construct the directory tree.
[0109] It can be understood that in this example, the extraction of the directory level relationship simultaneously depends on the text model and the visual model, not only considers the hierarchical information of the table of contents page title text, but also considers the visual layout features of the pdf document
[0110] The error rate of hierarchical extraction in a single mode is reduced by using a dual-modal fusion mode, and the directory tree structure obtained is closer to the real structure of the document, thereby enhancing the accuracy of subsequent content organization.
[0111] Step S50, based on the semantic similarity and the text similarity between the title data of the directory page and the title data of the non-directory page, matching the title data of the directory page and the title data of the non-directory page, according to the matching result, filling the content data to each title node of the directory tree, obtaining the structured representation result of the PDF document.
[0112] It should be noted that, according to the text similarity and the semantic similarity between the non-directory page title data and the directory page title data, the directory title is matched with the title (text title) in the non-directory page to obtain the complete PDF structured representation result. The text similarity refers to the similarity of the title data at the character level, and the semantic similarity refers to the similarity of the title data at the semantic level.
[0113] In a feasible implementation, steps D10-D60 in step S50:
[0114] Step D10, obtaining the title data of all directory pages and the title data of all non-directory pages, and constructing a directory title list and a text title list respectively.
[0115] Step D20, taking the order of the title data in the directory title list as a reference, sequentially traversing the directory title list forward, and sequentially performing strong matching between the directory title data traversed in the directory title list and the text title data after the last matched text title data in the text title list until the first text title data meeting the strong matching condition is found or the text title data meeting the strong matching condition is not found; the strong matching condition is determined based on the semantic similarity between the directory title data and the text title data, the text similarity between the directory title data and the text title data, and a strong matching similarity threshold.
[0116] Step D30, after traversing all the directory title data, if there is directory title data that is not matched with text title data, based on the weak matching condition, weakly matching the directory title data that is not matched with text title data with the text title data that is not matched; the weak matching condition is determined based on the semantic similarity between the directory title data and the text title data, the text similarity between the directory title data and the text title data, and a weak matching similarity threshold.
[0117] Step D30 further includes step D31:
[0118] If there is catalog title data that does not match the text title data, the text title data matched by the catalog title data closest to the catalog title data that does not match the text title data before is the upper bound, and the text title data matched by the catalog title data closest to the catalog title data that does not match the text title data after is the lower bound, and the catalog title data that does not match the text title data is weakly matched with the text title data between the upper bound and the lower bound.
[0119] In step D40, a title data matching table is obtained. Each catalog title data value in the title data matching table corresponds to at most one text title data, and each text title data appears only once.
[0120] Specifically, to achieve accurate alignment between catalog titles and text titles, the embodiment combines semantic similarity and text similarity, adopts a double-scoring mechanism, is supplemented by a strong-weak matching hierarchical strategy, and introduces a forward-only constraint on the matching path to ensure the stability and semantic consistency of the matching result. The algorithm is suitable for multi-level and structured document structure analysis tasks, and is particularly suitable for catalog-driven text structure restoration scenarios.
[0121] For ease of understanding, exemplary, first, a catalog title list (catalog_titles) and a text title list (content_titles) are constructed.
[0122] Based on the arrangement order of the catalog title data in the catalog title list, all catalog title data is traversed in a forward-only manner, and for the catalog title data being traversed, strong matching is performed with the text title data after the last matched text title data in turn until the first text title data meeting the strong matching condition is found or not. It can be understood that, to ensure the order consistency, the arrangement order of the catalog title data is consistent with the order of the titles in the catalog page, and the matching order of the catalog title data and the text title data is consistent with the arrangement order of the titles in the text.
[0123] In this example, whether the strong matching condition is met between the catalog title data and the text title data can be determined by the following steps:
[0124] The text similarity and the semantic similarity of the catalog title data being traversed and the text title data to be matched are determined. Based on the text similarity and the semantic similarity, a fused similarity is determined. If the fused similarity is not less than a preset similarity threshold, the strong matching condition is met between the catalog title data being traversed and the text title data to be matched.
[0125] The semantic similarity is determined by using a cosine similarity algorithm, and the text similarity is determined by using a text ranking comparison algorithm.
[0126] Specifically, an Embedding model can be used to represent each title text in the list to obtain text semantic information of the title. In this example, the Embedding model uses a gte-qwen model:
[0127]
[0128]
[0129] The calculation method of the semantic similarity can be:
[0130]
[0131]
[0132] wherein, represents text semantic information of the i-th directory title data being traversed, represents text semantic information of the j-th article title data in the article title list.
[0133] The calculation method of the text similarity can be:
[0134] For the directory title data being traversed and the article title data being matched with the directory title data, spaces in the directory title data and the article title data are removed.
[0135] Based on the minimum editing operation number between the directory title data and the article title data, an editing score between the directory title data and the article title data is determined.
[0136] The editing score is normalized to obtain the text similarity of the directory title data and the article title data.
[0137] For ease of understanding, the calculation method can be represented as:
[0138]
[0139] wherein, represents the directory title data after removing spaces, represents the article title data after removing spaces, () represents a minimum editing operation number calculation function.
[0140] It can be understood that removing the spaces before and after the directory title data and the text title data can avoid the decrease of the matching degree caused by the format problem. The minimum edit operation number represents the minimum edit operation number (insertion, deletion, replacement) required to convert all characters of the directory title data into all characters of the text title data. After normalizing the minimum operation number to the 0-1 interval, the text similarity can be obtained.
[0141] The text similarity and the semantic similarity are combined to form a weighted fusion score fusion_score. The calculation method of the fusion score is as follows:
[0142]
[0143] The weight factor alpha represents the weight factor of the semantic similarity, and the weight factor beta represents the weight factor of the text similarity.
[0144] If the fusion score fusion_score is not less than a set similarity threshold similarity_threshold, it is considered that the two titles (for example, the i th directory title data and the j th text title data) meet the strong matching condition, and they are added to the title data matching table alignment.
[0145]
[0146] i The directory title index of the i th directory title data that is traversed is represented by i, and the matching subscript of the text title data matched with the i th directory title data is represented by j.
[0147] Further, for the convenience of finding the directory title data that is not matched to the text title data, if the current directory title data is not matched to the text title data, the content_idx is set to j+1. The matching subscript of the directory title data in the table is marked as -1: .
[0148] If the j th text title data in the text title list is the latest matched text title data, the j+1 th text title data in the text title list is used to find the text title data matched with the next directory title data in the directory title list. In this example, the implementation method can be as follows: a pointer variable content_idx is set, which points to the first text title data allowed to be matched with the current directory title data. If the current directory title data is matched, the pointer is pointed to the next title data of the text title data matched with the current directory title data, so as to ensure that the next matching is only performed with the subsequent text title.
[0149] After the traversal is completed, find the directory title data that is not matched to the body title data (i.e. the directory title data with index -1 in the table), if exists, weakly match the directory title data that is not matched to the body title data with the body title data that is not matched based on the weak matching condition. In this example, the weak matching is performed in the following way:
[0150] For the weak matching, based on the strong matching that has traversed the directory title list, determine the unmatched directory title index unmatched_indices from the preliminary title data matching table alignment.
[0151] According to the directory title index, determine the unmatched directory title data, for each unmatched directory title data, determine its matching range, which is calculated by the body title data matched by its previous matched directory title data (as upper bound prev_match) and the body title data matched by its next matched directory title data (as lower bound next_match). The upper and lower bounds limit the range of the body title data that can be matched in the weak matching stage (i.e. only the body title data between the body title data matched by the previous matched directory title data and the body title data matched by the next matched directory title data can be searched for the body title data that satisfies the weak matching condition).
[0152] Within the determined upper and lower bounds, recalculate the semantic similarity and text similarity between the unmatched directory title and the body title, and try to find a suitable match by adjusting the similarity threshold (decrease similarity_threshold) for a more relaxed matching. Through this strategy, it is possible to find a suitable match under the condition of allowing a lower similarity, ensuring that the body title that has been paired will not be matched repeatedly in the weak matching process, avoiding false matching. Based on the strong matching and the weak matching, each directory title data value in the final title data matching table alignment corresponds to at most one body title data and each body title data appears only once.
[0153] Step D50, determine the position information of each body title data in the title data matching table in the data set to be processed.
[0154] Step D60, based on the position information and the matching relationship between the body title data and the directory title data, fill the content data to each title node of the directory tree to obtain the structured representation result of the PDF document.
[0155] The embodiment realizes the final pdf document structured representation by the step D50~step D60, forms the nested structure with the PDF document as the root node and each chapter as the sub node. Specifically, the title data matching table alignment reflects the matching relationship between the directory title and the text title, and according to each matching relationship, the text title and the content data corresponding to the text title can be filled back to each directory title node in the directory tree structure.
[0156] Exemplarily, the content data corresponding to the text title can be determined by the following way:
[0157] For each to-be-processed data set, according to the type mark "the position of the title item in the to-be-processed data set is determined, the content data (not including the data of the type mark) between the adjacent two title items is classified under the first title item, and for the adjacent two to-be-processed data sets, if there is content data in front of the first title item in the latter to-be-processed data set, the content data is classified under the last title item of the former to-be-processed data set. For the convenience of understanding, the data set after the classification of the title item can be represented as:
[0158]
[0159]
[0160]
[0161] Wherein, the title field represents the title item; the datalist represents the content data under the title, and the page_idx represents the page code range of the title item and the content data corresponding thereto in the pdf document.
[0162] In this example, according to The way to determine the structured representation result of the PDF document can be: reading the text title item from , removing spaces and cleaning white spaces of the text title item to ensure the uniformity and comparability of the title. The title chapter range mapping generation step is performed, according to the page code range, the binary tuple composed of the start page and the end page of each text title item is taken as the key (start, end), and the corresponding text title text is taken as the value, which is written into the section range mapping (section_map)
[0163] The corresponding relationship between the text title item and the page range (start page, end page) is extracted from the section_map, and the reverse index of the title to multiple page ranges is established to support the case that the same title appears multiple times in the document.
[0164] A title use counter is set to record the number of times the same title has been assigned, and the title is matched with the directory title in order from low to high according to the page range, to avoid repeated matching of the same text title.
[0165] The nested JSON structure with the PDF document as the root node and each chapter as a sub-node is output, the original semantic hierarchical relationship of the document is retained, and subsequent retrieval, display and knowledge extraction are facilitated.
[0166] It can be understood that, by introducing the dual recognition mechanism of the language model and the visual model, the embodiment can not only accurately extract the directory structure and title information in the PDF document from the text feature dimension, but also can combine visual features such as layout, font style and position relationship to realize accurate differentiation of the directory page and the text page, thereby avoiding directory recognition errors caused by complex document layout or OCR recognition errors and improving recognition accuracy. Secondly, in the matching stage of the directory and the text, a dual calculation strategy of semantic similarity and text similarity is adopted, and a sequential forward traversal and a strong-weak matching mode are combined, so that the directory title can be accurately matched with the text title, effectively overcoming the problems of mismatch and missing match that are prone to occur in the traditional page number or rule matching method, and ensuring the integrity and correctness of the document structure hierarchical relationship. Thirdly, the text content is filled into the directory tree node that has been constructed according to the matching relationship, and the document is realized to be semantically complete and hierarchically clear, so that the chapter division is more accurate, and the efficiency and reliability of subsequent content retrieval, knowledge extraction and semantic analysis are improved. In summary, the embodiment can provide a structured processing scheme that takes into account accuracy and practicality when facing diversified and complex PDF documents, and fundamentally solves the deficiencies of the prior art in document semantic restoration, chapter organization and knowledge utilization.
[0167] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the PDF document content processing method of the present application. More forms of simple transformation based on this technical concept are within the protection scope of the present application.
[0168] The present application also provides a PDF document content processing device, please refer to Figure 2 The PDF document content processing device comprises:
[0169] The acquisition module 10 is configured to acquire a PDF document, and the PDF document comprises at least one page;
[0170] The preprocessing module 20 is configured to preprocess the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document; the to-be-processed data set comprises title data and / or content data;
[0171] The classification module 30 is configured to determine a page type of each page of the PDF document based on all the to-be-processed data sets and the image of each page of the PDF document, wherein the page type comprises a table of contents page and / or a non-table of contents page.
[0172] The directory tree construction module 40 is configured to extract a hierarchical relationship of each title data in the table of contents page based on the to-be-processed data set corresponding to each table of contents page and the image of the table of contents page, and construct a directory tree, wherein a node structure of the directory tree corresponds to the hierarchical relationship of the title data in the table of contents page.
[0173] The matching module 50 is configured to match the title data of the table of contents page and the title data of the non-table of contents page based on semantic similarity and text similarity between the title data of the table of contents page and the title data of the non-table of contents page, and fill the content data corresponding to each title node of the directory tree according to a matching result, to obtain a structured representation result of the PDF document.
[0174] The PDF document content processing device provided in the present application adopts the PDF document content processing method in the above embodiments, and can solve the technical problem of inaccurate chapter division in the related art in PDF document content processing. Compared with the related art, the PDF document content processing device provided in the present application has the same beneficial effects as the PDF document content processing method provided in the above embodiments, and other technical features in the PDF document content processing device are the same as the features disclosed in the above embodiments, which will not be repeated here.
[0175] The present application provides a PDF document content processing device, which comprises at least one processor and a memory connected with the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the PDF document content processing method in the above embodiments.
[0176] Reference will be made to the following description of the embodiments of the present application with reference to the drawings. Figure 3 The PDF document content processing device in the embodiments of the present application can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistant), PADs (Portable Application Description), PMPs (Portable Media Player), vehicle-mounted terminals (for example, vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. Figure 3The illustrated PDF document content processing device is merely an example and should not bring any limitation to the function and scope of use of the embodiments of the present application.
[0177] As shown in Figure 3 The PDF document content processing device can include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in a read only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. In the RAM 1004, various programs and data required for the operation of the PDF document content processing device are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; the storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the PDF document content processing device to communicate with other devices wirelessly or by wire to exchange data. Although the PDF document content processing device having various systems is illustrated in the figure, it should be understood that all of the illustrated systems are not required to be implemented or provided. More or less systems can be alternatively implemented or provided.
[0178] In particular, according to the embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, the embodiments of the present application include a computer program product including a computer program carried on a computer readable medium, the computer program containing program codes for executing the methods illustrated in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of the embodiments of the present application are performed.
[0179] The PDF document content processing device provided in the application adopts the PDF document content processing method in the above embodiments, and can solve the technical problem of inaccurate chapter division in PDF document content processing in the related art. Compared with the related art, the PDF document content processing device provided in the application has the same beneficial effects as the PDF document content processing method provided in the above embodiments, and other technical features in the PDF document content processing device are the same as the features disclosed in the previous embodiment method, which will not be described here.
[0180] It should be understood that parts of the present application can be realized by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0181] The above is merely specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0182] The present application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e. computer programs) for performing the PDF document content processing method in the above embodiments.
[0183] The computer readable storage medium provided in the application may be, for example, a U disk, but is not limited to an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination of the above. More specific examples of the computer readable storage medium may include, but are not limited to, an electric connection with one or more conductive 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 embodiment, the 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, system, or device. The program code contained on the computer readable storage medium can be transmitted by any suitable medium, including but not limited to an electric wire, an optical cable, an RF (Radio Frequency), and the like, or any suitable combination of the above.
[0184] The computer readable storage medium described above may be contained in the PDF document content processing device, or may exist separately and not be assembled into the PDF document content processing device.
[0185] The computer readable storage medium described above carries one or more programs, when the one or more programs are executed by the PDF document content processing device, the PDF document content processing device: acquires a PDF document, the PDF document containing at least one page; pre-processes the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document; the to-be-processed data set includes title data and / or content data; determines the page type of each page of the PDF document based on all to-be-processed data sets and the image of each page of the PDF document; the page type includes a table of contents page and / or a non-table of contents page; based on the to-be-processed data set corresponding to each table of contents page and the image of the table of contents page, extracts the hierarchical relationship of each title data in the table of contents page, constructs a table of contents tree, and the node structure of the table of contents tree corresponds to the hierarchical structure of the title data in the table of contents page; based on the semantic similarity and the text similarity between the title data of the table of contents page and the title data of the non-table of contents page, the title data of the table of contents page and the title data of the non-table of contents page are matched, according to the matching result, the content data is filled into each title node of the table of contents tree, and the structured representation result of the PDF document is obtained.
[0186] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0187] The flow diagrams and the block diagrams in the drawings are meant as possible implementations of systems, methods, and computer program products according to various embodiments of the application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flow diagrams, and combinations thereof, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0188] The modules involved in the embodiments of the present application can be implemented in software or hardware. In some cases, the names of the modules do not constitute a limitation on the modules themselves.
[0189] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e., computer programs) for executing the above-mentioned PDF document content processing method, and can solve the technical problem of inaccurate chapter division in PDF document content processing in the related art. Compared with the related art, the computer readable storage medium provided by the present application has the same beneficial effects as the PDF document content processing method provided by the above-mentioned embodiments, which will not be described here.
[0190] The application further provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the PDF document content processing method as described above.
[0191] The computer program product provided by the application can solve the technical problem of inaccurate chapter division in the related art in PDF document content processing. Compared with the related art, the beneficial effects of the computer program product provided by the application are the same as those of the PDF document content processing method provided by the above-described embodiments, and are not described here.
[0192] The above is only some embodiments of the application, and does not limit the patent scope of the application. Any equivalent structural transformation made by using the content of the specification and drawings, or direct / indirect application in other related technical fields under the technical concept of the application is included in the patent protection scope of the application.
Claims
1. A method of processing content of a PDF document, characterized by, The method comprises: acquiring a PDF document, the PDF document comprising at least one page; preprocessing the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document; the to-be-processed data set comprising title data and / or content data; determining the page type of each page of the PDF document based on all the to-be-processed data sets and the images of the pages of the PDF document; the page type comprising a table of contents page and / or a non-table of contents page; extracting the hierarchical relationship of each title data in the table of contents page based on the to-be-processed data set corresponding to each table of contents page and the image of the table of contents page, constructing a table of contents tree, the node structure of the table of contents tree corresponding to the hierarchical structure of the title data in the table of contents page; matching the title data of the table of contents page and the title data of the non-table of contents page based on the semantic similarity and the text similarity between the title data of the table of contents page and the title data of the non-table of contents page, and filling the content data corresponding to each title node of the table of contents tree according to the matching result to obtain a structured representation result of the PDF document; the step of extracting the hierarchical relationship of each title data in the table of contents page based on the to-be-processed data set corresponding to each table of contents page and the image of the table of contents page, and constructing a table of contents tree comprises: for each to-be-processed data set corresponding to a table of contents page, inputting the to-be-processed data set into a language-based table of contents structure extraction model to obtain a first table of contents hierarchical extraction result of the table of contents page; for each table of contents page of a PDF document, converting the table of contents page of the PDF document into an image and inputting the image into a visual-based table of contents structure extraction model to obtain a second table of contents hierarchical extraction result of the table of contents page; constructing the table of contents tree based on the first table of contents hierarchical extraction result and the second table of contents hierarchical extraction result of the table of contents page; the step of constructing the table of contents tree based on the first table of contents hierarchical extraction result and the second table of contents hierarchical extraction result of the table of contents page comprises: inputting the first table of contents hierarchical extraction result and the second table of contents hierarchical extraction result combined with a prompt word into a language-based large model again to obtain a final table of contents hierarchical structure and construct a table of contents tree; the step of matching the title data of the table of contents page and the title data of the non-table of contents page based on the semantic similarity and the text similarity between the title data of the table of contents page and the title data of the non-table of contents page comprises: acquiring the title data of all the table of contents pages and the title data of all the non-table of contents pages, and constructing a table of contents title list and a main text title list, respectively; The strong matching is sequentially performed between the catalog title data and the text title data after the last matched text title data in the text title list according to the order of the title data in the catalog title list until the first text title data meeting the strong matching condition is found or no text title data meeting the strong matching condition is found; the strong matching condition is determined based on semantic similarity between the catalog title data and the text title data, text similarity between the catalog title data and the text title data, and a strong matching similarity threshold value; After all the catalog title data is traversed, if there is catalog title data that is not matched to text title data, the catalog title data that is not matched to text title data is weakly matched to the text title data that is not matched based on a weak matching condition; the weak matching condition is determined based on semantic similarity between the catalog title data and the text title data, text similarity between the catalog title data and the text title data, and a weak matching similarity threshold value; A title data matching table is obtained; each catalog title data in the title data matching table corresponds to at most one text title data, and each text title data appears only once; The step of weak matching comprises: For weak matching, the un-matched catalog title index is determined from the preliminary title data matching table on the basis that strong matching has traversed the catalog title list; According to the catalog title index, the un-matched catalog title data is determined, and for each un-matched catalog title data, the matching range thereof is determined, which is calculated by taking the text title data matched by the previous matched catalog title data as the upper bound and the text title data matched by the next matched catalog title data as the lower bound; Within the determined upper and lower bounds, the semantic similarity and the text similarity between the un-matched catalog title and the text title are recalculated, and weak matching is performed by adjusting the similarity threshold value.
2. The method of claim 1, wherein, The step of determining the page type of each page of the PDF document based on all the to-be-processed data sets and the images of the pages of the PDF document comprises: The to-be-processed data sets are sorted according to the page numbers, for each to-be-processed data set, the to-be-processed data set and the previous and next to-be-processed data sets of the to-be-processed data set are taken as a to-be-recognized data group, and the to-be-recognized data group is input into a language-based page recognition model to obtain a first page type of a current page in the to-be-recognized data group; wherein the to-be-processed data set is marked as the current page, the previous to-be-processed data set of the to-be-processed data set is marked as the previous page, and the next to-be-processed data set of the to-be-processed data set is marked as the next page; After all the pages of the PDF document are converted into images, the images are input into a visual-based page recognition model to obtain a second page type of all the to-be-recognized images; The page type of each page of the PDF document is determined based on the first page type and the second page type.
3. The method of claim 2, wherein, The step of determining the page type of each page of the PDF document based on the first page type and the second page type comprises: determining a first directory page number sequence based on the first page type and a second directory page number sequence based on the second page type; taking a union of the first directory page number sequence and the second directory page number sequence, and taking the longest continuous page number sequence in the union as a first candidate page number sequence; taking an intersection of the first directory page number sequence and the second directory page number sequence to obtain a first page number intersection sequence, and performing continuous interval extraction on the first page number intersection sequence to obtain at least one second candidate page number sequence; for each second candidate page number sequence, taking an intersection of the second candidate page number sequence and the first page number intersection sequence to obtain a second page number intersection sequence; selecting a second candidate page number sequence that meets a preset requirement from all the second candidate page number sequences as the directory page number range of the PDF document; the intersection density is determined based on a ratio of a sequence length of the second page number intersection sequence to a sequence length of the second candidate page number sequence; the preset requirement includes that the intersection density is greater than a preset threshold and the sequence length is the maximum among all the second candidate page number sequences; if no second candidate page number sequence meets the preset requirement, taking the first candidate page number sequence as the directory page number range of the PDF document.
4. The method of claim 1, wherein, The step of filling the content data into each title node of the directory tree according to the matching result to obtain the structured representation result of the PDF document comprises: determining position information of each text title data in the matching table in the to-be-processed data set; based on the position information and the matching relationship between the text title data and the directory title data, filling the content data into each title node of the directory tree to obtain the structured representation result of the PDF document.
5. A PDF document content processing apparatus characterized by comprising: The device comprises: an acquisition module configured to acquire a PDF document, the PDF document comprising at least one page; a preprocessing module configured to preprocess the PDF document to obtain a to-be-processed data set corresponding to each page of the PDF document; the to-be-processed data set comprises title data and / or content data; a classification module configured to determine a page type of each page of the PDF document based on all the to-be-processed data sets and images of the pages of the PDF document; the page type comprises a directory page and / or a non-directory page; a directory tree construction module configured to extract a hierarchical structure relationship of each title data in the directory page based on the to-be-processed data set corresponding to each directory page and an image of the directory page, and construct a directory tree, a node structure of the directory tree corresponding to the hierarchical structure of the title data in the directory page; The matching module is configured to match the title data of the directory page and the title data of the non-directory page based on semantic similarity and text similarity between the title data of the directory page and the title data of the non-directory page, and fill the content data corresponding to the title data of the directory page and the title data of the non-directory page into each title node of the directory tree according to a matching result to obtain a structured representation result of the PDF document. The directory tree construction module is further configured to: For each directory page corresponding to a to-be-processed data set, input the to-be-processed data set into a language-based directory structure extraction model to obtain a first directory level extraction result of the directory page. For each directory page of a PDF document, input the directory page of the PDF document into a visual-based directory structure extraction model as an image to obtain a second directory level extraction result of the directory page. The directory tree is constructed based on the first directory level extraction result and the second directory level extraction result of the directory page. The step of constructing the directory tree based on the first directory level extraction result and the second directory level extraction result of the directory page comprises: The first directory level extraction result and the second directory level extraction result are combined with prompt words and input into a language-based large model again to obtain a final directory level structure, and the directory tree is constructed. The matching module is further configured to: Obtain the title data of all the directory pages and the title data of all the non-directory pages, and construct a directory title list and a text title list, respectively. Based on the order of the title data in the directory title list, sequentially forward traverse the directory title list, and for the directory title data traversed in the directory title list, sequentially perform strong matching with the text title data after the last matched text title data in the text title list until the first text title data meeting the strong matching condition is found or no text title data meeting the strong matching condition is found; the strong matching condition is determined based on semantic similarity between the directory title data and the text title data, text similarity between the directory title data and the text title data, and a strong matching similarity threshold. After traversing all the directory title data, if there is directory title data that is not matched with text title data, weak matching is performed between the directory title data that is not matched with text title data and the text title data that is not matched based on a weak matching condition; the weak matching condition is determined based on semantic similarity between the directory title data and the text title data, text similarity between the directory title data and the text title data, and a weak matching similarity threshold. A title data matching table is obtained; each directory title data in the title data matching table corresponds to at most one text title data, and each text title data appears only once. The step of weak matching comprises: For weak matching, based on the fact that strong matching has traversed the directory title list, the un-matched directory title index is determined from the preliminary title data matching table. According to the directory title index, determine unmatched directory title data, for each unmatched directory title data, determine its matching range, the matching range is calculated by the upper limit of the text title data matched by its previous matched directory title data, and the lower limit of the text title data matched by its next matched directory title data; In the determined upper and lower limits, the semantic similarity and the text similarity between the unmatched directory title and the text title are recalculated, and weak matching is performed by adjusting the similarity threshold.
6. A PDF document content processing device characterized by comprising: The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the PDF document content processing method according to any one of claims 1 to 4.
7. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the PDF document content processing method according to any one of claims 1 to 4.
8. A computer program product, characterised in that, The computer program product comprises a computer program, and the computer program is executed by the processor to implement the steps of the PDF document content processing method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Industrial chain construction method and system
CN117633518A
Document processing method and device, storage medium, terminal and computer program product
CN118313352A
Automatic identification method and device for academic paper directory page, and electronic equipment
CN118411730A
PDF (Portable Document Format) conversion multiplexing method and device, computer equipment and storage medium
CN120373260A
Document searching method and device, electronic equipment and storage medium
CN120508631A