Document structure analysis method and device, terminal equipment and storage medium

Identifying paragraph categories through paragraph segmentation, feature determination and classification models solves the problem of poor versatility in the existing technology, enables structural analysis of different types of documents, and improves the versatility and efficiency of document structure identification.

CN118734830APending Publication Date: 2024-10-01JINGDONG CITY BEIJING DIGITS TECH CO LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410876093.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing document structure parsing technology requires relevant attributes to be set in advance, resulting in poor versatility and inability to effectively identify and parse different types of document structures.

Method used

By obtaining text data, paragraph segmentation is performed, paragraph characteristics are determined, and a preset classification model is used to identify paragraph categories, convert title category paragraphs into title patterns, and determine title levels according to title patterns, thereby building a document structure and realizing a common structure for different types of documents. parse.

Benefits of technology

The document hierarchy can be identified and constructed without preset attribute matching, which improves the versatility and efficiency of document structure parsing and is suitable for various types of documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734830A_ABST
    Figure CN118734830A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a document structure analysis method and device, terminal equipment and a storage medium, and the method comprises the steps: obtaining the text data of a to-be-analyzed document, and carrying out the paragraph segmentation of the text data; traversing the paragraphs obtained by segmentation, and determining paragraph features of the currently traversed paragraphs; determining the paragraph category of the current traversal paragraph according to the paragraph features of the current traversal paragraph through a preset classification model; when the traversal is completed, converting each paragraph of which the paragraph category belongs to the title category into a title mode; and according to the sequence of the paragraphs corresponding to the title modes, determining title hierarchies corresponding to the title modes, and according to the title hierarchies, determining a document structure of the to-be-analyzed document. Structural analysis of various documents can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a document structure parsing method, apparatus, terminal device and storage medium. Background Art

[0002] Content analysis of documents such as regulations and technologies is an important intelligence tool for industrial development. Document structure analysis lays an important foundation for document content analysis. Existing document structure analysis technologies usually identify document structures through simple preset attribute matching.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following technical problems in the prior art: relevant attributes need to be set in advance for each type of document, resulting in poor versatility. Summary of the invention

[0004] The embodiments of the present invention provide a document structure parsing method, apparatus, terminal device and storage medium, which can implement the structure parsing of various types of documents.

[0005] In a first aspect, an embodiment of the present invention provides a document structure parsing method, comprising:

[0006] Obtaining text data of the document to be parsed, and segmenting the text data into paragraphs;

[0007] Traverse each segmented paragraph and determine the paragraph features of the currently traversed paragraph;

[0008] Determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph by using a preset classification model;

[0009] When the traversal is completed, each paragraph whose paragraph category belongs to the title category is converted into a title mode;

[0010] According to the sequence of paragraphs corresponding to each of the title patterns, the title levels corresponding to each of the title patterns are determined, and the document structure of the document to be parsed is determined according to each of the title levels.

[0011] In a second aspect, an embodiment of the present invention provides a document structure parsing device, comprising:

[0012] A paragraph segmentation module, used to obtain text data of a document to be parsed and segment the text data into paragraphs;

[0013] A feature determination module is used to traverse each segmented paragraph and determine the paragraph feature of the currently traversed paragraph;

[0014] A classification module, used to determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph by using a preset classification model;

[0015] A conversion module, used for converting each paragraph belonging to the title category into a title mode when the traversal is completed;

[0016] The structure determination module is used to determine the title level corresponding to each title pattern according to the sequence of paragraphs corresponding to each title pattern, and determine the document structure of the document to be parsed according to each title level.

[0017] In a third aspect, an embodiment of the present invention provides a terminal device, including:

[0018] one or more processors;

[0019] A memory for storing one or more programs;

[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement the document structure parsing method as described in any embodiment of the present invention.

[0021] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the document structure parsing method as described in any embodiment of the present invention.

[0022] A document structure parsing method, apparatus, terminal device and storage medium provided by an embodiment of the present invention obtain text data of a document to be parsed, and segment the text data into paragraphs; traverse each paragraph obtained by segmentation, and determine the paragraph features of the currently traversed paragraph; determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph through a preset classification model; when the traversal is completed, convert each paragraph whose paragraph category belongs to the title category into a title mode; determine the title level corresponding to each title mode according to the sequence of paragraphs corresponding to each title mode, and determine the document structure of the document to be parsed according to each title level.

[0023] In the technical solution of the present invention, it is possible to identify whether each paragraph belongs to the title category based on the paragraph features of each paragraph based on a preset classification model. Then, for the paragraphs belonging to the title category, the paragraph can be converted into a title pattern. After that, each title pattern can be compared in sequence according to the general writing specifications to determine the title level corresponding to each title pattern. Furthermore, the hierarchical structure of the document to be parsed can be obtained according to each title level. For different types of documents, there is no need to perform preset attribute matching. Only by comparing the title patterns in the document, the hierarchical structure of the document can be constructed, thereby realizing the structural parsing of various types of documents. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are 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.

[0025] Figure 1 A flowchart of a document structure parsing method provided by an embodiment of the present invention is shown;

[0026] Figure 2 A flowchart of a document structure parsing method provided by an embodiment of the present invention is shown;

[0027] Figure 3 A flowchart of paragraph classification in a document structure parsing method provided by an embodiment of the present invention is shown;

[0028] Figure 4 A flowchart of constructing a preset path dictionary in a document structure parsing method provided by an embodiment of the present invention is shown;

[0029] Figure 5 A schematic diagram of the structure of a document structure parsing device provided by an embodiment of the present invention is shown;

[0030] Figure 6 A schematic diagram of the hardware structure of a terminal device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described through the implementation method with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in 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. In the following embodiments, optional features and examples are provided in each embodiment at the same time. The various features recorded in the embodiments can be combined to form multiple optional schemes, and each numbered embodiment should not be regarded as only one technical scheme. The acquisition, storage, use, processing, etc. of data in the technical scheme of this application comply with the relevant provisions of national laws and regulations.

[0032] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0033] Figure 1 A flowchart of a document structure parsing method provided by an embodiment of the present invention is shown. The document structure parsing method provided by an embodiment of the present invention can be applied to the structural parsing of unstructured documents. The method can be executed by a document structure parsing device, which is implemented in software and / or hardware, and is preferably configured in a terminal device, such as a computer or other terminal device.

[0034] like Figure 1 As shown, the document structure parsing method provided in the embodiment of the present invention includes the following steps:

[0035] S110: Acquire text data of the document to be parsed, and divide the text data into paragraphs.

[0036] In an embodiment of the present invention, the document to be parsed can be considered as a document whose document structure has not been parsed, and can be considered as an unstructured document. Among them, the format of the document to be parsed may include but is not limited to word, PDF, image, and voice formats. In the case where the document to be parsed is in a non-text format, the text data of the document to be parsed can be obtained through an existing recognition algorithm. For example, the document to be parsed in PDF or image format can be recognized by an optical character recognition (OCR) algorithm to obtain its text data; for example, the document to be parsed in voice format can be recognized by an automatic speech recognition (ASR) algorithm to obtain its text data, etc.

[0037] After obtaining the text data of the document to be parsed, the text data may be segmented into paragraphs according to line break marks in the text data to obtain at least one paragraph.

[0038] S120, traversing each segmented paragraph and determining the paragraph feature of the currently traversed paragraph.

[0039] In this embodiment, traversing each paragraph can be understood as obtaining each paragraph in sequence according to the order of the text of the document to be parsed. When each paragraph is obtained, the paragraph feature of the currently traversed paragraph can be determined. Among them, the paragraph feature can be used to characterize the paragraph category, and the paragraph feature can include but is not limited to text content features, character quantity features, and position features in the document.

[0040] In some optional implementations, determining the paragraph features of the currently traversed paragraph may include: determining the word embedding features and the word frequency-inverse text frequency index of each word in the currently traversed paragraph; determining the paragraph features of the currently traversed paragraph based on the word embedding features and the word frequency-inverse text frequency index of each word.

[0041] For the currently traversed paragraph, first remove the spaces, tabs and other characters at both ends of the paragraph to obtain the plain text data. Then, segment the paragraph based on the existing word segmentation technology to obtain the words. After that, use the existing word-semantic vector set to query the semantic vector corresponding to each word. The semantic vector can be called the word embedding feature of the corresponding word. In addition, the term frequency-inverse text frequency index (TF-IDF) of each word can be determined based on the following formula:

[0042]

[0043] tfidf i,j =tf i,j ×idf i,j ;

[0044] Among them, n i,j Indicates the frequency of word i appearing in the current traversal paragraph j; n k,j Indicates the frequency of word k appearing in the current traversal paragraph j; tf i,j It can represent the frequency of word i appearing in the currently traversed paragraph j. Among them, |D| can represent the number of paragraphs in the entire document to be parsed, |{j:t i ∈d j}| can represent the number of paragraphs containing word i, idf i,j It can represent the inverse text frequency index of word i, which can represent the importance of the word. i,j With idf i,j Multiplying them together gives the TF-IDF of the word. A high word frequency in a paragraph and a low paragraph frequency of the word in the entire document can produce a high-weighted TF-IDF. TF-IDF tends to filter out common words and retain important words.

[0045] In these optional implementations, the TF-IDF of the words in the paragraph can be used as the weight of the word importance, and the TF-IDF of each word can be multiplied by the corresponding word embedding feature and then summed up to obtain the text content feature of the paragraph, which can be used as the paragraph feature of the paragraph.

[0046] In addition, in some optional implementations, paragraph features can also be determined based on at least one of the following: the paragraph category of the previous paragraph, the ratio of the current traversal paragraph sequence number to the total number of paragraphs in the document to be parsed, and the number of characters in the current traversal paragraph, the number and density of punctuation marks, the number and density of numbers, and the number of sentences.

[0047] The paragraph category of the preceding paragraph may include the paragraph category of at least one preceding paragraph, which may characterize the possible paragraph category of the current paragraph to a certain extent. The paragraph category may be characterized in a one-hot encoding format. In one-hot encoding, the numerical values ​​of each dimension may correspond to each paragraph category, and the numerical value of the dimension of the paragraph category to which the preceding paragraph belongs may be assigned a value of 1, and the numerical values ​​of other dimensions may be 0. The ratio of the sequence number of the currently traversed paragraph to the total number of paragraphs in the document to be parsed may characterize the positional characteristics of the currently traversed paragraph in the document to be parsed. The number of characters, the number and density of punctuation marks, the number and density of numbers, and the number of sentences in the currently traversed paragraph may also characterize the content characteristics of the current paragraph to a certain extent.

[0048] Among them, the features involving quantity (such as the number of characters, the number and density of punctuation marks, the number and density of numbers, and the number of sentences) can be scaled to the range of 0-1 through maximum-minimum value normalization. For example, assuming that f is the original feature value and f′ is the normalized feature value, then f′ can be expressed as f′=(ff min ) / (f max -f min ), where f max 、f min It can be set according to the empirical value in the specific application scenario. By normalizing the quantitative features, it is helpful to construct a unified measurement for different documents, so that paragraphs can be classified according to paragraph features for any document.

[0049] S130 , determining the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph through a preset classification model.

[0050] In the embodiment of the present invention, the preset classification model can be considered as a trained text classification model, for example, it can include a text convolutional neural network (text CNN) model, etc. The paragraph features of the currently traversed paragraph can be input into the preset classification model, so that the preset classification model can perform a binary classification judgment on whether it belongs to the title category, and further determine whether the currently traversed paragraph belongs to the title category or the non-title category.

[0051] S140, when the traversal is completed, convert each paragraph whose paragraph category belongs to the title category into the title mode.

[0052] In the embodiment of the present invention, it is possible to sequentially determine whether each paragraph is a title category, and when the traversal is completed, each paragraph belonging to the title category can be determined. Among them, the title mode can be considered as a character mode that can represent the substantive level of the title. By converting each paragraph belonging to the title category into the title mode, the representational content of each paragraph can be removed, and the content that can represent the substantive level of the title can be retained, which is conducive to the hierarchical division of the title paragraph.

[0053] In some optional implementations, converting each paragraph whose paragraph category belongs to the title category into a title mode may include: retaining the paragraph whose paragraph category belongs to the title category until the matching end position; replacing the retained text with target characters according to a preset replacement rule to obtain a title mode.

[0054] Among them, the position of the preset end position character (such as ",","." or space, etc.) can be used as the matching end position. When the preset end position character is matched, the character and the previous text can be retained. Exemplarily, when the paragraph content belonging to the paragraph category is "I. Development background", the paragraph content can be retained to the matching end position, for example, only the text "I." is retained. In this way, the representational content of the paragraph can be removed, and the content that can represent the substantive level of the title can be retained.

[0055] After obtaining the retained text, the retained text can be replaced with the target characters according to the preset replacement rules. The preset replacement rules may include corresponding replacement rules for numbers of different formats, different symbols and preset characters. For example, the text formats of "one", "two" and "three" can correspond to the preset characters "$$$"; the numbers of "1", "2" and "3" can correspond to the preset characters "###". Accordingly, the retained text "one," in the above example can be replaced with "$$$," to obtain the title mode "$$$,".

[0056] In these optional implementations, by retaining the paragraphs until the matching end position and replacing the retained text with the target characters, the title paragraphs of the same format can be ensured to have the same title pattern, thus laying the foundation for the recognition of the title level.

[0057] S150, determining the title levels corresponding to the title patterns according to the sequence of the paragraphs corresponding to the title patterns, and determining the document structure of the document to be parsed according to the title levels.

[0058] In general writing standards, usually a parent title contains a subset title, and after the subset title ends, it can return to the parent title. In this embodiment, each title mode can be compared in sequence based on the general writing standards to determine the title level corresponding to each title mode.

[0059] Among them, the first title mode obtained can be defined as a first-level title, that is, the highest-level title. At this time, the first-level title mode can be used as a parent title and compared with the newly obtained title mode. When the title mode obtained again is the same as the title mode of the first-level title, the title mode obtained again is still a first-level title; when the title mode obtained again is different from the title mode of the first-level title, the title mode obtained again can be defined as a second-level title, that is, the second-highest-level title.

[0060] After that, the second-level title can be used as the parent title to compare with the newly acquired title pattern. When the title pattern acquired for the third time is the same as the title pattern of the second-level title, the title pattern acquired for the third time is still the second-level title; when it is the same as the title pattern of the first-level title, the title pattern acquired for the third time will return to the first-level title; when it is different from the title patterns of both the first-level title and the second-level title, the title pattern acquired for the third time is the third-level title. Among them, after returning to the parent-level title pattern from the child-level title pattern, it will be compared with the parent-level title pattern to determine the title level of the title pattern acquired subsequently.

[0061] In the first-level title, second-level title and third-level title described in this embodiment, the smaller the number, the higher the level. In addition, the description methods of other title levels can also be applied here, and they are not exhaustive here. It is worth noting that in this embodiment, only examples are given for the identification of "first-level title", "second-level title" and "third-level title", and the identification of other title levels can also refer to this description, and they are not exhaustive here.

[0062] After identifying the title levels, a hierarchical structure of the document to be parsed can be constructed according to each title level. The hierarchical structure can include various forms of structures, such as a hierarchical structure in a tree navigation format, or a hierarchical structure in a title path dictionary format.

[0063] In this embodiment, for different types of documents, there is no need to perform preset attribute matching. Only by comparing the title patterns within the document, the hierarchical structure of the document can be constructed, thereby achieving structural analysis of various types of documents.

[0064] A document structure parsing method provided by an embodiment of the present invention includes: obtaining text data of a document to be parsed, and dividing the text data into paragraphs; traversing each paragraph obtained by the segmentation, and determining the paragraph features of the currently traversed paragraph; determining the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph through a preset classification model; when the traversal is completed, converting each paragraph whose paragraph category belongs to the title category into a title mode; determining the title level corresponding to each title mode according to the sequence of paragraphs corresponding to each title mode, and determining the document structure of the document to be parsed according to each title level.

[0065] In the technical solution of the present invention, it is possible to identify whether each paragraph belongs to the title category based on the paragraph features of each paragraph based on a preset classification model. Then, for the paragraphs belonging to the title category, the paragraph can be converted into a title pattern. After that, each title pattern can be compared in sequence according to the general writing specifications to determine the title level corresponding to each title pattern. Furthermore, the hierarchical structure of the document to be parsed can be obtained according to each title level. For different types of documents, there is no need to perform preset attribute matching. Only by comparing the title patterns in the document, the hierarchical structure of the document can be constructed, thereby realizing the structural parsing of various types of documents.

[0066] Based on the above embodiments, this embodiment describes in detail how to determine the document structure of the document to be parsed according to the title level. By initializing a preset path dictionary, sequentially comparing each title pattern to determine the title level, and determining the title path of the corresponding paragraph in the preset path dictionary according to the title level, the document structure in the form of a title path dictionary can be obtained.

[0067] Figure 2 A flowchart of a document structure parsing method provided by an embodiment of the present invention is shown. Figure 2 , the document structure parsing method may include the following steps:

[0068] S201, obtaining text data of a document to be parsed, and dividing the text data into paragraphs.

[0069] S202: traverse each segmented paragraph and determine the paragraph feature of the currently traversed paragraph.

[0070] S203: Determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph by using a preset classification model.

[0071] S204: When the traversal is completed, each paragraph whose paragraph category belongs to the title category is converted into the title mode.

[0072] S205. Obtain each title mode in sequence according to the order of the paragraphs corresponding to each title mode.

[0073] Before obtaining the title mode, the preset path dictionary D can be initialized to be empty, and the title path P can be initialized to be empty; wherein P can be used to mark the title path in D corresponding to the current title mode. Exemplarily, the format of P can be {"first-level title": "paragraph content", "second-level title": "paragraph content", ...}, wherein P can include multiple title levels, and the number of levels contained therein can be set according to the actual application scenario, for example, it can be 5 title levels.

[0074] S206. When the current title mode is the same as the previous title mode, the title level of the previous title mode is used as the title level of the current title mode.

[0075] The first title pattern obtained can be used as the highest level title pattern. For example, its title path P is, for example, {"First Level Title": "I. Development Background"}, that is, other levels in P that are lower than the level corresponding to the current title pattern can be deleted. The title pattern obtained later can be compared with the previous title pattern.

[0076] For example, when the first title pattern obtained is "$$$," and the second current title pattern obtained is also "$$$," the title level of the previous title pattern is the title level of the current title pattern. At this time, the title path P can be, for example, {"First-level title": "II. Overall requirements"}.

[0077] S207: When the current title mode and the title mode acquired in the history are different, the next level of the title level of the previous title mode is used as the title level of the current title mode.

[0078] Exemplarily, when the first title pattern obtained is "$$$," and the current title pattern obtained for the second time is also "($$$),," the current title pattern is different from the title pattern obtained historically. At this time, the next level of the title hierarchy of the previous title pattern can be used as the title hierarchy of the current title pattern. At this time, the title path P can be, for example, {"First-level title": "I. Development background", "Second-level title": "(I) Reality foundation"}.

[0079] S208. When the current title mode is different from the previous title mode, but the same title mode exists in the historically acquired title modes, the title level of the same title mode is used as the title level of the current title mode.

[0080] For example, when the title pattern obtained for the third time is "$$$," which is different from the title pattern "($$$)," obtained for the second time, but the same as the title pattern "$$$," obtained for the first time, the title level of the title pattern obtained for the first time can be used as the title level of the current title pattern. At this time, the title path P can be, for example, {"First-level title": "II. Overall requirements"}.

[0081] As can be seen from the above description, the title path P changes with the current title mode obtained in sequence.

[0082] S209: updating the titles of the corresponding levels in the preset path dictionary according to the paragraphs corresponding to each title level, and using the updated preset path dictionary as the document structure of the document to be parsed.

[0083] In this embodiment, the title levels and the paragraphs corresponding to the title levels may be included in the title path P. Updating the titles of the corresponding levels in the preset path dictionary D according to the paragraphs corresponding to each title level may include updating the path in the preset path dictionary D with the title path P corresponding to the current title mode. For example, the title path P corresponding to the current title mode may be added to the preset path dictionary D.

[0084] Exemplarily, the title path P changes as the current title mode is acquired in sequence as follows:

[0085] {“First-level title”: “I. Development background”};

[0086] {“First-level title”: “I. Development background”, “Second-level title”: “(I) Realistic basis”};

[0087] {“First-level title”: “I. Development Background”, “Second-level title”: “(II) Opportunities and Challenges”;

[0088] {“First level title”: “II. Overall requirements”};

[0089] {“First-level title”: “II. General requirements”, “Second-level title”: “(I) Guiding ideology};

[0090] {“First-level title”: “II. General requirements”, “Second-level title”: “(II) Basic principles”;

[0091] {“First-level title”: “II. General requirements”, “Second-level title”: “(III) Main objectives}.

[0092] Each updated P can be added to the preset path dictionary D until all P corresponding to the paragraphs of each title category are added to D, thereby obtaining an updated preset path dictionary D. The updated D can be used as the document structure of the document to be parsed.

[0093] In some optional implementations, the paragraph category may also include at least one of the following: a directory category, a table category, and a body category. Figure 3 FIG. 1 is a flowchart showing paragraph classification in a document structure parsing method provided by an embodiment of the present invention. Figure 3 ,The process of paragraph classification in the document structure parsing method may include:

[0094] S301, after starting, obtaining text data of the document to be parsed;

[0095] S302, segmenting the text data into paragraphs;

[0096] S303, sequentially obtaining each segmented paragraph, and determining the paragraph feature of the currently traversed paragraph;

[0097] S304, using a preset catalog classification model, determine whether the currently traversed paragraph is a catalog category according to the paragraph characteristics; if so, mark the category label of the currently traversed paragraph as a catalog label, if not, jump to S305;

[0098] S305, using a preset title classification model, determine whether the currently traversed paragraph is a title category according to the paragraph characteristics; if so, mark the category label of the currently traversed paragraph as a title label, if not, jump to S306;

[0099] S306, using a preset table classification model, determine whether the currently traversed paragraph is a table category according to the paragraph characteristics; if so, mark the category label of the currently traversed paragraph as a table label, if not, jump to S307;

[0100] S307, taking the currently traversed paragraph as the text category, and marking the category tag of the currently traversed paragraph as the text tag;

[0101] S308, determine whether all paragraphs have been obtained; if yes, jump to S309, if not, jump to S303;

[0102] S309: Output the paragraphs of the text to be parsed and the category labels corresponding to each paragraph, and then end the process.

[0103] Among them, the preset directory classification model, the preset title classification model, and the preset table classification model can all belong to the binary classification text CNN model, but the training data used in these models are different. For example, in the training data of the preset directory classification model, the positive sample data are paragraphs belonging to the directory category, and the negative sample data are paragraphs not belonging to the directory category; in the training data of the preset title classification model, the positive sample data are paragraphs belonging to the title category, and the negative sample data are paragraphs not belonging to the title category; in the training data of the preset table classification model, the positive sample data are paragraphs belonging to the table category, and the negative sample data are paragraphs not belonging to the table category.

[0104] After determining the category label of each paragraph, each paragraph belonging to the title tag can be converted into a title mode, and according to the sequence of paragraphs corresponding to each title mode, the title level corresponding to each title mode can be determined, and the document structure of the document to be parsed can be determined according to each title level.

[0105] Correspondingly, the document structure parsing method may further include: determining the title levels corresponding to the paragraphs belonging to the directory category, table category and text category according to the title level of the preceding paragraph. In this embodiment, the title levels of the paragraphs belonging to the directory category, table category and text category may be determined as the title levels of the paragraphs belonging to the preceding title category, thereby facilitating the query analysis of the paragraphs belonging to the directory category, table category and text category.

[0106] For example, Figure 4 The flowchart of constructing a preset path dictionary in a document structure parsing method provided by an embodiment of the present invention is shown. Figure 4 , the construction process of the preset path dictionary in the document structure parsing method may include:

[0107] S401, after starting, initialize the default path dictionary to be empty;

[0108] S402, obtaining each paragraph and its category label in sequence according to the sequence of each paragraph;

[0109] S403, determine whether the category tag is a title tag; if so, jump to S404, if not, jump to S406;

[0110] S404, converting the currently acquired paragraph into a title mode;

[0111] S405, determining the title level corresponding to each title mode according to the sequence of paragraphs corresponding to each title mode; wherein the title level corresponding to the title mode can be represented by a title path;

[0112] S406, determining the title levels corresponding to the paragraphs belonging to the directory category, the table category, and the text category according to the title level of the preceding paragraph;

[0113] S406, updating the titles of the corresponding levels in the preset path dictionary according to the paragraphs corresponding to each title level;

[0114] S407, determine whether all paragraphs of the document to be parsed are obtained; if so, end the process, if not, jump to S402.

[0115] In this embodiment, in addition to extracting paragraphs of the title category to construct the document structure, paragraphs of the document body category, table category, directory category, etc. can also be extracted to assist in constructing the document structure, which is conducive to achieving more detailed document parsing and is of great significance to industrial development.

[0116] Based on the above embodiment, the embodiment of the present invention describes in detail the document structure of the document to be parsed according to the title level. By initializing the preset path dictionary, comparing each title pattern in sequence to determine the title level, and determining the title path of the corresponding paragraph in the preset path dictionary according to the title level, the document structure in the form of a title path dictionary can be obtained. In addition, the document structure parsing method proposed in the embodiment of the present invention and the above embodiment belongs to the same inventive concept, and the technical details not described in detail in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0117] Figure 5 The schematic diagram of the structure of a document structure parsing device provided by an embodiment of the present invention is shown. The embodiment of the present invention is applicable to the structural parsing of unstructured documents. The document structure parsing method provided by the above embodiment can be implemented by the document structure parsing device provided by the present invention.

[0118] like Figure 5 As shown, the document structure parsing device in the embodiment of the present invention may include:

[0119] The paragraph segmentation module 510 is used to obtain text data of the document to be parsed and segment the text data into paragraphs;

[0120] A feature determination module 520 is used to traverse each segmented paragraph and determine the paragraph feature of the currently traversed paragraph;

[0121] The classification module 530 is used to determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph by using a preset classification model;

[0122] A conversion module 540, used for converting each paragraph whose paragraph category belongs to the title category into a title mode when the traversal is completed;

[0123] The structure determination module 550 is used to determine the title level corresponding to each title pattern according to the sequence of paragraphs corresponding to each title pattern, and determine the document structure of the document to be parsed according to each title level.

[0124] In some optional implementations, the feature determination module may be used to:

[0125] Determine the word embedding features and word frequency-inverse text frequency index of each word in the currently traversed paragraph;

[0126] According to the word embedding features of each word and the word frequency-inverse text frequency index, the paragraph features of the current traversal paragraph are determined.

[0127] In some optional implementations, the feature determination module may also be used to determine the paragraph feature based on at least one of the following:

[0128] The paragraph category of the previous paragraph, the ratio of the current traversal paragraph number to the total number of paragraphs in the document to be parsed, and the number of characters, the number and density of punctuation marks, the number and density of numbers, and the number of sentences in the current traversal paragraph.

[0129] In some optional implementations, the conversion module may be used to:

[0130] Keep the paragraphs whose paragraph category belongs to the heading category until the matching ends;

[0131] The retained text is replaced with target characters according to the preset replacement rules to obtain the title mode.

[0132] In some optional embodiments, the structure determination module can be used to:

[0133] Obtain each title mode in sequence according to the order of the paragraphs corresponding to each title mode;

[0134] When the current title mode is the same as the previous title mode, the title level of the previous title mode is used as the title level of the current title mode;

[0135] When the current title mode is different from the title mode obtained in the past, the next level of the title level of the previous title mode is used as the title level of the current title mode;

[0136] When the current title mode is different from the previous title mode, but the same title mode exists in the historically acquired title modes, the title level of the same title mode is used as the title level of the current title mode.

[0137] In some optional embodiments, the structure determination module can be used to:

[0138] According to the paragraphs corresponding to each title level, the titles of the corresponding levels in the preset path dictionary are updated, and the updated preset path dictionary is used as the document structure of the document to be parsed.

[0139] In some optional embodiments, the paragraph category further includes at least one of the following: a directory category, a table category, and a body category;

[0140] Correspondingly, the structure determination module can also be used to determine the title levels corresponding to paragraphs belonging to the directory category, table category and text category according to the title level of the preceding paragraph.

[0141] The document structure parsing device provided in the embodiment of the present invention belongs to the same inventive concept as the document structure parsing method provided in the above embodiment. The technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.

[0142] Figure 6 The hardware structure diagram of a terminal device provided by an embodiment of the present invention is shown. The terminal device in the embodiment of the present invention may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0143] like Figure 6 As shown, the terminal device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the terminal device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0144] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the terminal device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The terminal device 600 is shown to have various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0145] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the document structure parsing method provided by or in the embodiment of the present invention are executed.

[0146] The terminal provided in the embodiment of the present invention and the document structure parsing method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.

[0147] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the document structure parsing method provided in the above embodiment or the like is implemented.

[0148] It should be noted that the computer-readable storage medium in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or a flash memory (FLASH), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In an embodiment of the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0149] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0150] The computer-readable storage medium may be included in the terminal device, or may exist independently without being installed in the terminal device.

[0151] The terminal device stores and carries one or more programs. When the one or more programs are executed by the terminal device, the terminal device:

[0152] Acquire the text data of the document to be parsed, and divide the text data into paragraphs; traverse the paragraphs obtained by the segmentation, and determine the paragraph features of the current traversal paragraph; determine the paragraph category of the current traversal paragraph according to the paragraph features of the current traversal paragraph through a preset classification model; when the traversal is completed, convert each paragraph whose paragraph category belongs to the title category into a title mode; determine the title level corresponding to each title mode according to the sequence of paragraphs corresponding to each title mode, and determine the document structure of the document to be parsed according to each title level.

[0153] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0154] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the function pages marked in the square box can occur in a different order from the order marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0155] The units involved in the embodiments of the present invention may be implemented by software or hardware, wherein the name of a unit does not limit the unit itself in some cases.

[0156] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0157] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A document structure parsing method, It is characterized in that include: Obtaining text data of the document to be parsed, and segmenting the text data into paragraphs; Traverse each segmented paragraph and determine the paragraph features of the currently traversed paragraph; Determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph by using a preset classification model; When the traversal is completed, each paragraph whose paragraph category belongs to the title category is converted into a title mode; According to the sequence of paragraphs corresponding to each of the title patterns, the title levels corresponding to each of the title patterns are determined, and the document structure of the document to be parsed is determined according to each of the title levels.

2. The method according to claim 1, It is characterized in that The step of determining the paragraph feature of the currently traversed paragraph includes: Determine the word embedding features and word frequency-inverse text frequency index of each word in the currently traversed paragraph; The paragraph features of the currently traversed paragraph are determined according to the word embedding features of each word and the word frequency-inverse text frequency index.

3. The method according to claim 2, It is characterized in that The paragraph feature is also determined based on at least one of the following: The paragraph category of the previous paragraph, the ratio of the current traversal paragraph number to the total number of paragraphs in the document to be parsed, and the number of characters, the number and density of punctuation marks, the number and density of numbers, and the number of sentences in the current traversal paragraph.

4. The method according to claim 1, It is characterized in that The step of converting each paragraph whose paragraph category belongs to the title category into the title mode comprises: The paragraphs whose paragraph category belongs to the title category are retained until the matching end position; The retained text is replaced with target characters according to the preset replacement rules to obtain the title mode.

5. The method according to claim 1, It is characterized in that Determining the title level corresponding to each title mode according to the sequence of paragraphs corresponding to each title mode includes: Obtaining each of the title modes in sequence according to the order of the paragraphs corresponding to each of the title modes; When the current title mode is the same as the previous title mode, the title level of the previous title mode is used as the title level of the current title mode; When the current title mode is different from the title mode obtained in the past, the next level of the title level of the previous title mode is used as the title level of the current title mode; When the current title mode is different from the previous title mode, but the same title mode exists in the historically acquired title modes, the title level of the same title mode is used as the title level of the current title mode.

6. The method according to claim 1, It is characterized in that Determining the document structure of the document to be parsed according to each of the title levels includes: According to the paragraphs corresponding to each of the title levels, the titles of the corresponding levels in the preset path dictionary are updated, and the updated preset path dictionary is used as the document structure of the document to be parsed.

7. The method according to any one of claims 1 to 6, It is characterized in that The paragraph category also includes at least one of the following: table of contents category, table category and body category; Correspondingly, the method further includes: determining the title levels corresponding to the paragraphs belonging to the directory category, the table category and the text category according to the title level of the preceding paragraph.

8. A document structure parsing device, It is characterized in that include: A paragraph segmentation module is used to obtain text data of a document to be parsed and segment the text data into paragraphs; A feature determination module is used to traverse each segmented paragraph and determine the paragraph feature of the currently traversed paragraph; A classification module, used to determine the paragraph category of the currently traversed paragraph according to the paragraph features of the currently traversed paragraph by using a preset classification model; A conversion module, used for converting each paragraph belonging to the title category into a title mode when the traversal is completed; The structure determination module is used to determine the title level corresponding to each title pattern according to the sequence of paragraphs corresponding to each title pattern, and determine the document structure of the document to be parsed according to each title level.

9. A terminal device, It is characterized in that The terminal comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the document structure parsing method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the document structure parsing method as described in any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Text segmentation method and device for retrieval enhancement generation

    CN119311723A

  • Document paragraph content merging and segmenting method based on combined tree structure

    CN119918505A