Document directory generation method, device, terminal equipment and storage medium

By reading the text document from the page and converting it into a syntax tree for deconstruction, it solves the problem of lagging document catalog updates, realizes automatic real-time updates, is suitable for real-time editing scenarios, and improves the accuracy and generation efficiency of the document catalog.

CN114265916BActive Publication Date: 2024-10-01WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111593879.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2024-10-01
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

The existing technology lags behind in document catalog updates in real-time editing scenarios, requires additional interface request overhead, is inefficient, and requires manual maintenance, causing document content updates to lag in catalog updates.

Method used

By reading the text document from the page, converting it into a syntax tree, deconstructing the syntax tree nodes, generating a document directory, and achieving automatic real-time updates.

Benefits of technology

It solves the problem of lagging document catalog updates, realizes automatic real-time updates, does not require manual maintenance, is suitable for WYSIWYG editing scenarios, reduces operating steps, and improves the accuracy and generation efficiency of document catalogs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114265916B_ABST
    Figure CN114265916B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, terminal device and storage medium for generating a document directory. The method comprises: reading a text document from a page; converting the text document into a syntax tree; deconstructing the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory and updates the document directory in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, terminal equipment and storage medium for generating a document directory. Background Art

[0002] In order to quickly check the content of a document, the document needs to have a detailed directory. However, when users are writing documents, they are more willing to focus on the actual content of the document rather than spending time compiling a detailed directory for the document.

[0003] Existing application systems choose to store document directories in document databases. Each time a document is read, the directory structure is read out together, and then the whole structure is displayed in the web page content. However, this document directory display method does not work well in some real-time editing scenarios. Each time a user edits and inputs, additional interface request overhead is required, resulting in a delay in updating the document directory. Summary of the invention

[0004] The main purpose of the embodiments of the present invention is to provide a method, apparatus, terminal device and storage medium for generating a traditional document directory, aiming to solve the problem of delayed updating of the document directory and update the document directory in real time.

[0005] To achieve the above object, an embodiment of the present invention provides a method for generating a traditional document directory, wherein the method for generating a document directory is applied to a page, and the method for generating a traditional document directory comprises:

[0006] reading a text document from said page;

[0007] Converting the text document into a syntax tree;

[0008] The nodes of the syntax tree are deconstructed to obtain a document directory.

[0009] Optionally, the step of converting the text document into a syntax tree includes:

[0010] Converting the text document into a Hypertext Markup Language (HTML) document;

[0011] The HTML document is converted into the syntax tree, and a label is assigned to the syntax tree.

[0012] Optionally, before the step of deconstructing the nodes of the syntax tree to obtain the document directory, the step includes:

[0013] Traversing the nodes of the syntax tree to obtain a directory object;

[0014] The directory object is traversed and deconstructed to obtain the document directory.

[0015] Optionally, the step of traversing the nodes of the syntax tree to obtain a directory object includes:

[0016] Assigning labels to the syntax tree;

[0017] Read a node of the syntax tree and determine whether the node is a leaf node;

[0018] If the node is a leaf node, determining whether the label of the node starts with a preset letter;

[0019] If the label of the node does not start with a preset letter, read the sibling node of the node;

[0020] If the label of the node begins with a preset letter, the node is used as the directory object.

[0021] Optionally, the step of reading the node of the syntax tree and determining whether the node is a leaf node includes:

[0022] If the node is not a leaf node, determining that the node is a subtree;

[0023] Reading a node of the subtree as a subtree node, and determining whether the subtree node is a leaf node;

[0024] If the subtree node is a leaf node, determining whether the label of the subtree node starts with a preset letter;

[0025] If the label of the subtree node does not start with a preset letter, read the sibling node of the subtree node;

[0026] If the label of the subtree node begins with a preset letter, the subtree node is used as the directory object.

[0027] Optionally, if the label of the node does not start with a preset letter, the step of reading the sibling nodes of the node includes:

[0028] If the brother node is a tree node, return to the execution step: read the node of the syntax tree and determine whether the node is a leaf node;

[0029] If the sibling node is not a tree node, the sibling node is discarded.

[0030] Optionally, before the step of traversing the nodes of the syntax tree to obtain the directory object, the step includes:

[0031] Create directory tree register;

[0032] If the label of the node begins with a preset letter, the step of taking the node as the directory object comprises:

[0033] If the label of the node begins with a preset letter, the node is taken as the node object and stored in the directory tree register.

[0034] Optionally, the step of traversing and deconstructing the directory object to obtain the document directory includes:

[0035] Assembling the directory objects of the directory tree register to obtain a directory tree;

[0036] The directory tree is traversed and deconstructed to obtain the document directory.

[0037] In addition, to achieve the above-mentioned purpose, the present invention also provides a device for generating a document directory, the system comprising:

[0038] A document reading module, used for reading a text document from the page;

[0039] A document conversion module, used for converting the text document into a syntax tree;

[0040] The traversal deconstruction module is used to deconstruct the nodes of the syntax tree to obtain a document directory.

[0041] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal device, which includes: a memory, a processor, and a method for generating a document directory stored in the memory and executable on the processor, wherein the program for generating the document directory implements the steps of the method for generating the document directory as described above when executed by the processor.

[0042] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a program for generating a document directory is stored, and when the program for generating a document directory is executed by a processor, the steps of the method for generating a document directory as described above are implemented.

[0043] The document directory generation method, device, terminal device and storage medium proposed in the embodiment of the present invention include: reading a text document from a page; converting the text document into a syntax tree; deconstructing the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory, automatically reads the document, and updates the document directory in real time. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is a functional module diagram of a terminal device to which the document directory generating device of the present invention belongs;

[0045] Figure 2 It is a flowchart of a first embodiment of a method for generating a document directory of the present invention;

[0046] Figure 3 It is a flowchart of a second embodiment of a method for generating a document directory of the present invention;

[0047] Figure 4 It is a flowchart of a third embodiment of a method for generating a document directory of the present invention;

[0048] Figure 5 It is a schematic diagram of the functional modules of the system for generating a document directory of the present invention.

[0049] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0051] The main solution of the embodiment of the present invention is: reading a text document from a page; converting the text document into a syntax tree; deconstructing the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory, automatically reads the document in real time, and updates the document directory in real time.

[0052] Technical terms involved in the embodiments of the present invention:

[0053] Hast: Hypertext Abstract Syntax Tree, Hast represents HTML as a specification of an abstract syntax tree.

[0054] WYSIWYG: What you see is what you get. WYSIWYG refers to a user interface that allows users to directly edit and manipulate the appearance and content of a document, page or file.

[0055] HTML: HTML stands for Hypertext Markup Language, which is a markup language. It includes a series of tags. Through these tags, the document format on the Internet can be unified, and scattered Internet resources can be connected into a logical whole. HTML text is a descriptive text composed of HTML commands. HTML commands can describe text, graphics, animations, sounds, tables, links, etc.

[0056] Directory tree: In any namespace, a directory tree refers to a hierarchical structure consisting of containers and objects. The leaves and nodes of the tree are often objects, and the non-leaf nodes of the tree are containers. The directory tree expresses how objects are connected and also shows the path from one object to another. In the Active Directory, the directory tree is the basic structure. Starting from each container, each layer can form a subtree. A simple directory can form a tree, and a computer network or a domain can also form a tree. "Directory tree" is also a kind of "path relationship".

[0057] Javascript: JavaScript ("JS" for short) is a lightweight, interpreted or just-in-time compiled programming language with function-first behavior. Although it is famous as a scripting language for developing web pages, it is also used in many non-browser environments. JavaScript is a prototype-based, multi-paradigm dynamic scripting language that supports object-oriented, imperative, declarative, and functional programming paradigms.

[0058] Dom: (Document Object Model) is a standard programming interface for processing extensible markup languages. It is an application programming interface (API) that is independent of platform and language. It can dynamically access programs and scripts to update their content, structure and style of www documents (HTML and XML documents are defined by the description part). The document can be further processed and the results of the processing can be added to the current page.

[0059] JAVA: Java is an object-oriented programming language. As a representative of static object-oriented programming languages, Java has two characteristics: powerful functions and simple and easy to use.

[0060] C#: C# includes features such as single inheritance, interfaces, syntax that is almost the same as Java, and the process of compiling into intermediate code and then running it. However, C# is significantly different from Java. It borrows a feature from Delphi and is directly integrated with COM (Component Object Model).

[0061] Traversal: Traversal refers to visiting each node in a tree (or graph) in sequence along a search route. The operations performed on the visited nodes depend on the specific application problem. The specific access operations may be checking the value of the node, updating the value of the node, etc. Different traversal methods have different order of visiting nodes.

[0062] Recursion: The programming technique of a program calling itself is called recursion. Recursion is widely used as an algorithm in programming languages. A procedure or function has a method of calling itself directly or indirectly in its definition or description. It usually transforms a large and complex problem into a smaller problem similar to the original problem to solve. The recursive strategy only needs a small amount of program to describe the multiple repeated calculations required for the problem-solving process, greatly reducing the amount of program code. The power of recursion lies in using finite statements to define an infinite set of objects. Generally speaking, recursion requires boundary conditions, recursive advance segments, and recursive return segments. When the boundary conditions are not met, the recursion advances; when the boundary conditions are met, the recursion returns.

[0063] The embodiment of the present invention takes into account that in the existing related solutions, a knowledge base document module is added to the application system, which is mainly used to accumulate business daily knowledge and experience. When writing a document, users are more willing to focus on the actual content of the document rather than spending time compiling a detailed directory for the document, but a detailed directory can facilitate our access to the document.

[0064] Generally, similar knowledge base documents will be divided into chapters and directories to effectively organize the content. The common document directory method is to store the document directory in the document database, read the directory structure each time the document is read, and then display it as a whole in the web page content; use the background programming language to call the software development kit of the relevant document format to parse and generate the directory, and when the document is displayed on the page, the generated directory will be printed on the page at the same time.

[0065] This approach has some disadvantages, as follows:

[0066] (1) It does not work well in some real-time editing scenarios. Every time a user edits and inputs, additional interface request overhead is required.

[0067] (2) The document directory requires manual maintenance, which is inefficient;

[0068] (3) Document content updates will cause document directory updates to lag behind.

[0069] Therefore, the present invention provides a solution to automatically read the document written by the user, and then automatically extract and compile a complete document directory from the document.

[0070] Specifically, refer to Figure 1 , Figure 1 Schematic diagram of the functional modules of the terminal device to which the document directory generation device of the present invention belongs. The document directory generation device can be a device independent of the terminal device, capable of image processing and network model training, which can be carried on the terminal device in the form of hardware or software. The terminal device can be a smart mobile terminal with data processing function such as a mobile phone or a tablet computer, or a fixed terminal device or server with data processing function.

[0071] In this embodiment, the terminal device to which the document directory generating apparatus belongs includes at least an output module 110 , a processor 120 , a memory 130 and a communication module 140 .

[0072] The memory 130 stores the operation method and the document directory generation program; the output module 110 may be a display screen, etc. The communication module 140 may include a WIFI module, a mobile communication module, a Bluetooth module, etc., and communicates with an external device or server through the communication module 140.

[0073] The document directory generation program in the memory 130 implements the following steps when executed by the processor:

[0074] Reading a text document from said page;

[0075] Converting the text document into a syntax tree;

[0076] The nodes of the syntax tree are deconstructed to obtain a document directory.

[0077] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0078] Converting the text document into a Hypertext Markup Language (HTML) document;

[0079] The HTML document is converted into the syntax tree.

[0080] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0081] Traversing the nodes of the syntax tree to obtain a directory object;

[0082] The step of deconstructing the nodes of the syntax tree to obtain a document directory includes:

[0083] The directory object is traversed and deconstructed to obtain the document directory.

[0084] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0085] Assigning labels to the syntax tree;

[0086] Read a node of the syntax tree and determine whether the node is a leaf node;

[0087] If the node is a leaf node, determining whether the label of the node starts with a preset letter;

[0088] If the label of the node does not start with a preset letter, read the sibling node of the node;

[0089] If the label of the node begins with a preset letter, the node is used as the directory object.

[0090] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0091] If the node is not a leaf node, determining that the node is a subtree;

[0092] Reading a node of the subtree as a subtree node, and determining whether the subtree node is a leaf node;

[0093] If the subtree node is a leaf node, determining whether the label of the subtree node starts with a preset letter;

[0094] If the label of the subtree node does not start with a preset letter, read the sibling node of the subtree node;

[0095] If the label of the subtree node begins with a preset letter, the subtree node is used as the directory object.

[0096] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0097] If the brother node is a tree node, return to the execution step: read the node of the syntax tree and determine whether the node is a leaf node;

[0098] If the sibling node is not a tree node, the sibling node is discarded.

[0099] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0100] Create directory tree register;

[0101] If the label of the node begins with a preset letter, the step of taking the node as the directory object comprises:

[0102] If the label of the node begins with a preset letter, the node is taken as the node object and stored in the directory tree register.

[0103] Furthermore, when the document directory generation program in the memory 130 is executed by the processor, the following steps are also implemented:

[0104] Assembling the directory objects of the directory tree register to obtain a directory tree;

[0105] The directory tree is traversed and deconstructed to obtain the document directory.

[0106] This embodiment uses the above solution to obtain a document directory by reading a text document from a page, converting the text document into a syntax tree, and deconstructing the nodes of the syntax tree. The present invention solves the problem of delayed update of the document directory. After the document content is updated, manual maintenance is not required, and the document directory structure is refreshed immediately, which is suitable for WYSIWYG editing scenarios.

[0107] Based on the above terminal device architecture but not limited to the above architecture, an embodiment of the method of the present invention is proposed.

[0108] Reference Figure 2 , Figure 2 The figure is a flow chart of a first embodiment of a method for generating a document directory of the present invention. The method for generating a document directory comprises:

[0109] Step S101, reading a text document from the page.

[0110] The execution subject of the method of this embodiment can be a document directory generation device, or it can be a document directory generation terminal device or server. This embodiment takes the document directory generation device as an example. The document directory generation device can be integrated on a terminal device such as a smart phone, tablet computer, etc. with data processing function.

[0111] The solution of this embodiment mainly realizes real-time acquisition of document information and automatically updates the document directory according to the content of the document.

[0112] The document directory generation device of this embodiment can be applied in the front end or the back end. This embodiment is described by applying the document directory generation device in the front end.

[0113] Furthermore, the document directory generation device is completed on the front-end web page using scripting technologies such as Javascript and DOM, without the need for background program logic coordination. The business logic is relatively lightweight and the generation efficiency is also high, making it suitable for use in some real-time editing and WYSIWYG document editing scenarios.

[0114] In order to generate a document directory, you need to read the text document. The specific solution is as follows:

[0115] As an implementation mode, in this embodiment, a text document is read at the front end; wherein the text document may be a text document updated in real time.

[0116] More specifically, the text document is searched and read in the document database of the front end; the text document may be a text document updated in real time; the text document may be read line by line or column by column; the text document may be read in C language, C#, JAVA, etc.

[0117] Step S102: convert the text document into a syntax tree.

[0118] As an implementation mode, in this embodiment, first, the read text document is converted into an HTML document recognizable by a web page, wherein the read document includes a plain text document.

[0119] Specifically, an open source algorithm can be applied, and the open source data package converts the read text document into an HTML document that can be recognized by the web page.

[0120] Thus, the ordinary text document input by the user is converted into an HTML document recognizable by the web page, in preparation for the post-Hast conversion, wherein the HTML document is an expression of a tree structure.

[0121] Secondly, convert the HTML document into a Hypertext Abstract Syntax Tree (HAST).

[0122] Specifically, the HTML document is converted into a Hypertext Abstract Syntax Tree (HAST), and further semantic abstraction is performed on the tree-like structured document such as HTML, which is converted into a real tree object, and labels are generated for the nodes of the HAST tree to facilitate further traversal and extraction of the tree object.

[0123] Among them, labels are assigned to the nodes of the HAST tree according to their types. The labels include h, which represents that the node is a title, in preparation for the subsequent generation of a document directory.

[0124] Next, define (set) the storage device to prepare for the subsequent storage of directory objects.

[0125] Specifically, a directory tree register is defined to prepare for the subsequent storage of directory objects.

[0126] Step S103, deconstructing the nodes of the syntax tree to obtain a document directory.

[0127] As an implementation mode, in this embodiment, the nodes of Hast are traversed and deconstructed (reverse traversal) based on a preset algorithm to generate a document directory that can be finally recognized by the web page; wherein the preset algorithm includes a recursive algorithm.

[0128] Furthermore, HAST construction and deconstruction technology is a technology that can directly act on the front-end web page. Therefore, this technology has the following two main features:

[0129] (1) The application overhead is very small and no additional network overhead is required;

[0130] (2) The construction and deconstruction efficiency is very high, which is very suitable for WYSIWYG document editing scenarios.

[0131] As another implementation, the directory tree is recursively deconstructed into different tree units, each tree unit including a root node and a subtree group;

[0132] Furthermore, the layout of each directory tree unit is determined based on the relationship between the root node and the subtree group within each directory tree unit and the relationship between each subtree within the subtree group, wherein the relationship between the root node and the subtree group is a parent-child relationship, and the relationship between each subtree within the subtree group is a brother relationship.

[0133] Furthermore, the directory tree is converted into HTML directory tags according to the layout of the directory tree as a document directory.

[0134] As another implementation, the relationship between the root node and the subtree group in each tree unit and the relationship between each subtree in the subtree group are deconstructed according to the coordinate axis, including:

[0135] Deconstruct the relationship between the root node and the subtree group into three types of relationships: inclusion, juxtaposition, and inclusion on each coordinate axis;

[0136] The relationship between each subtree in the subtree group is deconstructed into two types of relationships: alignment and tiling on each coordinate axis.

[0137] Furthermore, according to the relationship between each tree and the relationship between the root node and the sub-array, the directory tree is converted into HTML directory tags as a document directory.

[0138] Therefore, HAST does not require manual maintenance, automatically obtains document information, automatically parses document content, and updates the document directory in real time.

[0139] This embodiment adopts the above scheme, specifically by reading a text document from a page; converting the text document into a syntax tree; and deconstructing the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory, and can directly generate a document directory on the front-end web page by using scripting technologies such as Javascript and DOM without the need for background program logic coordination; it does not require manual maintenance, automatically obtains document information, automatically parses document content, and updates the document directory in real time.

[0140] Reference Figure 3 , Figure 3 FIG. 2 is a flow chart of a second embodiment of a method for generating a document directory according to the present invention. Figure 2 In the embodiment shown, in this embodiment, step S103: deconstructing the syntax tree based on a preset algorithm to obtain a document directory includes:

[0141] Step S1031, traverse the nodes of the syntax tree to obtain directory objects.

[0142] As an implementation mode, in this embodiment, based on a recursive algorithm, a HAST node is read, and then it is determined whether the node is a leaf node.

[0143] The types of the node include leaf nodes and tree nodes. If the node is a leaf node, it may contain the expected title; if the node is a tree node, the tree needs to be judged again.

[0144] Therefore, the nodes of HAST are traversed through a recursive algorithm, and the traversal status of the nodes of HAST is effectively controlled, so that the document directory is updated in real time.

[0145] Furthermore, if the node is not a leaf node, the node is a subtree, and the subtree is recursively processed.

[0146] Specifically, read the node of the subtree, and then determine the type of the subtree node.

[0147] If the node / subtree node is a leaf node, it is further determined whether the label of the node / subtree node begins with a preset letter, wherein only leaf nodes with the expected title have preset letters, and the preset letters include letters such as h.

[0148] If the label of a node / subtree node starts with h, the node / subtree node is treated as a directory object and stored in a pre-prepared directory tree register.

[0149] If the label of the node / subtree node does not start with h, continue to read its sibling nodes and determine whether the sibling nodes are trees.

[0150] If the sibling node is a tree, then the node may have leaves. If the node is not a tree, then the node does not have the expected title.

[0151] Furthermore, if the node is a subtree, the execution is returned based on the preset algorithm: the node of HAST is read, and then the type of the node is determined.

[0152] If the node is not a subtree, discard the node.

[0153] Step S1032, traverse and deconstruct the directory object to obtain the document directory;

[0154] As an implementation mode, in this embodiment, the directory objects of the directory tree register are read and assembled to obtain the directory tree.

[0155] More specifically, the directory objects of the directory tree register are read and assembled according to the hierarchy of the directory objects to obtain the directory tree.

[0156] Among them, the hierarchy of the directory object is the level of the title. For example, the level of the title includes first-level title, second-level title, third-level title, etc.; the titles are sorted and assembled according to the level of the title to obtain a directory tree, that is: assembled according to the hierarchy of the directory object to obtain a directory tree.

[0157] Furthermore, the directory tree is traversed and deconstructed to obtain HTML directory tags as document directories.

[0158] As another implementation, the directory tree is recursively deconstructed into different tree units, each tree unit including a root node and a subtree group;

[0159] Furthermore, the layout of each directory tree unit is determined based on the relationship between the root node and the subtree group within each directory tree unit and the relationship between each subtree within the subtree group, wherein the relationship between the root node and the subtree group is a parent-child relationship, and the relationship between each subtree within the subtree group is a brother relationship.

[0160] Furthermore, the directory tree is converted into HTML directory tags according to the layout of the directory tree as a document directory.

[0161] As another implementation, the relationship between the root node and the subtree group in each tree unit and the relationship between each subtree in the subtree group are deconstructed according to the coordinate axis, including:

[0162] Deconstruct the relationship between the root node and the subtree group into three types of relationships: inclusion, juxtaposition, and inclusion on each coordinate axis;

[0163] The relationship between each subtree in the subtree group is deconstructed into two types of relationships: alignment and tiling on each coordinate axis.

[0164] Furthermore, according to the relationship between each tree and the relationship between the root node and the sub-array, the directory tree is converted into HTML directory tags as a document directory.

[0165] Therefore, the nodes of HAST are extracted based on a recursive algorithm to obtain a document directory, which reduces the operation steps and improves the accuracy of the document directory.

[0166] This embodiment adopts the above scheme, specifically by reading a text document from a page; converting the text document into a syntax tree; and deconstructing the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory, does not require manual maintenance, automatically obtains document information, automatically parses document content, and updates the document directory in real time; and extracts the nodes of HAST based on a recursive algorithm to obtain a document directory, thereby reducing the operation steps and improving the accuracy of the document directory.

[0167] Reference Figure 4 , Figure 4 Schematic diagram of the flow of the third embodiment of the method for generating a document directory of the present invention.

[0168] As an implementation manner, in this embodiment, a common text document input by a user is read.

[0169] Specifically, the text document is searched and read in the document database of the front end; wherein the document information may be a text document updated in real time.

[0170] Specifically, the text document is searched and read in the document database of the front end; the text document may be a text document updated in real time; the text document may be read line by line or column by column; the text document may be read in C language, C#, JAVA, etc.

[0171] Furthermore, the read text document is converted into an HTML document.

[0172] The read document is converted into an HTML document recognizable by a web page, wherein the read text document includes a plain text document.

[0173] Specifically, an open source algorithm can be applied, and the open source data package converts the read text document into an HTML document that can be recognized by the web page.

[0174] Thus, the ordinary text document input by the user is converted into an HTML document recognizable by the web page, in preparation for the subsequent Hast conversion, wherein the HTML document is an expression of a tree structure.

[0175] Furthermore, the HTML document is converted into a HAST structure.

[0176] Convert HTML documents into a Hypertext Abstract Syntax Tree (HAST), and further abstract the HTML document into a real tree object. Label the nodes of the HAST tree to prepare for the subsequent generation of the document directory.

[0177] Among them, a label is assigned to the node of the HAST tree according to its type. The label is h, which means that the node is a title, in preparation for the subsequent generation of a document directory.

[0178] Furthermore, a storage device is defined (set) to prepare for the subsequent storage of directory objects.

[0179] Specifically, a list of registered directory trees is defined to prepare for the subsequent storage of directory objects.

[0180] Furthermore, the HAST node is read and the node type is determined.

[0181] Based on the recursive algorithm, read the node of HAST, and then determine whether the node is a leaf node, where the node type includes leaf node and tree node. If the node is a leaf node, it may contain the expected title; if the node is not a leaf node, the node needs to be judged again.

[0182] Therefore, the nodes of HAST are traversed through a recursive algorithm, and the traversal status of the nodes of HAST is effectively controlled, so that the document directory is updated in real time.

[0183] Furthermore, if the node is not a leaf node, the node is a subtree node, and the subtree node is recursively processed.

[0184] If the node is a leaf node, it is further determined whether it has an h tag. Only leaf nodes with the expected title have the preset letter h.

[0185] If the node has an h tag, read the node and add it to the directory tree storage;

[0186] If the node has no h label, read the node's sibling nodes.

[0187] If the node's sibling node is a tree, the node may contain leaf nodes. If it contains leaf nodes, the leaf nodes may contain h tags, and the node may have the expected title. If the node is not a tree, the node does not have the expected title.

[0188] Furthermore, it is determined whether the brother node is a subtree.

[0189] If the sibling node is a subtree, return to execute: read the node of HAST and determine the type of the node;

[0190] If the sibling node is not a subtree, the sibling node is discarded.

[0191] Furthermore, the directory object storing the directory tree list is read, and assembled according to the hierarchy of the directory object to obtain the directory tree.

[0192] Furthermore, the directory tree is traversed and deconstructed to obtain HTML directory tags, and it is determined whether the stored directory tree list is empty.

[0193] If the stored directory tree list is empty, return to execute: traverse and deconstruct the directory tree.

[0194] If the stored directory tree list is not empty, the obtained HTML directory tag will be used as the document directory.

[0195] As another implementation, the directory tree is recursively deconstructed into different tree units, each tree unit including a root node and a subtree group;

[0196] Furthermore, the layout of each directory tree unit is determined based on the relationship between the root node and the subtree group within each directory tree unit and the relationship between each subtree within the subtree group, wherein the relationship between the root node and the subtree group is a parent-child relationship, and the relationship between each subtree within the subtree group is a brother relationship.

[0197] Furthermore, the directory tree is converted into HTML directory tags according to the layout of the directory tree as a document directory.

[0198] As another implementation, the relationship between the root node and the subtree group in each tree unit and the relationship between each subtree in the subtree group are deconstructed according to the coordinate axis, including:

[0199] Deconstruct the relationship between the root node and the subtree group into three types of relationships: inclusion, juxtaposition, and inclusion on each coordinate axis;

[0200] The relationship between each subtree in the subtree group is deconstructed into two types of relationships: alignment and tiling on each coordinate axis.

[0201] Furthermore, according to the relationship between each tree and the relationship between the root node and the sub-array, the directory tree is converted into HTML directory tags as a document directory.

[0202] Therefore, the nodes of HAST are extracted based on a recursive algorithm to obtain a document directory, which reduces the operation steps and improves the accuracy of the document directory.

[0203] This embodiment adopts the above scheme, specifically by reading a text document from a page; converting the text document into a syntax tree; and deconstructing the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory, does not require manual maintenance, automatically obtains document information, automatically parses document content, and updates the document directory in real time; and extracts the nodes of HAST based on a recursive algorithm to obtain a document directory, thereby reducing the operation steps and improving the accuracy of the document directory.

[0204] Reference Figure 5 , Figure 5 The functional module diagram of the system for generating a document directory of the present invention is shown in FIG. 1 , wherein the device for generating a document directory includes:

[0205] A document reading module 10, used for reading a text document from the page;

[0206] A document conversion module 20, used to convert the text document into a syntax tree;

[0207] The traversal deconstruction module 30 is used to deconstruct the nodes of the syntax tree to obtain a document directory.

[0208] For the principle and implementation process of generating a document directory in this embodiment, please refer to the above embodiments and will not be described in detail here.

[0209] In addition, an embodiment of the present invention also proposes a terminal device, which includes a memory, a processor, and a document directory generation program stored in the memory and runnable on the processor, wherein the document directory generation program implements the steps of the document directory generation method as described above when executed by the processor.

[0210] Since all the technical solutions of all the aforementioned embodiments are adopted when the document directory generation program is executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.

[0211] In addition, an embodiment of the present invention further proposes a computer-readable storage medium, on which a program for generating a document directory is stored. When the program for generating a document directory is executed by a processor, the steps of the method for generating a document directory as described above are implemented.

[0212] Since all the technical solutions of all the aforementioned embodiments are adopted when the document directory generation program is executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.

[0213] Compared with the prior art, the present invention provides a method, device, terminal device and storage medium for generating a document directory, which reads a text document from a page; converts the text document into a syntax tree; and deconstructs the nodes of the syntax tree to obtain a document directory. The present invention solves the problem of delayed update of the document directory and updates the document directory in real time.

[0214] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or method. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or method including the element.

[0215] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0216] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, a controlled terminal, or a network device, etc.) to execute the method of each embodiment of the present invention.

[0217] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for generating a document directory, It is characterized in that The document directory generation method is applied to a page, and the method comprises the following steps: Reading a text document from the page, the text document comprising a plain text document; Converting the text document into a syntax tree; The step of converting the text document into a syntax tree comprises: Converting the text document into a Hypertext Markup Language (HTML) document; Performing semantic abstraction on the HTML document to convert the HTML document into the syntax tree; Deconstructing the nodes of the syntax tree to obtain a document directory; Wherein, before the step of deconstructing the nodes of the syntax tree to obtain the document directory, the following steps are included: Traversing the nodes of the syntax tree to obtain a directory object; The step of deconstructing the nodes of the syntax tree to obtain a document directory comprises: Traversing and deconstructing the directory object to obtain the document directory; The step of traversing the nodes of the syntax tree to obtain the directory object comprises: Assigning labels to the syntax tree according to the types of the nodes of the syntax tree; Read a node of the syntax tree and determine whether the node is a leaf node; If the node is a leaf node, determining whether the label of the node starts with a preset letter; If the label of the node does not start with a preset letter, read the sibling node of the node; If the label of the node begins with a preset letter, the node is used as the directory object.

2. The method for generating a document directory according to claim 1, It is characterized in that The step of reading the node of the syntax tree and determining whether the node is a leaf node includes: If the node is not a leaf node, determining that the node is a subtree; Reading a node of the subtree as a subtree node, and determining whether the subtree node is a leaf node; If the node is a leaf node, the step of determining whether the label of the node begins with a preset letter comprises: If the subtree node is a leaf node, determining whether the label of the subtree node starts with a preset letter; If the label of the node does not start with a preset letter, the step of reading the sibling nodes of the node comprises: If the label of the subtree node does not start with a preset letter, read the sibling node of the subtree node; If the label of the node begins with a preset letter, the step of taking the node as the directory object comprises: If the label of the subtree node begins with a preset letter, the subtree node is used as the directory object.

3. The method for generating a document directory according to claim 1, It is characterized in that If the label of the node does not start with a preset letter, the step of reading the sibling nodes of the node includes: If the brother node is a tree node, return to the execution step: read the node of the syntax tree and determine whether the node is a leaf node; If the sibling node is not a tree node, the sibling node is discarded.

4. The method for generating a document directory according to claim 1, It is characterized in that The step of traversing the nodes of the syntax tree to obtain the directory object includes: Create directory tree register; If the label of the node begins with a preset letter, the step of taking the node as the directory object comprises: If the label of the node begins with a preset letter, the node is taken as the node object and stored in the directory tree register.

5. The method for generating a document directory according to claim 1, It is characterized in that The step of traversing and deconstructing the directory object to obtain the document directory includes: Assemble the directory objects of the directory tree register to obtain a directory tree; The directory tree is traversed and deconstructed to obtain the document directory.

6. A device for generating a document directory, It is characterized in that The document directory generation device is applied to a page, and includes: A document reading module, used for reading a text document from the page, wherein the text document includes a plain text document; A document conversion module, used for converting the text document into a syntax tree; Wherein, the document conversion module is also used for: Converting the text document into a Hypertext Markup Language (HTML) document; Performing semantic abstraction on the HTML document to convert the HTML document into the syntax tree; Traversing the deconstruction module, used to deconstruct the nodes of the syntax tree to obtain a document directory; Wherein, the traversal deconstruction module is also used for: Traversing the nodes of the syntax tree to obtain a directory object; The step of deconstructing the nodes of the syntax tree to obtain a document directory comprises: Traversing and deconstructing the directory object to obtain the document directory; Wherein, the traversal deconstruction module is also used for: Assigning labels to the syntax tree according to the types of the nodes of the syntax tree; Read a node of the syntax tree and determine whether the node is a leaf node; If the node is a leaf node, determining whether the label of the node starts with a preset letter; If the label of the node does not start with a preset letter, read the sibling node of the node; If the label of the node begins with a preset letter, the node is used as the directory object.

7. A terminal device, It is characterized in that The terminal device includes a memory, a processor, and a method for generating a document directory stored in the memory and executable on the processor. When the program for generating the document directory is executed by the processor, the steps of the method for generating a document directory as described in any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program for generating a document directory, and when the program for generating a document directory is executed by a processor, the steps of the method for generating a document directory according to any one of claims 1 to 5 are implemented.