Text classification method

By using the text feature extraction method of dependency parse tree and word weight calculation in government text classification, combined with semantic similarity and induction of supporting text feature vectors, the problem of incomplete and poor accuracy in multi-label classification of government texts is solved. for more accurate and comprehensive text classification.

WO2024216804A1PCT designated stage expired Publication Date: 2024-10-24CETC BIGDATA RES INST CO LTD +1

Patent Information

Application Number
PCT/CN2023/114850
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-20
Filing Date
2023-08-25
Publication Date
2024-10-24

AI Technical Summary

Technical Problem

Existing text classification methods are not comprehensive and accurate in multi-label scenarios of government texts, and ignore text structure information, resulting in inaccurate semantic extraction.

Method used

By obtaining multiple text segments of the text to be classified, text feature extraction is performed, text feature vectors are obtained using dependency parse trees and word weight calculations, categories are determined based on semantic similarity, and summary is performed based on supporting text feature vectors to improve classification accuracy.

Benefits of technology

It improves the comprehensiveness and accuracy of government text classification, reduces the probability of missing category labels in multi-label scenarios, extracts more accurate and rich contextual information, and enhances text semantic extraction capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023114850_24102024_PF_FP_ABST
    Figure CN2023114850_24102024_PF_FP_ABST
Patent Text Reader

Abstract

The present invention provides a text classification method. Text categories to which text segments to be classified belong are determined on the basis of the semantic similarity between text feature vectors of said text segments and supporting text feature vectors of text categories, and even if some text categories have a small number of supporting text segments, supporting text feature vectors of the text categories can be accurately summarized according to text feature vectors of the supporting text segments of the text categories, so as to identify, according to the semantic similarity, text segments to be classified belonging to the text categories, thereby reducing the probability of missing category labels in a multi-label classification scenario; in addition, during text feature extraction, the grammar structure of corresponding text segments is fully used to extract more accurate and richer context information, and overall semantic extraction is performed in view of semantic information of non-stop words and context semantic information, facilitating improvement of the accuracy of government text classification.
Need to check novelty before this filing date? Find Prior Art

Description

A text classification method Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a text classification method. Background Art

[0002] With the advent of the big data era and the development of network technology, e-government systems have gained widespread application, leveraging their innovative management models. Compared to traditional administrative methods, the most significant feature of e-government lies in its electronic nature, namely, paperless administration, networked information transmission, and virtualized administrative and legal relationships. This networked information transmission effectively strengthens government information services, enabling the public to receive the most comprehensive and comprehensive information services possible and achieving government transparency. With the continued use of e-government systems, a large volume of government documents is being disseminated and pushed online to the public, causing the public to suffer from "information overload" and struggle to quickly locate the documents they need within this vast volume. Therefore, a method is needed to rapidly categorize these massive volumes of government documents, assigning them corresponding category tags so that the public can quickly filter through them.

[0003] Current text classification methods often use supervised methods to train text classification models to enhance their classification performance. However, when applied to government text classification scenarios, the classification results of these text classification methods are difficult to meet actual application requirements. This is because government texts can typically contain multiple category labels. When training text classification models, these methods use an imbalanced number of training samples corresponding to different category labels. Category labels with a larger number of categories have better training results and more accurate classification, while category labels with a smaller number of categories have poor training results and are prone to misclassification. This results in the omission of these category labels with poor training results during actual government text classification, resulting in incomplete classification results. Furthermore, the performance bottleneck of current text classification methods lies in the extraction of text features. These methods ignore the structural information of the text when extracting text features, which affects the meaning of word segmentations in the text, resulting in inaccurate text semantic extraction and poor classification accuracy. Therefore, there is a need to improve the comprehensiveness and accuracy of government text classification in multi-label scenarios. Technical issues

[0004] The present invention provides a text classification method to solve the defects of the prior art in that multi-label classification of government texts is incomplete and inaccurate. Technical Solutions

[0005] The present invention provides a text classification method, comprising:

[0006] Acquire multiple text segments to be classified of government affairs text to be classified;

[0007] Performing text feature extraction on the multiple text segments to be classified to obtain text feature vectors of the multiple text segments to be classified, and determining multiple categories of the government text to be classified based on the semantic similarity between the text feature vectors of the multiple text segments to be classified and the supporting text feature vectors of each text category in the supporting text set; the supporting text feature vector of any text category is obtained by performing text feature extraction on the supporting text segments of the any text category, and then summarizing the text feature vectors of each supporting text segment after obtaining the text feature vector of the supporting text segment;

[0008] The text feature extraction specifically includes:

[0009] Obtaining a dependency parse tree for a corresponding text segment, and determining a plurality of parse subtrees for each non-stop word in the corresponding text segment based on the dependency parse tree; a parse subtree for any non-stop word is a subtree in the dependency parse tree with the non-stop word as a root node;

[0010] Determining a text feature vector of the corresponding text segment based on each non-stop word in the corresponding text segment and its parsed subtree;

[0011] Determining the text feature vector of the corresponding text segment based on each non-stop word in the corresponding text segment and its parsed subtree specifically includes:

[0012] Determining a word vector for each non-stop word in the corresponding text segment;

[0013] Fusing the word vectors of each word in the parsing subtree of any non-stop word to obtain the subtree vector of the parsing subtree of any non-stop word;

[0014] Fusing the word vector of any non-stop word and the subtree vector of its parsed subtree to obtain a fused context vector of the any non-stop word;

[0015] Based on the word weights of the non-stop words, the fused context vectors of the non-stop words are weighted and summed to obtain the text feature vector of the corresponding text segment.

[0016] According to a text classification method provided by the present invention, the word weight of each non-stop word is determined based on the following steps:

[0017] Determining the word weight of each word in the corpus based on the number of co-occurrences between each word in the corpus; wherein the higher the number of co-occurrences between any word and other words in the corpus, the lower the word weight of any word;

[0018] Based on the word weight of each word segment in the corpus, the word weight of each non-stop word in the corresponding text segment is determined.

[0019] According to a text classification method provided by the present invention, determining the word weight of each word in the corpus based on the number of co-occurrences between each word in the corpus specifically includes:

[0020] Based on each sample sentence in the corpus, obtaining a dependency parse tree of each sample sentence;

[0021] Determining the number of co-occurrences between each pair of word segments in each sample sentence based on the dependency parse tree of each sample sentence;

[0022] Constructing a weight graph based on each of the segmented words in each of the sample sentences; wherein the nodes in the weight graph correspond to each of the segmented words, and the edge weights in the weight graph are determined based on the number of co-occurrences of two segmented words connected by the corresponding edge;

[0023] Based on the edge weights of each node in the weight graph and the edges connecting the nodes, the word weights of the segmentations corresponding to the nodes are determined; wherein, the higher the edge weight of the edge connecting any node, the lower the word weight of the segmentation corresponding to the any node.

[0024] According to a text classification method provided by the present invention, the edge weights in the weight graph are determined based on the following steps:

[0025] The edge weight of any edge in the weight graph is determined based on the number of co-occurrences of the segment words corresponding to the two nodes connected by the edge, and the distance between the segment words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence; wherein, the farther the distance between the segment words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence, the lower the edge weight of the edge.

[0026] According to a text classification method provided by the present invention, determining the edge weight of any edge based on the co-occurrence count of the segmentations corresponding to the two nodes connected by any edge in the weight graph and the distance between the segmentations corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence specifically includes:

[0027] The edge weight of any edge is obtained by dividing the number of co-occurrences of the segment words corresponding to the two nodes connected by any edge by the distance between the segment words corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence.

[0028] According to a text classification method provided by the present invention, determining the word weight of the word segment corresponding to each node based on the edge weights of each node and the edges connecting each node in the weight graph specifically includes:

[0029] Based on the edge weight of the edge connecting any node in the weight graph, using the page value algorithm, determine the page value of the word corresponding to any node;

[0030] The inverse of the webpage value of the word corresponding to any node is determined as the word weight of the word corresponding to any node.

[0031] According to a text classification method provided by the present invention, summarizing the text feature vectors of each supporting text segment specifically includes:

[0032] In each round of iteration, based on the text feature vectors of each supporting text segment of any text category and the text segment weights of each supporting text segment, a candidate supporting text feature vector of any text category in the current round of iteration is determined, and based on the correlation between the candidate supporting text feature vector of any text category in the current round of iteration and the text feature vectors of each supporting text segment, the text segment weights of each supporting text segment are updated;

[0033] The candidate supporting text feature vector of any text category in the last round of iteration is used as the supporting text feature vector of any text category.

[0034] According to a text classification method provided by the present invention, the text segment weights of the respective supporting text segments are obtained by processing the text coefficients of the respective supporting text segments using a softmax function; the initial value of the text coefficient is 0;

[0035] The updating of the text segment weights of the respective supporting text segments based on the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vectors of the respective supporting text segments specifically includes:

[0036] Determining the degree of correlation between the candidate supporting text feature vectors of any text category in the current iterative process and the text feature vectors of each supporting text segment; wherein the degree of correlation between the candidate supporting text feature vectors of any text category in the current iterative process and the text feature vector of any supporting text segment is calculated based on vector dot product;

[0037] Adding the current value of the text coefficient of any supporting text segment and the correlation between the candidate supporting text feature vector of any text category in the current round of iteration and the text feature vector of any supporting text segment to obtain an updated text coefficient of any supporting text segment;

[0038] Based on the updated text coefficients of the respective supporting text segments, the text segment weights of the respective supporting text segments are updated.

[0039] According to a text classification method provided by the present invention, based on the semantic similarity between the text feature vectors of the plurality of text segments to be classified and the supporting text feature vectors of each text category in the supporting text set, the method further comprises:

[0040] Perform vector dot product or cosine similarity calculation on the text feature vector of any text segment to be classified and the supporting text feature vector of any text category to obtain the semantic similarity between the text feature vector of any text segment to be classified and the supporting text feature vector of any text category;

[0041] If the semantic similarity between the text feature vector of any text segment to be classified and the supporting text feature vector of any text category is greater than a preset similarity threshold, the any text category is determined to be the text category to which the any text segment to be classified belongs; wherein, the text categories to which the multiple text segments to be classified belong constitute multiple categories of the government text to be classified.

[0042] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-described text classification methods is implemented.

[0043] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements any of the above-mentioned text classification methods when executed by a processor.

[0044] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned text classification methods. Beneficial effects

[0045] The present invention provides a text classification method, which determines the text category to which the text segment to be classified belongs based on the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vectors of each text category, thereby obtaining multiple categories of the entire government text to be classified. Even if the number of supporting text segments of some text categories is small, the supporting text feature vector of the text category can still be accurately summarized based on the text feature vector of the supporting text segment of the text category, so as to identify the supporting text feature vector belonging to the text category based on the above-mentioned semantic similarity, reduce the probability of missing category labels in multi-label classification scenarios, and improve the comprehensiveness of government text classification; in addition, when performing text feature extraction, the grammatical structure of the corresponding text segment is fully utilized to extract more accurate and richer context information, so as to combine the semantic information of each non-stop word itself and the context information for overall semantic extraction, thereby improving the accuracy of text segment semantic extraction and helping to improve the accuracy of government text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to 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 any creative work.

[0047] FIG1 is a flow chart of a text classification method provided by the present invention;

[0048] FIG2 is a flow chart of a text feature extraction method according to the present invention;

[0049] FIG3 is a second flow chart of the text feature extraction method provided by the present invention;

[0050] FIG4 is a flow chart of a method for determining word weights provided by the present invention;

[0051] 5 is a schematic flow chart of a method for summarizing supported text feature vectors provided by the present invention;

[0052] FIG6 is a flow chart of a method for updating text segment weights provided by the present invention;

[0053] FIG7 is a schematic structural diagram of an electronic device provided by the present invention. Modes for Carrying Out the Invention

[0054] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0055] FIG1 is a flow chart of a text classification method provided by the present invention. As shown in FIG1 , the method includes:

[0056] Step 110, obtaining a plurality of text segments to be classified of the government affairs text to be classified;

[0057] Step 120: Perform text feature extraction on the multiple text segments to be classified to obtain text feature vectors of the multiple text segments to be classified, and determine multiple categories of the government documents to be classified based on the semantic similarity between the text feature vectors of the multiple text segments to be classified and the supporting text feature vectors of each text category in the supporting text set; the supporting text feature vector of any text category is obtained by performing text feature extraction on the supporting text segments of the any text category, and then summarizing the text feature vectors of each supporting text segment;

[0058] The text feature extraction specifically includes:

[0059] Step 121: Obtain a dependency parse tree for a corresponding text segment, and determine a plurality of parse subtrees for each non-stop word in the corresponding text segment based on the dependency parse tree; a parse subtree for any non-stop word is a subtree in the dependency parse tree with the non-stop word as a root node;

[0060] Step 122: Determine a text feature vector of the corresponding text segment based on each non-stop word in the corresponding text segment and its parsed subtree.

[0061] Specifically, since government documents typically have standardized structure and wording, and each section is relatively independent, the government documents to be classified can be segmented into multiple sections, and subsequent text classification operations can be performed independently on each section. For each section, text feature extraction is performed to obtain a text feature vector for the section. This text feature vector contains semantic information about the section and can be used to identify the text category to which the section belongs.

[0062] Considering that government texts can usually contain multiple category labels, the existing supervised training methods use the difference between the model output results and the annotation results of the training samples corresponding to the same category label to reversely adjust the model parameters when training the text classification model. However, the number of training samples corresponding to different category labels is unbalanced. The training effect of category labels with a larger number is better and the classification is more accurate, while the training effect of category labels with a smaller number is poor and classification errors are prone to occur, which leads to the easy omission of the above-mentioned category labels with poor training effect when actually classifying government texts. Therefore, when using training samples to help the model distinguish the characteristics of texts with different category labels, the embodiment of the present invention extracts text features from the supporting text segments of each text category in the supporting text set (i.e., the training set). After obtaining the text feature vectors of the supporting text segments of each text category, the text feature vectors of the supporting text segments of each text category are summarized to obtain the supporting text feature vectors of each text category.

[0063] Among them, the supporting text segments belonging to the same text category have a certain degree of semantic similarity, so by summarizing the text feature vectors of the supporting text segments of the text category, the representative semantic features of the text category can be extracted. Therefore, the supporting text feature vector of any text category can represent the commonality of the text semantics of the text category, and can be used as a representative of the text category to identify whether the text segment to be classified conforms to the text category. Therefore, after extracting the text feature vector of the text segment to be classified, the text category to which the text segment to be classified belongs can be determined based on the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vectors of each text category, thereby obtaining multiple categories of the entire government text to be classified. Among them, the semantic similarity between the text feature vector of any text segment to be classified and the supporting text feature vectors of each text category can be calculated respectively, and then the text category with higher semantic similarity is determined as the text category to which the text segment to be classified belongs. Here, when calculating the semantic similarity between the text feature vector of any text segment to be classified and the supporting text feature vector of any text category, the similarity between the two vectors can be obtained by using vector dot product, cosine similarity and other calculation methods as the semantic similarity between the two vectors. After calculating the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vectors of each text category, the above semantic similarity can be compared with a preset similarity threshold. When the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vector of any text category is greater than the similarity threshold, it can be determined that the text category is the text category to which the text segment to be classified belongs. It should be noted that if the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vectors of multiple text categories is greater than the similarity threshold, then the above corresponding multiple text categories are all text categories to which the text segment to be classified belongs.

[0064] It can be seen that even if the number of supporting text segments of some text categories is small, the supporting text feature vector of the text category can still be accurately summarized based on the text feature vector of the supporting text segments of the text category, thereby identifying the supporting text feature vector belonging to the text category based on the above-mentioned semantic similarity, reducing the probability of missing category labels in multi-label classification scenarios, and improving the comprehensiveness of government text classification.

[0065] Here, the text feature extraction method for the to-be-classified text segment and the supporting text segment is the same. As can be seen above, the accuracy of the text feature extraction method affects the semantic expressiveness of the supporting text feature vectors for each text category and the semantic expressiveness of the text feature vectors for the to-be-classified text segment, thus affecting the accuracy of multi-label text classification. Therefore, it is necessary to improve the performance of text feature extraction.

[0066] Specifically, when performing text feature extraction, the degree of association between the same word and different word segments in different grammatical structures varies, resulting in certain differences in the semantic information of the word in the corresponding text segment. Therefore, the grammatical structure of the corresponding text segment can be fully utilized to perform text feature extraction on the corresponding text segment. A dependency parse tree can be obtained for the corresponding text segment. The dependency parse tree contains the dependency relationships between the word segments in the text segment and contains rich grammatical structure information. Based on the dependency parse tree, one or more parse subtrees are obtained for each non-stop word in the corresponding text segment (stop words have no specific semantics and can be excluded in advance). The parse subtree of any non-stop word is the subtree in the dependency parse tree with the non-stop word as the root node. Furthermore, any non-stop word can correspond to multiple parse subtrees of varying depths to obtain different levels of contextual semantic information. The deeper the parse subtree, the richer the corresponding contextual semantic information.

[0067] Subsequently, based on each non-stop word in the corresponding text segment and its parsed subtree, the text feature vector of the corresponding text segment is determined. Specifically, the semantic information of the entire corresponding text segment can be determined based on the semantic information of each non-stop word itself and the contextual semantic information of the corresponding non-stop word carried by the parsed subtree of each non-stop word, thereby forming a text feature vector for the corresponding text segment. It can be seen that when performing text feature extraction, the grammatical structure of the corresponding text segment is fully utilized to extract more accurate and richer contextual information, so as to combine the semantic information of each non-stop word itself and the contextual information for overall semantic extraction, thereby improving the accuracy of semantic extraction of the text segment and helping to improve the accuracy of government text classification.

[0068] The method provided by the embodiment of the present invention determines the text category to which the text segment to be classified belongs based on the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vectors of each text category, thereby obtaining multiple categories of the entire government text to be classified. Even if the number of supporting text segments of some text categories is small, the supporting text feature vector of the text category can still be accurately summarized based on the text feature vector of the supporting text segment of the text category, so as to identify the supporting text feature vector belonging to the text category based on the above-mentioned semantic similarity, reduce the probability of missing category labels in multi-label classification scenarios, and improve the comprehensiveness of government text classification; in addition, when performing text feature extraction, the grammatical structure of the corresponding text segment is fully utilized to extract more accurate and richer context information, so as to combine the semantic information of each non-stop word itself and the context information for overall semantic extraction, thereby improving the accuracy of text segment semantic extraction and helping to improve the accuracy of government text classification.

[0069] Based on the above embodiment, as shown in FIG2 , step 122 specifically includes:

[0070] Step 1221, determining the word vector of each non-stop word in the corresponding text segment;

[0071] Step 1222: Determine a subtree vector of the parse subtree of any non-stop word based on the word vectors of each word in the parse subtree of any non-stop word.

[0072] Step 1223: Determine a fused context vector of any non-stop word based on the word vector of the any non-stop word and the subtree vector of its parsed subtree;

[0073] Step 1224 : Determine a text feature vector of the corresponding text segment based on the fused context vectors of the non-stop words in the corresponding text segment.

[0074] Specifically, we can first extract the word vectors of each non-stop word in the corresponding text segment based on existing word vector extraction models (such as word2vec, BERT, etc.). The word vectors of non-stop words contain the semantic information of the non-stop words themselves.

[0075] On the other hand, the subtree vector of the parse subtree of any non-stop word can also be determined based on the word vectors of each word in the parse subtree of the non-stop word. The subtree vector of the parse subtree contains the semantic information of the parse subtree, that is, the contextual semantic information of the non-stop word corresponding to the parse subtree. Here, the word vectors of each word in the parse subtree of the non-stop word can be fused using various fusion methods to obtain the subtree vector of the parse subtree of the non-stop word. For example, the average value of the word vectors of each word in the parse subtree can be obtained, or the word vectors of each word in the parse subtree can be weighted averaged, wherein the weight of each word can be determined according to the distance between the corresponding word and the stop word (that is, the number of hops in the parse subtree), and the closer the distance, the higher the weight.

[0076] Based on the word vector of the non-stop word and the subtree vector of its parsed subtree, a fusion context vector of the non-stop word is obtained. The fusion method here can also adopt an average or weighted average method. When the weighted average method is adopted, the corresponding weight can be determined according to the depth of the parsed subtree. The greater the depth, the smaller the weight, and the weight of the word vector of the non-stop word itself can be the largest. Based on the fusion context vector of each non-stop word in the corresponding text segment, the text feature vector of the corresponding text segment is finally determined.

[0077] Based on any of the above embodiments, as shown in FIG3 , step 1224 specifically includes:

[0078] Step 1224-1: determining a word weight of each word in the corpus based on the number of co-occurrences between each word in the corpus; wherein the higher the number of co-occurrences between a word and other words in the corpus, the lower the word weight of the word;

[0079] Step 1224-2, determining the word weight of each non-stop word in the corresponding text segment based on the word weight of each word segment in the corpus;

[0080] Step 1224 - 3 : Determine the text feature vector of the corresponding text segment based on the fused context vector of each non-stop word and the word weight of each non-stop word.

[0081] Specifically, different non-stop words in a text segment have different effects on the semantics of the entire text segment. Therefore, when obtaining the text feature vector of a text segment, the degree of influence of different non-stop words on the overall semantics of the text can be considered to improve the semantic expression ability of the text feature vector for the corresponding text segment.

[0082] The word weight of each word in a preset corpus can be determined based on the number of co-occurrences between each word in the corpus. The higher the number of co-occurrences between a word and other words in the corpus, the less novel and distinctive the meaning of the word is, and the less impact it has on the semantics of the entire text segment, and therefore the lower the word weight of the word. Subsequently, a query is performed based on the word weights of each word in the corpus to determine the word weights of each non-stop word in the corresponding text segment.

[0083] Then, based on the fused context vectors of each non-stop word and the word weights of each non-stop word, weighted fusion is performed to obtain the text feature vector of the corresponding text segment.

[0084] Based on any of the above embodiments, as shown in FIG4 , step 1224 - 1 specifically includes:

[0085] Step 1224-11, based on each sample sentence in the corpus, obtaining a dependency parse tree of each sample sentence;

[0086] Step 1224-12, determining the number of co-occurrences between each pair of word segments in each sample sentence based on the dependency parse tree of each sample sentence;

[0087] Step 1224-13: constructing a weight graph based on each of the segmented words in each of the sample sentences; wherein the nodes in the weight graph correspond to each of the segmented words, and the edge weights in the weight graph are determined based on the number of co-occurrences of two segmented words connected by the corresponding edge;

[0088] Step 1224-14, based on the edge weights of each node in the weight graph and the edges connecting each node, determine the word weights of the word segments corresponding to each node; wherein, the higher the edge weight of the edge connecting any node, the lower the word weight of the word segment corresponding to any node.

[0089] Specifically, the dependency parse tree of each sample sentence in the corpus is obtained, and based on the dependency parse tree of each sample sentence, the number of co-occurrences between each pair of segmentations in each sample sentence is counted. Co-occurrence of two segmentations means that the two segmentations appear in the same subtree within a preset depth in the corresponding dependency parse tree. For example, if two segmentations are in the same subtree with a depth of 3, it indicates that the two segmentations are closely related and can be considered to co-occur.

[0090] Then, a global weight graph is constructed based on each segmentation in each sample sentence. The nodes in the weight graph correspond to each segmentation in the corpus, and the edges in the weight graph connect two co-occurring segmentations, with the edge weights of the edges being determined based on the number of co-occurrences of the two segmentations connected by the edge. The edge weight of any edge is proportional to the number of co-occurrences of the two segmentations connected by the edge.

[0091] Then, based on the edge weights of each node and the edges connecting each node in the weight graph, the word weight of the segmentation corresponding to each node is determined. Among them, the higher the edge weight of the edge connecting any node, the more times the segmentation corresponding to the node co-occurs with other segmentations, the weaker the novelty and distinctiveness of the segmentation corresponding to the node, and therefore the lower the word weight of the segmentation corresponding to the node.

[0092] Based on any of the above embodiments, the edge weights in the weight graph are determined based on the following steps:

[0093] The edge weight of any edge in the weight graph is determined based on the number of co-occurrences of the segment words corresponding to the two nodes connected by the edge, and the distance between the segment words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence; wherein, the farther the distance between the segment words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence, the lower the edge weight of the edge.

[0094] Specifically, when determining the edge weight of any edge in the weight graph, the edge weight of the edge can be determined based on the number of co-occurrences of the segmentation words corresponding to the two nodes connected by the edge in the weight graph, and the distance between the segmentation words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence. Among them, the distance between the segmentation words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence can be obtained. If the segmentation words corresponding to the two nodes connected by the edge appear in multiple dependency parse trees, the minimum value of the distance between the two segmentation words in the chrome dependency parse tree is selected. Subsequently, the edge weight of the edge is determined based on the number of co-occurrences of the segmentation words corresponding to the two nodes connected by the edge in the weight graph, and the distance between the segmentation words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence, to ensure that the farther the distance between the segmentation words corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence, the lower the edge weight of the edge is, to indicate that although the two segmentation words co-occur, the degree of correlation between the two is not large, thereby helping to improve the accuracy of text feature vector extraction.

[0095] Based on any of the above embodiments, determining the edge weight of any edge based on the co-occurrence counts of the segmentations corresponding to the two nodes connected by any edge in the weight graph and the distance between the segmentations corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence specifically includes:

[0096] The edge weight of any edge is obtained by dividing the number of co-occurrences of the segment words corresponding to the two nodes connected by any edge by the distance between the segment words corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence.

[0097] Specifically, the number of co-occurrences of the word segments corresponding to the two nodes connected by the edge is divided by the distance between the two word segments in the dependency parse tree of each sample sentence, and the result can be used as the edge weight of the edge, so that the farther the distance between the word segments corresponding to the two nodes connected by the edge in the dependency parse tree of each sample sentence is, the lower the edge weight of the edge is.

[0098] Based on any of the above embodiments, determining the word weight of the word segmentation corresponding to each node based on the edge weights of each node and the edges connecting each node in the weight graph specifically includes:

[0099] Based on the edge weight of the edge connecting any node in the weight graph, using the page value algorithm, determine the page value of the word corresponding to any node;

[0100] The inverse of the webpage value of the word corresponding to any node is determined as the word weight of the word corresponding to any node.

[0101] Specifically, any node may correspond to multiple edges. To combine the edge weights of all edges connecting a node when determining the word weight of a segmentation corresponding to a node, the PageRank algorithm can be used to calculate the page weight of the segmentation corresponding to the node based on the edge weights of all edges connecting the node. Subsequently, the inverse of the page weight of the segmentation corresponding to the node is used as the word weight of the segmentation corresponding to the node.

[0102] Based on any of the foregoing embodiments, determining the text feature vector of the corresponding text segment based on the fused context vectors of the respective non-stop words and the word weights of the respective non-stop words specifically includes:

[0103] Based on the word weights of the non-stop words, the fused context vectors of the non-stop words are weighted and summed to obtain the text feature vector of the corresponding text segment.

[0104] Based on any of the above embodiments, as shown in FIG5 , summarizing the text feature vectors of each supporting text segment specifically includes:

[0105] Step 510: In each iteration, based on the text feature vectors of each supporting text segment of any text category and the text segment weights of each supporting text segment, determine the candidate supporting text feature vectors of the text category in the current iteration, and based on the correlation between the candidate supporting text feature vectors of the text category in the current iteration and the text feature vectors of each supporting text segment, update the text segment weights of each supporting text segment.

[0106] Step 520 : Using the candidate supporting text feature vector of any text category in the last round of iteration as the supporting text feature vector of any text category.

[0107] Specifically, when obtaining the supporting text feature vector of any text category, in order to improve the summarization ability of the text feature vector of the supporting text segment of the text category and improve the semantic expression ability of the supporting text feature vector for the text category, multiple rounds of iterative summarization can be performed on the supporting text segment of the text category.

[0108] Specifically, during each iteration, a summary is performed based on the text feature vectors of all supporting text segments for the text category. During this process, because different supporting text segments are described differently and may belong to multiple text categories, different supporting text segments have different degrees of association with the current text category. To prevent semantic information associated with other text categories in the supporting text segments from being mixed into the supporting text feature vector of the current text category, thereby affecting the subsequent text classification accuracy, a corresponding text segment weight can be set for each supporting text segment to strengthen the semantic information of supporting text segments with a stronger association with the current text category and weaken the semantic information of supporting text segments with a weaker association with the current text category. Then, based on the text feature vectors and text segment weights of each supporting text segment for the current text category, a candidate supporting text feature vector for the current text category in the current iteration is summarized. A weighted summation of the text feature vectors and text segment weights of each supporting text segment can be performed to obtain the candidate supporting text feature vector for the current iteration.

[0109] However, the degree of association between the supporting text segment and the current text category is difficult to define, and the accuracy of the weight assigned based on experience is poor, which can easily lead to inaccurate candidate supporting text feature vectors obtained by induction. Therefore, a model self-supervision method can be adopted. After obtaining the candidate supporting text feature vectors of the current iteration process in each round of iteration, the text segment weights of each supporting text segment are updated based on the correlation between the candidate supporting text feature vectors of the text category in the current iteration process and the text feature vectors of each supporting text segment. Among them, the higher the correlation between the text feature vector of any supporting text segment and the candidate supporting text feature vector of the text category in the current iteration process, it can be temporarily considered that the degree of association between the supporting text segment and the current text category is higher, so its text segment weight can be temporarily adjusted to be higher. The updated text segment weight of the supporting text segment can be used to determine the new candidate supporting text feature vector corresponding to the text category in the next iteration process.

[0110] Since the text segment weights of each supporting text segment are adaptively updated in the above-mentioned manner during multiple rounds of iterations, the text segment weights of each supporting text segment will tend to be more accurate, thereby gradually improving the accuracy of the candidate supporting text feature vectors of the current text category. After the last round of iterations, the candidate supporting text feature vectors of the current text category in the last round of iterations can be used as the supporting text feature vectors of the current text category. It should be noted that in each round of iterations, all supporting text segments corresponding to each text category will be traversed, and the above-mentioned step 510 will be performed based on each supporting text segment of each text category to obtain the candidate supporting text feature vectors of each text category in the current round of iterations, as well as the text segment weights of each supporting text segment corresponding to each text category. When executing the last round of iteration (the total number of iterations can be set in advance), all supporting text segments corresponding to each text category are traversed in the same manner, and the above step 510 is executed based on each supporting text segment of each text category. When the candidate supporting text feature vectors of each text category in the current round of iteration are obtained based on step 510, it indicates that the last round of iteration is completed, and the candidate supporting text feature vectors of each text category obtained at this time can be used as the supporting text feature vectors of the corresponding text category.

[0111] Based on any of the above embodiments, the text segment weights of the respective supporting text segments are obtained by processing the text coefficients of the respective supporting text segments using a softmax function; the initial value of the text coefficient is 0;

[0112] As shown in FIG6 , the updating of the text segment weights of the respective supporting text segments based on the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vectors of the respective supporting text segments specifically includes:

[0113] Step 511, determining the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vectors of each supporting text segment;

[0114] Step 512: updating the text coefficients of the respective supporting text segments based on the current values ​​of the text coefficients of the respective supporting text segments and the correlation between the candidate supporting text feature vectors of the respective supporting text segments in the current round of iteration of any text category;

[0115] Step 513: Update the text segment weight of each supporting text segment based on the updated text coefficient of each supporting text segment.

[0116] Specifically, for each supporting text segment of the current text category, the initial value of the text coefficient of each supporting text segment is set to 0, and the initial value of the text coefficient of each supporting text segment is processed based on the softmax function to obtain the initial value of the text segment weight of each supporting text segment. When the first round of iteration begins, the induction operation described in the above embodiment can be performed based on the initial value of the text segment weight of each supporting text segment. In subsequent iterations, the induction operation can be performed based on the text segment weight of each supporting text segment updated in the previous round.

[0117] Among them, when updating the text segment weights of each supporting text segment, the method adopted is to update the text coefficients of each supporting text segment, and then use the softmax function to process the updated text coefficients to obtain the updated text segment weights.

[0118] Specifically, the degree of correlation between the candidate supporting text feature vectors of the current text category in the current round of iteration and the text feature vectors of each supporting text segment can be calculated. The above-mentioned degree of correlation can be calculated by vector dot multiplication. Based on the current value of the text coefficient of each supporting text segment (the initial value in the first round of iteration and the updated value of the previous round of iteration in the subsequent iterations), and the degree of correlation between the candidate supporting text feature vectors of the current text category in the current round of iteration and the text feature vectors of each supporting text segment, the text coefficient of each supporting text segment is updated. Here, the degree of correlation between the text feature vector of any supporting text segment and the candidate supporting text feature vector of the current text category in the current round of iteration can be added to the current value of the text coefficient of the supporting text segment. When the degree of correlation between the text feature vector of the supporting text segment and the candidate supporting text feature vector of the current text category in the current round of iteration is large, the updated text coefficient is also large.

[0119] It should be noted that when updating the text coefficient, even if the correlation between the text feature vector of the supporting text segment and the candidate supporting text feature vector of the current text category in the current round of iteration is small, the updated text coefficient will be slightly larger than the text coefficient before the update. However, after processing with the softmax function, the difference between the updated text segment weight and the text segment weight before the update is small. However, if the correlation between the text feature vector of the supporting text segment and the candidate supporting text feature vector of the current text category in the current round of iteration is large, the updated text coefficient will be a larger value. After processing with the softmax function, the difference between the updated text segment weight and the text segment weight before the update is large, and the numerical increase is more obvious. Therefore, the above-mentioned update method can strengthen the supporting text segment that has a greater degree of correlation with the current text category.

[0120] Subsequently, the updated text coefficients of the supporting text segments are processed using a softmax function to obtain updated text segment weights of the supporting text segments.

[0121] Figure 7 is a structural diagram of the electronic device provided by the present invention. As shown in Figure 7, the electronic device may include: a processor (processor) 710, a memory (memory) 720, a communication interface (Communications Interface) 730 and a communication bus 740, wherein the processor 710, the memory 720, and the communication interface 730 communicate with each other through the communication bus 740. The processor 710 can call the logic instructions in the memory 720 to execute the text classification method, which includes: obtaining multiple text segments to be classified of the government text to be classified; performing text feature extraction on the multiple text segments to be classified to obtain text feature vectors of the multiple text segments to be classified, and determining multiple categories of the government text to be classified based on the semantic similarity between the text feature vectors of the multiple text segments to be classified and the support text feature vectors of each text category in the support text set; the support text feature vector of any text category is obtained by performing text feature extraction on the support text segment of the any text category, and then summarizing the text feature vectors of each support text segment after obtaining the text feature vector of the support text segment; wherein the text feature extraction specifically includes: obtaining a dependency parse tree of the corresponding text segment, and determining several parse subtrees of each non-stop word in the corresponding text segment based on the dependency parse tree; the parse subtree of any non-stop word is a subtree in the dependency parse tree with the any non-stop word as the root node; and determining the text feature vector of the corresponding text segment based on each non-stop word in the corresponding text segment and its parse subtree.

[0122] In addition, the logic instructions in the aforementioned memory 720 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0123] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the text classification method provided by the above methods, which includes: obtaining a plurality of text segments to be classified of government texts to be classified; performing text feature extraction on the plurality of text segments to be classified to obtain text feature vectors of the plurality of text segments to be classified, and determining the government texts to be classified based on the semantic similarity between the text feature vectors of the plurality of text segments to be classified and the supporting text feature vectors of each text category in the supporting text set. There are multiple categories of this; the supporting text feature vector of any text category is obtained by performing text feature extraction on the supporting text segments of any text category, and after obtaining the text feature vector of the supporting text segment, summarizing the text feature vectors of each supporting text segment; wherein, the text feature extraction specifically includes: obtaining a dependency parse tree of the corresponding text segment, and determining a number of parse subtrees of each non-stop word in the corresponding text segment based on the dependency parse tree; the parse subtree of any non-stop word is a subtree in the dependency parse tree with the any non-stop word as the root node; based on each non-stop word in the corresponding text segment and its parse subtree, determining the text feature vector of the corresponding text segment.

[0124] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented to perform the above-mentioned text classification methods when executed by a processor, the method comprising: obtaining a plurality of to-be-classified text segments of government texts to be classified; performing text feature extraction on the plurality of to-be-classified text segments to obtain text feature vectors of the plurality of to-be-classified text segments, and determining a plurality of categories of the government texts to be classified based on the semantic similarity between the text feature vectors of the plurality of to-be-classified text segments and the supporting text feature vectors of each text category in the supporting text set; and extracting the supporting text feature vectors of any text category. The feature vector is obtained by performing text feature extraction on the supporting text segments of any text category, and after obtaining the text feature vectors of the supporting text segments, summarizing the text feature vectors of each supporting text segment; wherein, the text feature extraction specifically includes: obtaining a dependency parse tree of the corresponding text segment, and determining a number of parse subtrees of each non-stop word in the corresponding text segment based on the dependency parse tree; the parse subtree of any non-stop word is a subtree in the dependency parse tree with the any non-stop word as the root node; based on each non-stop word in the corresponding text segment and its parse subtree, determining the text feature vector of the corresponding text segment.

[0125] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A text classification method, characterized in that: include: Acquire multiple text segments to be classified of government affairs texts to be classified; Performing text feature extraction on the multiple text segments to be classified to obtain text feature vectors of the multiple text segments to be classified, and determining multiple categories of the government texts to be classified based on the semantic similarity between the text feature vectors of the multiple text segments to be classified and the supporting text feature vectors of each text category in the supporting text set; the supporting text feature vector of any text category is obtained by extracting text features from the supporting text segment of any text category, and then summarizing the text feature vectors of each supporting text segment after obtaining the text feature vector of the supporting text segment; The text feature extraction specifically includes: Obtain a dependency parse tree of the corresponding text segment, and determine a plurality of parse subtrees of each non-stop word in the corresponding text segment based on the dependency parse tree; the parse subtree of any non-stop word is a subtree in the dependency parse tree with the any non-stop word as a root node; Determine a text feature vector of the corresponding text segment based on each non-stop word in the corresponding text segment and its parsed subtree; The determining of the text feature vector of the corresponding text segment based on each non-stop word in the corresponding text segment and its parsing subtree specifically includes: Determine the word vector of each non-stop word in the corresponding text segment; Merge the word vectors of each word in the parsing subtree of any non-stop word to obtain the subtree vector of the parsing subtree of any non-stop word; Based on the word vector of any non-stop word and the subtree vector of its parsed subtree, a fused context vector of any non-stop word is obtained; Based on the word weights of the non-stop words, weighted summation is performed on the fused context vectors of the non-stop words to obtain a text feature vector of the corresponding text segment.

2. The text classification method according to claim 1, characterized in that: The word weights of the non-stop words are determined based on the following steps: Determine the word weight of each word in the corpus based on the number of co-occurrences between each word in the corpus; wherein the higher the number of co-occurrences between any word in the corpus and other words, the lower the word weight of any word; Based on the word weight of each word segment in the corpus, the word weight of each non-stop word in the corresponding text segment is determined.

3. The text classification method according to claim 2, characterized in that: The determining of the word weight of each word in the corpus based on the number of co-occurrences between each word in the corpus specifically includes: Based on each sample sentence in the corpus, obtaining a dependency parse tree of each sample sentence; Determine the number of co-occurrences between each word in each sample sentence based on the dependency parse tree of each sample sentence; Constructing a weight graph based on each of the participles in each of the sample sentences; wherein the nodes in the weight graph correspond to each of the participles, and the edge weights in the weight graph are determined based on the number of co-occurrences of two participles connected by the corresponding edge; Based on the edge weights of each node in the weight graph and the edges connecting the nodes, the word weights of the participles corresponding to the nodes are determined; wherein, the higher the edge weight of the edge connecting any node, the lower the word weight of the participle corresponding to the any node.

4. The text classification method according to claim 3, characterized in that: The edge weights in the weight graph are determined based on the following steps: The edge weight of any edge is determined based on the number of co-occurrences of the participles corresponding to the two nodes connected by any edge in the weight graph and the distance between the participles corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence; wherein, the farther the distance between the participles corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence, the lower the edge weight of any edge.

5. The text classification method according to claim 4, characterized in that: The determining the edge weight of any edge based on the co-occurrence count of the segment words corresponding to the two nodes connected by any edge in the weight graph and the distance between the segment words corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence specifically includes: The co-occurrence times of the participles corresponding to the two nodes connected by any edge are divided by the distance between the participles corresponding to the two nodes connected by any edge in the dependency parse tree of each sample sentence to obtain the edge weight of any edge.

6. The text classification method according to claim 5, characterized in that: The determining, based on the edge weights of the nodes in the weight graph and the edges connecting the nodes, the word weights of the word segments corresponding to the nodes specifically include: Based on the edge weight of the edge connecting any node in the weight graph, using the webpage value algorithm, determine the webpage value of the word corresponding to any node; The inverse of the webpage value of the word corresponding to any node is determined as the word weight of the word corresponding to any node.

7. The text classification method according to claim 1, characterized in that: The text feature vectors of each supporting text segment are summarized, specifically including: In each round of iteration, based on the text feature vectors of each supporting text segment of any text category and the text segment weights of each supporting text segment, determine the candidate supporting text feature vectors of any text category in the current round of iteration, and based on the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vectors of each supporting text segment, update the text segment weights of each supporting text segment; The candidate supporting text feature vector of any text category in the last round of iteration process is used as the supporting text feature vector of any text category.

8. The text classification method according to claim 7, characterized in that: The text segment weights of the respective supporting text segments are obtained by processing the text coefficients of the respective supporting text segments using a softmax function; the initial value of the text coefficient is 0; The updating of the text segment weights of the respective supporting text segments based on the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vectors of the respective supporting text segments specifically includes: Determine the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vectors of each supporting text segment; wherein the correlation between the candidate supporting text feature vectors of any text category in the current round of iteration and the text feature vector of any supporting text segment is calculated based on vector dot multiplication; Adding the current value of the text coefficient of any supporting text segment and the correlation between the candidate supporting text feature vector of any text category in the current round of iteration and the text feature vector of any supporting text segment to obtain an updated text coefficient of any supporting text segment; Based on the updated text coefficients of the respective supporting text segments, the text segment weights of the respective supporting text segments are updated.

9. The text classification method according to claim 7, characterized in that: Determining multiple categories of the government text to be classified based on the semantic similarity between the text feature vectors of the multiple text segments to be classified and the supporting text feature vectors of each text category in the supporting text set specifically includes: Performing vector dot multiplication or cosine similarity calculation on the text feature vector of any text segment to be classified and the supporting text feature vector of any text category to obtain the semantic similarity between the text feature vector of any text segment to be classified and the supporting text feature vector of any text category; If the semantic similarity between the text feature vector of any text segment to be classified and the supporting text feature vector of any text category is greater than a preset similarity threshold, the any text category is determined to be the text category to which the any text segment to be classified belongs; wherein the text categories to which the multiple text segments to be classified belong constitute multiple categories of the government text to be classified.

Citation Information

Patent Citations

  • Text classification method and device

    CN111858917A

  • Sentiment classification method and device, storage medium and computer equipment

    CN113449110A

  • Semantic classification method and device

    CN114722833A

  • Text classification method

    CN116127079A

  • Methods and apparatuses for training service model and determining text classification category

    US11216620B1

Cited By

  • Data processing system for determining final application text

    CN120144748A