A method, device, terminal device and storage medium for constructing a document title tree
By converting the document into a plain text format and performing the construction operations in batches, combined with the hierarchical relationship recognition of the pre-trained language model, the problems of large amount of calculation and inaccurate hierarchical structure in the existing technology are solved, and efficient and accurate document title tree construction is achieved.
Patent Information
- Application Number
- CN202411442347.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2044-10-16
AI Technical Summary
The existing document title tree construction technology is computationally expensive and inefficient, and the dependence on pairwise comparison leads to inaccurate hierarchical structures, which are prone to bias.
Convert the original file to plain text format, perform build operations in batches through the text order of the title in the file, and use the hierarchical relationship of the existing subtitle text tree to determine the hierarchical relationship between the target titles during non-first construction, and use a pre-trained large language model for semantic recognition.
Improve the efficiency and accuracy of title tree construction, ensure hierarchical coherence between titles in different groups, and overcome the shortcomings of inaccurate title hierarchy structure in the prior art.
Smart Images

Figure CN119476269B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a method, apparatus, terminal device, and storage medium for constructing a document title tree. Background Art
[0002] Document title recognition is a crucial technology in document processing, which mainly relies on machine learning and natural language processing technologies (NLP) in the field of artificial intelligence (AI). The principle of document title recognition is mainly based on machine learning and natural language processing technologies. Through training with a large amount of text data, a machine learning model can learn how to extract key information from a document, such as topics, keywords, etc., and generate or recognize appropriate titles based on this information. Natural language processing technology is responsible for processing and understanding the language structure, semantic relationships, etc. in the document, so as to more accurately extract key information.
[0003] However, the current document title tree construction technology constructs the title tree by performing title comparisons at the node level, that is, by judging the parent-child relationship between the current title and each node in the title tree, and a large number of preset rules are required, resulting in a very large amount of computation and a low construction efficiency of the document title tree. Moreover, the current document title tree construction method relies on the results of pairwise comparisons to construct the hierarchical structure, is limited to pairwise comparisons of two titles, lacks a global perspective, and is prone to incorrect associations. Therefore, a biased hierarchical structure may be generated. This may affect users' understanding and use of information. Summary of the Invention
[0004] Embodiments of the present invention provide a method, apparatus, terminal device, and storage medium for constructing a document title tree. When performing the title tree construction operation for the non-first time, several first titles on the path from the root node to the rightmost leaf node in the existing subtitle text tree are input into the title tree construction model together with the target title to be recognized and the target text content, so that the title tree construction model determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first titles, so as to ensure the hierarchical coherence between different groups of titles and overcome the defect that the title hierarchical structure of the current document title tree construction technology is not accurate enough or has deviations.
[0005] An embodiment of the present invention provides a method for constructing a document title tree, including:
[0006] Obtain the original file of the title tree to be constructed;
[0007] Convert the original file into a preset plain text format to generate a file to be recognized;
[0008] According to the file to be recognized, recognize several titles in the file to be recognized and the text content corresponding to each title;
[0009] Construct a model based on a number of headings and a preset heading tree, and repeatedly execute the heading tree construction operation until the document heading tree of the original file is generated;
[0010] Among them, the heading tree construction operation includes:
[0011] According to the writing order of a number of the headings in the file to be recognized, obtain a number of target headings for which the heading tree construction operation has not been performed, and obtain the target text content corresponding to each target heading;
[0012] Judge whether it is the first time to execute the heading tree construction operation currently;
[0013] If so, input the target heading and the target text content into the heading tree construction model, so that the heading tree construction model performs semantic recognition on the target heading and the target text content, determines the hierarchical relationship between the target headings, and generates a sub-heading text tree;
[0014] If not, obtain a number of first headings on the path from the root node to the rightmost leaf node of the current sub-heading text tree, and input the target heading, the target text content, and the first heading into the heading tree construction model, so that the heading tree construction model performs semantic recognition on the target heading and the target text content, and determines the hierarchical relationship between the target headings according to the hierarchical relationship of the first headings, and then inserts the target headings into the sub-heading text tree according to the hierarchical relationship;
[0015] When it is confirmed that all the headings have been executed for the heading tree construction operation, use the latest sub-heading text tree as the document heading tree of the original file;
[0016] When it is confirmed that there are headings for which the heading tree construction operation has not been performed, repeatedly execute the heading tree construction operation.
[0017] Furthermore, the recognition of a number of headings in the file to be recognized and the text content corresponding to each heading includes:
[0018] Obtain a preset prefix character matching list;
[0019] Recognize each line of text in the file to be recognized, and determine a number of prefix characters in each line of text;
[0020] Match a number of the prefix characters with the prefix character matching list;
[0021] When it is determined that a prefix character match is successful, the target line corresponding to the prefix character is used as the title, and the text between the target line and the next adjacent target line is used as the text content corresponding to the title.
[0022] Further, the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree, including:
[0023] Performing semantic recognition on each target title and the corresponding target text content, determining the text meaning of each target title, and based on the text meaning, determining the irrelevant text that does not conform to the text meaning in each target title and the corresponding target text content;
[0024] Deleting the irrelevant text from the target title and the corresponding target text content to generate a second title and a second text content that conform to the text meaning;
[0025] Determining the hierarchical relationship between the second titles based on the second title and the second text content, and generating a sub-title text tree according to the hierarchical relationship.
[0026] Further, the inputting the target title, the target text content, and the first title into the title tree construction model includes:
[0027] Generating a large model prompt word according to the hierarchical relationship between several first titles;
[0028] Inputting the first title and the large model prompt word into the title tree construction model first, and then inputting the target title and the target text content into the title tree construction model.
[0029] Another embodiment of the present invention provides a device for constructing a document title tree, including:
[0030] A file acquisition module for acquiring the original file to be used for constructing the title tree;
[0031] A format conversion module for converting the original file into a preset plain text format to generate a file to be recognized;
[0032] A title recognition module for recognizing several titles in the file to be recognized and the text content corresponding to each title according to the file to be recognized;
[0033] A title tree construction module for repeatedly performing the title tree construction operation according to several titles and a preset title tree construction model until the document title tree of the original file is generated;
[0034] Among them, the title tree construction operation includes:
[0035] According to the writing order of several of the titles in the file to be recognized, obtain several target titles for which the title tree construction operation has not been performed, and obtain the target text content corresponding to each target title;
[0036] Determine whether it is the first time to perform the title tree construction operation currently;
[0037] If so, input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree;
[0038] If not, obtain several first titles on the path from the root node to the rightmost leaf node of the current sub-title text tree, and input the target title, the target text content, and the first title into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, and determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first titles, and then inserts the target titles into the sub-title text tree according to the hierarchical relationship;
[0039] When it is confirmed that all the titles have performed the title tree construction operation, use the latest sub-title text tree as the document title tree of the original file;
[0040] When it is confirmed that there are titles for which the title tree construction operation has not been performed, repeat the title tree construction operation.
[0041] Further, the recognition of several titles in the file to be recognized and the text content corresponding to each title includes:
[0042] Obtain a preset prefix character matching list;
[0043] Recognize each line of text in the file to be recognized, and determine several prefix characters in each line of text;
[0044] Match several of the prefix characters with the prefix character matching list;
[0045] When it is determined that a prefix character matches successfully, use the target line corresponding to the prefix character as the title, and use the text between the target line and the next adjacent target line as the text content corresponding to the title.
[0046] Further, the title tree construction model performs semantic recognition on the target titles and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree, including:
[0047] Performs semantic recognition on each target title and the corresponding target text content, determines the text meaning of each target title, and based on the text meaning, determines the irrelevant text that does not match the text meaning in each target title and the corresponding target text content;
[0048] Deletes the irrelevant text from the target title and the corresponding target text content to generate a second title and a second text content that match the text meaning;
[0049] Based on the second title and the second text content, determines the hierarchical relationship between the second titles, and generates a sub-title text tree according to the hierarchical relationship.
[0050] Further, the step of inputting the target title, the target text content, and the first title into the title tree construction model includes:
[0051] Generates a large model prompt word according to the hierarchical relationship between several first titles;
[0052] Inputs the first title and the large model prompt word into the title tree construction model first, and then inputs the target title and the target text content into the title tree construction model.
[0053] Another embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for constructing a document title tree as described in any one of the above embodiments.
[0054] Another embodiment of the present invention provides a storage medium, which includes a stored computer program. When the computer program runs, it controls the device where the storage medium is located to execute a method for constructing a document title tree as described in any one of the above embodiments.
[0055] By implementing the present invention, the following beneficial effects are achieved:
[0056] The present invention discloses a method, apparatus, terminal device and storage medium for constructing a document title tree. The method converts the original file into a preset plain text format to improve the subsequent title recognition efficiency and text segmentation efficiency in a unified format. Further, by performing the title tree construction operation batch by batch according to the writing order of the titles in the file to be recognized, it prevents the title tree construction model from being unable to capture and remember the key information in the text, and improves the accuracy of semantic recognition of the title tree construction model. And when the title tree construction operation is not performed for the first time, several first titles on the path from the root node to the rightmost leaf node in the existing sub-title text tree are input into the title tree construction model together with the target title and the target text content to be recognized, so that the title tree construction model determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first titles, so as to ensure the hierarchical coherence between different groups of titles and overcome the defects that the title hierarchical structure of the current document title tree construction technology is not accurate enough or has deviations. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 FIG. is a flowchart of a method for constructing a document title tree according to an embodiment of the present invention.
[0058] Figure 2 FIG. is a structural diagram of an apparatus for constructing a document title tree according to an embodiment of the present invention.
[0059] Figure 3 FIG. is another flowchart of a method for constructing a document title tree according to an embodiment of the present invention DETAILED DESCRIPTION
[0060] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusion.
[0062] In the description of the embodiments of the present application, technical terms such as "first" and "second" are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity, specific order or primary-secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "a plurality" is more than two, unless otherwise specifically defined.
[0063] Reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0064] In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after.
[0065] In the description of the embodiments of the present application, the term "a plurality" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0066] In the description of the embodiments of the present application, unless otherwise clearly specified and limited, technical terms such as "installation", "connection", "connection", "fixation" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or integrated; it can also be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and can be the communication inside two components or the interaction relationship between two components. For those of ordinary skill in the art, the specific meanings of the above terms in the embodiments of the present application can be understood according to specific circumstances.
[0067] See Figure 1 , which is a schematic flowchart of a method for constructing a document title tree provided by an embodiment of the present invention, including:
[0068] S1. Obtain the original file of the title tree to be constructed;
[0069] In a preferred embodiment of the present invention, the original file is an arbitrary format file with text content, such as:.txt,.pdf,.docx,.html, etc.
[0070] S2. Convert the original file into a preset plain text format to generate a file to be recognized;
[0071] In a preferred embodiment of the present invention, the preset plain text format is Markdown format. It should be noted that the core of format conversion is how to support more document types and ensure that the extracted results are still understandable to humans. This part of the work relies more on traditional document parsing capabilities such as OCR. However, due to the wide variety of file formats in real scenarios, this part is very challenging and is also a step-by-step process that requires combining needs and technical reality. In this embodiment, the mainstream RAG development framework Langchain[4] and LlamaIndex[5] are used, both of which have different components that can meet basic functions.
[0072] S3, according to the file to be identified, identifying a number of titles in the file to be identified, and text content corresponding to each title;
[0073] Preferably, the step of identifying, based on the file to be identified, a number of titles in the file to be identified, and text content corresponding to each title, includes:
[0074] S31, obtaining a preset prefix character matching list;
[0075] S32, identifying each line of text in the to-be-identified file, and determining a number of prefix characters in each line of text;
[0076] S33, matching a plurality of the prefix characters with the prefix character matching list;
[0077] S34. When it is determined that a prefix character matches successfully, the target row corresponding to the prefix character is used as a title, and the text between the target row and the next adjacent target row is used as text content corresponding to the title.
[0078] In a preferred embodiment of the present invention, based on a preset prefix character matching rule, it is determined whether each independent line is a title. An example prefix character matching list is as follows: ["§","第","一","二","三","四","五","六","七","八","九","十","零","0","1","2","3","4","5","6","7","8","9","0","(一","(二","(三","(四","(五","(六","(七","(八","(九","(十"], where the prefix character matching rule can be customized and modified to regular matching according to the content of the original file, or more complex methods such as LLM Chain.
[0079] It should be noted that in the current document title tree technology, the "title format restrictions" are set relatively strictly, such as punctuation restrictions, text length restrictions, and special symbol restrictions. This results in many correct titles being easily missed during recall. Therefore, in this embodiment, during the title recognition stage, relatively loose title recognition rules are adopted to make the recall rate of document titles higher, without missing important potential titles. And based on the powerful text semantic understanding ability of the subsequent title tree construction model, irrelevant and incorrect titles can be removed during the title tree construction stage, while ensuring the accuracy of the titles.
[0080] S4. According to a number of titles and a preset title tree construction model, repeatedly execute the title tree construction operation until the document title tree of the original file is generated;
[0081] Among them, the title tree construction operation includes:
[0082] S41. According to the writing order of a number of the titles in the file to be recognized, obtain a number of target titles for which the title tree construction operation has not been performed, and obtain the target text content corresponding to each target title;
[0083] S42. Determine whether the title tree construction operation is performed for the first time currently;
[0084] S43. If so, input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree;
[0085] Preferably, the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree, including:
[0086] S431. Perform semantic recognition on each target title and the corresponding target text content, determine the text meaning of each target title, and according to the text meaning, determine the irrelevant text in each target title and the corresponding target text content that does not conform to the text meaning;
[0087] S432. Delete the irrelevant text from the target title and the corresponding target text content to generate a second title and a second text content that conform to the text meaning;
[0088] S433. According to the second title and the second text content, determine the hierarchical relationship between the second titles, and generate a sub-title text tree according to the hierarchical relationship.
[0089] S44. If not, obtain several first-level headings on the path from the root node to the rightmost leaf node of the current sub-heading text tree, and input the target heading, the target text content, and the first-level headings into the heading tree construction model, so that the heading tree construction model performs semantic recognition on the target heading and the target text content, determines the hierarchical relationship between the target headings according to the hierarchical relationship of the first-level headings, and then inserts the target headings into the sub-heading text tree according to the hierarchical relationship;
[0090] Preferably, the step of inputting the target heading, the target text content, and the first-level headings into the heading tree construction model includes:
[0091] S441. Generate large model prompt words according to the hierarchical relationship between several of the first-level headings;
[0092] S442. Input the first-level headings and the large model prompt words into the heading tree construction model first, and then input the target heading and the target text content into the heading tree construction model.
[0093] S45. When it is confirmed that all the headings have performed the heading tree construction operation, use the latest sub-heading text tree as the document heading tree of the original document;
[0094] S46. When it is confirmed that there are headings that have not performed the heading tree construction operation, repeat the heading tree construction operation.
[0095] In a preferred embodiment of the present invention, the heading tree construction model is a pre-trained large language model (Large Language Model, abbreviated as LLM). For the list of potential headings obtained by heading recognition, as Figure 3 shown, in this embodiment, a fusion task is designed based on a large-scale pre-trained generation model.
[0096] a) Group the list of headings in order (the size of each group can be set to 20 by default) and input them into the large-scale pre-trained generation model, requiring the model to recognize the hierarchical relationship between the headings according to the heading content and return it in the form of markdown, and directly discard the content that is not a heading in the result. Then parse and integrate the model return result into the current heading tree.
[0097] b) Among them, in order to ensure the coherence of the hierarchy between different groups, we design a "bait and switch" strategy. Before each new group of headings is input into the model, place the heading included in the rightmost sub-path of the current heading at the front of the current group, and include its corresponding hierarchical result in the large model prompt words.
[0098] (4) Document tree construction: Based on the title tree and Markdown-format files, construct the corresponding document tree.
[0099] It can be understood that in the actual scenario, the LLM structure analysis (LLM Based Method) may extract a relatively large number of titles. Feeding all of them to the LLM at once has two risks: (1) being too long and exceeding the input_length of the LLM will cause the model to fail to respond; (2) when the overall input is long, how can the LLM ensure the consistency of the front and back levels in the results. For this reason, we have involved corresponding strategies in the strategy:
[0100] (1) Model failure due to long input: Limit the number of titles input at one time, which is set to 20 in the current actual solution.
[0101] (2) Consistency of the front and back levels of the results: In the Prompt results of each input, add the rightmost path of the already constructed Title Tree as a "lead" to inspire, so as to ensure the consistency of the result levels.
[0102] The final results show that even when using the locally quantized model with relatively poor performance (qwen-72b-int8), the above two-stage extraction strategy still achieves very impressive results.
[0103] This embodiment provides a method for constructing a document title tree. By converting the original file into a preset plain text format, the efficiency of subsequent title recognition and text segmentation is improved in a unified format. Further, by batch-executing the title tree construction operation according to the writing order of the titles in the file to be recognized, it is prevented that the title tree construction model cannot capture and remember the key information in the text, and the accuracy of semantic recognition of the title tree construction model is improved. And when the title tree construction operation is not performed for the first time, several first titles on the path from the root node to the rightmost leaf node in the existing sub-title text tree are input into the title tree construction model together with the target titles and target text content to be recognized, so that the title tree construction model determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first titles, so as to ensure the hierarchical coherence between different groups of titles and overcome the defect that the title hierarchical structure of the current document title tree construction technology is not accurate enough or has deviations.
[0104] See Figure 2 , which is a schematic structural diagram of a device for constructing a document title tree provided by an embodiment of the present invention, including:
[0105] A file acquisition module, configured to acquire the original file for which the title tree is to be constructed;
[0106] A format conversion module, configured to convert the original file into a preset plain text format to generate a file to be recognized;
[0107] A title recognition module, configured to recognize a plurality of titles in the file to be recognized and the text content corresponding to each title according to the file to be recognized;
[0108] A title tree construction module, configured to repeatedly perform a title tree construction operation according to a plurality of titles and a preset title tree construction model until a document title tree of the original file is generated;
[0109] Wherein, the title tree construction operation includes:
[0110] Obtain a plurality of target titles for which the title tree construction operation has not been performed according to the writing order of the plurality of titles in the file to be recognized, and obtain the target text content corresponding to each target title;
[0111] Determine whether the title tree construction operation is performed for the first time currently;
[0112] If so, input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree;
[0113] If not, obtain a plurality of first titles on the path from the root node to the rightmost leaf node of the current sub-title text tree, and input the target title, the target text content, and the first title into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first title, and then inserts the target title into the sub-title text tree according to the hierarchical relationship;
[0114] When it is confirmed that all the titles have performed the title tree construction operation, use the latest sub-title text tree as the document title tree of the original file;
[0115] When it is confirmed that there are titles for which the title tree construction operation has not been performed, repeat the title tree construction operation.
[0116] Preferably, the recognizing a plurality of titles in the file to be recognized and the text content corresponding to each title according to the file to be recognized includes:
[0117] Obtain a preset prefix character matching list;
[0118] Recognize each line of text in the file to be recognized, and determine a plurality of prefix characters in each line of text;
[0119] Match a number of the prefix characters with the prefix character matching list;
[0120] When it is determined that a prefix character match is successful, use the target line corresponding to the prefix character as the title, and use the text between the target line and the next adjacent target line as the text content corresponding to the title.
[0121] Preferably, the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree, including:
[0122] Perform semantic recognition on each target title and the corresponding target text content, determine the text meaning of each target title, and based on the text meaning, determine the irrelevant text in each target title and the corresponding target text content that does not match the text meaning;
[0123] Delete the irrelevant text from the target title and the corresponding target text content to generate a second title and a second text content that match the text meaning;
[0124] Based on the second title and the second text content, determine the hierarchical relationship between the second titles, and generate a sub-title text tree according to the hierarchical relationship.
[0125] Preferably, the step of inputting the target title, the target text content, and the first title into the title tree construction model includes:
[0126] Generate large model prompt words according to the hierarchical relationship between several of the first titles;
[0127] First input the first title and the large model prompt words into the title tree construction model, and then input the target title and the target text content into the title tree construction model.
[0128] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the attached drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that they have a communication connection, which can be specifically implemented as one or more communication buses or signal lines. Those of ordinary skill in the art can understand and implement without creative work.
[0129] Those skilled in the art can clearly understand that for the sake of convenience and brevity, the specific working process of the device described above can refer to the corresponding process in the foregoing method embodiments, and will not be elaborated herein.
[0130] Another preferred embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for constructing a document title tree as described in any one of the foregoing embodiments.
[0131] The terminal device may be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The terminal device may include, but is not limited to, a processor and a memory.
[0132] The so-called processor may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The processor is the control center of the terminal device, and connects various parts of the entire terminal device through various interfaces and lines.
[0133] The memory may be used to store the computer program. The processor realizes various functions of the terminal device by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function, etc.; the data storage area may store data created according to the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0134] Another preferred embodiment of the present invention provides a storage medium, which is a computer-readable storage medium. The computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0135] The above is the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements are also regarded as the protection scope of the present invention.
Claims
1. A method for constructing a document title tree, characterized in that Including: Obtain the original file for which the title tree is to be constructed; Convert the original file into a preset plain text format to generate a file to be recognized; According to the file to be recognized, identify a number of titles in the file to be recognized and the corresponding text content of each title; According to a number of titles and a preset title tree construction model, repeatedly execute the title tree construction operation until the document title tree of the original file is generated; Among them, the title tree construction operation includes: According to the writing order of a number of the titles in the file to be recognized, obtain a number of target titles for which the title tree construction operation has not been performed, and obtain the target text content corresponding to each target title; Judge whether it is the first time to execute the title tree construction operation currently; If so, input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree; If not, obtain a number of first titles on the path from the root node to the rightmost leaf node of the current sub-title text tree, and generate a large model prompt word according to the hierarchical relationship between the first titles; input the first titles and the large model prompt word into the title tree construction model preferentially, and then input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first titles, and then inserts the target titles into the sub-title text tree according to the hierarchical relationship; When it is confirmed that all the titles have performed the title tree construction operation, use the latest sub-title text tree as the document title tree of the original file; When it is confirmed that there are titles for which the title tree construction operation has not been performed, repeatedly execute the title tree construction operation.
2. The construction method of a document title tree according to claim 1, characterized in that, The step of identifying a number of titles in the file to be recognized and the corresponding text content of each title according to the file to be recognized includes: Obtain a preset prefix character matching list; Identify each line of text in the file to be recognized and determine a number of prefix characters in each line of text; Match the number of prefix characters with the prefix character matching list; When it is determined that a prefix character matches successfully, use the target line corresponding to the prefix character as the title, and use the text between the target line and the next adjacent target line as the text content corresponding to the title.
3. The method for constructing a document title tree according to claim 2, characterized in that The title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree, including: Perform semantic recognition on each target title and the corresponding target text content, determine the text meaning of each target title, and according to the text meaning, determine the irrelevant text that does not match the text meaning in each target title and the corresponding target text content; Delete the irrelevant text from the target title and the corresponding target text content to generate a second title and a second text content that conform to the meaning of the text. Determine the hierarchical relationship between the second titles based on the second title and the second text content, and generate a sub-title text tree according to the hierarchical relationship.
4. A device for constructing a document title tree, characterized in that It includes: A file acquisition module for acquiring the original file to be used for constructing the title tree. A format conversion module for converting the original file into a preset plain text format to generate a file to be recognized. A title recognition module for recognizing a number of titles in the file to be recognized and the text content corresponding to each title according to the file to be recognized. A title tree construction module for repeatedly performing title tree construction operations according to a number of titles and a preset title tree construction model until the document title tree of the original file is generated. Among them, the title tree construction operation includes: According to the writing order of a number of the titles in the file to be recognized, obtain a number of target titles for which the title tree construction operation has not been performed, and obtain the target text content corresponding to each target title. Determine whether the title tree construction operation is performed for the first time currently. If so, input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree. If not, obtain a number of first titles on the path from the root node to the rightmost leaf node of the current sub-title text tree, and generate a large model prompt word according to the hierarchical relationship between the first titles; input the first title and the large model prompt word into the title tree construction model preferentially, and then input the target title and the target text content into the title tree construction model, so that the title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles according to the hierarchical relationship of the first titles, and then inserts the target title into the sub-title text tree according to the hierarchical relationship. When it is confirmed that all the titles have performed the title tree construction operation, use the latest sub-title text tree as the document title tree of the original file. When it is confirmed that there are titles for which the title tree construction operation has not been performed, repeat the title tree construction operation.
5. The construction device of a document title tree according to claim 4, characterized in that The recognition of a number of titles in the file to be recognized and the text content corresponding to each title according to the file to be recognized includes: Obtain a preset prefix character matching list. Identify each line of text in the file to be recognized and determine a number of prefix characters in each line of text. Match the number of the prefix characters with the prefix character matching list. When it is determined that a prefix character matches successfully, use the target line corresponding to the prefix character as the title, and use the text between the target line and the next adjacent target line as the text content corresponding to the title.
6. The construction device of a document title tree according to claim 5, characterized in that, The title tree construction model performs semantic recognition on the target title and the target text content, determines the hierarchical relationship between the target titles, and generates a sub-title text tree, including: Performing semantic recognition on each target title and the corresponding target text content, determining the text meaning of each target title, and based on the text meaning, determining the irrelevant text in each target title and the corresponding target text content that does not conform to the text meaning; Deleting the irrelevant text from the target title and the corresponding target text content to generate a second title and a second text content that conform to the text meaning; Based on the second title and the second text content, determining the hierarchical relationship between the second titles, and generating a sub-title text tree according to the hierarchical relationship.
7. A terminal device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for constructing a document title tree as described in any one of claims 1 to 3.
8. A storage medium, characterized in that, The storage medium includes a stored computer program. Wherein, when the computer program runs, it controls the device where the storage medium is located to execute a method for constructing a document title tree as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Document directory extraction method and system based on generative language model
CN118170863A