Text classification method, device, electronic device and medium based on text summary
By using keywords and deep learning extraction abstract extraction methods in text classification technology, combining text classification models, classifying texts in classified paragraphs, the problem of redundant information affecting classification accuracy is solved, and higher text classification accuracy is achieved sex.
Patent Information
- Application Number
- CN202110780257.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-09
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-07-09
AI Technical Summary
The existing text classification technology has low classification accuracy and cannot effectively highlight key information due to the existence of a large amount of redundant and irrelevant information in the text of the paragraph to be classified.
Using a text summary-based method, the text summary is extracted from the text to be classified through keyword extraction and deep learning extraction abstract extraction methods, and the text summary is classified using the preset text classification model to reduce information redundancy and improve Classification accuracy.
Extracting text summary through various methods reduces the problem of insufficient extraction by a single means, improves the accuracy of abstracts, and thus improves the accuracy of text classification.
Smart Images

Figure CN113407722B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent decision-making technology, and in particular to a text classification method, device, electronic device and computer-readable storage medium based on text summarization. Background Art
[0002] With the rapid development of Internet technology, multimedia information on the Internet is growing rapidly. How to effectively organize, classify, manage and mine this rapidly growing information has become an urgent problem that needs to be solved.
[0003] Existing text classification technologies generally directly input the paragraph text to be classified into the text classification model. Since the paragraph text to be classified contains a large amount of redundant and irrelevant information, the key information obtained by text classification cannot be highlighted, making the classification result far from the expectation, that is, the classification accuracy is not high. Summary of the invention
[0004] The present invention provides a text classification method, device, electronic device and computer-readable storage medium based on text summarization, the main purpose of which is to improve the accuracy of text classification.
[0005] To achieve the above object, the present invention provides a text classification method based on text summarization, comprising:
[0006] Obtaining a paragraph text to be classified, dividing the paragraph text to be classified into single sentences, and obtaining a set of single sentences to be classified;
[0007] Extracting a first text summary from the single sentence set to be classified using a keyword-based extractive summary extraction method;
[0008] Extracting a second text summary from the set of single sentences to be classified using an extractive summary extraction method based on deep learning;
[0009] Calculating the matching degree between the first text summary and the second text summary and the paragraph text to be classified respectively, and determining the first text summary or the second text summary as the target text summary according to the matching degree;
[0010] The target text summary is classified using a preset text classification model to obtain the text category of the paragraph text to be classified.
[0011] Optionally, extracting a first text summary from the single sentence set to be classified by using a keyword-based extractive summary extraction method includes:
[0012] Vectorizing each single sentence to be classified in the single sentence set to be classified to obtain a text single sentence vector set;
[0013] Calculating the similarity between each text single sentence vector in the text single sentence vector set, and storing the similarity in a preset blank matrix to construct a transition probability matrix;
[0014] Calculate the text ranking value of the single sentence to be classified based on the transition probability matrix;
[0015] The single sentence to be classified in the single sentence set to be classified is selected as the first text summary according to the text ranking value.
[0016] Optionally, vectorizing each single sentence to be classified in the single sentence set to be classified to obtain a text single sentence vector set includes:
[0017] Splitting the multiple single sentences to be classified in the single sentence set to be classified to obtain multiple text words to be classified;
[0018] A plurality of the text words to be classified are vectorized using a preset word vector model to obtain a plurality of vector text words, and the plurality of vector text words are combined to obtain a text single sentence vector set.
[0019] Optionally, the calculating the text ranking value of the single sentence to be classified based on the transition probability matrix includes:
[0020] Obtaining the similarity between each text single sentence vector in the transition probability matrix;
[0021] Taking each of the text sentences as a node and the similarity between the text sentence vectors as the edge of the node, a similarity graph structure is constructed;
[0022] The text ranking value of the single sentence to be classified is calculated using the similarity graph structure.
[0023] Optionally, the step of selecting the single sentence to be classified in the single sentence set to be classified as the first text summary by using the text sorting value includes:
[0024] Traversing the text ranking values of each single sentence to be classified in the paragraph text to be classified, and selecting a preset number of text ranking values from large to small;
[0025] The target to-be-classified single sentences corresponding to the preset number of text ranking values are combined into the first text summary.
[0026] Optionally, extracting a second text summary from the single sentence set to be classified by using an extractive summary extraction method based on deep learning includes:
[0027] Acquire a training text set and a text summary of the training text set, and use the training text set and the text summary of the training text set to train a preset binary classification model to obtain a labeling model;
[0028] Using the annotation model to annotate each single sentence to be classified in the single sentence set to be classified, to obtain annotated single sentences;
[0029] A second text summary is obtained according to the order of the individual sentences in the paragraph text to be classified and the annotations of the annotated individual sentences.
[0030] Optionally, the using a preset text classification model to perform text classification on the target text summary to obtain the text category of the paragraph text to be classified includes:
[0031] Establishing an information processor through a preset category dictionary in a preset text classification model;
[0032] Inputting the abstract segmentation into the information processor to obtain the text category of the abstract segmentation;
[0033] The text category of the abstract segmentation is determined to be the text category of the paragraph text to be classified.
[0034] In order to solve the above problems, the present invention also provides a text classification device based on text summarization, the device comprising:
[0035] A paragraph text division module is used to obtain the paragraph text to be classified, divide the paragraph text to be classified into single sentences, and obtain a set of single sentences to be classified;
[0036] A first summary acquisition module is used to extract a first text summary from the single sentence set to be classified by using a keyword-based extractive summary extraction method;
[0037] A second summary acquisition module is used to extract a second text summary from the single sentence set to be classified by using an extractive summary extraction method based on deep learning;
[0038] a target summary confirmation module, configured to respectively calculate the matching degree between the first text summary and the second text summary and the paragraph text to be classified, and determine the first text summary or the second text summary as a target text summary according to the matching degree;
[0039] The text summary classification module is used to perform text classification on the target text summary using a preset text classification model to obtain the text category of the paragraph text to be classified.
[0040] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0041] at least one processor; and,
[0042] a memory communicatively connected to the at least one processor; wherein,
[0043] The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can perform the text classification method based on text summarization as described above.
[0044] In order to solve the above problems, the present invention also provides a computer-readable storage medium, including a data storage area and a program storage area, the data storage area stores created data, and the program storage area stores a computer program; wherein, when the computer program is executed by a processor, the text classification method based on text summarization as described above is implemented.
[0045] In the embodiment of the present invention, on the one hand, a keyword-based extractive summary extraction method is used to extract a first text summary from the paragraph text to be classified, and on the other hand, a deep learning-based extractive summary extraction method is used to extract a second text summary from the paragraph text to be classified, and the matching degree between the first text summary and the second text summary and the paragraph text to be classified is calculated, and the text summary with a high matching degree is screened out as the text summary of the paragraph text to be classified, and then the text summary is classified through a text classification model to obtain the text category of the paragraph text to be classified, and the text classification is performed by first obtaining the summary and then performing text classification, thereby reducing information redundancy and making the classification result more accurate. At the same time, multiple methods are used for summary extraction, thereby avoiding the problem of insufficient accuracy of the text summary caused by extracting the text summary by a single means, improving the accuracy of the obtained summary, and then improving the accuracy of text classification. Therefore, the embodiment of the present invention can achieve the purpose of improving the accuracy of text classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A flowchart of a text classification method based on text summarization provided by an embodiment of the present invention;
[0047] Figure 2 In the first embodiment of the present invention Figure 1 A detailed flowchart of one of the steps in the text classification method based on text summarization is provided;
[0048] Figure 3 A schematic diagram of modules of a text classification device based on text summarization provided by an embodiment of the present invention;
[0049] Figure 4 A schematic diagram of the internal structure of an electronic device for implementing a text classification method based on text summarization provided by an embodiment of the present invention;
[0050] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0051] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0052] The embodiment of the present application provides a text classification method based on text summary. The execution subject of the text classification method based on text summary includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the text classification method based on text summary can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0053] Reference Figure 1 FIG. 1 is a flow chart of a text classification method based on text summarization provided by an embodiment of the present invention. In this embodiment, the text classification method based on text summarization includes:
[0054] S1. Obtain a paragraph text to be classified, divide the paragraph text to be classified into single sentences, and obtain a set of single sentences to be classified.
[0055] In the embodiment of the present invention, the paragraph text to be classified is the text that needs to be classified, and the paragraph text to be classified can be in any format, for example, the paragraph text to be classified is Chinese text, or the paragraph text to be classified is English text.
[0056] In the embodiment of the present invention, the paragraph text to be classified may be text input by a user, or may be text extracted from a preset database of paragraph text to be classified.
[0057] In the embodiment of the present invention, the single sentence set to be classified is a set of single sentences in the paragraph text to be classified. Specifically, the paragraph text to be classified can be divided into single sentences by identifying punctuation marks in the paragraph text to be classified.
[0058] For example, punctuation marks in the paragraph text to be classified are identified, and when there are preset punctuation marks (such as a period or a semicolon), the sentences between the preset punctuation marks are divided into a single sentence.
[0059] For example, when identifying the first period in the paragraph text to be classified, the content before the period is determined as a single sentence. When a period is recognized again, the content between the previous period and the period recognized again is determined as a single sentence.
[0060] S2. Extracting a first text summary from the set of single sentences to be classified using a keyword-based extractive summary extraction method.
[0061] In an embodiment of the present invention, the keyword-based extractive summary extraction method may be the Lead3 algorithm, which is an extractive summary extraction method for text and can select 3 sentences from a text as a summary of the text.
[0062] See also Figure 2 , Figure 2 In the first embodiment Figure 1 A detailed flowchart of one of the steps in the text classification method based on text summarization is provided.
[0063] Furthermore, the extractive summary extraction method based on keywords is used to extract the first text summary from the single sentence set to be classified, including:
[0064] S201, vectorizing each single sentence to be classified in the single sentence set to be classified to obtain a text single sentence vector set.
[0065] In the embodiment of the present invention, by vectorizing the single sentence to be classified, vector information in the single sentence to be classified can be obtained from a digital perspective, and text information recognized by humans can be converted into vector information that can be recognized by a machine.
[0066] Specifically, in the embodiment of the present invention, vectorizing each single sentence to be classified in the single sentence set to be classified to obtain a text single sentence vector set includes:
[0067] Splitting the multiple single sentences to be classified in the single sentence set to be classified to obtain multiple text words to be classified;
[0068] A plurality of the text words to be classified are vectorized using a preset word vector model to obtain a plurality of vector text words, and the plurality of vector text words are combined to obtain a text single sentence vector set.
[0069] In the embodiment of the present invention, splitting multiple sentences to be classified in the sentence set to be classified is to perform word segmentation processing on each sentence to be classified in the sentence set to be classified to obtain words constituting each sentence, that is, text words to be classified.
[0070] S202, calculating the similarity between each text single sentence vector in the text single sentence vector set, and storing the similarity in a preset blank matrix to construct a transition probability matrix.
[0071] In the embodiment of the present invention, each element in the transition probability matrix is represented by probability and is non-negative, and the sum of the elements in each row is equal to 1.
[0072] In detail, the calculating of the similarity between each text single sentence vector in the text single sentence vector set, storing the similarity in a preset blank matrix, and constructing a transition probability matrix includes:
[0073] Calculate the similarity of each text single sentence vector in the text single sentence vector set using a similarity calculation formula to obtain a vector similarity set;
[0074] Each vector similarity in the vector similarity set is stored in a pre-constructed matrix to obtain a transition probability matrix.
[0075] In this embodiment, the vector similarity set is obtained by calculating the similarity of each text single sentence vector in the single sentence vector set using a preset similarity calculation formula, wherein the preset similarity calculation formula can be a cosine similarity calculation formula, a Euclidean distance calculation formula, or the like.
[0076] S203: Calculate the text ranking value of the single sentence to be classified based on the transition probability matrix.
[0077] In an embodiment of the present invention, the text ranking value (textrank value) is a value representing the semantic connection between the single sentence to be classified and the paragraph text to be classified, wherein the stronger the semantic correlation between the single sentence to be classified and the paragraph to be classified, the higher the text ranking value, and therefore, the single sentence to be classified with a higher text ranking value is more likely to serve as a text summary of the paragraph text to be classified.
[0078] In detail, the calculating the text ranking value of the single sentence to be classified based on the transition probability matrix includes:
[0079] Obtaining the similarity between each text single sentence vector in the transition probability matrix;
[0080] Taking each of the text sentences as a node and the similarity between the text sentence vectors as the edge of the node, a similarity graph structure is constructed;
[0081] The text ranking value of the single sentence to be classified is calculated using the similarity graph structure.
[0082] In the embodiment of the present invention, the similarity graph structure is used to calculate the text ranking value S(V i ) is realized by the following formula:
[0083]
[0084] Among them, J is a single sentence that has a similarity relationship with the target text single sentence i, V i is the node of the text sentence i, V j is the node of text sentence j, E is the edge of the node, d is the damping coefficient, k is the co-occurring word of target text sentence i, E(V i ) is the node V i The set of all connected nodes, E(vj ) is the node V j The set of all connected nodes, W ij Indicates V i and V j The weight of the edge between them, W jk Indicates V k and V j The weight of the edge between them, S(V j ) is V j The text sort value of .
[0085] Furthermore, the co-occurring words are words that describe the same phenomenon or object with a certain frequency in the same text paragraph.
[0086] S204: Filter the single sentences to be classified in the single sentence set to be classified as the first text summary by using the text ranking value.
[0087] In detail, the step of selecting the single sentence to be classified in the single sentence set to be classified as the first text summary by using the text sorting value includes:
[0088] Traversing the text ranking values of each single sentence to be classified in the paragraph text to be classified, and selecting a preset number of text ranking values from large to small;
[0089] The target to-be-classified single sentences corresponding to the preset number of text ranking values are combined into the first text summary.
[0090] Alternatively, after selecting a preset number of target sentences to be classified, the order of the sentences to be classified in the paragraph text to be classified is obtained according to the paragraph text to be classified, and all the selected target sentences to be classified are sorted according to the order.
[0091] In this embodiment, the preset number of summary sentences is the number of sentences in the first text summary preset by the user, and the number of sentences to be classified in the first text summary of the paragraph text to be classified satisfies the number of summary sentences preset by the user.
[0092] S3. Extracting a second text summary from the set of single sentences to be classified using an extractive summary extraction method based on deep learning.
[0093] Furthermore, the extractive summary extraction method based on deep learning is used to extract a second text summary from the single sentence set to be classified, including:
[0094] Acquire a training text set and a text summary of the training text set, and use the training text set and the text summary of the training text set to train a preset binary classification model to obtain a labeling model;
[0095] Using the annotation model to annotate each single sentence to be classified in the single sentence set to be classified, to obtain annotated single sentences;
[0096] A second text summary is obtained according to the order of the individual sentences in the paragraph text to be classified and the annotations of the annotated individual sentences.
[0097] In this embodiment, each single sentence to be classified in the single sentence set to be classified is marked, and there are two types of markings: one is that the sentence belongs to the subsequent summary, and the other is that the sentence does not belong to the subsequent summary.
[0098] In this embodiment, the order of the single sentence is the sentence number of the sentence in the paragraph to be classified, and then the sentences in the marked single sentence that belong to the subsequent summary are combined according to the order of the single sentence to obtain the second text summary.
[0099] In the embodiment of the present invention, the training text and the text summary of the training text set can be obtained by crawling the public text on the network from the network using crawler technology.
[0100] Furthermore, the binary classification model is a model constructed based on the sigmoid binary classification function, and is trained using the text summary of the training text set and the training text set to obtain a labeled model.
[0101] Furthermore, before using the annotation model to annotate each single sentence to be classified in the single sentence set to be classified, the method further includes: adding an identifier to the single sentence to be classified.
[0102] For example, a leading identifier [CLS] is added before the single sentence to be classified, and a trailing identifier [SEP] is added at the end of the single sentence to be classified.
[0103] In this embodiment, adding an identifier to the single sentence to be classified can define the scope of the single sentence to be classified, provide signals for the start and end of reading of the model, and avoid errors in reading the single sentence to be classified.
[0104] S4. Calculate the matching degree between the first text summary and the second text summary and the paragraph text to be classified respectively, and determine the first text summary or the second text summary as the target text summary according to the matching degree.
[0105] In the embodiment of the present invention, there are multiple methods for determining the target text summary, for example, determining the target text summary according to a quick sorting method.
[0106] In detail, the matching degree between the first text summary and the second text summary is calculated. If the matching degree between the first text summary and the paragraph text to be classified is higher than the matching degree between the second text summary and the paragraph text to be classified, the first text summary is used as the target text summary of the paragraph text to be classified; if the matching degree between the second text summary and the paragraph text to be classified is higher than the matching degree between the first text summary and the paragraph text to be classified, the second text summary is used as the target text summary of the paragraph text to be classified.
[0107] Furthermore, the calculation of the matching degree between the first text summary and the paragraph text to be classified may be achieved by calculating the number of single sentences in the first text summary.
[0108] For example, when the paragraph text to be classified contains twenty single sentences to be classified, if the first text summary contains six single sentences to be classified, the matching degree between the first text summary and the paragraph text to be classified is 6; if the second text summary contains eight single sentences to be classified, the matching degree between the second text summary and the paragraph text to be classified is 8; therefore, the matching degree between the second text summary and the paragraph text to be classified is higher than that of the first text summary, and the second text summary is used as the target text summary of the paragraph text to be classified.
[0109] S5. Using a preset text classification model to perform text classification on the target text summary, and obtain the text category of the paragraph text to be classified.
[0110] In an embodiment of the present invention, the preset text classification model is the Albert model, which is a model obtained by streamlining and optimizing the Bert model. The Albert model requires fewer parameters than the Bert model and is faster to train, which can solve the problem of excessive parameters and slow training of the Bert text classification model. Therefore, this paper uses the Albert model for classification to reduce memory usage and improve the speed of text classification.
[0111] Specifically, in this embodiment, the pre-training task of the Bert text classification model can be replaced with a sentence order prediction task (sentence-order prediction, SOP) by factorizing the embedding layer (Embedding) of the Bert text classification model and sharing the parameters of the encoder to obtain the Albert text classification model. By factorizing the embedding layer (Embedding) of the Bert text classification model and sharing the parameters of the encoder, the amount of parameters required for the Bert model is reduced, and by replacing the pre-training task of the Bert text classification model with the sentence order prediction task, the speed and classification accuracy of the model are improved.
[0112] Specifically, the text classification of the target text abstract using a preset text classification model to obtain the text category of the paragraph text to be classified includes:
[0113] Performing a word segmentation operation on the target text summary to obtain a summary word segmentation of the target text summary;
[0114] Establishing an information processor through a preset category dictionary in a preset text classification model;
[0115] Inputting the abstract segmentation into the information processor to obtain the text category of the abstract segmentation;
[0116] The text category of the abstract segmentation is determined to be the text category of the paragraph text to be classified.
[0117] In this embodiment, the category dictionary is a dictionary preset in the Albert model, and the information processor constructed by the category dictionary can achieve the purpose of segmenting the abstract words into categories.
[0118] In the embodiment of the present invention, the text category of the paragraph text to be classified finally obtained may be one or at least two. For example, the text category of the paragraph text to be classified obtained through the above operation may be multiple categories such as education, sports, and testing.
[0119] Furthermore, after obtaining the text category of the paragraph text to be classified, it can be applied to intelligent information recommendation.
[0120] Specifically, after obtaining the text category of the paragraph text to be classified, the method further includes:
[0121] According to the text category of interest to the target user, a paragraph text to be classified is selected from a plurality of paragraph texts to be classified and pushed to the target user.
[0122] For example, the paragraph text to be classified is a judgment document text, which includes 20 single sentences. The summary of the judgment document text is extracted by the keyword-based extractive summary extraction method and the deep learning-based extractive summary extraction method. If the first text summary extracted by the keyword-based extractive summary extraction method is 6 single sentences, and if the first text summary extracted by the deep learning-based extractive summary extraction method is 8 single sentences, then the target summary text of the judgment document is determined to be 8 single sentences. After obtaining the target text summary of the judgment document, the judgment document text is classified according to the target text summary of the judgment document text to determine whether the judgment document text belongs to a civil judgment document, a criminal judgment document, an administrative judgment document, or other general litigation documents.
[0123] In the embodiment of the present invention, on the one hand, a keyword-based extractive summary extraction method is used to extract a first text summary from the paragraph text to be classified, and on the other hand, a deep learning-based extractive summary extraction method is used to extract a second text summary from the paragraph text to be classified, and the matching degree between the first text summary and the second text summary and the paragraph text to be classified is calculated, and the text summary with a high matching degree is screened out as the text summary of the paragraph text to be classified, and then the text summary is classified through a text classification model to obtain the text category of the paragraph text to be classified, and the text classification is performed by first obtaining the summary and then performing text classification, thereby reducing information redundancy and making the classification result more accurate. At the same time, multiple methods are used for summary extraction, thereby avoiding the problem of insufficient accuracy of the text summary caused by extracting the text summary by a single means, improving the accuracy of the obtained summary, and then improving the accuracy of text classification. Therefore, the embodiment of the present invention can achieve the purpose of improving the accuracy of text classification.
[0124] like Figure 3 , which is a module schematic diagram of a text classification device based on text summarization of the present invention.
[0125] The text classification device 100 based on text summarization of the present invention can be installed in an electronic device. According to the functions to be implemented, the text classification device based on text summarization can include a paragraph text segmentation module 101, a first summary acquisition module 102, a second summary acquisition module 103, a target summary confirmation module 104 and a text summary classification module 105. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0126] In this embodiment, the functions of each module / unit are as follows:
[0127] The paragraph text division module 101 is used to obtain the paragraph text to be classified, divide the paragraph text to be classified into single sentences, and obtain a set of single sentences to be classified.
[0128] In the embodiment of the present invention, the paragraph text to be classified is the text that needs to be classified, and the paragraph text to be classified can be in any format, for example, the paragraph text to be classified is Chinese text, or the paragraph text to be classified is English text.
[0129] In the embodiment of the present invention, the paragraph text to be classified may be text input by a user, or may be text extracted from a preset database of paragraph text to be classified.
[0130] In the embodiment of the present invention, the single sentence set to be classified is a set of single sentences in the paragraph text to be classified. Specifically, the paragraph text to be classified can be divided into single sentences by identifying punctuation marks in the paragraph text to be classified.
[0131] For example, punctuation marks in the paragraph text to be classified are identified, and when there are preset punctuation marks (such as a period or a semicolon), the sentences between the preset punctuation marks are divided into a single sentence.
[0132] For example, when identifying the first period in the paragraph text to be classified, the content before the period is determined as a single sentence. When a period is recognized again, the content between the previous period and the period recognized again is determined as a single sentence.
[0133] The first summary acquisition module 102 is used to extract a first text summary from the single sentence set to be classified by using a keyword-based extractive summary extraction method.
[0134] In an embodiment of the present invention, the keyword-based extractive summary extraction method may be the Lead3 algorithm, which is an extractive summary extraction method for text and can select 3 sentences from a text as a summary of the text.
[0135] Furthermore, the first summary acquisition module 102 includes a vector processing unit, a matrix construction unit, a calculation unit and a first text summary determination unit.
[0136] The vector processing unit is used to vectorize each single sentence to be classified in the single sentence set to be classified to obtain a text single sentence vector set.
[0137] Specifically, in the embodiment of the present invention, the vector processing unit is specifically used for:
[0138] Splitting the multiple single sentences to be classified in the single sentence set to be classified to obtain multiple text words to be classified;
[0139] A plurality of the text words to be classified are vectorized using a preset word vector model to obtain a plurality of vector text words, and the plurality of vector text words are combined to obtain a text single sentence vector set.
[0140] In the embodiment of the present invention, by vectorizing the single sentence to be classified, vector information in the single sentence to be classified can be obtained from a digital perspective, and text information recognized by humans can be converted into vector information that can be recognized by a machine.
[0141] The matrix construction unit is used to calculate the similarity between each text single sentence vector in the text single sentence vector set, store the similarity in a preset blank matrix, and construct a transition probability matrix.
[0142] In the embodiment of the present invention, each element in the transition probability matrix is represented by probability and is non-negative, and the sum of the elements in each row is equal to 1.
[0143] In detail, the matrix construction unit is specifically used for:
[0144] Calculate the similarity of each text single sentence vector in the text single sentence vector set using a similarity calculation formula to obtain a vector similarity set;
[0145] Each vector similarity in the vector similarity set is stored in a pre-constructed matrix to obtain a transition probability matrix.
[0146] In this embodiment, the vector similarity set is obtained by calculating the similarity of each text single sentence vector in the single sentence vector set using a preset similarity calculation formula, wherein the preset similarity calculation formula can be a cosine similarity calculation formula, a Euclidean distance calculation formula, or the like.
[0147] A calculation unit is used to calculate the text ranking value of the single sentence to be classified based on the transition probability matrix.
[0148] In an embodiment of the present invention, the text ranking value (textrank value) is a value representing the semantic connection between the single sentence to be classified and the paragraph text to be classified, wherein the stronger the semantic correlation between the single sentence to be classified and the paragraph to be classified, the higher the text ranking value, and therefore, the higher the text ranking value of the single sentence to be classified, the greater the possibility that it is used as the text summary of the paragraph text to be classified.
[0149] In detail, the computing unit is specifically used for:
[0150] Obtaining the similarity between each text single sentence vector in the transition probability matrix;
[0151] Constructing a similarity graph structure by taking each of the text sentences as a node and the similarities between the text sentence vectors as the edges of the nodes;
[0152] The text ranking value of the single sentence to be classified is calculated using the similarity graph structure.
[0153] In the embodiment of the present invention, the similarity graph structure is used to calculate the text ranking value S(V i ) is realized by the following formula:
[0154]
[0155] Among them, j is a sentence that has a similarity relationship with the target text sentence i, V i is the node of the text sentence i, Vj is the node of text sentence J, E is the edge of the node, d is the damping coefficient, k is the co-occurring word of target text sentence i, E(V i ) is the node V i The set of all connected nodes, E(v j ) is the node V j The set of all connected nodes, W ij Indicates V i and V j The weight of the edge between them, W jk Indicates V k and V j The weight of the edge between them, S(V j ) is V j The text sort value of .
[0156] Furthermore, the co-occurring words are words that describe the same phenomenon or object with a certain frequency in the same text paragraph.
[0157] The first text summary determining unit is configured to select the single sentence to be classified in the single sentence set to be classified as the first text summary according to the text ranking value.
[0158] In detail, the first text summary determination unit is specifically used for:
[0159] Traversing the text ranking values of each single sentence to be classified in the paragraph text to be classified, and selecting a preset number of text ranking values from large to small;
[0160] The target to-be-classified single sentences corresponding to the preset number of text ranking values are combined into the first text summary.
[0161] Alternatively, after selecting a preset number of target sentences to be classified, the order of the sentences to be classified in the paragraph text to be classified is obtained according to the paragraph text to be classified, and all the selected target sentences to be classified are sorted according to the order.
[0162] In this embodiment, the preset number of summary sentences is the number of sentences in the first text summary preset by the user, and the number of sentences to be classified in the first text summary of the paragraph text to be classified satisfies the number of summary sentences preset by the user.
[0163] The second summary acquisition module 103 is used to extract a second text summary from the single sentence set to be classified by using an extractive summary extraction method based on deep learning.
[0164] Furthermore, the second summary obtaining module 103 is specifically used for:
[0165] Acquire a training text set and a text summary of the training text set, and use the training text set and the text summary of the training text set to train a preset binary classification model to obtain a labeling model;
[0166] Using the annotation model to annotate each single sentence to be classified in the single sentence set to be classified, to obtain annotated single sentences;
[0167] A second text summary is obtained according to the order of the individual sentences in the paragraph text to be classified and the annotations of the annotated individual sentences.
[0168] In this embodiment, each single sentence to be classified in the single sentence set to be classified is marked, and there are two types of markings: one is that the sentence belongs to the subsequent summary, and the other is that the sentence does not belong to the subsequent summary.
[0169] In this embodiment, the order of the single sentence is the sentence number of the sentence in the paragraph to be classified, and then the sentences in the marked single sentence that belong to the subsequent summary are combined according to the order of the single sentence to obtain the second text summary.
[0170] In the embodiment of the present invention, the training text and the text summary of the training text set can be obtained by crawling the public text on the network from the network using crawler technology.
[0171] Furthermore, the binary classification model is a model constructed based on the sigmoid binary classification function, and is trained using the text summary of the training text set and the training text set to obtain a labeled model.
[0172] Furthermore, before using the annotation model to annotate each single sentence to be classified in the single sentence set to be classified, the method further includes: adding an identifier to the single sentence to be classified.
[0173] For example, a leading identifier [CLS] is added before the sentence to be classified, and a trailing identifier [SEP] is added at the end of the sentence to be classified.
[0174] In this embodiment, adding an identifier to the annotated single sentence can define the scope of the identified single sentence, provide signals for the start and end of reading of the model, and avoid reading errors of the annotated single sentence.
[0175] The target summary confirmation module 104 is used to calculate the matching degree between the first text summary and the second text summary and the paragraph text to be classified, and determine the first text summary or the second text summary as the target text summary according to the matching degree.
[0176] In the embodiment of the present invention, there are multiple methods for determining the target text summary, for example, determining the target text summary according to a quick sorting method.
[0177] In detail, the matching degree between the first text summary and the second text summary is calculated. If the matching degree between the first text summary and the paragraph text to be classified is higher than the matching degree between the second text summary and the paragraph text to be classified, the first text summary is used as the target text summary of the paragraph text to be classified; if the matching degree between the second text summary and the paragraph text to be classified is higher than the matching degree between the first text summary and the paragraph text to be classified, the second text summary is used as the target text summary of the paragraph text to be classified.
[0178] Furthermore, the calculation of the matching degree between the first text summary and the paragraph text to be classified is achieved by calculating the number of single sentences in the first text summary.
[0179] For example, when the paragraph text to be classified contains twenty single sentences to be classified, if the first text summary contains six single sentences to be classified, the matching degree between the first text summary and the paragraph text to be classified is 6; if the second text summary contains eight single sentences to be classified, the matching degree between the second text summary and the paragraph text to be classified is 8; therefore, the matching degree between the second text summary and the paragraph text to be classified is higher than that of the first text summary, and the second text summary is used as the target text summary of the paragraph text to be classified.
[0180] The text summary classification module 105 is used to perform text classification on the target text summary using a preset text classification model to obtain the text category of the paragraph text to be classified.
[0181] In an embodiment of the present invention, the preset text classification model is the Albert model, which is a model obtained by streamlining and optimizing the Bert model. The Albert model requires fewer parameters than the Bert model and is faster to train, which can solve the problem of excessive parameters and slow training of the Bert text classification model. Therefore, this paper uses the Albert model for classification to reduce memory usage and improve the speed of text classification.
[0182] Specifically, in this embodiment, the pre-training task of the Bert text classification model can be replaced with a sentence order prediction task (sentence-order prediction, SOP) by factorizing the embedding layer (Embedding) of the Bert text classification model and sharing the parameters of the encoder to obtain the Albert text classification model. By factorizing the embedding layer (Embedding) of the Bert text classification model and sharing the parameters of the encoder, the amount of parameters required for the Bert model is reduced, and by replacing the pre-training task of the Bert text classification model with the sentence order prediction task, the speed and classification accuracy of the model are improved.
[0183] In detail, the text summary classification module 105 is specifically used for:
[0184] Performing a word segmentation operation on the target text summary to obtain a summary word segmentation of the target text summary;
[0185] Establishing an information processor through a category dictionary preset in a preset text classification model;
[0186] Inputting the abstract segmentation into the information processor to obtain the text category of the abstract segmentation;
[0187] The text category of the abstract segmentation is determined to be the text category of the paragraph text to be classified.
[0188] In this embodiment, the category dictionary is a dictionary preset in the Albert model, and the information processor constructed by the category dictionary can achieve the purpose of segmenting the abstract words into categories.
[0189] In the embodiment of the present invention, the text category of the paragraph text to be classified finally obtained may be one or at least two. For example, the text category of the paragraph text to be classified obtained through the above operation may be multiple categories such as education, sports, and testing.
[0190] Furthermore, after obtaining the text category of the paragraph text to be classified, it can be applied to intelligent information recommendation.
[0191] Specifically, the device further includes a recommendation module, and the recommendation module is used to:
[0192] After the text category of the paragraph text to be classified is obtained, a paragraph text to be classified is selected from a plurality of paragraph texts to be classified according to the text category of interest to the target user and pushed to the target user.
[0193] For example, the paragraph text to be classified is a judgment document text, which includes 20 single sentences. The summary of the judgment document text is extracted by the keyword-based extractive summary extraction method and the deep learning-based extractive summary extraction method. If the first text summary extracted by the keyword-based extractive summary extraction method is 6 single sentences, and if the first text summary extracted by the deep learning-based extractive summary extraction method is 8 single sentences, then the target summary text of the judgment document is determined to be 8 single sentences. After obtaining the target text summary of the judgment document, the judgment document text is classified according to the target text summary of the judgment document text to determine whether the judgment document text belongs to a civil judgment document, a criminal judgment document, an administrative judgment document, or other general litigation documents.
[0194] In the embodiment of the present invention, on the one hand, a keyword-based extractive summary extraction method is used to extract a first text summary from the paragraph text to be classified, and on the other hand, a deep learning-based extractive summary extraction method is used to extract a second text summary from the paragraph text to be classified, and the matching degree between the first text summary and the second text summary and the paragraph text to be classified is calculated, and the text summary with a high matching degree is screened out as the text summary of the paragraph text to be classified, and then the text summary is classified through a text classification model to obtain the text category of the paragraph text to be classified, and the text classification is performed by first obtaining the summary and then performing text classification, thereby reducing information redundancy and making the classification result more accurate. At the same time, multiple methods are used for summary extraction, thereby avoiding the problem of insufficient accuracy of the text summary caused by extracting the text summary by a single means, improving the accuracy of the obtained summary, and then improving the accuracy of text classification. Therefore, the embodiment of the present invention can achieve the purpose of improving the accuracy of text classification.
[0195] like Figure 4 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing a text classification method based on text summarization according to the present invention.
[0196] The electronic device may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a text classification program based on text summarization.
[0197] In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing a text classification program based on text summarization, etc.), and calls data stored in the memory 11 to execute various functions of the electronic device and process data.
[0198] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device, such as the code of a text classification program based on text summarization, but also be used to temporarily store data that has been output or is to be output.
[0199] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0200] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0201] Figure 4 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3The structure shown does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0202] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0203] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0204] The text classification program based on text summarization stored in the memory 11 in the electronic device is a combination of multiple computer programs. When running in the processor 10, it can achieve:
[0205] Obtaining a paragraph text to be classified, dividing the paragraph text to be classified into single sentences, and obtaining a set of single sentences to be classified;
[0206] Extracting a first text summary from the single sentence set to be classified using a keyword-based extractive summary extraction method;
[0207] Extracting a second text summary from the set of single sentences to be classified using an extractive summary extraction method based on deep learning;
[0208] Calculating the matching degree between the first text summary and the second text summary and the paragraph text to be classified respectively, and determining the first text summary or the second text summary as the target text summary according to the matching degree;
[0209] The target text summary is classified using a preset text classification model to obtain the text category of the paragraph text to be classified.
[0210] Specifically, the specific implementation method of the processor 10 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0211] Furthermore, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0212] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0213] Obtaining a paragraph text to be classified, dividing the paragraph text to be classified into single sentences, and obtaining a set of single sentences to be classified;
[0214] Extracting a first text summary from the single sentence set to be classified using a keyword-based extractive summary extraction method;
[0215] Extracting a second text summary from the set of single sentences to be classified using an extractive summary extraction method based on deep learning;
[0216] Calculating the matching degree between the first text summary and the second text summary and the paragraph text to be classified respectively, and determining the first text summary or the second text summary as the target text summary according to the matching degree;
[0217] The target text summary is classified using a preset text classification model to obtain the text category of the paragraph text to be classified.
[0218] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0219] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0220] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0221] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0222] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0223] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0224] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0225] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A text classification method based on text summarization, characterized in that: The method comprises: Obtaining a paragraph text to be classified, dividing the paragraph text to be classified into single sentences, and obtaining a set of single sentences to be classified; Extracting a first text summary from the single sentence set to be classified using a keyword-based extractive summary extraction method; A training text set and a text summary of the training text set are obtained, and a preset binary classification model is trained using the training text set and the text summary of the training text set to obtain a labeling model, and each single sentence to be classified in the single sentence set to be classified is labeled using the labeling model to obtain a labeled single sentence, and a second text summary is obtained according to the single sentence order in the paragraph text to be classified and the labeling of the labeled single sentence; Calculating the matching degree between the first text summary and the second text summary and the paragraph text to be classified respectively, and determining the first text summary or the second text summary as the target text summary according to the matching degree; A word segmentation operation is performed on the target text summary to obtain a summary word segmentation of the target text summary, an information processor is established through a category dictionary preset in a preset text classification model, the summary word segmentation is input into the information processor to obtain a text category of the summary word segmentation, and the text category of the summary word segmentation is determined to be the text category of the paragraph text to be classified.
2. The text classification method based on text summarization according to claim 1, characterized in that: The method of extracting a first text summary from the single sentence set to be classified by using a keyword-based extractive summary extraction method includes: Vectorizing each single sentence to be classified in the single sentence set to be classified to obtain a text single sentence vector set; Calculating the similarity between each text single sentence vector in the text single sentence vector set, and storing the similarity in a preset blank matrix to construct a transition probability matrix; Calculate the text ranking value of the single sentence to be classified based on the transition probability matrix; The single sentence to be classified in the single sentence set to be classified is selected as the first text summary according to the text ranking value.
3. The text classification method based on text summarization as claimed in claim 2, characterized in that: The step of vectorizing each of the single sentences to be classified in the single sentence set to be classified to obtain a text single sentence vector set includes: Splitting the multiple single sentences to be classified in the single sentence set to be classified to obtain multiple text words to be classified; A plurality of the text words to be classified are vectorized using a preset word vector model to obtain a plurality of vector text words, and the plurality of vector text words are combined to obtain a text single sentence vector set.
4. The text classification method based on text summarization as claimed in claim 2, characterized in that: The calculating the text ranking value of the single sentence to be classified based on the transition probability matrix includes: Obtaining the similarity between each text single sentence vector in the transition probability matrix; Taking each of the text sentences as a node and the similarity between the text sentence vectors as the edge of the node, a similarity graph structure is constructed; The text ranking value of the single sentence to be classified is calculated using the similarity graph structure.
5. The text classification method based on text summarization as claimed in claim 2, characterized in that: The step of selecting the single sentence to be classified in the single sentence set to be classified as the first text summary by using the text sorting value includes: Traversing the text ranking values of each single sentence to be classified in the paragraph text to be classified, and selecting a preset number of text ranking values from large to small; The target to-be-classified single sentences corresponding to the preset number of text ranking values are combined into the first text summary.
6. A text classification device based on text summarization, used to implement the text classification method based on text summarization according to any one of claims 1 to 5, characterized in that: The device comprises: A paragraph text division module is used to obtain the paragraph text to be classified, divide the paragraph text to be classified into single sentences, and obtain a set of single sentences to be classified; A first summary acquisition module is used to extract a first text summary from the single sentence set to be classified by using a keyword-based extractive summary extraction method; A second summary acquisition module is used to add identifiers to each of the single sentences to be classified in the single sentence set to be classified, input the single sentence set to be classified with the identifiers added into a pre-trained annotation model, the annotation model reads each of the single sentences to be classified in the single sentence set according to the identifiers and annotates them to obtain annotated sentences, and obtains a second text summary according to the order of the single sentences in the paragraph text to be classified and the annotations of the annotated sentences; a target summary confirmation module, configured to respectively calculate the matching degree between the first text summary and the second text summary and the paragraph text to be classified, and determine the first text summary or the second text summary as a target text summary according to the matching degree; The text summary classification module is used to perform text classification on the target text summary using a preset text classification model to obtain the text category of the paragraph text to be classified.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the text classification method based on text summarization according to any one of claims 1 to 5.
8. A computer-readable storage medium, comprising a data storage area and a program storage area, wherein the data storage area stores created data and the program storage area stores a computer program; wherein: When the computer program is executed by a processor, the text classification method based on text summarization according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and device for generating text abstract
CN110019768A
Text abstract generation method and system
CN110705287A
Text sentiment classification model training method and device, computer equipment and medium
CN111984793A
Text classification method and apparatus, electronic device and computer non-volatile readable storage medium
WO2020232898A1
