A method for extracting the hierarchical structure of article titles

By constructing a title discriminant model and a relational classification model, and using semantic features to extract the hierarchy of the article title, the title hierarchy recognition problem caused by format loss in the existing technology is solved, and a more accurate title hierarchy extraction is achieved.

CN113961702BActive Publication Date: 2025-04-08NANJING UNIV OF POSTS & TELECOMM +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111242645.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-25
Publication Date
2025-04-08
Estimated Expiration
2041-10-25

AI Technical Summary

Technical Problem

The prior art tends to lose format when reading article format information, resulting in the machine being unable to correctly identify the hierarchy of the article title, affecting subsequent applications.

Method used

Using machine learning methods, we construct a title discriminant model and title relationship classification model, and identify and construct the hierarchy of article titles through semantic feature extraction and classification.

Benefits of technology

In the case of missing or missing format information, the hierarchy of the article title can be effectively identified and constructed, supplementing the shortcomings of traditional methods, and improving the accuracy of the extraction of the article title hierarchy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113961702B_ABST
    Figure CN113961702B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for extracting the hierarchical structure of article titles. Firstly, a title discrimination model and a classification model for the relationship between titles are respectively constructed. Then, a specific article example is input into the title discrimination model to obtain the article title. The article title is input into the classification model for the relationship between titles to obtain the relationship between the titles. Finally, a hierarchical structure of the titles is constructed according to the relationship between the titles. The beneficial effect of the present invention is that when Python reads an article, for a title whose serial number cannot be read, a judgment model is constructed to judge the relationship between the title and other titles, and the title hierarchical structure information is identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of natural language processing, and in particular relates to a method for extracting a hierarchical structure of article titles. Background Art

[0002] Natural language processing is a discipline that uses computer technology to analyze, understand and process natural language, with language as the object. Its tasks include lexical analysis, syntactic analysis, semantic analysis, information extraction, etc. When natural language processing is used for sentence analysis, it is usually used for sentiment analysis, text similarity, etc., and the relationship analysis between sentences is rarely mentioned. In fact, as machines deepen their understanding of natural language, the application field of natural language processing will become more extensive. In order to meet more application needs, the extraction of relationships between sentences by machines is of certain importance.

[0003] At present, the recognition of the hierarchical structure of article titles is a relatively mature technology. Many text editing software (such as: word, PDF, HTML, etc.) have their own format information. When writing articles, authors will also highlight the hierarchy of titles and paragraphs by adding title numbers and using different font sizes, so that computers can recognize them; however, in actual operation, we found that when using tools such as python to read the format information of the article, the format is lost, resulting in the machine being unable to recognize the correct hierarchical structure information of the article title, affecting subsequent applications. In this regard, the current existing technology does not have any good way to avoid this situation. Summary of the invention

[0004] In order to solve the above technical problems, the present invention provides a method for extracting the hierarchical structure of article titles. When Python reads the article, for the title whose serial number cannot be read, a judgment model is constructed to judge the relationship between the title and other titles, and the hierarchical structure information of the title is identified.

[0005] The method for extracting the hierarchical structure of article titles described in the present invention comprises the following steps:

[0006] Step 1: Build a title discrimination model to determine whether a paragraph in the article is a title;

[0007] Step 2: Build a relationship classification model between titles to obtain classification results between titles;

[0008] Step 3: Extract the hierarchical relationship of titles based on the classification results between titles.

[0009] Furthermore, the steps to construct the title discrimination model are:

[0010] Step 1-1: Construct an article dataset {d1, d2, …, d n}, where n is the number of articles;

[0011] Step 1-2: Assume that the i-th article d i There are m paragraphs {p1,p2,…,p m}, manually annotate the paragraph label for the j-th paragraph pj, if it is a title, it is marked as 1, if it is not a title, it is marked as 0;

[0012] Step 1-3: Use Python document reading tool to read the article i , and the font size of the jth paragraph is SIZE j , the length of the jth segment is LENGTH j ;

[0013] Step 1-4: Use the hanlp word segmentation tool to segment the article i The jth segment of the index is processed by word segmentation, and the word segmentation result is a list [s1s2…s h ], where h is the number of words in the jth segment, s i is an element consisting of the i-th word, the word part of speech, and the word offset in the paragraph obtained after the index segmentation of the j-th paragraph. i The structure is: "word / word part of speech / word offset in the paragraph";

[0014] Step 1-5: Use the word2vec algorithm to calculate the word vector of si and obtain the word vector sequence vec of si i , then the word vector sequence of all words in pj is {vec1,vec2,…,vec h};

[0015] Step 1-6: Repeat steps 1-2 to 1-5 to obtain the article dataset {d1, d2, …, d n}The font size, length, and vector sequence of all word vectors of all paragraphs of each article in};

[0016] Step 1-7: Use the svm algorithm in the sklearn toolkit to transform the article dataset {d1, d2, …, d n The font size, length, vector sequence composed of all word vectors and paragraph labels of each paragraph of all articles in} are used as the input of the algorithm to train a title discrimination model.

[0017] Further, the steps to construct the relationship classification model between titles are:

[0018] Step 2-1: Get the article d i The set of all titles in is {t1,t2,…,t r}, where r is the number of titles;

[0019] Step 2-2: For article d i All titles are marked with the relationship between two titles. The relationship between article titles is defined as: included, parallel, and irrelevant. The relationship between titles is manually marked. The relationship between the upper-level title of the article and the subordinate titles is marked as "included", the relationship between the same-level titles under the same upper-level title is marked as "parallel", and the relationship between titles other than the above is marked as "irrelevant";

[0020] Step 2-3: For the title set {t1, t2, …, t r Any two titles in} i and t j , use hanlp word segmentation tool to segment the title i and t j Perform word segmentation to get the word list wt i and wt;

[0021] Step 2-4: Use the word2vec algorithm to calculate the word list wt i , wt j The word vector of each word in gets the title t i ,t j The sequence of word vectors of all words in st i 、st j ;

[0022] Step 2-5: Use the LSTM neural network algorithm in the Keras toolkit to transform the word vector sequence into i 、st j Input into the lstm neural network respectively and output title t i The eigenvectors u and t j The feature vector v of

[0023] Step 2-6: Use the Batch normalize algorithm in the keras toolkit to input the feature vector u and feature vector v into the Batch normalize algorithm for normalization to obtain vectors u' and v';

[0024] Step 2-7, use the cosine similarity algorithm in the sklearn toolkit to calculate the cosine similarity of vectors u' and v', and obtain the cosine similarity value cos similarity(u',v') of u' and v';

[0025] Step 2-8, calculate the absolute value of the vector u'-v' to obtain the vector abs(u'-v');

[0026] Step 2-9, concatenate vectors u' and v', vector abs(u'-v'), and cos similarity(u',v') to form a vector [u',v',abs(u'-v'),cos similarity(u',v')];

[0027] Step 2-10: Use the fully connected layer dense in the keras toolkit, with the activation function as softmax, and use the vector [u', v', abs(u'-v'), cos similarity(u', v')] as the input of the dense layer, and output the title t i With title j The classification results of the relationship between

[0028] Step 2-11: Train the LSTM neural network and classifier through the input classification labels (i.e., inclusion, parallel, and irrelevant), so that the parameters of the LSTM neural network and the parameters of the dense layer can be continuously updated and optimized to obtain a title relationship classification model.

[0029] Furthermore, the steps of extracting the title hierarchy relationship are:

[0030] Step 3-1: For the article dataset {d1, d2, …, d n}, use the python document reading tool to read article A and get the paragraph numbers Pn={0, 1, 2, 3, ..., N} of each paragraph of the article, where N is the number of paragraphs in article A;

[0031] Step 3-2, input article A into the title discrimination model obtained in step 1, and obtain the title set T = {T1, T2, ..., TM}, where M is the number of titles;

[0032] Step 3-3, for any T i , T j ∈T, use the hanlp word segmentation tool to segment the title T i and T j Perform word segmentation and get the title T i 、T j The word list WT i , WTj;

[0033] Step 3-4: Use the word2vec algorithm to calculate the word list WT separately i , the word vector of each word in WTj, and get the title T i 、T j The sequence ST consisting of the word vectors of all words in i ,STj;

[0034] Step 3-5: STi , STj inputs the relationship classification model between titles obtained in step 2 to obtain title T i and T j The relationship between.

[0035] Further, in step 3, some titles in the title set T = {T1, T2, ..., TM} contain serial numbers, and some hierarchical relationships are constructed directly through the serial numbers;

[0036] Through regular expressions, the titles containing serial numbers in the title set T are matched to form a subset T1 = {T11,…,T1 f}, where f is the number of titles with serial numbers, and the titles without serial numbers form a subset T2 = {T21,…,T2 g}, where g is the number of titles without sequence numbers;

[0037] To T1 i ∈T1, according to the title number, T1 i In Python, use the list Tree to store in the form of a tree structure;

[0038] For T2 i ∈T2, find all titles in the title set T that have a "contains" relationship with it, and form a set Ui;

[0039] Find all paragraphs in Ui with a number less than T2 i The titles of the paragraph numbers form the subset Ui0;

[0040] If Ui0 is empty, then T2 i It is the first-level title;

[0041] If Ui0 is not empty, for any title t1∈Ui0, if T2 i The difference between the paragraph number of title t1 and the paragraph number of title t1 For T2 i The minimum difference between the paragraph number of the title and all the paragraph numbers of the title in Ui0, then T2 i It is the sub-title of title t1;

[0042] Find all paragraphs in Ui with a number greater than T2 i The title of the paragraph number forms the subset Ui1;

[0043] If Ui1 is empty, then T2 i There are no subheadings;

[0044] If Ui1 is not empty, for any title t2∈Ui1, if the parent node of the node where t2 is located in the list Tree is "empty", then T2 i It is the parent title of t2.

[0045] Traverse T2 to perform the above operations. If the construction result of the title structure during the traversal is inconsistent with the previous result, update it to the latest result.

[0046] The beneficial effects described in the present invention are as follows: compared with the method of extracting the title hierarchy structure through article format information by existing text editing software, the present invention proposes a method of extracting the title hierarchy structure of an article through semantic features by using machine learning; first, judging whether a paragraph is a title by the format and text features of the paragraph. Then, the relationship between the titles is defined as: inclusion, parallel, and irrelevant. The semantic features of the title paragraphs are extracted by a long short-term memory artificial neural network (LSTM), and the relationship between the titles is classified based on the semantic features of the titles. Finally, the hierarchy of the titles is constructed using the logical relationship between the classification results and the title hierarchy relationship; the present invention mainly uses the semantic features of the titles when constructing the title hierarchy structure, and can play a supplementary role in the construction of the title hierarchy when the format information is missing and the computer cannot recognize it. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to make the contents of the present invention more clearly understood, the present invention is further described in detail below based on specific embodiments in conjunction with the accompanying drawings.

[0048] Figure 1 This is a flowchart of extracting the title hierarchy structure of an article A in an embodiment of the present invention;

[0049] Figure 2 Construct a schematic diagram for the title discrimination model;

[0050] Figure 3 This is a schematic diagram of the classification model structure of the relationship between titles;

[0051] Figure 4 A tree structure representation diagram of a title containing a serial number stored in Python in an embodiment of the present invention;

[0052] Figure 5 This is a tree structure representation diagram of the title hierarchy extraction result stored in Python according to an embodiment of the present invention. DETAILED DESCRIPTION

[0053] like Figure 1-3 As shown, the method for extracting the hierarchical structure of article titles described in the present invention first constructs a title discrimination model and a classification model for the relationship between titles, then inputs a specific article example into the title discrimination model to obtain the article title, inputs the article title into the classification model for the relationship between titles to obtain the relationship between titles, and finally constructs a hierarchical structure of titles based on the relationship between titles.

[0054] The steps to construct the title discrimination model in step 1 are as follows:

[0055] Assume that there is a certain article dataset {d1, d2, …, d n}, where n is the number of articles;

[0056] Assume that the i-th article d i There are m paragraphs, {p1,p2,…,p m};

[0057] For the jth paragraph p j Manually annotate, if the title is marked as 1, non-title is marked as 0. Then the paragraph label of the i-th article can be marked as {11, 02, ..., 0 m};

[0058] Use Python document reading tool to read the article d i , we get p j The font size is SIZE j ; For example: Article d i The font sizes of all the paragraphs obtained are {251, 202, 183, 204, ..., 18 m}, where 251 means the font size of the first paragraph is 25;

[0059] Use Python document reading tool to read the article d i , the length of the jth segment is LENGTH j For example: Article d i The length of all the obtained paragraphs is {51,642,…,105 m}, where 51 represents the length of the first segment is 5;

[0060] Use hanlp word segmentation tool to j Perform index segmentation processing, and the segmentation result is a list [s1 s2…s h ], where h is p j The number of words in s i For p j The element consisting of the i-th word, the word part of speech, and the word offset in the paragraph obtained after the index segmentation processing has the structure of "word / word part of speech / word offset in the paragraph"; for example: assuming p jIf the text content is "Overview of machine learning", the word segmentation result is: [machine / n / [0:2]learning / v / [2:4]related / ad / [4:6]overview / n / [6:8]]. The English letters represent the part of speech, such as n for noun, v for verb, and ad for adjective; the form [number 1, number 2] represents the offset of the word in the paragraph, such as [0:2] means the position of the word in the paragraph is 0 to 2;

[0061] Use the word2vec algorithm to calculate s i The word vector of s i The word vector sequence vec i , then p j The word vector sequence of all words is {vec1,vec2,…,vec h};

[0062] For the article dataset {d1,d2,…,d n}Perform the above data processing and obtain articles d1, d2, …, d n The font size, length, and vector sequence of all word vectors for each paragraph;

[0063] Use the svm algorithm in the sklearn toolkit to transform the article dataset {d1, d2, …, d n The font size, length, vector sequence composed of all word vectors and paragraph labels of each paragraph of all articles in} are used as the input of the algorithm to train a title discrimination model.

[0064] The steps for constructing the classification model of the relationship between titles in step 2 are as follows:

[0065] Assume that article d i The set of all titles in is {t1,t2,…,t r}, where r is the number of titles;

[0066] Define the relationships between titles including: inclusion, parallel, and unrelated;

[0067] For the title set {t1,t2,…,t r Any two titles in} i , t j , the relationship between titles is manually annotated. The relationship between the upper-level title of the article and the subordinate titles is marked as "included"; the relationship between the same-level titles under the same upper-level title is marked as "parallel"; the relationship between titles other than the above situation is marked as "unrelated";

[0068] Use hanlp word segmentation tool to segment the title i , t j Perform word segmentation to get the word list wt i, wt j For example: Assume the title t i The text content is: 2.1 Overview of dependency syntax, then the word segmentation result wt i =[2.1 Overview of Dependency Syntax];

[0069] Use word2vec algorithm to calculate word list wt i , wt j The word vector of each word in gets the title t i , t j The sequence of word vectors of all words in st i , st j ;

[0070] Use the LSTM neural network algorithm in the Keras toolkit to transform the word vector sequence into i , st j Input into the lstm neural network respectively and output title t i The characteristic vector u,t j The feature vector v of

[0071] Use the Batch normalize algorithm in the keras toolkit to input vectors u and v into the Batchnormalize algorithm for normalization to obtain vectors u' and v';

[0072] Use the cosine similarity algorithm in the sklearn toolkit to calculate the cosine similarity of vectors u', v', and get the cosine similarity value cos similarity(u',v') of u' and v';

[0073] Calculate the absolute value of the vector u'-v' to obtain the vector abs(u'-v');

[0074] Concatenate vector u', v', vector abs(u'-v'), and cos similarity(u',v') to form the vector [u',v',abs(u'-v'),cos similarity(u',v')];

[0075] Use the fully connected layer dense in the keras toolkit, and the activation function is softmax. Take the vector [u', v', abs(u'-v'), cos similarity(u', v')] as the input of the dense layer and output the title t i With title j The classification results of the relationship between

[0076] Through the input classification labels, the LSTM neural network and classifier are trained so that the parameters of the LSTM neural network and the parameters of the dense layer can be continuously updated and optimized to obtain the title relationship classification model.

[0077] Extraction of article title hierarchy in step 3:

[0078] Assume that there is an article A in the article dataset.

[0079] Use the Python document reading tool to read article A and obtain the paragraph numbers Pn={0, 1, 2, 3, ..., N} of each paragraph of the article, where N is the number of paragraphs in article A;

[0080] Input article A into the title discrimination model to obtain a title set T; in this embodiment, T = {2 Overview of Chinese complex sentence division and hierarchical structure system, 2.1 Overview of dependency syntax, 2.2 Division of Chinese complex sentence based on punctuation and dependency syntax, 2.2.1 Division of sentence based on punctuation, Division of Chinese complex sentence based on dependency syntax, 2.3 Overview of hierarchical structure, Overview of Bert-CNN deep learning model, 3.1 Overview of machine learning related content, 3.2 Overview of neural network related content, 3.2.1 Basic working principle of neural network, 3.2.2 Related concepts of neural network};

[0081] For any T i , T j ∈T, use the hanlp word segmentation tool to segment the title T i and T j Perform word segmentation and get the title T i , T j The word list WT i , WTj;

[0082] Use the word2vec algorithm to calculate the word list WT separately i , the word vector of each word in WTj, and get the title T2 i ,T1 j The sequence ST consisting of the word vectors of all words in i ,STj;

[0083] ST i , STj inputs the relationship classification model between titles and obtains the title T i and T j For example: T2 = "2.2 Division of Chinese complex sentences based on punctuation and dependency syntax", T4 = Division of Chinese complex sentences based on dependency syntax, the classification result of the relationship between the output titles is "include".

[0084] When reading articles in Python, due to the docx format, some titles can be read with serial numbers, while some cannot. The titles with serial numbers can directly construct relationships, while the titles that cannot be read need to use a model to determine the relationship between the title and other titles.

[0085] Some titles in the title set T contain serial numbers, and some hierarchical relationships can be constructed directly through the serial numbers;

[0086] Through regular expressions, the titles containing serial numbers in the title set T are matched to form a subset T1 = {T11,…,T1 f}, where f is the number of titles with serial numbers, and the titles without serial numbers form a subset T2 = {T21,…,T2 g}, where g is the number of titles without sequence numbers. In this embodiment, T1 = {2 Overview of Chinese complex sentence division and hierarchical structure system, 2.1 Overview of dependency syntax, 2.2 Division of Chinese complex sentences based on punctuation and dependency syntax, 2.2.1 Division of sentences based on punctuation, 2.3 Overview of hierarchical structure, 3.1 Overview of machine learning, 3.2 Overview of neural network related content, 3.2.1 Basic working principle of neural network, 3.2.2 Related concepts of neural network}, T2 = {Division of Chinese complex sentences based on dependency syntax, Overview of Bert-CNN deep learning model}.

[0087] To T1 i ∈T1, according to the title number, T1 i In Python, a list Tree is used to store data in a tree structure. The tree structure diagram in this embodiment is as follows: Figure 4 shown.

[0088] like Figure 5 As shown, for T2 i ∈T2, find all titles in the title set T that have a "contains" relationship with it, and form a set Ui. For example: T20 = "Division of Chinese complex sentences based on dependency syntax", U0 = {2 Overview of Chinese complex sentence division and hierarchical structure system, 2.2 Division of Chinese complex sentences based on punctuation and dependency syntax};

[0089] Find all paragraphs in Ui with a number less than T2 i The titles of the paragraph numbers form the subset Ui0;

[0090] If Ui0 is empty, then T2 iIt is a first-level title; for example: T21 = "Overview of Bert-CNN Deep Learning Model", paragraph number is 37; U1 = {3.1 Overview of machine learning, 3.2 Overview of neural network related content, 3.2.1 Basic working principle of neural network, 3.2.2 Related concepts of neural network}, paragraph numbers are 38, 42, 43, 47 respectively. There is no title with a paragraph number smaller than T21 in U1, so T21 is a first-level title;

[0091] If Ui0 is not empty, for any title t1∈Ui0, if T2 i The difference between the paragraph number of title t1 and the paragraph number of title t1 For T2 i The minimum difference between the paragraph number of the title and all the paragraph numbers of the title in Ui0, then T2 i It is the sub-title of title t1. For example, for T20 = "Division of Chinese complex sentences based on dependency syntax", the paragraph number is 30, U000 = "2 Overview of Chinese complex sentence division and hierarchical structure system", the paragraph number is 21, and U001 = "2.2 Division of Chinese complex sentences based on punctuation and dependency syntax", the paragraph number is 24. Since 30-24 = 6 < 30-21 = 9, T20 is the sub-title of U001;

[0092] Find all paragraphs in Ui with a number greater than T2 i The title of the paragraph number forms the subset Ui1;

[0093] If Ui1 is empty, then T2 i There are no subheadings;

[0094] If Ui1 is not empty, for any title t2∈Ui1, if the parent node of the node where t2 is located in the list Tree is "empty", then T2 i It is the parent title of t2; for example: T21 = "Overview of Bert-CNN Deep Learning Model", U1 = {3.1 Overview of Machine Learning, 3.2 Overview of Neural Network, 3.2.1 Basic Working Principles of Neural Network, 3.2.2 Related Concepts of Neural Network}, the nodes of U110 and U111 in Tree are Tree[1][1] and Tree[1][2] respectively, and the parent node Tree[1] is "empty", then T21 is the parent title of U110 and U111;

[0095] Traverse T2 to perform the above operations. If the construction result of the title structure during the traversal is inconsistent with the previous result, update it to the latest result.

[0096] The above description is only a preferred embodiment of the present invention and is not intended to be a further limitation of the present invention. All equivalent changes made using the contents of the present specification and drawings are within the protection scope of the present invention.

Claims

1. A method for extracting the hierarchical structure of article titles, characterized in that: The steps of the method are: Step 1: Build a title discrimination model to determine whether a paragraph in the article is a title; Step 2: Build a relationship classification model between titles to obtain classification results between titles; Specifically: Step 2-1: Get the article d i The set of all titles in is {t1,t2,…,t r }, where r is the number of titles; Step 2-2: For article d i All titles are marked with the relationship between two titles. The relationship between article titles is defined as: included, parallel, and irrelevant. The relationship between titles is manually marked. The relationship between the upper-level title and the subordinate titles is marked as "included", the relationship between the same-level titles under the same upper-level title is marked as "parallel", and the relationship between titles other than the above is marked as "irrelevant"; Step 2-3: For the title set {t1, t2, …, t r Any two titles in} i and t j , use hanlp word segmentation tool to segment the title i and t j Perform word segmentation to get the word list wt i and wt j ; Step 2-4: Use the word2vec algorithm to calculate the word list wt i , wt j The word vector of each word in gets the title t i ,t j The sequence of word vectors of all words in st i 、st j ; Step 2-5: Use the LSTM neural network algorithm in the Keras toolkit to transform the word vector sequence into i 、st j Input into the lstm neural network respectively and output the title t i The eigenvectors u and t j The feature vector v of Step 2-6: Use the Batch normalize algorithm in the keras toolkit to input the feature vector u and feature vector v into the Batch normalize algorithm for normalization to obtain vectors u' and v'; Step 2-7, use the cosine similarity algorithm in the sklearn toolkit to calculate the cosine similarity of vectors u' and v', and obtain the cosine similarity value cos similarity(u',v') of u' and v'; Step 2-8, calculate the absolute value of the vector u'-v' to obtain the vector abs(u'-v'); Step 2-9, concatenate vectors u' and v', vector abs(u'-v'), and cos similarity(u',v') to form a vector [u',v',abs(u'-v'),cos similarity(u',v')]; Step 2-10: Use the fully connected layer dense in the keras toolkit, with the activation function as softmax, and use the vector [u', v', abs(u'-v'), cos similarity(u', v')] as the input of the dense layer, and output the title t i With title j The classification results of the relationship between Step 2-11, train the LSTM neural network and classifier through the input classification label, so that the parameters of the LSTM neural network and the parameters of the dense layer can be continuously updated and optimized to obtain the title relationship classification model; Step 3: Extract the hierarchical relationship of titles based on the classification results between titles.

2. The method for extracting the hierarchical structure of article titles according to claim 1, characterized in that: The steps to build a title discrimination model are: Step 1-1: Construct an article dataset {d1, d2, …, d n }, where n is the number of articles; Step 1-2: Assume that the i-th article d i There are m paragraphs {p1,p2,…,p m }, manually annotate the paragraph label for the j-th paragraph pj, if it is a title, it is marked as 1, if it is not a title, it is marked as 0; Step 1-3: Use Python document reading tool to read the article i , and the font size of the jth paragraph is SIZE j , the length of the jth segment is LENGTH j ; Step 1-4: Use the hanlp word segmentation tool to segment the article i The jth segment of the index is processed by word segmentation, and the word segmentation result is a list [s1s2…s h ], where h is the number of words in the jth segment, s i is an element consisting of the i-th word, the word part of speech, and the word offset in the paragraph obtained after the index segmentation of the j-th paragraph. i The structure is: "word / word part of speech / word offset in the paragraph"; Step 1-5: Use the word2vec algorithm to calculate the word vector of si and obtain the word vector sequence vec of si i , then the word vector sequence of all words in pj is {vec1,vec2,…,vec h }; Step 1-6: Repeat steps 1-2 to 1-5 to obtain the article dataset {d1, d2, …, d n }The font size, length, and vector sequence of all word vectors of all paragraphs of each article in}; Step 1-7: Use the svm algorithm in the sklearn toolkit to transform the article dataset {d1, d2, …, d n The font size, length, vector sequence composed of all word vectors and paragraph labels of each paragraph of all articles in} are used as the input of the algorithm to train a title discrimination model.

3. The method for extracting the hierarchical structure of article titles according to claim 1, characterized in that: The steps to extract the title hierarchy are: Step 3-1: For the article dataset {d1, d2, …, d n }, use the python document reading tool to read article A and get the paragraph numbers Pn={0, 1, 2, 3, ..., N} of each paragraph of the article, where N is the number of paragraphs in article A; Step 3-2, input article A into the title discrimination model to obtain the title set T = {T1, T2, ..., TM}, where M is the number of titles; Step 3-3, for any T i , T j ∈T, use the hanlp word segmentation tool to segment the title T i and T j Perform word segmentation and get the title T i , T j The word list WT i , WTj; Step 3-4: Use the word2vec algorithm to calculate the word list WT separately i , the word vector of each word in WTj, and get the title T i 、T j The sequence ST consisting of the word vectors of all words in i ,STj; Step 3-5: ST i , STj inputs the relationship classification model between titles and obtains title T i and T j The relationship between.

4. The method for extracting the hierarchical structure of article titles according to claim 3, characterized in that: In step 3, some titles in the title set T = {T1, T2, ..., TM} contain serial numbers, and some hierarchical relationships are constructed directly through the serial numbers; Through regular expressions, the titles containing serial numbers in the title set T are matched to form a subset T1 = {T11,…,T1 f }, where f is the number of titles with serial numbers, and the titles without serial numbers form a subset T2 = {T21,…,T2 g }, where g is the number of titles without sequence numbers; To T1 i ∈T1, according to the title number, T1 i In Python, use the list Tree to store in the form of a tree structure; For T2 i ∈T2, find all titles in the title set T that have a "contains" relationship with it, and form a set Ui; Find all paragraphs in Ui with a number less than T2 i The titles of the paragraph numbers form the subset Ui0; If Ui0 is empty, then T2 i It is the first-level title; If Ui0 is not empty, for any title t1∈Ui0, if T2 i The difference between the paragraph number of title t1 and the paragraph number of title t1 T2i -Pn t1 For T2 i The minimum difference between the paragraph number of the title and all the paragraph numbers of the title in Ui0, then T2 i It is the sub-title of title t1; Find all paragraphs in Ui with a number greater than T2 i The title of the paragraph number forms the subset Ui1; If Ui1 is empty, then T2 i There are no subheadings; If Ui1 is not empty, for any title t2∈Ui1, if the parent node of the node where t2 is located in the list Tree is "empty", then T2 i It is the parent title of t2; Traverse T2 to perform the above operations. If the construction result of the title structure during the traversal is inconsistent with the previous result, update it to the latest result.

Citation Information

Patent Citations

  • Article title detection method based on a hierarchical hybrid network and a federated learning strategy

    CN109657055A

  • Method and device for extracting process system from article title hierarchical structure

    CN111737985A