A text classification method, device, computer equipment and storage medium

By building a graph network containing documents, paragraphs, sentences and word nodes, and using graph convolutional neural network to extract deep semantic features, the shortcomings of obtaining higher-level information in the existing technology are solved, and the accuracy of text classification is significantly improved.

CN112818121BActive Publication Date: 2025-04-11华润数字科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110110584.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-27
Publication Date
2025-04-11
Estimated Expiration
2041-01-27

AI Technical Summary

Technical Problem

The existing text classification methods have limited technical means to obtain higher-level and more implicit information at the overall document level, resulting in room for improvement in the accuracy of text classification.

Method used

By building a graph network with four types of nodes: document, paragraph, sentence and word, and using graph convolution neural network to extract deep semantic features, combined with sub-graph clustering and target graph network matrix splicing, the accuracy of text classification is improved.

Benefits of technology

Considering different semantic features from multiple dimensions, using graph convolutional neural networks to extract deep semantic features, significantly improving the accuracy and effect of text classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112818121B_ABST
    Figure CN112818121B_ABST
Patent Text Reader

Abstract

The present invention discloses a text classification method, device, computer equipment and storage medium, the method comprising: obtaining a document to be classified, and segmenting the document; constructing a graph network containing four types of nodes, and setting a corresponding graph network matrix, wherein the four types of nodes refer to document nodes, paragraph nodes, sentence nodes and word nodes; constructing a target adjacency matrix; performing subgraph clustering on the four types of nodes, and combining the graph network matrix to obtain a target graph network matrix; inputting the target adjacency matrix and the target graph network matrix into a graph convolutional neural network, and the graph convolutional neural network outputs a graph latent vector corresponding to the document, and then using a classification function to classify the graph latent vector to obtain a classification result of the document. The embodiment of the present invention uses a graph convolutional neural network to extract deep semantic features in a document, so that text classification is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer software application technology, and in particular to a text classification method, device, computer equipment and storage medium. Background Art

[0002] Text classification is a common task in the field of natural language processing. In recent years, the accuracy of text classification has been greatly improved, from the traditional classification technology based on feature engineering + machine learning, such as extracting features based on TF-IDF (term frequency-inverse document frequency) and then training machine learning classifiers, to the introduction of various deep learning methods based on CNN (convolutional neural network) and RNN (recurrent neural network) into the field of text classification. However, the existing methods, on the whole, still focus on capturing local features, and the technical means to obtain higher-level and more implicit information from the overall document level are still limited, so the accuracy of text classification still has room for improvement.

[0003] For example, the paper "Graph Convolutional Networks for Text Classification" uses graph convolutional neural networks (GCNs) to extract deeper information from documents. A graph consisting of document nodes and word nodes is constructed. The edge weights between word nodes are TF-IDF (term frequency–inverse document frequency, a common weighting technique for information retrieval and data mining), and the edge weights between document nodes and word nodes are PMI (Pointwise mutual information) information-word co-occurrence information. Two layers of GCN are used to extract information, and finally the softmax classification function is used to output the category label. Although it takes into account the implicit connection between documents and words, it ignores other important information, such as the implicit features between documents and sentences. Secondly, the way of using GCN to perform convolution operations on the entire graph is relatively rough. Summary of the invention

[0004] The embodiments of the present invention provide a text classification method, apparatus, computer equipment and storage medium, aiming to improve the accuracy of text classification.

[0005] In a first aspect, an embodiment of the present invention provides a text classification method, comprising:

[0006] Obtaining a document to be classified, and performing word segmentation on the document;

[0007] Based on the word segmentation results, a graph network including four types of nodes is constructed, and a corresponding graph network matrix is ​​set for the graph network, wherein the four types of nodes refer to document nodes of the document, paragraph nodes in the document, sentence nodes in the paragraph, and word nodes in the sentence;

[0008] Constructing a target adjacency matrix according to the graph network matrix;

[0009] Perform sub-graph clustering on the four types of nodes, and combine them with the graph network matrix to obtain a target graph network matrix;

[0010] The target adjacency matrix is ​​input into a graph convolutional neural network, and the graph convolutional neural network outputs a graph latent vector corresponding to the document. The graph latent vector is then classified using a classification function to obtain a classification result of the document.

[0011] In a second aspect, an embodiment of the present invention provides a text classification device, including:

[0012] A word segmentation unit, used to obtain a document to be classified and perform word segmentation on the document;

[0013] A first construction unit is used to construct a graph network including four types of nodes based on the word segmentation result, and set a corresponding graph network matrix for the graph network, wherein the four types of nodes refer to document nodes of the document, paragraph nodes in the document, sentence nodes in the paragraph, and word nodes in the sentence;

[0014] A second construction unit is used to construct a target adjacency matrix according to the graph network matrix;

[0015] A first clustering unit is used to perform sub-graph clustering on the four types of nodes, and combine the sub-graphs with the graph network matrix to obtain a target graph network matrix;

[0016] The first classification unit is used to input the target graph network matrix and the target adjacency matrix into the graph convolutional neural network, and the graph convolutional neural network outputs the graph latent vector corresponding to the document, and then classifies the graph latent vector using a classification function to obtain a classification result of the document. In a third aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text classification method as described in the first aspect when executing the computer program.

[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the text classification method as described in the first aspect is implemented.

[0018] The embodiment of the present invention provides a text classification method, device, computer equipment and storage medium, the method comprising: obtaining a document to be classified, and performing word segmentation on the document; constructing a graph network containing four types of nodes based on the word segmentation results, and setting a corresponding graph network matrix for the graph network, wherein the four types of nodes refer to the document node of the document, the paragraph node in the document, the sentence node in the paragraph, and the word node in the sentence; constructing a target adjacency matrix according to the graph network matrix; performing subgraph clustering on the four types of nodes, and combining the graph network matrix to obtain a target graph network matrix; inputting the target adjacency matrix and the target graph network matrix into a graph convolutional neural network, and the graph convolutional neural network outputs the graph latent vector corresponding to the document, and then using a classification function to classify the graph latent vector to obtain a classification result of the document. The embodiment of the present invention considers different semantic features from multiple dimensions including words, sentences, paragraphs, documents, etc., and uses a graph convolutional neural network to extract deep semantic features, so that text classification is more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0020] Figure 1 A flowchart of a text classification method provided by an embodiment of the present invention;

[0021] Figure 2 A schematic diagram of a process for constructing a first adjacency matrix in a text classification method provided by an embodiment of the present invention;

[0022] Figure 3 A schematic block diagram of a text classification device provided by an embodiment of the present invention;

[0023] Figure 4 A sub-schematic block diagram of a text classification device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0026] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0027] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0028] See below Figure 1 , Figure 1 A flowchart of a text classification method provided by an embodiment of the present invention specifically includes: steps S101 to S106.

[0029] S101, obtaining a document to be classified, and performing word segmentation on the document;

[0030] S102, constructing a graph network including four types of nodes based on the word segmentation results, and setting a corresponding graph network matrix for the graph network, wherein the four types of nodes refer to document nodes of the document, paragraph nodes in the document, sentence nodes in the paragraph, and word nodes in the sentence;

[0031] S103, constructing a target adjacency matrix according to the graph network matrix;

[0032] S104, performing sub-graph clustering on the four types of nodes, and combining the graph network matrix to obtain a target graph network matrix;

[0033] S105. Input the target adjacency matrix and the target graph network matrix into a graph convolutional neural network, and have the graph convolutional neural network output a graph latent vector corresponding to the document. Then, a classification function is used to classify the graph latent vector to obtain a classification result of the document.

[0034] In this embodiment, when performing text classification, the document to be classified is firstly segmented, and a graph network and a corresponding graph network matrix are constructed based on the segmentation results, wherein the graph network includes documents, paragraphs in documents, sentences in paragraphs, and words in sentences. Then, a corresponding adjacency matrix, i.e., the target adjacency matrix, is set for the graph network matrix, and subgraph clustering is performed according to the four types of nodes contained in the graph network, and the target graph network matrix can be spliced ​​together by combining the graph network matrix, and then the target adjacency matrix and the graph network matrix are processed by a graph convolutional neural network, and the output results of the graph convolutional neural network are classified by a classification function, so as to obtain the final text classification result.

[0035] This embodiment considers different semantic features from multiple dimensions including words, sentences, paragraphs, documents, etc., and uses graph convolutional neural networks to extract deep semantic features, which can enhance the effect of text classification and improve the accuracy of text classification. It can be understood that in the step of obtaining the document to be classified and segmenting the document described in this implementation, since the segmentation technology is very mature and there are many segmentation tools, the appropriate segmentation method can be selected according to the specific application scenario.

[0036] In one embodiment, the step S102 includes:

[0037] Using one-bit effective coding to represent the features of the document, thereby obtaining the document node, paragraph node and sentence node;

[0038] Based on the word2vec method, the document is represented by a word embedding vector according to the word segmentation result, and then the word embedding vector is used as the word node;

[0039] Constructing the graph network based on the document nodes, paragraph nodes, sentence nodes and word nodes;

[0040] Set the graph network matrix of the graph network to X∈R n×m , where R n×m is the dimension of the graph network matrix, n is the number of nodes in the graph network, and m is the feature dimension of each node.

[0041] In this embodiment, a graph network containing four types of nodes, namely, documents, paragraphs in documents, sentences in paragraphs, and words in sentences, is constructed, and the vector dimensions of document nodes, paragraph nodes, sentence nodes, and word nodes in the graph network are consistent. A corresponding graph network matrix x∈R is set for the graph network n×m, where n is the number of nodes in the graph network. In a specific embodiment, n = Nd + Np + Ns + Nw, where Nd is the number of document nodes, Np is the number of paragraph nodes, Ns is the number of sentence nodes, and Nw is the number of word nodes. The graph network described in this embodiment contains the multi-dimensional semantics of the document, so that subsequent steps can perform accurate calculations and analysis, etc., thereby improving the final text classification accuracy.

[0042] In one embodiment, the step S103 includes:

[0043] Constructing a first adjacency matrix between the word node and other types of nodes, constructing a second adjacency matrix between the sentence node and other types of nodes, and constructing a third adjacency matrix between the paragraph node and other types of nodes;

[0044] The first adjacency matrix, the second adjacency matrix and the third adjacency matrix are concatenated into the target adjacency matrix.

[0045] In this embodiment, when setting the corresponding adjacency matrix for the graph network matrix, since the graph network contains four types of nodes, the adjacency matrices of the corresponding types of nodes can be constructed separately according to the different types of nodes, and then the adjacency matrices of each type of nodes are spliced ​​into the adjacency matrix corresponding to the graph network matrix, that is, the target adjacency matrix.

[0046] In one embodiment, if Figure 2 As shown, constructing a first adjacency matrix of the word node and other types of nodes includes:

[0047] S201, calculate the first edge weight between each word node according to the following formula:

[0048]

[0049] Where Wt w-w is the first edge weight between each word node, dis w-w is the edit distance between word nodes, cos w-w is the similarity between word nodes, α and β are weight coefficients, and α, β∈(0,1);

[0050] S202, obtaining the semantic role weight of each word in each sentence according to the semantic role standard, and obtaining the part-of-speech role weight of each word in each sentence according to the part-of-speech classification standard, and then calculating the second edge weight between the word node and the sentence node according to the following formula:

[0051]

[0052] Wt w -s=Sem wt×POS wt

[0053] Where Wt w-s is the second edge weight between the word node and the sentence node, POS wt is the part-of-speech role weight of the word node, Sem wt is the semantic role weight of the word node, N_POS(i) is the part of speech of the i-th word node;

[0054] S203, obtaining the number of times the word node appears in the paragraph node, and obtaining the position order of the word node in the corresponding paragraph, and then calculating the third edge weight between the word node and the paragraph node according to the following formula:

[0055] Wt w-p =N_wp ij ×PE ij

[0056] Where Wt w-p is the third edge weight between the word node and the paragraph node, N_wp ij is the number of times the i-th word node appears in paragraph node j, PE ij is the position order of the i-th word node in paragraph node j;

[0057] S204, obtaining the number of times the word node appears in the document node, and obtaining the position order of the word node in the corresponding document, and then calculating the weight of the fourth edge between the word node and the document node;

[0058] S205: Construct the first adjacency matrix according to the first edge weight, the second edge weight, the third edge weight, and the fourth edge weight.

[0059] In this embodiment, when constructing the first adjacency matrix for the word node, first calculate the first edge weight between the word node and the word node, then calculate the second edge weight between the word node and the sentence node, then calculate the third edge weight between the word node and the paragraph node and the fourth edge weight between the word node and the document node, and then construct the first adjacency matrix based on the first edge weight, the second edge weight, the third edge weight and the fourth edge weight. This embodiment considers different semantic features from multiple dimensions including words, sentences, paragraphs, documents, etc., so that the constructed adjacency matrix can fully contain different semantic features, thereby making the constructed adjacency matrix more accurate and convincing. It should be noted that when calculating the first edge weight, the edit distance between each word node used can be calculated by conventional means, and the similarity between each word node can be calculated using cosine similarity, or obtained using methods such as Euclidean distance.

[0060] In another embodiment, constructing a second adjacency matrix of the sentence node and other types of nodes includes:

[0061] The sentence nodes are extracted using a convolutional neural network to obtain a sentence vector of the corresponding sentence, and then cosine similarity is calculated based on the sentence vector to obtain edge weights between sentence nodes;

[0062] The TextRank method (a keyword extraction method) is used to calculate the edge weight between sentence nodes and paragraph nodes, with the edge weight between sentence nodes as the numerator and the edge weight between all sentence nodes in the corresponding paragraph as the denominator;

[0063] The TextRank method is used to calculate the edge weight between sentence nodes and document nodes, with the edge weight between sentence nodes as the numerator and the edge weight between all sentence nodes in the corresponding document as the denominator;

[0064] The second adjacency matrix is ​​constructed according to the edge weights between sentence nodes, the edge weights between sentence nodes and paragraph nodes, and the edge weights between sentence nodes and document nodes.

[0065] In another embodiment, constructing a second adjacency matrix of the paragraph node and other types of nodes includes:

[0066] Use convolutional neural network to extract features of paragraphs corresponding to paragraph nodes to obtain paragraph vectors, and use the cosine similarity between two paragraph vectors as the edge weight between two paragraph nodes;

[0067] The TextRank method is used to calculate the edge weight between paragraph nodes and document nodes, with the paragraph edge weight as the numerator and the edge weight between all paragraph nodes in the corresponding document as the denominator;

[0068] The second adjacency matrix is ​​constructed according to the edge weights between paragraph nodes and the edge weights between paragraph nodes and document nodes.

[0069] In one embodiment, the step S104 includes:

[0070] Performing subgraph clustering based on nodes of the same type and combining the graph network matrix to obtain a first combined feature, and performing subgraph clustering based on nodes of different types and combining the graph network matrix to obtain a second combined feature;

[0071] The first combined features and the second combined features are concatenated to obtain the target graph network matrix.

[0072] In this embodiment, since the graph network contains four types of nodes, when performing subgraph clustering, on the one hand, subgraph clustering can be performed based on nodes of the same type, such as clustering word nodes with word nodes, clustering sentence nodes with sentence nodes, etc. On the other hand, subgraph clustering can also be performed based on different types of nodes, such as clustering word nodes and sentence nodes, etc. Through the above two aspects of subgraph clustering, the obtained target graph network matrix can be made more accurate and reliable, thereby improving the final classification accuracy.

[0073] In one embodiment, clustering subgraphs based on nodes of the same type and obtaining a first combined feature in combination with the graph network matrix includes:

[0074] Subgraph clustering is performed according to document nodes, paragraph nodes, sentence nodes, and word nodes respectively;

[0075] The average feature vector of the nodes in all the clustered subgraphs is obtained, and the average feature vector is concatenated with the node features in the graph network matrix to form the first combined feature.

[0076] In this embodiment, when subgraphs are clustered based on nodes of the same type, document nodes are clustered with document nodes, paragraph nodes are clustered with paragraph nodes, sentence nodes are clustered with sentence nodes, and word nodes are clustered with word nodes. Of course, in actual application scenarios, there may be only one document node or paragraph node, etc. In this case, only this document node or paragraph node needs to be classified. After obtaining subgraphs of multiple categories, the average feature vector of all subgraph nodes is obtained, and then the first combined feature is obtained in combination with the graph network matrix.

[0077] In another embodiment, the subgraph clustering based on different types of nodes and obtaining the second combined feature in combination with the graph network matrix includes:

[0078] In this embodiment, the four types of nodes contained in the graph network have a hierarchical relationship. Specifically, word nodes belong to sentence nodes, sentence nodes belong to paragraph nodes, and paragraph nodes belong to document nodes. This embodiment clusters different types of nodes into subgraphs, that is, clusters each type of node with other types of nodes. Similarly, the average feature vector of all clustered subgraph nodes is obtained, and further, the feature weight is assigned to the average feature vector using a machine learning method, and then it is spliced ​​with the graph network matrix to form the second combined feature.

[0079] In one embodiment, the step S106 includes:

[0080] The target adjacency matrix is ​​calculated according to the following formula:

[0081]

[0082] In the formula, is a normalized symmetric adjacency matrix, A is the target adjacency matrix, and D is the degree matrix of the target adjacency matrix;

[0083] The graph implicit vector is calculated as follows:

[0084]

[0085] Where, L (j+1) is the graph implicit vector output by the j+1th layer of the graph convolutional neural network, L (j) is the graph implicit vector output by the jth layer of the graph convolutional neural network, W0 is the weight matrix, σ is the activation function, where L (0) is the target graph network matrix;

[0086] The graph latent vector is classified using a classification function to obtain a classification result of the document.

[0087] In this embodiment, the target adjacency matrix is ​​input into the graph convolution network, and the graph convolution network calculates the target adjacency matrix and outputs the corresponding graph latent vector. In the actual application scenario of using the graph convolution network to output the graph latent vector, the number of layers included in the graph convolution network can be flexibly set according to the actual situation, so as to output the graph latent vector with higher accuracy. Then, the graph latent vector is classified using a classification function (such as a softmax function, etc.), so that the classification result of the document corresponding to the graph latent vector can be obtained.

[0088] In a specific embodiment, the graph latent vector is classified according to the following formula:

[0089]

[0090] Where X is the classification result and W1 is the weight matrix.

[0091] In another embodiment, the graph convolutional neural network is optimized and updated using a cross entropy loss function and an optimization method, such as an Adam algorithm or an SGD algorithm (i.e., a stochastic gradient descent algorithm).

[0092] Figure 3 A schematic block diagram of a text classification device 300 provided in an embodiment of the present invention, the device 300 includes:

[0093] A word segmentation unit 301 is used to obtain a document to be classified and perform word segmentation on the document;

[0094] A first construction unit 302 is used to construct a graph network including four types of nodes based on the word segmentation result, and set a corresponding graph network matrix for the graph network, wherein the four types of nodes refer to the document node of the document, the paragraph node in the document, the sentence node in the paragraph, and the word node in the sentence;

[0095] A second construction unit 303 is used to construct a target adjacency matrix according to the graph network matrix;

[0096] A first clustering unit 304 is used to perform sub-graph clustering on the four types of nodes, and combine the sub-graph clustering with the graph network matrix to obtain a target graph network matrix;

[0097] The first classification unit 305 is used to input the target graph network matrix and the target adjacency matrix into the graph convolutional neural network, and the graph convolutional neural network outputs the graph latent vector corresponding to the document, and then uses the classification function to classify the graph latent vector to obtain the classification result of the document.

[0098] In one embodiment, the first construction unit 302 includes:

[0099] A feature representation unit, used for performing feature representation on the document using a single-bit effective encoding, thereby obtaining the document node, paragraph node and sentence node;

[0100] A vector representation unit, used for representing the document by a word embedding vector based on the word2vec method and according to the word segmentation result, and then using the word embedding vector as the word node;

[0101] A third construction unit, configured to construct the graph network based on the document nodes, paragraph nodes, sentence nodes, and word nodes;

[0102] A matrix setting unit, used to set the graph network matrix of the graph network to X∈R n×m , where R n×m is the dimension of the graph network matrix, n is the number of nodes in the graph network, and m is the feature dimension of each node.

[0103] In one embodiment, the second constructing unit 303 includes:

[0104] A fourth construction unit is used to construct a first adjacency matrix between the word node and other types of nodes, a second adjacency matrix between the sentence node and other types of nodes, and a third adjacency matrix between the paragraph node and other types of nodes;

[0105] The first concatenation unit is used to concatenate the first adjacency matrix, the second adjacency matrix and the third adjacency matrix into the target adjacency matrix.

[0106] In one embodiment, if Figure 4 As shown, the fourth building unit includes:

[0107] The first calculation unit 401 is used to calculate the first edge weight between each word node according to the following formula:

[0108]

[0109] Where Wt w-w is the first edge weight between each word node, dis w-w is the edit distance between word nodes, cos w-w is the similarity between word nodes, α and β are weight coefficients, and α, β∈(0,1);

[0110] The second calculation unit 402 is used to obtain the semantic role weight of each word in each sentence according to the semantic role standard, and obtain the part-of-speech role weight of each word in each sentence according to the part-of-speech classification standard, and then calculate the second edge weight between the word node and the sentence node according to the following formula:

[0111]

[0112] Wt w-s =Sem wt ×POS wt

[0113] Where Wt w-s is the second edge weight between the word node and the sentence node, POS wt is the part-of-speech role weight of the word node, Sem wt is the semantic role weight of the word node, N_POS(i) is the part of speech of the i-th word node;

[0114] The third calculation unit 403 is used to obtain the number of times the word node appears in the paragraph node, and obtain the position order of the word node in the corresponding paragraph, and then calculate the third edge weight between the word node and the paragraph node according to the following formula:

[0115] Wt w-p =N_wp ij ×PE ij

[0116] Where Wt w-p is the third edge weight between the word node and the paragraph node, N_wp ij is the number of times the i-th word node appears in paragraph node j, PE ij is the position order of the i-th word node in paragraph node j;

[0117] The fourth calculation unit 404 is used to obtain the number of times the word node appears in the document node, and obtain the position order of the word node in the corresponding document, and then calculate the fourth edge weight between the word node and the document node;

[0118] The fifth constructing unit 405 is configured to construct the first adjacency matrix according to the first edge weight, the second edge weight, the third edge weight and the fourth edge weight.

[0119] In one embodiment, the first clustering unit 304 includes:

[0120] A first combination unit is used to cluster subgraphs based on nodes of the same type and obtain a first combination feature by combining the graph network matrix, and to cluster subgraphs based on nodes of different types and obtain a second combination feature by combining the graph network matrix;

[0121] The second splicing unit is used to splice the first combined features and the second combined features to obtain the target graph network matrix.

[0122] In one embodiment, the first combination unit includes:

[0123] The second clustering unit is used to perform sub-graph clustering according to document nodes, paragraph nodes, sentence nodes and word nodes respectively;

[0124] The second combination unit is used to obtain the average feature vector of the nodes in all the subgraphs after clustering, and concatenate the average feature vector with the node features in the graph network matrix into the first combined feature.

[0125] In one embodiment, the first classification unit 306 includes:

[0126] A matrix calculation unit is used to calculate the target adjacency matrix according to the following formula:

[0127]

[0128] In the formula, is a normalized symmetric adjacency matrix, A is the target adjacency matrix, and D is the degree matrix of the target adjacency matrix;

[0129] The graph implicit vector calculation unit is used to calculate the graph implicit vector according to the following formula:

[0130]

[0131] Where, L (j+1) is the graph implicit vector output by the j+1th layer of the graph convolutional neural network, L (j) is the graph implicit vector output by the jth layer of the graph convolutional neural network, W0 is the weight matrix, σ is the activation function, where L(0) is the target graph network matrix;

[0132] The second classification unit is used to classify the graph latent vector using a classification function to obtain a classification result of the document.

[0133] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0134] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0135] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.

[0136] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

[0137] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

Claims

1. A text classification method, characterized in that: include: Obtaining a document to be classified, and performing word segmentation on the document; Based on the word segmentation results, a graph network including four types of nodes is constructed, and a corresponding graph network matrix is ​​set for the graph network, wherein the four types of nodes refer to document nodes of the document, paragraph nodes in the document, sentence nodes in the paragraph, and word nodes in the sentence; Constructing a target adjacency matrix according to the graph network matrix; Perform subgraph clustering on the four types of nodes, and combine them with the graph network matrix to obtain a target graph network matrix; The target adjacency matrix and the target graph network matrix are input into a graph convolutional neural network, and the graph convolutional neural network outputs a graph latent vector corresponding to the document, and then the graph latent vector is classified using a classification function to obtain a classification result of the document; The graph network including four types of nodes is constructed based on the word segmentation results, and a corresponding graph network matrix is ​​set according to the graph network, wherein the four types of nodes refer to the document nodes of the document, the paragraph nodes in the document, the sentence nodes in the paragraphs, and the word nodes in the sentences, including: Using one-bit effective coding to represent the features of the document, thereby obtaining the document node, paragraph node and sentence node; Based on the word2vec method, the document is represented by a word embedding vector according to the word segmentation result, and then the word embedding vector is used as the word node; Constructing the graph network based on the document nodes, paragraph nodes, sentence nodes and word nodes; Set the graph network matrix of the graph network to X∈R n×m , where R n×m is the dimension of the graph network matrix, n is the number of nodes in the graph network, and m is the feature dimension of each node.

2. The text classification method according to claim 1, characterized in that: The step of constructing a target adjacency matrix according to the graph network matrix includes: Constructing a first adjacency matrix between the word node and other types of nodes, constructing a second adjacency matrix between the sentence node and other types of nodes, and constructing a third adjacency matrix between the paragraph node and other types of nodes; The first adjacency matrix, the second adjacency matrix and the third adjacency matrix are concatenated into the target adjacency matrix.

3. The text classification method according to claim 2, characterized in that: The constructing of a first adjacency matrix between the word node and other types of nodes comprises: The first edge weight between each word node is calculated according to the following formula: Where Wt w-w is the first edge weight between each word node, dis w-w is the edit distance between word nodes, cos w-w is the similarity between word nodes, α and β are weight coefficients, and α, β∈(0,1); The semantic role weight of each word in each sentence is obtained according to the semantic role standard, and the part-of-speech role weight of each word in each sentence is obtained according to the part-of-speech classification standard, and then the second edge weight between the word node and the sentence node is calculated according to the following formula: Wtw-s=Sem wt ×POSwt Where Wt w-s is the second edge weight between the word node and the sentence node, POS wt is the part-of-speech role weight of the word node, Sem wt is the semantic role weight of the word node, N_POS(i) is the part of speech of the i-th word node; Get the number of times a word node appears in a paragraph node, and get the position order of the word node in the corresponding paragraph, and then calculate the third edge weight between the word node and the paragraph node according to the following formula: Wt w-p =N_wp ij ×PE ij Where Wt w-p is the third edge weight between the word node and the paragraph node, N_wp ij is the number of times the i-th word node appears in paragraph node j, PE ij is the position order of the i-th word node in paragraph node j; Get the number of times the word node appears in the document node, and get the position order of the word node in the corresponding document, and then calculate the weight of the fourth edge between the word node and the document node; The first adjacency matrix is ​​constructed according to the first edge weight, the second edge weight, the third edge weight and the fourth edge weight.

4. The text classification method according to claim 1, characterized in that: The sub-graph clustering of the four types of nodes and combining the graph network matrix to obtain the target graph network matrix includes: Performing subgraph clustering based on nodes of the same type and combining the graph network matrix to obtain a first combined feature, and performing subgraph clustering based on nodes of different types and combining the graph network matrix to obtain a second combined feature; The first combined features and the second combined features are concatenated to obtain the target graph network matrix.

5. The text classification method according to claim 4, characterized in that: The subgraph clustering based on nodes of the same type and obtaining the first combined feature in combination with the graph network matrix include: Subgraph clustering is performed according to document nodes, paragraph nodes, sentence nodes, and word nodes respectively; The average feature vector of the nodes in all the clustered subgraphs is obtained, and the average feature vector is concatenated with the node features in the graph network matrix to form the first combined feature.

6. The text classification method according to claim 1, characterized in that: The target adjacency matrix and the target graph network matrix are input into the graph convolutional neural network, and the graph convolutional neural network outputs the graph latent vector corresponding to the document, and then the graph latent vector is classified by using a classification function to obtain the classification result of the document, including: The target adjacency matrix is ​​calculated according to the following formula: In the formula, is a normalized symmetric adjacency matrix, A is the target adjacency matrix, and D is the degree matrix of the target adjacency matrix; The graph implicit vector is calculated as follows: Where, L (j+1) is the graph implicit vector output by the j+1th layer of the graph convolutional neural network, L (j) is the graph implicit vector output by the jth layer of the graph convolutional neural network, W0 is the weight matrix, σ is the activation function, where L (0) is the target graph network matrix; The graph latent vector is classified using a classification function to obtain a classification result of the document.

7. A text classification device, characterized in that: include: A word segmentation unit, used to obtain a document to be classified and perform word segmentation on the document; A first construction unit is used to construct a graph network including four types of nodes based on the word segmentation result, and set a corresponding graph network matrix for the graph network, wherein the four types of nodes refer to document nodes of the document, paragraph nodes in the document, sentence nodes in the paragraph, and word nodes in the sentence; A second construction unit is used to construct a target adjacency matrix according to the graph network matrix; A first clustering unit is used to perform sub-graph clustering on the four types of nodes, and combine the sub-graph clustering with the graph network matrix to obtain a target graph network matrix; A first classification unit is used to input the target graph network matrix and the target adjacency matrix into a graph convolutional neural network, and the graph convolutional neural network outputs a graph latent vector corresponding to the document, and then classifies the graph latent vector using a classification function to obtain a classification result of the document; The first building block comprises: A feature representation unit, used for performing feature representation on the document using a single-bit effective encoding, thereby obtaining the document node, paragraph node and sentence node; A vector representation unit, used for representing the document by a word embedding vector based on the word2vec method and according to the word segmentation result, and then using the word embedding vector as the word node; A third construction unit, configured to construct the graph network based on the document nodes, paragraph nodes, sentence nodes, and word nodes; A matrix setting unit is used to set the graph network matrix of the graph network to X∈Rn×m, wherein Rn×m is the dimension of the graph network matrix, n is the number of nodes of the graph network, and m is the feature dimension of each node.

8. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the text classification method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the text classification method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Multi-level fusion document classification method and system based on deep learning

    CN109492108A

  • Web service classification method based on graph convolutional neural network

    CN110717047A

  • Text classification method and system based on graph convolutional neural network

    CN110929029A