A method and device for generating a directory
By applying serial number judgment rules in files to automatically determine directory items and levels, the problem of low efficiency in generating file directories in the prior art is solved, and an automated directory generation process is realized.
Patent Information
- Application Number
- CN201910500726.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-11
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2039-06-11
AI Technical Summary
The existing technology requires manual search for directory entries and setting of directory levels when generating a file directory, which is inefficient.
Through the preset serial number judgment rules, the directory items are determined from the files, and the directory level is determined based on the serial numbers and distribution positions of the directory items, and the file directory is generated.
It improves the efficiency of file directory generation, reduces manual intervention, and automates the search and hierarchical setting of directory items.
Smart Images

Figure CN112069126B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer file processing, and in particular to a directory generation method and device. Background Art
[0002] In order to facilitate users to quickly find information when reading files, it is usually necessary to generate a directory for the file. In the prior art, when an electronic device generates a file directory, it is usually necessary to manually search for text with a sequence number in the file, use the found text as a directory item, and set a directory level for each directory item, such as a first-level directory, a second-level directory, a third-level directory, etc., and then the electronic device generates the file directory according to the directory level set by the user.
[0003] It can be seen that although the existing technology can generate a file directory, it requires manual search for directory items and setting of directory levels, and the efficiency of generating the file directory is low. Summary of the invention
[0004] The purpose of the embodiment of the present invention is to provide a directory generation method and device to improve the efficiency of generating a file directory. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a directory generation method, the method comprising:
[0006] According to a preset sequence number judgment rule, a directory item for generating a directory is determined from a file, and a distribution position of each directory item in the file is obtained, wherein the directory item includes: a directory sequence number and directory content, the directory sequence number is located at the start position of a paragraph, and the directory content is adjacent to the directory sequence number position;
[0007] Determine the directory level of each directory item according to the directory serial number included in each directory item and the distribution position of each directory item;
[0008] Generate a file directory for the directory entry after determining the directory hierarchy.
[0009] In one embodiment of the present invention, determining the directory entry for generating the directory from the file according to a preset sequence number judgment rule includes:
[0010] According to the preset sequence number judgment rule, the directory items arranged in the order of paragraphs for generating the directory are determined from the file.
[0011] In one embodiment of the present invention, determining the directory level of each directory entry according to the directory sequence number included in each directory entry and the distribution position of each directory entry includes:
[0012] Determine the directory level of each directory item according to a preset directory level determination rule;
[0013] The directory level determination rule is as follows:
[0014] When the current directory item is the first directory item,
[0015] The directory level of the first category directory item is the same as the directory level of the first directory item, wherein the first category directory item is a directory item including a directory serial number of the same type as the directory serial number included in the first directory item;
[0016] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0017] When the current directory item is not the first directory item,
[0018] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0019] The first serial number is: the serial number of the directory included in the next directory item of the current directory item;
[0020] The second serial number is: the serial number of the directory included in the current directory item;
[0021] The third directory entry is: the first directory entry after the directory entry with the first serial number, which has a level higher than or equal to the level of the current directory entry.
[0022] In one embodiment of the present invention, the serial number determination rule is: a regular expression formed by characters representing the serial number format and the serial number string;
[0023] The serial number character string is a character string formed by characters representing each serial number of the same type.
[0024] In a second aspect, an embodiment of the present invention provides a directory generation device, the device comprising:
[0025] A directory item determination module is used to determine the directory items used to generate the directory from the file according to a preset sequence number judgment rule, and obtain the distribution position of each directory item in the file, wherein the directory item includes: a directory sequence number and directory content, the directory sequence number is located at the beginning of a paragraph, and the directory content is adjacent to the directory sequence number position;
[0026] A level determination module, used to determine the directory level of each directory item according to the directory serial number included in each directory item and the distribution position of each directory item;
[0027] The directory generation module is used to generate a file directory for the directory items after determining the directory hierarchy.
[0028] In one embodiment of the present invention, the directory entry determination module is specifically used to:
[0029] According to the preset sequence number judgment rule, the directory items arranged in the order of paragraphs for generating the directory are determined from the file.
[0030] In one embodiment of the present invention, the level determination module is specifically used to:
[0031] Determine the directory level of each directory item according to a preset directory level determination rule;
[0032] The directory level determination rule is as follows:
[0033] When the current directory item is the first directory item,
[0034] The directory level of the first category directory item is the same as the directory level of the first directory item, wherein the first category directory item is a directory item including a directory serial number of the same type as the directory serial number included in the first directory item;
[0035] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0036] When the current directory item is not the first directory item,
[0037] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0038] The first serial number is: the serial number of the directory included in the next directory item of the current directory item;
[0039] The second serial number is: the serial number of the directory included in the current directory item;
[0040] The third directory entry is: the first directory entry after the directory entry with the first serial number, which has a level higher than or equal to the level of the current directory entry.
[0041] In one embodiment of the present invention, the serial number determination rule is: a regular expression formed by characters representing the serial number format and the serial number string;
[0042] The serial number character string is a character string formed by characters representing each serial number of the same type.
[0043] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0044] Memory, used to store computer programs;
[0045] The processor is used to implement the method steps described in any one of the first aspects above when executing the program stored in the memory.
[0046] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.
[0047] It can be seen from the above technical solution that when the solution provided by the embodiment of the present invention is applied to generate a directory, the directory items used to generate the directory are determined from the file according to the pre-set sequence number judgment rule, and the distribution position of each directory item in the file is obtained, and then the directory level of each directory item is determined according to the directory sequence number included in each directory item and the distribution position of each directory item, and finally a file directory is generated for the directory items after the directory level is determined. It can be seen that when the solution provided by the embodiment of the present invention is applied to generate a directory, it is no longer necessary to manually search for directory items and set the directory level, but to use the sequence number judgment rule of the directory item to search for the directory item, and then use the directory sequence number and distribution position of the directory item to classify the directory items.
[0048] It can be seen that when the solution provided by the embodiment of the present invention is applied to generate a directory, the efficiency of generating the file directory can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 A schematic diagram of a process for generating a directory provided by an embodiment of the present invention;
[0051] Figure 2 A schematic diagram of the structure of a directory generating device provided by an embodiment of the present invention;
[0052] Figure 3A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] The embodiments of the present invention provide a directory generation method and device, which are described in detail below.
[0055] See also Figure 1 , Figure 1 A flowchart of a directory generation method provided by an embodiment of the present invention includes the following steps.
[0056] Step 101, according to a preset sequence number judgment rule, determine the directory items used to generate the directory from the file, and obtain the distribution position of each directory item in the file.
[0057] The above-mentioned directory item includes: a directory serial number and directory content, and the above-mentioned directory serial number is located at the beginning of the paragraph.
[0058] The above-mentioned directory content is adjacent to the above-mentioned directory serial number position. For example, the above-mentioned directory content can be a text of a preset length after the above-mentioned directory serial number, and the above-mentioned directory content can also be a text of a preset length including the directory serial number, wherein the above-mentioned preset length can be a preset number of words or text within preset punctuation marks.
[0059] In one embodiment of the present invention, the above-mentioned sequence number determination rule may be: a regular expression formed by characters representing the sequence number format and the sequence number character string.
[0060] The serial number character string is a character string formed by characters representing each serial number of the same type.
[0061] Specifically, the above type is the type of serial number, which is determined by the expression form of the serial number. For example, if the serial numbers are 1, 2, 3, etc., then the types of these serial numbers can be considered as Roman numeral types. If the serial numbers are one, two, three, etc., then the types of these serial numbers can be considered as Chinese character numeral types.
[0062] Furthermore, when the above serial numbers are 1, 2, 3, ..., each serial number can be represented by the characters "1", "2", "3", ... respectively, and accordingly, the above serial number character string can be: "123456789".
[0063] In the cases of the above serial numbers one, two, three... etc., each serial number can be represented by the characters "one", "two", "three"... respectively. Correspondingly, the above serial number string can be: "one two three four five six seven eight nine".
[0064] Those skilled in the art can understand that various serial numbers have their respective forms, and these forms can be represented by certain characters.
[0065] For example, when the serial numbers are: the first, the second, the third, the characters representing the serial number forms for these serial numbers can be "the". When the serial numbers are (one):, (two):, (three):, the characters representing the serial number forms for these serial numbers can be "(", ")", ":".
[0066] In view of the above situation, in the case where the above serial number string is "one two three four five six seven eight nine" and the character representing the serial number form is "the", the above regular expression is:
[0067] the[one two three four five six seven eight nine]+
[0068] In an embodiment of the present invention, according to a pre-set serial number judgment rule, directory items for generating a table of contents can be determined from a file in the order of paragraphs.
[0069] Since the determined directory items are sorted in the order of the file paragraphs, the directory serial numbers included in the directory items are also sorted in the order of the file paragraphs. In the subsequent steps of determining the directory levels of the directory items, it is no longer necessary to return and judge the position order of each directory serial number in the file, which can greatly simplify the process of determining the directory levels of the subsequent directory items.
[0070] Step 102, determine the directory levels of each directory item according to the directory serial numbers included in each directory item and the distribution positions of each directory item.
[0071] In an embodiment of the present invention, in the case where the determined directory items are arranged in the order of paragraphs, the directory levels of each directory item can be determined according to a pre-set directory level determination rule.
[0072] Among them, the above directory level determination rule is:
[0073] When the current directory item is the first directory item,
[0074] The directory level of the first type of directory item is the same as the directory level of the first directory item, where the first type of directory item is: the directory item whose included directory serial number type is the same as the directory serial number type included in the first directory item;
[0075] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0076] When the current directory item is not the first directory item,
[0077] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0078] The first serial number is: the serial number of the directory included in the next directory item of the current directory item;
[0079] The second serial number is: the serial number of the directory included in the current directory item;
[0080] The third directory entry is: the first directory entry after the directory entry with the first serial number, which has a level higher than or equal to the level of the current directory entry.
[0081] It should be noted that, in this embodiment, only the relationship between the directory levels of each directory item is given, but the execution flow for determining the directory level of each directory item is not limited. In the specific implementation process, any method that can satisfy the above-mentioned target level determination rule can be adopted to determine the directory level of each directory item. For example, the directory level of each directory item can be determined in a recursive manner, that is, first determine the directory items with a directory level of the first directory level, and set the directory level for these directory items, and then determine the directory items with a directory level of the second directory level for the directory items between every two adjacent directory items of the first directory level, and set the directory level for these directory items, until the directory levels of all directory items are determined.
[0082] The above directory level determination rules are explained below through specific examples.
[0083] Assume that the directory items arranged in paragraph order determined in step 101 are:
[0084] First, fruit
[0085] (a) Banana
[0086] (ii) Apple
[0087] Second, plants
[0088] Third, animals
[0089] In this case, "First, Fruit" is the first directory item, and the type of directory serial numbers included in "Second, Plants" and "Third, Animals" is the same as the type of directory serial numbers included in the first directory item, and belong to the first category of directory items, so the directory levels of the directory items "First, Fruit", "Second, Plants", and "Third, Animals" are the same directory level.
[0090] When the current directory item is the first directory item, the directory serial number "(one)" included in the directory item "(one), banana" is the first serial number, and the directory serial number "one" included in the directory item "first, fruit" is the second serial number. Since the types of the first serial number and the second serial number are inconsistent, and between the directory item "first, fruit" and the directory item "second, plant", the directory serial number "(two)" included in the directory item "(two), apple" is of the same type as the first serial number, the directory levels of the directory item "(one), banana" and the directory item "(two), apple" are both the next directory level of the directory level of the directory item "first, fruit".
[0091] In one embodiment of the present invention, when there is no directory entry at the same level as the current directory entry after the directory entry where the first serial number is located, the directory level of the directory entry where the directory serial number of the first type is located after the current directory entry is the next directory level of the directory level of the current directory entry.
[0092] In one embodiment of the present invention, when the first type of the first serial number is consistent with the second type of the second serial number, the directory level of the directory entry where the first serial number is located is the same as the directory level of the directory entry where the second serial number is located.
[0093] Step 103, generating a file directory for the directory entry after determining the directory hierarchy.
[0094] It can be seen that when the solution provided by the embodiment of the present invention is applied to generate a directory, the directory items used to generate the directory are determined from the file according to the pre-set sequence number judgment rule, and the distribution position of each directory item in the file is obtained, and then the directory level of each directory item is determined according to the directory sequence number included in each directory item and the distribution position of each directory item, and finally a file directory is generated for the directory items after the directory level is determined. When the solution provided by the embodiment of the present invention is applied to generate a directory, the efficiency of generating the file directory can be improved.
[0095] With respect to step 102, in another embodiment of the present invention, when the determined directory items are arranged in paragraph order, the directory serial numbers in each directory item can be extracted first, and then the directory level of each directory item can be determined according to a preset directory level determination rule.
[0096] For example, the directory numbers included in each extracted directory entry are as follows:
[0097] [“One,” “(One),” “(1),” “(2),” “(Two),” “Two,” “1,” “2,” “Three,”]
[0098] Among them, when the second serial number is "one," the first serial number is "(one)," and "two" is the directory serial number included in the third directory item. Since the serial number type of "two" and "three" is the same as that of "one," the directory level of the directory items where "two" and "three" are located is the same as the directory level of the directory item where "one" is located, and the directory level of the directory items where "(one)" and "(two)" are located is the next directory level of the directory level of the directory item where "one" is located.
[0099] When the second serial number is "(one)", the first serial number is "(1)", "(two)" is the directory serial number included in the third directory item, and the directory level of the directory items where "(1)" and "(2)" are located is the next directory level of the directory level of the directory item where "(one)" is located.
[0100] In one embodiment of the present invention, the directory items arranged in paragraph order and used to generate the directory can be determined from the file according to a preset sequence number judgment rule, and the directory sequence numbers included in each directory item can be extracted:
[0101] [“One,” “(One),” “(1),” “(2),” “(Two),” “Two,” “1,” “2,” “Three,”]
[0102] According to the directory level determination rule, the directory level of the directory item where each of the above directory serial numbers is located is determined.
[0103] Since the directory entry where "1," is located is the first directory entry, and the sequence number type of "2," and "3," is the same as that of "1," the directory levels of the directory entries where "1," "2," and "3," are located are the same, which is the first directory level;
[0104] The serial number type of "(I)" and "(II)" is the same, and "(I)" and "(II)" are located between the serial numbers "I," and "II," so the directory level where "(I)" and "(II)" are located is the next directory level of the first directory level, and is the second directory level;
[0105] Similarly, "1," and "2," are also the second directory level;
[0106] The serial number type of "(1)" and "(2)" is the same, and "(1)" and "(2)" are located between the serial numbers "(one)" and "(two)", so the directory level where "(1)" and "(2)" are located is the next directory level of the second directory level, which is the third directory level.
[0107] Generate a file directory for the directory entry after determining the directory hierarchy.
[0108] Figure 2 A schematic diagram of a graphic adjustment device provided by an embodiment of the present invention, the device comprising:
[0109] The directory item determination module 201 is used to determine the directory items used to generate the directory from the file according to the preset sequence number judgment rule, and obtain the distribution position of each directory item in the file, wherein the directory item includes: a directory sequence number and directory content, the directory sequence number is located at the beginning of a paragraph, and the directory content is adjacent to the directory sequence number position;
[0110] The level determination module 202 is used to determine the directory level of each directory item according to the directory serial number included in each directory item and the distribution position of each directory item;
[0111] Directory generation module 203: used to generate a file directory for the directory items after determining the directory hierarchy.
[0112] In one embodiment of the present invention, the directory item determination module 201 is specifically used to:
[0113] According to the pre-set sequence number judgment rule, the directory items arranged in paragraph order and used to generate the directory are determined from the file.
[0114] In one embodiment of the present invention, the level determination module 202 is specifically configured to:
[0115] Determine the directory level of each directory item according to the preset directory level determination rule;
[0116] The directory level determination rule is as follows:
[0117] When the current directory item is the first directory item,
[0118] The directory level of the first category directory item is the same as the directory level of the first directory item, wherein the first category directory item is a directory item including a directory serial number of the same type as the directory serial number included in the first directory item;
[0119] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0120] When the current directory item is not the first directory item,
[0121] When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item;
[0122] The first serial number is: the serial number of the directory included in the next directory item of the current directory item;
[0123] The second serial number is: the serial number of the directory included in the current directory item;
[0124] The third directory entry is: the first directory entry after the directory entry with the first serial number, which has a level higher than or equal to the level of the current directory entry.
[0125] In one embodiment of the present invention, the above-mentioned serial number determination rule is: a regular expression formed by characters representing the serial number format and the serial number string;
[0126] The serial number character string is a character string formed by characters representing each serial number of the same type.
[0127] It can be seen that when the solution provided by the embodiment of the present invention is used to generate a directory, the directory items used to generate the directory are determined from the file according to the pre-set sequence number judgment rule, and the distribution position of each directory item in the file is obtained, and then the directory level of each directory item is determined according to the directory sequence number included in each directory item and the distribution position of each directory item, and finally a file directory is generated for the directory items after the directory level is determined. When the device provided by the embodiment of the present invention is used to generate a directory, the efficiency of generating the file directory can be improved.
[0128] The embodiment of the present invention further provides an electronic device, such as Figure 3 As shown, it includes a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304.
[0129] Memory 303, used for storing computer programs;
[0130] The processor 301 is used to implement the directory generation method provided by the embodiment of the present invention when executing the program stored in the memory 303.
[0131] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0132] The communication interface is used for communication between the above electronic device and other devices.
[0133] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0134] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0135] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned directory generation methods are implemented.
[0136] In another embodiment of the present invention, a computer program product including instructions is provided, which, when executed on a computer, enables the computer to execute any directory generation method in the above embodiments.
[0137] It can be seen that when the electronic device provided by the above embodiment is applied to generate a directory, when the computer program stored in the computer-readable storage medium provided by the above embodiment is executed to generate a directory, and when the computer program product provided by the above embodiment is run on a computer to generate a directory, the directory items used to generate the directory are determined from the file according to the pre-set serial number judgment rule, and the distribution position of each directory item in the file is obtained, and then the directory level of each directory item is determined according to the directory serial number included in each directory item and the distribution position of each directory item, and finally a file directory is generated for the directory items after the directory level is determined.
[0138] The electronic device, readable storage medium and computer program product provided by the embodiment of the present invention can quickly and accurately implement the directory generation method provided by the embodiment of the present invention. Compared with the prior art, the solution provided by the embodiment of the present invention no longer requires manual search for directory items and setting of directory levels, but uses the sequence number judgment rule of the directory item to search for directory items, and then uses the directory sequence number and distribution position of the directory item to classify the directory items. It can be seen that when the solution provided by the embodiment of the present invention is used to generate a directory, the generation efficiency of the file directory can be improved.
[0139] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0140] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device 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 device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0141] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, electronic device embodiment, computer-readable storage medium embodiment, and computer program product embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0142] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for generating a directory, characterized in that: The method comprises: According to a preset sequence number judgment rule, a directory item for generating a directory is determined from a file, and a distribution position of each directory item in the file is obtained, wherein the directory item includes: a directory sequence number and directory content, the directory sequence number is located at the start position of a paragraph, and the directory content is adjacent to the directory sequence number position; Determine the directory level of each directory item according to the directory serial number included in each directory item and the distribution position of each directory item; Generate a file directory for the directory items after determining the directory hierarchy; Determining the directory level of each directory item according to the directory serial number included in each directory item and the distribution position of each directory item includes: Determine the directory level of each directory item according to a preset directory level determination rule; The directory level determination rule is as follows: When the current directory item is the first directory item, The directory level of the first category directory item is the same as the directory level of the first directory item, wherein the first category directory item is a directory item including a directory serial number of the same type as the directory serial number included in the first directory item; When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item; When the current directory item is not the first directory item, When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item; The first serial number is: the serial number of the directory included in the next directory item of the current directory item; The second serial number is: the serial number of the directory included in the current directory item; The third directory entry is: the first directory entry after the directory entry with the first serial number, which has a level higher than or equal to the level of the current directory entry.
2. The method according to claim 1, characterized in that The step of determining the directory entry for generating the directory from the file according to the preset sequence number judgment rule includes: According to the preset sequence number judgment rule, the directory items arranged in the order of paragraphs for generating the directory are determined from the file.
3. The method according to any one of claims 1 to 2, characterized in that: The serial number judgment rule is: a regular expression formed by characters representing the serial number format and the serial number string; The serial number character string is a character string formed by characters representing each serial number of the same type.
4. A directory generating device, characterized in that: The device comprises: A directory item determination module is used to determine the directory items used to generate the directory from the file according to a preset sequence number judgment rule, and obtain the distribution position of each directory item in the file, wherein the directory item includes: a directory sequence number and directory content, the directory sequence number is located at the beginning of a paragraph, and the directory content is adjacent to the directory sequence number position; A level determination module, used to determine the directory level of each directory item according to the directory serial number included in each directory item and the distribution position of each directory item; A directory generation module is used to generate a file directory for the directory items after determining the directory hierarchy; The level determination module is specifically used to: Determine the directory level of each directory item according to a preset directory level determination rule; The directory level determination rule is as follows: When the current directory item is the first directory item, The directory level of the first category directory item is the same as the directory level of the first directory item, wherein the first category directory item is a directory item including a directory serial number of the same type as the directory serial number included in the first directory item; When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item; When the current directory item is not the first directory item, When the first type of the first serial number is inconsistent with the second type of the second serial number, the directory level of the directory item between the current directory item and the third directory item and where the directory serial number of the first type is located is the next directory level of the directory level of the current directory item; The first serial number is: the serial number of the directory included in the next directory item of the current directory item; The second serial number is: the serial number of the directory included in the current directory item; The third directory entry is: the first directory entry after the directory entry with the first serial number, which has a level higher than or equal to the level of the current directory entry.
5. The device according to claim 4, characterized in that The directory item determination module is specifically used to: According to the pre-set sequence number judgment rule, the directory items arranged in paragraph order and used to generate the directory are determined from the file.
6. The device according to any one of claims 4-5, characterized in that The serial number judgment rule is: a regular expression formed by characters representing the serial number format and the serial number string; The serial number character string is a character string formed by characters representing each serial number of the same type.
7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 3 when executing a program stored in a memory.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented.
