A PDF title identification method, device and equipment and storage medium

CN122693643APending Publication Date: 2026-09-04BEIJING HUAXING TAIJI INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610776670.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-29
Publication Date
2026-09-04

AI Technical Summary

Benefits of technology

[0014]在本申请实施例中,对待处理PDF文档进行解析,得到文本块序列,根据每个文本块中有效字符最多的字号确定各文本块的主导字号,并按字号统计各主导字号在待处理PDF文档中的有效字符数,对各主导字号的有效字符数加权,确定待处理PDF文档的正文基准字号,基于正文基准字号,对文本块序列进行嵌入排除和极短文本排除,得到标题候选文本块,对标题候选文本块进行文本特征提取,得到各个标题候选文本块的文本特征,若目标标题候选文本块的局部字号变化特征或局部字符粗细变化特征满足特征变化条件,且目标标题候选文本块的字符数小于字符数阈值,则将目标标题候选文本块判定为待处理PDF文档的标题。可见,通过有效字符数确定正文基准字号并结合局部字号变化与局部字符粗细变化特征进行标题判定,可以自适应不同PDF文档的字号差异,从而提高PDF标题识别准确率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122693643A_ABST
    Figure CN122693643A_ABST
Patent Text Reader

Abstract

Embodiments of the application disclose a PDF title identification method, device and equipment and a storage medium. The method comprises: parsing a to-be-processed PDF document to obtain a text block sequence, determining a dominant font size of each text block according to the font size of the most effective characters in each text block, and counting the number of effective characters of each dominant font size in the to-be-processed PDF document according to the font size, weighting the number of effective characters of each dominant font size, determining a body reference font size of the to-be-processed PDF document, embedding and excluding the text block sequence based on the body reference font size, and excluding extremely short text to obtain a title candidate text block, extracting text features of the title candidate text block to obtain text features of each title candidate text block, and if a local font size change feature or a local character thickness change feature of a target title candidate text block meets a feature change condition and the number of characters of the target title candidate text block is less than a character threshold, the target title candidate text block is determined as a title of the to-be-processed PDF document.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a PDF title recognition method, a PDF title recognition device, a computer device, and a computer-readable storage medium. Background Technology

[0002] Portable Document Format (PDF) is one of the mainstream formats for electronic document exchange and storage. In applications such as document digitization, knowledge base construction, and Retrieval-Augmented Generation (RAG), structured parsing of PDF documents is required, and title recognition is a fundamental step in this process. How to accurately identify PDF titles without using GPUs and neural networks has become a hot research topic in this field. Summary of the Invention

[0003] This application provides a PDF title recognition method, apparatus, device, and computer-readable storage medium, which can improve the accuracy of PDF title recognition.

[0004] On the one hand, embodiments of this application provide a PDF title recognition method, including: The PDF document to be processed is parsed to obtain a sequence of text blocks in the PDF document. Each text block contains the text content, page number, position coordinates and character-level font attributes of the PDF document to be processed. Based on the font size with the most valid characters in each text block, determine the dominant font size for each text block, and count the number of valid characters for each dominant font size in the PDF document to be processed. Weight the number of valid characters for each dominant font size to determine the base font size for the main text of the PDF document to be processed. Based on the base font size of the main text, the text block sequence is subjected to embedding exclusion and extremely short text exclusion to obtain candidate title text blocks; Text features are extracted from the candidate title text blocks to obtain the text features of each candidate title text block; the text features include local font size variation features and local character thickness variation features; If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition, and the number of characters in the target title candidate text block is less than the character number threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed; the target title candidate text block is any title candidate text block.

[0005] On one hand, embodiments of this application provide a PDF title recognition device, which includes: The parsing unit is used to parse the PDF document to be processed, and obtain a sequence of text blocks of the PDF document to be processed. Each text block contains the text content, page number, position coordinates and character-level font attributes of the PDF document to be processed. The processing unit is used to determine the dominant font size of each text block based on the font size with the most effective characters in each text block, and to count the number of effective characters of each dominant font size in the PDF document to be processed. The effective character counts of each dominant font size are weighted to determine the base font size of the main text of the PDF document to be processed. And it is used to perform embedding exclusion and extremely short text exclusion on text block sequences based on the base font size of the main text to obtain candidate title text blocks; The feature extraction unit is used to extract text features from the candidate title text blocks to obtain the text features of each candidate title text block; the text features include local font size variation features and local character thickness variation features; The processing unit is further configured to determine the target title candidate text block as the title of the PDF document to be processed if the local font size change feature or local character thickness change feature of the target title candidate text block meets the feature change condition and the number of characters in the target title candidate text block is less than the character number threshold; the target title candidate text block is any title candidate text block.

[0006] In one implementation, the processing unit is configured to perform embedding exclusion and extremely short text exclusion on the text block sequence based on the body text reference font size to obtain candidate title text blocks, specifically configured to: If the number of target characters in the preceding and following text blocks of the current text block is greater than the character count threshold, then the style change range between the current text block and the adjacent text blocks is detected; the font size of the target character is the base font size of the body text; the style change range includes the change range of font size and character thickness of the current text block relative to the preceding and following text blocks. If the style change of the current text block and its adjacent text blocks is less than the change threshold, then the current text block is determined as a non-heading candidate text block. Non-title candidate text blocks are embedded and excluded from the text block sequence of the PDF document to be processed to obtain title candidate text blocks.

[0007] In one implementation, the base font size of the main text of the PDF document to be processed is determined based on the dominant font size of each text block, wherein the dominant font size of any text block is the font size with the most valid characters in that text block; the processing unit is further configured to: The system detects the increase in the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks. If the increase in font size exceeds a first increase threshold, the system determines that the local font size change feature of the target title candidate text block satisfies the feature change condition; or... The character thickness increase of the first character in the target title candidate text block compared to the second character in the adjacent text block is detected. If the character thickness increase is greater than the second increase threshold, it is determined that the local character thickness change feature of the target title candidate text block meets the feature change condition. The first character is the character corresponding to the dominant font size of the target title candidate text block, and the second character is the character corresponding to the dominant font size of the adjacent text block.

[0008] In one implementation, the feature extraction unit is used to extract text features from the candidate title text blocks to obtain the text features of each candidate title text block, specifically for: Based on the variation of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks, local font size variation features of the target title candidate text block are generated. Based on the variation in character thickness of the character corresponding to the dominant font size in the target title candidate text block compared to the character corresponding to the dominant font size in the adjacent text block, local character thickness variation features of the target title candidate text block are generated. The text features of the target title candidate text block are obtained by concatenating the local font size variation features and the local character thickness variation features of the target title candidate text block.

[0009] In one implementation, after determining the target title candidate text block as the title of the PDF document to be processed, the processing unit is further configured to: Add the title to the candidate title sequence; If there are two adjacent candidate title text blocks on the same page in the candidate title sequence, and the difference in the vertical coordinate of the text blocks of the two adjacent candidate titles is less than the distance threshold, then the text blocks of the two adjacent candidate titles are determined to belong to the same line. Merge the text blocks of two adjacent candidate titles to obtain a new text block; Title recognition is performed on the new text block.

[0010] In one implementation, the processing unit is configured to perform embedding exclusion and extremely short text exclusion on the text block sequence based on the body text reference font size to obtain candidate title text blocks, specifically configured to: Based on the base font size of the body text of the PDF document to be processed, determine the threshold for the title font size; and based on the character thickness of the characters corresponding to the base font size of the body text, determine the threshold for the title character thickness. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is greater than the title character thickness threshold, and the font size of the characters in the current text block is greater than the title font size threshold, then the current text block is determined as a title candidate text block. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is less than the title character thickness threshold, or the font size of the characters in the current text block is less than the title font size threshold, then the current text block is determined as extremely short text and excluded.

[0011] In one implementation, the processing unit is configured to determine the target title candidate text block as the title of the PDF document to be processed if the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition and the number of characters in the target title candidate text block is less than the character number threshold. Specifically, the processing unit is configured to: Based on the base font size of the body text of the PDF document to be processed, determine the threshold for the title font size; and based on the character thickness of the characters corresponding to the base font size of the body text, determine the threshold for the title character thickness. If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition, and the number of characters in the target title candidate text block is less than the character number threshold, and the target title candidate text block meets the supplementary condition, then the target title candidate text block is determined to be the title of the PDF document to be processed. The supplementary conditions include at least one of the following: R1: If the target title candidate text block contains a serial number, but it is not an independent serial number, the number of characters is within the preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R2: If the target title candidate text block is an independent sequence number, the number of characters does not exceed the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R3: If the target title candidate text block contains strong keywords, the number of characters is not less than the quantity threshold, and the character weight of the characters is greater than the title character weight threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R4: If the target title candidate text block contains preset title keywords, the number of characters is within the preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R5: If the target title candidate text block consists entirely of uppercase English characters, and the number of characters is less than the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R6: If the font size of the characters in the target title candidate text block is greater than the title font size threshold, and the number of characters is within the preset character range, then the target title candidate text block is determined to be the title of the PDF document to be processed. R7: If the character thickness of the characters in the target title candidate text block is greater than the title character thickness threshold, the number of characters is within the preset character range, and there is no sentence-ending punctuation, then the target title candidate text block is determined to be the title of the PDF document to be processed.

[0012] Accordingly, this application provides a computer device comprising: Memory, which stores computer programs; The processor is used to load computer programs to implement the PDF title recognition method described above.

[0013] Accordingly, this application provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the above-described PDF title recognition method.

[0014] In this embodiment, the PDF document to be processed is parsed to obtain a sequence of text blocks. The dominant font size of each text block is determined based on the font size with the most effective characters. The number of effective characters for each dominant font size in the PDF document is then counted. The effective character counts of each dominant font size are weighted to determine the baseline font size for the main text of the PDF document. Based on this baseline font size, the text block sequence is subjected to embedding exclusion and extremely short text exclusion to obtain candidate title text blocks. Text features are extracted from these candidate title text blocks to obtain their text features. If the local font size variation features or local character thickness variation features of the target candidate title text block meet the feature variation conditions, and the number of characters in the target candidate title text block is less than a character count threshold, then the target candidate title text block is determined to be the title of the PDF document. Therefore, by determining the baseline font size of the main text through the number of effective characters and combining it with local font size variation and local character thickness variation features for title determination, the font size differences of different PDF documents can be adapted to, thereby improving the accuracy of PDF title recognition. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 A flowchart illustrating a PDF title recognition method provided in an embodiment of this application; Figure 2 A flowchart illustrating another PDF title recognition method provided in this application embodiment; Figure 3 This is a schematic diagram of the structure of a PDF title recognition device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0017] It should be noted in advance that, in order to enable those skilled in the art to better understand the technical solutions proposed in the embodiments of this application, the embodiments of this application will be described clearly and completely in conjunction with one or more accompanying drawings. Furthermore, the various drawings shown in the embodiments of this application are merely illustrative examples; for example, the execution order of each step in the drawings can be adaptively adjusted according to the actual application scenario. In addition, in the embodiments of this application, the block diagrams shown in the various drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0018] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0019] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0020] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0021] It should be noted that "multiple" in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0022] Please see Figure 1 , Figure 1 This is a flowchart illustrating a PDF title recognition method provided in an embodiment of this application. The method can be applied to computer devices, such as personal computers, servers, or cloud server clusters. The method aims to improve the accuracy of PDF title recognition. Figure 1 As shown, the method may include the following steps S101 to S105.

[0023] S101. Parse the PDF document to be processed to obtain a sequence of text blocks in the PDF document.

[0024] In one implementation, a computer device can parse an input PDF document using a PDF parsing library (such as PDFium, Poppler, etc.). After parsing, a sequence of text blocks in the document is obtained, which can be represented as B={b1, b2, ...,b...} n}. Each text block b i It may include, but is not limited to, the following information: text content (string), page number, bounding box coordinates on the page (e.g., top-left corner coordinates, width, height), character-level font attributes (e.g., font name, font size), and the output order of the text block on the page. By preserving font attributes at the character level, a basis can be provided for distinguishing between body text and headings later.

[0025] Optionally, to reduce errors caused by floating-point precision, the font sizes can be normalized to a granularity of 0.5pt before performing font size statistics; for example, 10.499pt and 10.501pt can be uniformly regarded as 10.5pt.

[0026] S102. Based on the font size with the most valid characters in each text block, determine the dominant font size of each text block, and count the number of valid characters of each dominant font size in the PDF document to be processed. Weight the number of valid characters of each dominant font size to determine the base font size of the main text of the PDF document to be processed.

[0027] This step aims to estimate the font size of the most frequently used body text in the current PDF document (i.e., the base font size for the body text), denoted as f_body.

[0028] In one implementation, after obtaining the text block sequence, this step can be further refined into the following sub-operations: First, for each text block b i The font size distribution of all characters within a text block is analyzed. Considering that a text block may contain multiple font sizes (e.g., a small-sized comment within a paragraph), the font size that appears most frequently in the text block can be taken as the dominant font size f of that block. i For example, if 90% of the characters in a paragraph are 10.5pt and 10% are 9pt, then the dominant font size of that paragraph is 10.5pt.

[0029] Then, count the "effective characters" for each different font size in the entire PDF document. Here, "effective characters" is c. i This refers to the actual number of characters after removing whitespace characters such as spaces and newlines. For a text block b... i Count its effective characters c i Accumulated to the dominant font size f of this block i For the same total number of valid characters FSC(f), it can be specifically expressed as: FSC(f) = SUM c i , where f i =f. This means: for a specific font size f, calculate the sum of the effective character count ci of all text blocks in the entire PDF document whose dominant font size is f.

[0030] Next, the font size f with the largest value of FSC(f) is determined as the baseline font size f_body for the body text. Furthermore, for subsequent title determination, a title font size threshold can be calculated based on f_body. For example, the predicted font size f_hdr for a first-level title can be set to f_body + 2.0pt, and the predicted font size f_hdr_star for a second-level title can be set to f_body + 4.0pt. Similarly, the title character thickness threshold can be calculated based on the average character thickness of the characters corresponding to the baseline font size f_body; for example, if the average character thickness of the characters corresponding to f_body is 1, the title character thickness threshold is 1 + 1.5 = 2.5.

[0031] As mentioned above, the base font size for the main text is derived from the number of valid characters, not the number of times the font size appears in the text block. This avoids being misled by page numbers, headers, or other content during title recognition. For example, font size 1 appears in a paragraph of 500 characters, while font size 2 (such as the page number font size) appears in 20 text blocks, 2 characters each time. If the number of occurrences in the text blocks is counted, font size 2 would be considered the base font size for the main text, which is inconsistent with the actual size.

[0032] As shown above, the two sub-operations, "dominant font size" and "weighted effective character count," effectively eliminate the interference of short character noise from headers, footers, and page numbers on the calculation of the base font size for the main text. An accurate f_body lays a solid foundation for subsequent processing. If f_body is inaccurate, while subsequent judgments based on local comparisons can still be made relatively, an important global reference frame will be lost, leading to decreased robustness when handling complex layouts. In other words, S102 enables this method to adapt to the differences in the base font size of the main text in different PDF documents, avoiding the problem of poor cross-document generalization ability of the fixed threshold method.

[0033] S103. Based on the base font size of the main text, perform embedding exclusion and extremely short text exclusion on the text block sequence to obtain candidate title text blocks.

[0034] After obtaining the base font size for the main text, a preliminary screening is performed to exclude some text blocks from the text block sequence, resulting in candidate title text blocks. This screening process may include, but is not limited to, one or more of the following methods: Method 1: Embedded exclusion.

[0035] If the number of target characters in the preceding and following text blocks of the current text block exceeds a character count threshold, the computer device detects the style variation range between the current text block and its adjacent text blocks. The font size of the target characters is the base font size of the body text, and the style variation range includes the variation range of font size and character weight in the current text block relative to the preceding and following text blocks. If the style variation range between the current text block and its adjacent text blocks is less than the variation range threshold (e.g., the style variation is not significant), the computer device identifies the current text block as a non-title candidate text block and embeds and excludes non-title candidate text blocks from the text block sequence of the PDF document to be processed, obtaining title candidate text blocks.

[0036] In one embodiment, for the current text block b[i], it is determined whether there exists a string in its adjacent text blocks (such as b[i-1] and b[i+1]) with a character count greater than a character count threshold (e.g., 50 characters) and a font size close to or equal to the base font size f_body of the main text. If such a string exists, the style similarity between the current text block b[i] and these adjacent text blocks is checked. Here, "style similarity" can include dimensions such as font size difference, whether it is bold, and whether it is italic. If the style similarity between the current text block and the adjacent text blocks is greater than the similarity threshold (e.g., the font size difference is less than 1.5pt and the bolding status is consistent), then the current text block is considered to be a fragment sandwiched between (long) main text without obvious style jumps.

[0037] In one implementation, the determination formula for non-title candidate text blocks can be expressed as: embed_exclude(b[i])=long(b[i-1]) AND long(b[i+1]) AND NOT style_jump(b[i]). Wherein, style_jump indicates that there is a style difference between the current text block and an adjacent text block (for example, the amplitude of style change is greater than a change amplitude threshold); for example, the dominant font size of the current text block is more than 2pt larger than that of an adjacent text block, or the characters of the current text block are bold while the characters of the adjacent text block are non-bold.

[0038] In combination with practical scenarios, for a bold phrase "key indicators" appearing between two long paragraphs, although it has the bold feature, since both the preceding and following parts are large sections of body text and there is no significant style change, it is more likely to be an emphasizing word in the body text rather than a title. In this case, the text block is determined as a non-title candidate text block and removed from the sequence.

[0039] Mode 2: Text constraint screening.

[0040] The computer device determines a title font size threshold based on the reference font size of the body text of the PDF document to be processed, and determines a title character weight threshold based on the character weight of characters corresponding to the reference font size of the body text. If the number of characters in the current text block is less than or equal to 2, the character weight of characters in the current text block is greater than the title character weight threshold (for example, characters in the current text block are bold), and the font size of characters in the current text block is greater than the title font size threshold, the current text block is determined as a title candidate text block; if the number of characters in the current text block is less than or equal to 2, and the character weight of characters in the current text block is less than the title character weight threshold, or the font size of characters in the current text block is less than the title font size threshold, the current text block is determined as an extremely short text to be excluded.

[0041] In one embodiment, a title font size threshold (for example, f_hdr) and a title character weight threshold (for example, a bold determination value determined based on the regular character weight corresponding to the reference font size of the body text) are determined based on the reference font size of the body text f_body.

[0042] In combination with practical application scenarios, an isolated character "de" (a structural particle in Chinese), even with a large font size, is very likely to be a fragment caused by forced line breaking in PDF rather than a real title, and thus is excluded; while the two characters "Abstract", despite the small number of characters, can still be retained if the font size is large.

[0043] Through one or more of the above screening methods, text blocks determined as non-title candidates are removed from the original text block sequence, so as to obtain a title candidate text block set.

[0044] It's important to note that S103 and S102 work together. The `f_body` provided by S102 can be used as the basis in S103. S103's "embedding exclusion" mechanism can resolve the issue of "bold phrases in the body text being misidentified as titles" in the PDF being processed. It utilizes the contextual relationships of text blocks to filter out a large amount of noise before feature extraction. Meanwhile, "text constraint filtering" addresses the fragmentation problem commonly encountered in PDF parsing by filtering in advance. This coarse filtering effectively reduces the burden on subsequent processing steps and minimizes the adverse effects of noisy text blocks corresponding to candidate titles, allowing title recognition rules to be more focused on text blocks that are truly likely titles, thereby reducing the overall misclassification rate.

[0045] S104. Extract text features from the candidate title text blocks to obtain the text features of each candidate title text block.

[0046] Text features include local font size variation features and local character thickness variation features.

[0047] Local font size variation feature (F_large_local): This feature represents the magnitude of font size variation of the current title candidate text block relative to its adjacent text blocks (such as the preceding and following text blocks). Specifically, it can detect the magnitude of the variation in the dominant font size of the current title candidate text block compared to the dominant font size of its adjacent text blocks (either the preceding or following block, or compared with both sides separately), and use this magnitude of variation as the local font size variation feature of the current title candidate text block.

[0048] Local character thickness variation feature (F_bold_local): This feature represents the variation in stroke thickness (i.e., whether it is bolded) of the current title candidate text block relative to its adjacent text blocks (such as the previous text block and the next text block). Specifically, it can detect the magnitude of the character thickness variation of the dominant font size character in the current candidate block compared to the dominant font size character in the adjacent text blocks, and use this magnitude of variation as the local character thickness variation feature of the current title candidate text block.

[0049] In one implementation, on one hand, the computer device generates local font size variation features of the target title candidate text block based on the variation range of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks. On the other hand, it generates local character thickness variation features of the target title candidate text block based on the variation range of character thickness of the characters corresponding to the dominant font size in the target title candidate text block compared to the characters corresponding to the dominant font size in adjacent text blocks. The computer device then concatenates the local font size variation features and the local character thickness variation features of the target title candidate text block to obtain the text features of the target title candidate text block.

[0050] Optionally, other auxiliary features can be extracted in addition to the two core features described above, for example: global first font size feature (F_large, used to determine whether the font size is greater than f_hdr), global second font size feature (F_large_star, used to determine whether the font size is greater than f_hdr_star), bold flag (F_bold), serial number features (F_num, indicating whether it contains numeric serial numbers; F_num_s, indicating whether it is an independent serial number such as "1."), keyword feature (F_kw, indicating whether it contains preset keywords such as "Abstract", "Conclusion", etc.), capitalization feature (F_upper), character number interval feature (F_mid), extremely short threshold (F_short), maximum font size threshold (F_very), etc. These features can be obtained by matching the content, font attributes of the text block with a preset rule base. In one implementation, the local font size variation feature and the local character thickness variation feature can be vector concatenated to form a richer feature vector for use in subsequent supplementary conditions.

[0051] It can be seen from the above that S104 is a bridge connecting the original data and the advanced judgment logic. It converts the original attributes (font size, bold, etc.) of text blocks into text features with clear physical meanings, and particularly introduces the concept of "local" comparison. This local feature complements the "global" reference font size calculated in S102. The combination of the two enables the method to grasp the document structure macroscopically and identify potential titles microscopically. Compared with the method that only relies on the global font size threshold, this "global + local" feature extraction strategy significantly enhances the adaptability to titles with the same font size and cross-document scenarios.

[0052] S105: If the local font size variation feature or the local character thickness variation feature of the target title candidate text block satisfies the feature variation condition, and the number of characters of the target title candidate text block is less than the character number threshold, then the target title candidate text block is determined as the title of the PDF document to be processed.

[0053] For any title candidate text block, at least one judgment condition is used to determine whether the title candidate text block is a title of the PDF document to be processed.

[0054] In one implementation, the base font size of the main text of the PDF document to be processed is determined based on the dominant font size of each text block, whereby the dominant font size of any text block is the font size with the most effective characters in that text block. The computer device detects the font size increase of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks. If the font size increase is greater than a first increase threshold, then the local font size change feature of the target title candidate text block is determined to meet the feature change condition. Alternatively, the computer device detects the character thickness increase of the first character in the target title candidate text block compared to the second character in the adjacent text block. If the character thickness increase is greater than a second increase threshold, then the local character thickness change feature of the target title candidate text block is determined to meet the feature change condition; wherein, the first character is the character corresponding to the dominant font size of the target title candidate text block, and the second character is the character corresponding to the dominant font size of the adjacent text block.

[0055] In one implementation (which can be considered as an R0 rule), the decision conditions include: Condition 1: At least one of the following features of the target title candidate text block satisfies the feature change condition: either the local font size variation feature (F_large_local) or the local character thickness variation feature (F_bold_local). Simply put, the target title candidate text block either has a significantly larger font size or is significantly bolder compared to adjacent blocks.

[0056] Condition 2: The number of valid characters in the candidate text block for the target title is less than a character threshold (e.g., 20 characters); optionally, a lower limit for the number of characters can also be set (e.g., more than 4 characters) to avoid identifying fragmented content as a title.

[0057] When both of the above conditions are met, the candidate text block for the target title can be determined as the title of the PDF document to be processed. Specifically, it can be represented as: R0 = (F_large_local OR F_bold_local) AND F_mid.

[0058] In another implementation, a set of supplementary conditions can be introduced to cover more header types. These supplementary conditions can be used in conjunction with the R0 rules described above, or as alternative rules when the R0 rules are not met.

[0059] In one embodiment, the computer device determines a title font size threshold based on the reference font size of the body text of the PDF document to be processed, and determines a title character weight threshold based on the character weight of the characters corresponding to the reference font size of the body text. If the local font size change feature or the local character weight change feature of the target candidate title text block satisfies the feature change condition, the number of characters of the target candidate title text block is less than the character number threshold, and the target candidate title text block satisfies the supplementary condition, then the target candidate title text block is determined as the title of the PDF document to be processed. Wherein, the supplementary condition includes at least one of the following: (1) The target candidate title text block contains a sequence number, and the number of characters belongs to a preset number interval.

[0060] (2) The font sizes of all characters in the target candidate title text block are larger than the title font size threshold.

[0061] (3) The character weights of all characters in the target candidate title text block are larger than the title character weight threshold.

[0062] (4) The target candidate title text block contains preset title keywords.

[0063] (5) The target candidate title text block has no end punctuation.

[0064] In one implementation, the supplementary condition includes the following rules: R1: If the target candidate title text block contains a sequence number (such as "1.", "I.") is not in an independent sequence number form, the number of characters is within a preset character interval, and the character weight of the characters therein is larger than the title character weight threshold or the font size is larger than the title font size threshold, then the target candidate title text block is determined as the title of the PDF document to be processed. It can be specifically expressed as: R1=F_num AND NOT F_num_s AND F_mid AND (F_bold OR F_large).

[0065] R2: If the target candidate title text block is an independent sequence number (such as "I."), the number of characters does not exceed the number threshold, and the character weight of the characters therein is larger than the title character weight threshold and the font size is larger than the title font size threshold, then the target candidate title text block is determined as the title of the PDF document to be processed. It can be specifically expressed as: R2=F_num_s AND char_count<=10 AND F_bold AND F_large_star.

[0066] R3: If the target title candidate text block contains strong keywords (such as "Chapter 1", "Chapter"), has a character count no less than the quantity threshold, and the character weight of the characters is greater than the title character weight threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. Specifically, this can be expressed as: R3 = char_count >= 4 AND F_very AND F_bold AND F_large.

[0067] R4: If the target title candidate text block contains preset title keywords (such as "Abstract" or "Conclusion"), the number of characters is within the preset character range, and the character weight of the characters is greater than the title character weight threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. Specifically, it can be expressed as: R4 = F_kw AND F_mid AND (F_bold OR F_large).

[0068] R5: If the target title candidate text block consists entirely of uppercase English characters, and the number of characters is less than the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. Specifically, it can be expressed as: R5 = F_upper AND F_short AND (F_bold OR F_large).

[0069] R6: If the font size of the characters in the target title candidate text block is greater than the title font size threshold, and the number of characters is within the preset character range, then the target title candidate text block is determined to be the title of the PDF document to be processed. Specifically, it can be expressed as: R6 = F_large_star AND F_mid.

[0070] R7: If the character thickness of the characters in the target title candidate text block is greater than the title character thickness threshold, the number of characters is within the preset character range, and there are no punctuation marks at the end of the sentence (such as periods, commas, etc.), then the target title candidate text block is determined to be the title of the PDF document to be processed. Specifically, it can be expressed as: R7 = F_bold AND 5 <= char_count <= 20 AND no_period_or_comma.

[0071] The above rules can be combined or prioritized according to the actual document type. When any candidate title text block satisfies any of the above rules, the candidate title text block can be determined as the title of the PDF document to be processed. The title judgment statement can be expressed as: isHeader(b[i])=R0 OR R1 OR R2 OR R3 OR R4 OR R5 OR R6 OR R7.

[0072] Optionally, text blocks identified as headings may include structured information such as heading tags, heading level (if estimated later), page numbers, and bounding boxes.

[0073] It should be noted that S105 is not simply a collection of rules, but rather a multi-level decision-making system that constructs a framework from "local comparison" to "global features" and then to "specific patterns." R0 solves the problem of "missed detection of titles with the same font size." Supplementary conditions (R1-R7) serve as a supplement, covering various special cases, which can be referred to in Examples 1-4 below. The entire process, from determining the baseline font size (S102), to eliminating noise (S103), to extracting local features (S104), and finally performing multi-rule fusion judgment (S105), forms a logically rigorous and progressively advanced technical closed loop. The global baseline font size method alone cannot solve the problem of missed detection of titles with the same font size, and the local comparison method alone may misjudge due to noise. However, the organic combination of the two, along with the intermediate elimination and screening, significantly improves the accuracy and robustness of this method.

[0074] After obtaining the preliminary title recognition results in S105, at least one of the following optional steps S106 and S107 may be included to further optimize the title recognition quality.

[0075] S106, Merging and Reassessing Peers.

[0076] In practical applications, PDF parsing engines may split a logically identical line heading into multiple independent text blocks (for example, the number "1." and the heading text "Overview" are split into two blocks), and direct output will result in broken or repetitive headings.

[0077] In one implementation, the computer device adds a title to a candidate title sequence. If two adjacent candidate title text blocks exist on the same page, and the difference in the ordinate of these two adjacent candidate title text blocks is less than a distance threshold, then the two adjacent candidate title text blocks are determined to belong to the same line. Next, the two adjacent candidate title text blocks are merged to obtain a new text block, and title recognition is performed on the new text block (see S101-S105 above for details).

[0078] Specifically, the computer device may add the title identified in S105 to the candidate title sequence. Then the computer device traverses the candidate title sequence. If the text blocks corresponding to two adjacent candidate titles are located on the same page, and the vertical coordinate difference between the text blocks of the two candidate titles is less than a distance threshold, it is determined that the text blocks of the two candidate titles belong to the same line. The computer device may merge the two text blocks into a new text block. After merging, the steps S101 to S105 above are re-performed on the merged text block for title identification. If the merged text block exhibits body text features (for example, the number of characters exceeds 50 and it ends with a period), it is degraded to body text; if the merged text block does not exhibit body text features, it is output as a complete title line.

[0079] It can be seen from the above that this step can effectively repair the fragmentation problem caused by PDF parsing, and avoid the situation that the body text is misjudged as a title due to wrong merging.

[0080] S107: Title level prediction.

[0081] For the identified titles, the computer device can predict their levels based on information such as font size, serial number format and indentation. For example, serial numbers in formats such as "I.", "Chapter 1" can be regarded as high-level titles; serial numbers in formats such as "(1)", "a." can be regarded as low-level titles; if a title does not contain a serial number, it can be sorted according to font size from large to small and bold intensity from high to low, and assigned a corresponding level. In addition, the level of a corresponding text block can also be predicted based on the variation range of the font size of characters or the variation range of character thickness; for example, the larger the variation range, the higher the title level of the corresponding text block.

[0082] Figure 2 is a schematic flowchart of another PDF title identification method provided by the embodiments of the present application. As shown in Figure 2As shown, the computer device acquires a sequence of text blocks from the PDF document to be processed. Then, it performs a first scan of the text block sequence, collecting character-level font attributes (such as the font size, font name, and bolding of each character). Next, based on these font attributes, a baseline font size for the PDF document is determined. Specifically, this can be achieved by statistically analyzing the font size with the most valid characters in each text block as the dominant font size, and then weighting and summing the effective character counts to obtain the baseline font size for the main text. A second scan of the text block sequence is then performed to obtain candidate title text blocks. This step can combine embedding exclusion rules and text constraints to filter out text blocks that are clearly not titles. Based on this, text features are extracted from the candidate title text blocks (such as F_large, F_large_star, F_bold, F_large_local, F_bold_local, F_very, F_mid, F_short, F_num, F_num_s, F_kw, F_upper, and F_large_local). Subsequently, based on R0... The R7 rule is used to determine whether the current text block is a title. Furthermore, the computer device can merge text blocks on the same line and perform title recognition on the merged text. Finally, the title recognition result is output; for example, it may include the title text, the page number, the bounding box position, and optional title level information.

[0083] The PDF title recognition method provided in this application is further illustrated below through specific embodiments: Example 1 (Same Font Size Heading Recognition): A 106-page PDF document contains 74 multi-level headings, of which 12 are third-level headings with the same 10.5pt font size as the body text, but in bold. Using a fixed font size threshold method (e.g., classifying text blocks with a font size greater than 12pt as headings) would completely miss these 12 headings. Using the PDF heading recognition method provided in this application, the baseline font size f_body for the body text is calculated to be 10.5pt in S102. In S105, although these headings have a font size equal to f_body, they are correctly recognized as headings because their local character thickness variation features (F_bold_local) meet the feature variation conditions (bold and neighboring characters are not bold), and the number of characters falls within a preset character range (e.g., between 4 and 20 characters).

[0084] Example 2 (Avoiding Misjudgment of Bold Phrases in Body Text): If bold phrases such as "key indicators" and "implementation path" appear in the body text (target text block), and both the preceding and following text are long body texts (more than 50 characters), and these phrases do not change in font size from the preceding and following body text, the target text block will be excluded and not output as a title according to the PDF title recognition method provided in this application. If the title is simply identified by bolding, "key indicators" and "implementation path" may be misidentified as titles.

[0085] Example 3 (English Specification Title Recognition): In an English technical specification, titles such as "APPENDIX A" and "GENERALREQUIREMENTS" have font sizes close to the body text (both 11pt), but the text is all uppercase, short lines, and bold. In step S105 of this method, because they satisfy the features of all uppercase (F_upper), short text (F_short), and bold (F_bold), the R5 rule is triggered, and they are correctly recognized as titles. If titles were simply identified by font size, "APPENDIX A" and "GENERAL REQUIREMENTS" might be identified as body text.

[0086] Example 4 (Same-Page Merging): The PDF parser splits a title "1.2 System Architecture" into two text blocks: the first block is "1.2", and the second block is "System Architecture". Both are on the same page and their Y-coordinates differ by less than 1 pixel. In the initial recognition, the first block may fail to meet the character count constraint due to its short length, and the second block may not be recognized due to the lack of a sequence number. After the same-page merging step, they are merged into "1.2 System Architecture". Re-examining the features reveals that it contains a sequence number, has a moderate character count, and lacks sentence-ending punctuation, satisfying the aforementioned R1 or R7 rules, and is thus correctly recognized as a complete title.

[0087] As can be seen from the above embodiments, compared with the pure font size threshold method, the PDF title recognition method provided in this application can reduce misjudgments caused by emphasized words in the body text (such as bolded terms); compared with the fixed keyword method, the PDF title recognition method provided in this application will not misjudge keywords that occasionally appear in the body text (such as long sentences containing "Conclusion shows") as titles. Through the synergistic effect of the above processes, this method can achieve better recognition results on various document types.

[0088] In this embodiment, the PDF document to be processed is parsed to obtain a sequence of text blocks. The dominant font size of each text block is determined based on the font size with the most effective characters. The number of effective characters for each dominant font size in the PDF document is then counted. The effective character counts of each dominant font size are weighted to determine the baseline font size for the main text of the PDF document. Based on this baseline font size, the text block sequence is subjected to embedding exclusion and extremely short text exclusion to obtain candidate title text blocks. Text features are extracted from these candidate title text blocks to obtain their text features. If the local font size variation features or local character thickness variation features of the target candidate title text block meet the feature variation conditions, and the number of characters in the target candidate title text block is less than a character count threshold, then the target candidate title text block is determined to be the title of the PDF document. Therefore, by determining the baseline font size of the main text through the number of effective characters and combining it with local font size variation and local character thickness variation features for title determination, the font size differences of different PDF documents can be adapted to, thereby improving the accuracy of PDF title recognition.

[0089] The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.

[0090] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of a PDF title recognition device provided in an embodiment of this application. Figure 3 The PDF title recognition device shown can be integrated into a computer device. Figure 3 The PDF title recognition device shown can be used to perform the above. Figure 1 Some or all of the functionality described in the method embodiments. Please refer to [link / reference]. Figure 3 The PDF title recognition device includes: The parsing unit 301 is used to parse the PDF document to be processed and obtain a sequence of text blocks of the PDF document to be processed. Each text block contains the text content, page number, position coordinates and character-level font attributes of the PDF document to be processed. The processing unit 302 is used to determine the dominant font size of each text block based on the font size with the most effective characters in each text block, and to count the number of effective characters of each dominant font size in the PDF document to be processed, and to weight the number of effective characters of each dominant font size to determine the base font size of the main text of the PDF document to be processed. And it is used to perform embedding exclusion and extremely short text exclusion on text block sequences based on the base font size of the main text to obtain candidate title text blocks; The feature extraction unit 303 is used to extract text features from the candidate title text blocks to obtain the text features of each candidate title text block; the text features include local font size variation features and local character thickness variation features; The processing unit 302 is further configured to determine the target title candidate text block as the title of the PDF document to be processed if the local font size change feature or local character thickness change feature of the target title candidate text block meets the feature change condition and the number of characters in the target title candidate text block is less than the character number threshold; the target title candidate text block is any title candidate text block.

[0091] In one implementation, the processing unit 302 is configured to perform embedding exclusion and extremely short text exclusion on the text block sequence based on the body text base font size to obtain candidate title text blocks, specifically configured to: If the number of target characters in the preceding and following text blocks of the current text block is greater than the character count threshold, then the style change range between the current text block and the adjacent text blocks is detected; the font size of the target character is the base font size of the body text; the style change range includes the change range of font size and character thickness of the current text block relative to the preceding and following text blocks. If the style change of the current text block and its adjacent text blocks is less than the change threshold, then the current text block is determined as a non-heading candidate text block. Non-title candidate text blocks are embedded and excluded from the text block sequence of the PDF document to be processed to obtain title candidate text blocks.

[0092] In one implementation, the base font size of the main text of the PDF document to be processed is determined based on the dominant font size of each text block, wherein the dominant font size of any text block is the font size with the most valid characters in that text block; the processing unit 302 is further configured to: The system detects the increase in the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks. If the increase in font size exceeds a first increase threshold, the system determines that the local font size change feature of the target title candidate text block satisfies the feature change condition; or... The character thickness increase of the first character in the target title candidate text block compared to the second character in the adjacent text block is detected. If the character thickness increase is greater than the second increase threshold, it is determined that the local character thickness change feature of the target title candidate text block meets the feature change condition. The first character is the character corresponding to the dominant font size of the target title candidate text block, and the second character is the character corresponding to the dominant font size of the adjacent text block.

[0093] In one embodiment, the feature extraction unit 303 is used to extract text features from the candidate title text blocks to obtain the text features of each candidate title text block, specifically for: Based on the variation of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks, local font size variation features of the target title candidate text block are generated. Based on the variation in character thickness of the character corresponding to the dominant font size in the target title candidate text block compared to the character corresponding to the dominant font size in the adjacent text block, local character thickness variation features of the target title candidate text block are generated. The text features of the target title candidate text block are obtained by concatenating the local font size variation features and the local character thickness variation features of the target title candidate text block.

[0094] In one implementation, after determining the target title candidate text block as the title of the PDF document to be processed, the processing unit 302 is further configured to: Add the title to the candidate title sequence; If there are two adjacent candidate title text blocks on the same page in the candidate title sequence, and the difference in the vertical coordinate of the text blocks of the two adjacent candidate titles is less than the distance threshold, then the text blocks of the two adjacent candidate titles are determined to belong to the same line. Merge the text blocks of two adjacent candidate titles to obtain a new text block; Title recognition is performed on the new text block.

[0095] In one implementation, the processing unit 302 is used to perform embedding exclusion and extremely short text exclusion on the text block sequence based on the body text reference font size to obtain candidate title text blocks, specifically for: Based on the base font size of the body text of the PDF document to be processed, determine the threshold for the title font size; and based on the character thickness of the characters corresponding to the base font size of the body text, determine the threshold for the title character thickness. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is greater than the title character thickness threshold, and the font size of the characters in the current text block is greater than the title font size threshold, then the current text block is determined as a title candidate text block. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is less than the title character thickness threshold, or the font size of the characters in the current text block is less than the title font size threshold, then the current text block is determined as extremely short text and excluded.

[0096] In one embodiment, the processing unit 302 is configured to determine the target title candidate text block as the title of the PDF document to be processed if the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition and the number of characters in the target title candidate text block is less than the character number threshold. Specifically, it is configured to: Based on the base font size of the body text of the PDF document to be processed, determine the threshold for the title font size; and based on the character thickness of the characters corresponding to the base font size of the body text, determine the threshold for the title character thickness. If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition, and the number of characters in the target title candidate text block is less than the character number threshold, and the target title candidate text block meets the supplementary condition, then the target title candidate text block is determined to be the title of the PDF document to be processed. The supplementary conditions include at least one of the following: R1: If the target title candidate text block contains a serial number, but it is not an independent serial number, the number of characters is within the preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R2: If the target title candidate text block is an independent sequence number, the number of characters does not exceed the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R3: If the target title candidate text block contains strong keywords, the number of characters is not less than the quantity threshold, and the character weight of the characters is greater than the title character weight threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R4: If the target title candidate text block contains preset title keywords, the number of characters is within the preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R5: If the target title candidate text block consists entirely of uppercase English characters, and the number of characters is less than the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R6: If the font size of the characters in the target title candidate text block is greater than the title font size threshold, and the number of characters is within the preset character range, then the target title candidate text block is determined to be the title of the PDF document to be processed. R7: If the character thickness of the characters in the target title candidate text block is greater than the title character thickness threshold, the number of characters is within the preset character range, and there is no sentence-ending punctuation, then the target title candidate text block is determined to be the title of the PDF document to be processed.

[0097] According to one embodiment of this application, Figure 1 The PDF title recognition method shown may involve some steps that can be achieved by... Figure 3The PDF title recognition device shown is executed by individual units. For example, Figure 1 Step S101 shown can be performed by Figure 3 The parsing unit 301 shown is executed, and steps S102, S103, and S105 can be performed by... Figure 3 The processing unit 302 shown executes the step S104, which can be performed by... Figure 3 The feature extraction unit 303 shown is executed. Figure 3 The various units in the PDF title recognition device shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the PDF title recognition device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.

[0098] According to another embodiment of this application, a general-purpose computing device, such as a computer device including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can perform operations such as... Figure 1 The computer program (including program code) involved in each step of the corresponding method shown, to construct such... Figure 3 The PDF title recognition device shown herein, and the PDF title recognition method for implementing embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the computer-readable recording medium, and run therein.

[0099] Based on the same inventive concept, the PDF title recognition device provided in the embodiments of this application solves the problem in a similar principle and with similar beneficial effects as the PDF title recognition method in the embodiments of this application. For details, please refer to the principle and beneficial effects of the method implementation. For the sake of brevity, these will not be repeated here.

[0100] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device may be a terminal device or a server. Figure 4As shown, the computer device includes at least a processor 401, a communication interface 402, and a memory 403. The processor 401, communication interface 402, and memory 403 can be connected via a bus or other means. The processor 401 (or Central Processing Unit, CPU) is the computing and control core of the computer device. It can parse various instructions within the computer device and process various data. For example, the CPU can parse power-on / off commands issued by objects to the computer device and control the computer device to perform power-on / off operations; it can also transmit various interactive data between internal structures of the computer device, and so on. The communication interface 402 may optionally include standard wired interfaces or wireless interfaces (such as Wi-Fi, mobile communication interfaces, etc.), and can be used to send and receive data under the control of the processor 401; the communication interface 402 can also be used for data transmission and interaction within the computer device. The memory 403 is the storage device in the computer device, used to store programs and data. It can be understood that the memory 403 here can include the computer device's built-in memory, or it can include extended memory supported by the computer device. The memory 403 provides storage space for storing the operating system of the computer device, which may include, but is not limited to, Android, iOS, Windows Phone, etc. This application does not limit this.

[0101] This application embodiment also provides a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the processing system of the computer device. Furthermore, the storage space also stores computer programs suitable for loading and execution by the processor 401. It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.

[0102] In one embodiment, processor 401 performs the following operations by running a computer program stored in memory 403: The PDF document to be processed is parsed to obtain a sequence of text blocks in the PDF document. Each text block contains the text content, page number, position coordinates and character-level font attributes of the PDF document to be processed. Based on the font size with the most valid characters in each text block, determine the dominant font size for each text block, and count the number of valid characters for each dominant font size in the PDF document to be processed. Weight the number of valid characters for each dominant font size to determine the base font size for the main text of the PDF document to be processed. Based on the base font size of the main text, the text block sequence is subjected to embedding exclusion and extremely short text exclusion to obtain candidate title text blocks; Text features are extracted from the candidate title text blocks to obtain the text features of each candidate title text block; the text features include local font size variation features and local character thickness variation features; If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition, and the number of characters in the target title candidate text block is less than the character number threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed; the target title candidate text block is any title candidate text block.

[0103] As an optional embodiment, the processor 401 performs embedding exclusion and extremely short text exclusion on the text block sequence based on the text base font size to obtain the title candidate text block. A specific embodiment of this is as follows: If the number of target characters in the preceding and following text blocks of the current text block is greater than the character count threshold, then the style change range between the current text block and the adjacent text blocks is detected; the font size of the target character is the base font size of the body text; the style change range includes the change range of font size and character thickness of the current text block relative to the preceding and following text blocks. If the style change of the current text block and its adjacent text blocks is less than the change threshold, then the current text block is determined as a non-heading candidate text block. Non-title candidate text blocks are embedded and excluded from the text block sequence of the PDF document to be processed to obtain title candidate text blocks.

[0104] As an optional embodiment, the base font size of the main text of the PDF document to be processed is determined based on the dominant font size of each text block, wherein the dominant font size of any text block is the font size with the most valid characters in that text block; the processor 401 also performs the following operations by running the computer program in the memory 403: The system detects the increase in the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks. If the increase in font size exceeds a first increase threshold, the system determines that the local font size change feature of the target title candidate text block satisfies the feature change condition; or... The character thickness increase of the first character in the target title candidate text block compared to the second character in the adjacent text block is detected. If the character thickness increase is greater than the second increase threshold, it is determined that the local character thickness change feature of the target title candidate text block meets the feature change condition. The first character is the character corresponding to the dominant font size of the target title candidate text block, and the second character is the character corresponding to the dominant font size of the adjacent text block.

[0105] As an optional embodiment, the processor 401 performs text feature extraction on the candidate title text blocks to obtain the text features of each candidate title text block. A specific embodiment of this is as follows: Based on the variation of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks, local font size variation features of the target title candidate text block are generated. Based on the variation in character thickness of the character corresponding to the dominant font size in the target title candidate text block compared to the character corresponding to the dominant font size in the adjacent text block, local character thickness variation features of the target title candidate text block are generated. The text features of the target title candidate text block are obtained by concatenating the local font size variation features and the local character thickness variation features of the target title candidate text block.

[0106] As an optional embodiment, after determining the target title candidate text block as the title of the PDF document to be processed, the processor 401 further performs the following operations by running the computer program in the memory 403: Add the title to the candidate title sequence; If there are two adjacent candidate title text blocks on the same page in the candidate title sequence, and the difference in the vertical coordinate of the text blocks of the two adjacent candidate titles is less than the distance threshold, then the text blocks of the two adjacent candidate titles are determined to belong to the same line. Merge the text blocks of two adjacent candidate titles to obtain a new text block; Title recognition is performed on the new text block.

[0107] As an optional embodiment, the processor 401 performs embedding exclusion and extremely short text exclusion on the text block sequence based on the text base font size to obtain the title candidate text block. A specific embodiment of this is as follows: Based on the base font size of the body text of the PDF document to be processed, determine the threshold for the title font size; and based on the character thickness of the characters corresponding to the base font size of the body text, determine the threshold for the title character thickness. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is greater than the title character thickness threshold, and the font size of the characters in the current text block is greater than the title font size threshold, then the current text block is determined as a title candidate text block. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is less than the title character thickness threshold, or the font size of the characters in the current text block is less than the title font size threshold, then the current text block is determined as extremely short text and excluded.

[0108] As an optional embodiment, if the processor 401 determines the target title candidate text block as the title of the PDF document to be processed if the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature change condition, and the number of characters in the target title candidate text block is less than the character number threshold, then the specific embodiment is as follows: Based on the base font size of the body text of the PDF document to be processed, determine the threshold for the title font size; and based on the character thickness of the characters corresponding to the base font size of the body text, determine the threshold for the title character thickness. If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition, and the number of characters in the target title candidate text block is less than the character number threshold, and the target title candidate text block meets the supplementary condition, then the target title candidate text block is determined to be the title of the PDF document to be processed. The supplementary conditions include at least one of the following: R1: If the target title candidate text block contains a serial number, but it is not an independent serial number, the number of characters is within the preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R2: If the target title candidate text block is an independent sequence number, the number of characters does not exceed the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R3: If the target title candidate text block contains strong keywords, the number of characters is not less than the quantity threshold, and the character weight of the characters is greater than the title character weight threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R4: If the target title candidate text block contains preset title keywords, the number of characters is within the preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R5: If the target title candidate text block consists entirely of uppercase English characters, and the number of characters is less than the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R6: If the font size of the characters in the target title candidate text block is greater than the title font size threshold, and the number of characters is within the preset character range, then the target title candidate text block is determined to be the title of the PDF document to be processed. R7: If the character thickness of the characters in the target title candidate text block is greater than the title character thickness threshold, the number of characters is within the preset character range, and there is no sentence-ending punctuation, then the target title candidate text block is determined to be the title of the PDF document to be processed.

[0109] Based on the same inventive concept, the principle and beneficial effects of the computer device provided in the embodiments of this application in solving the problem are similar to the principle and beneficial effects of the PDF title recognition method in the embodiments of this application in solving the problem. Please refer to the principle and beneficial effects of the implementation of the method. For the sake of brevity, they will not be repeated here.

[0110] This application also provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and execute the PDF title recognition method of the above method embodiments.

[0111] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned PDF title recognition method.

[0112] The steps in the method of this application embodiment can be adjusted, combined, or deleted according to actual needs.

[0113] The modules in the device of this application embodiment can be merged, divided, and deleted according to actual needs.

[0114] In the embodiments of this application, the term "module" or "unit" refers to a computer program or part of a computer program with a predetermined function, which works together with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0115] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.

[0116] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Those skilled in the art will understand that all or part of the processes for implementing the above embodiments and equivalent variations made in accordance with the claims of this application are still within the scope of this application.

Claims

1. A method for recognizing PDF titles, characterized in that, include: The PDF document to be processed is parsed to obtain a sequence of text blocks of the PDF document to be processed. Each text block contains the text content, page number, position coordinates and character-level font attributes of the PDF document to be processed. Based on the font size with the most effective characters in each text block, determine the dominant font size of each text block, and count the effective characters of each dominant font size in the PDF document to be processed. Weight the effective character counts of each dominant font size to determine the base font size of the main text of the PDF document to be processed. Based on the base font size of the main text, the text block sequence is subjected to embedding exclusion and extremely short text exclusion to obtain candidate title text blocks; Text features are extracted from the candidate title text blocks to obtain the text features of each candidate title text block; the text features include local font size variation features and local character thickness variation features; If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature change condition, and the number of characters in the target title candidate text block is less than the character number threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed; the target title candidate text block is any title candidate text block.

2. The method as described in claim 1, characterized in that, The process of embedding and excluding extremely short texts based on the base font size of the main text to obtain candidate title text blocks includes: If the number of target characters in the preceding and following text blocks of the current text block is greater than the character count threshold, then the style change range between the current text block and the adjacent text blocks is detected; the font size of the target character is the base font size of the main text; the style change range includes the change range of font size and character thickness of the current text block relative to the preceding and following text blocks. If the style change of the current text block and its adjacent text blocks is less than the change threshold, then the current text block is determined as a non-heading candidate text block. The non-title candidate text blocks are embedded and excluded from the text block sequence of the PDF document to be processed to obtain the title candidate text blocks.

3. The method as described in claim 1, characterized in that, The method further includes: The font size increase of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks is detected. If the font size increase is greater than a first increase threshold, then the local font size change feature of the target title candidate text block is determined to meet the feature change condition; or, The character thickness increase of the first character in the target title candidate text block compared to the second character in the adjacent text block is detected. If the character thickness increase is greater than the second increase threshold, it is determined that the local character thickness change feature of the target title candidate text block satisfies the feature change condition. The first character is the character corresponding to the dominant font size of the target title candidate text block, and the second character is the character corresponding to the dominant font size of the adjacent text block.

4. The method as described in claim 1, characterized in that, The step of extracting text features from the candidate title text blocks to obtain the text features of each candidate title text block includes: Based on the variation of the dominant font size of the target title candidate text block compared to the dominant font size of adjacent text blocks, local font size variation features of the target title candidate text block are generated; Based on the variation in character thickness of the character corresponding to the dominant font size in the target title candidate text block compared to the character corresponding to the dominant font size in the adjacent text block, local character thickness variation features of the target title candidate text block are generated. The text features of the target title candidate text block are obtained by concatenating the local font size variation features and the local character thickness variation features of the target title candidate text block.

5. The method as described in claim 1, characterized in that, After determining the target title candidate text block as the title of the PDF document to be processed, the method further includes: Add the title to the candidate title sequence; If there are two adjacent candidate title text blocks in the candidate title sequence located on the same page, and the difference in the vertical coordinate of the text blocks of the two adjacent candidate titles is less than the distance threshold, then the text blocks of the two adjacent candidate titles are determined to belong to the same line. The text blocks of the two adjacent candidate titles are merged to obtain a new text block; Title recognition is performed on the new text block.

6. The method as described in claim 1, characterized in that, The process of embedding and excluding extremely short texts based on the base font size of the main text to obtain candidate title text blocks includes: Based on the base font size of the main text of the PDF document to be processed, a threshold for the title font size is determined; and based on the character thickness of the characters corresponding to the base font size of the main text, a threshold for the title character thickness is determined. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is greater than the title character thickness threshold, and the font size of the characters in the current text block is greater than the title font size threshold, then the current text block is determined as a title candidate text block. If the number of characters in the current text block is less than or equal to 2, and the character thickness of the characters in the current text block is less than the title character thickness threshold, or the font size of the characters in the current text block is less than the title font size threshold, then the current text block is determined to be extremely short text and excluded.

7. The method as described in claim 1, characterized in that, If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature change condition, and the number of characters in the target title candidate text block is less than the character number threshold, then the target title candidate text block is determined as the title of the PDF document to be processed, including: Based on the base font size of the main text of the PDF document to be processed, a threshold for the title font size is determined; and based on the character thickness of the characters corresponding to the base font size of the main text, a threshold for the title character thickness is determined. If the local font size variation feature or local character thickness variation feature of the target title candidate text block meets the feature variation condition, and the number of characters in the target title candidate text block is less than the character number threshold, and the target title candidate text block meets the supplementary condition, then the target title candidate text block is determined to be the title of the PDF document to be processed. The supplementary conditions include at least one of the following: R1: If the target title candidate text block contains a sequence number, but it is not an independent sequence number, the number of characters is within a preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R2: If the target title candidate text block is an independent sequence number, the number of characters does not exceed the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined as the title of the PDF document to be processed. R3: If the target title candidate text block contains strong keywords, the number of characters is not less than the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold and the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R4: If the target title candidate text block contains preset title keywords, the number of characters is within a preset character range, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R5: If the target title candidate text block consists entirely of uppercase English characters, and the number of characters is less than the quantity threshold, and the character thickness of the characters is greater than the title character thickness threshold or the font size is greater than the title font size threshold, then the target title candidate text block is determined to be the title of the PDF document to be processed. R6: If the font size of the characters in the target title candidate text block is greater than the title font size threshold and the number of characters is within the preset character range, then the target title candidate text block is determined to be the title of the PDF document to be processed. R7: If the character thickness of the characters in the target title candidate text block is greater than the title character thickness threshold, and the number of characters is within the preset character range, and there is no sentence-ending punctuation, then the target title candidate text block is determined to be the title of the PDF document to be processed.

8. A PDF title recognition device, characterized in that, The PDF title recognition device includes: The parsing unit is used to parse the PDF document to be processed to obtain a sequence of text blocks of the PDF document to be processed. Each text block contains the text content, page number, position coordinates and character-level font attributes of the PDF document to be processed. The processing unit is used to determine the dominant font size of each text block based on the font size with the most effective characters in each text block, and to count the effective characters of each dominant font size in the PDF document to be processed by font size, and to weight the effective character counts of each dominant font size to determine the base font size of the main text of the PDF document to be processed. And for using the above-mentioned base font size to perform embedding exclusion and extremely short text exclusion on the text block sequence to obtain title candidate text blocks; The feature extraction unit is used to extract text features from the candidate title text blocks to obtain the text features of each candidate title text block; the text features include local font size variation features and local character thickness variation features; The processing unit is further configured to determine the target title candidate text block as the title of the PDF document to be processed if the local font size change feature or local character thickness change feature of the target title candidate text block meets the feature change condition and the number of characters in the target title candidate text block is less than the number of characters threshold; the target title candidate text block is any title candidate text block.

9. A computer device, characterized in that, include: A memory, wherein a computer program is stored; A processor for loading the computer program to implement the PDF title recognition method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed as described in any one of claims 1-7.