Text classification method and device, computer device and storage medium
By retrieving cluster center sentences and similar sentences from text data to form first and second clusters, the problem of high cost of traditional text classification methods when the scene changes is solved, realizing unsupervised text data classification and reducing costs.
Patent Information
- Application Number
- CN202210484210.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-06
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-05-06
AI Technical Summary
Traditional text classification methods rely on existing business scenarios and cannot adapt to changes in scenarios, resulting in high costs.
By retrieving keyword-matched sentences from text data, cluster center sentences and similar sentences are obtained to form the first cluster. Sentences other than the first cluster are clustered to obtain the second cluster. Based on these two clusters, category labels are determined to achieve unsupervised text data classification.
Even when faced with new business scenarios, it can effectively adapt and reduce the cost of text classification.
Smart Images

Figure CN115129864B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of machine learning, and in particular to a text classification method and device, computer equipment and a storage medium. BACKGROUND
[0002] With the rapid development of social economy, there are a large amount of business data in many industries. Analyzing the business data helps to understand the hot and painful issues of users, thereby improving the service quality.
[0003] In the traditional method, a classification model is first trained using labeled text data, and then the text data under the business is labeled based on the trained classification model, so as to realize data analysis of the business data. However, the classification model is too dependent on the existing business scenarios and cannot adapt to changes in business scenarios. When the business scenario changes, the classification model often needs to be retrained. Obviously, this method will cause the problem of high cost. SUMMARY
[0004] Therefore, it is necessary to provide a text classification method, device, computer equipment, computer readable storage medium and computer program product capable of reducing cost in view of the above technical problems.
[0005] In a first aspect, the present application provides a text classification method. The method comprises:
[0006] retrieving a sentence matching a keyword in the text data from the text data to obtain a class cluster center sentence;
[0007] retrieving a similar sentence of the class cluster center sentence from the text data;
[0008] obtaining a first class cluster based on the class cluster center sentence and the similar sentence;
[0009] clustering sentences other than the first class cluster in the text data to obtain at least one second class cluster;
[0010] determining a class label corresponding to the text data based on the first class cluster and the second class cluster.
[0011] In a second aspect, the present application further provides a text classification device. The device comprises:
[0012] The clustering module is configured to retrieve a sentence matching a keyword in the text data from the text data to obtain a class cluster center sentence; retrieve a similar sentence of the class cluster center sentence from the text data; obtain a first class cluster based on the class cluster center sentence and the similar sentence; and cluster sentences other than the first class cluster in the text data to obtain at least one second class cluster.
[0013] determining module, configured to determine a category label corresponding to the text data based on the first type of cluster and the second type of cluster.
[0014] In one of the embodiments, the clustering module is further configured to extract a keyword from the text data based on a growth of each word in the text data if the text data is streaming data, or extract the keyword from the text data based on a proportion of a number of each word in the text data if the text data is non-streaming data.
[0015] In one of the embodiments, the clustering module is further configured to extract a keyword from the text data, determine a seed keyword filtered from the extracted keyword, and retrieve a sentence semantically close to the seed keyword from the text data to obtain a cluster center sentence.
[0016] In one of the embodiments, the clustering module is further configured to cluster sentences other than the first type of cluster in the text data to obtain at least one initial cluster, determine, for each initial cluster, a cluster center sentence of the initial cluster from a plurality of sentences in the initial cluster, determine a noise sentence of the initial cluster based on a distance between the cluster center sentence and the plurality of sentences in the initial cluster, and filter the sentences in the initial cluster according to the noise sentence to obtain the second type of cluster.
[0017] In one of the embodiments, the clustering module is further configured to cluster sentences other than the first type of cluster in the text data to obtain at least one initial cluster, determine a cluster density of each initial cluster, and perform cluster filtering on the at least one initial cluster based on the cluster density to obtain a second type of cluster remaining after filtering.
[0018] In one of the embodiments, the determining module is further configured to determine a cluster keyword corresponding to each cluster in the text data, the clusters in the text data including the first type of cluster and the second type of cluster, determine a similar cluster corresponding to each cluster from a plurality of clusters in the text data, and determine a category label corresponding to the text data based on the similar cluster corresponding to each cluster and the cluster keyword.
[0019] In one of the embodiments, the determining module is further configured to determine a cluster center sentence of each cluster, respectively, and determine a similar cluster corresponding to each cluster from the plurality of clusters in the text data by comparing similarities between the cluster center sentences of the clusters.
[0020] In a third aspect, the present application provides a computer device. The computer device comprises a memory and a processor. The memory stores a computer program. The processor implements the steps in each embodiment of the method of the present application when executing the computer program.
[0021] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the steps in each embodiment of the method of the present application.
[0022] In a fifth aspect, the present application provides a computer program product. The computer program product comprises a computer program. The computer program is executed by a processor to implement the steps in each embodiment of the method of the present application.
[0023] The above text classification method, device, computer device, storage medium and computer program product retrieve a cluster center sentence matching a keyword in the text data from the text data, retrieve similar sentences of the cluster center sentence from the text data, obtain a first cluster based on the cluster center sentence and the similar sentences, cluster sentences in the text data except the first cluster to obtain at least one second cluster, and determine a category label corresponding to the text data based on the first cluster and the second cluster. First, the first cluster is retrieved based on the keyword in the text data, then the second cluster is obtained by clustering the sentences except the first cluster, and finally the corresponding category label is determined based on the first cluster and the second cluster. The category label of the text data can be determined unsupervisedly, so that even if a new business scenario is involved in the text data, it can be well adapted, and compared with the traditional way based on a classification model, the cost is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0024] Figure 1 An application environment diagram of an embodiment of the text classification method;
[0025] Figure 2 A flowchart of an embodiment of the text classification method;
[0026] Figure 3a A simple flowchart of an embodiment of the text classification method;
[0027] Figure 3b A simple flowchart of an embodiment of retrieving the cluster center sentence of the first cluster;
[0028] Figure 4 A block diagram of an embodiment of the text classification device;
[0029] Figure 5 An internal structure diagram of an embodiment of the computer device;
[0030] Figure 6 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0032] The text classification method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Server 104 can retrieve sentences matching keywords from text data to obtain cluster center sentences; server 104 can retrieve similar sentences from the cluster center sentences in the text data; server 104 can obtain a first cluster based on the cluster center sentences and similar sentences, and cluster sentences in the text data other than the first cluster to obtain at least one second cluster; server 104 can determine the category label corresponding to the text data based on the first and second clusters. It can be understood that server 104 can return the category labels corresponding to the text data to terminal 102. Terminal 102 can display the category labels corresponding to the text data.
[0033] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle systems. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0034] In one embodiment, the steps performed by server 104 can also be performed by terminal 102, or jointly by terminal 102 and server 104. It is understood that the implementation of the text classification method is not limited to a specific execution entity.
[0035] In one embodiment, such as Figure 2 As shown, a text classification method is provided. This embodiment illustrates the application of this method to a server. It is understood that this method can also be applied to a terminal, or to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0036] Step 202, retrieving a sentence matching the keyword in the text data from the text data to obtain a class cluster center sentence.
[0037] The class cluster center sentence is a standard sentence for reflecting the characteristics of the class cluster. It can be understood that the class cluster center sentence is equivalent to the class cluster center point. The class cluster center sentence is the most representative sentence in the class cluster and can best reflect the characteristics of the class cluster. The keyword is a relatively important word in the text data. It can be understood that the keyword can reflect the category label corresponding to the text data to some extent. The sentences under the same category label in the text data can be semantically close to the same keyword.
[0038] Specifically, the server can extract the keyword from the text data based on the keyword evaluation standard, and retrieve a sentence matching the keyword in the text data from the text data to obtain a class cluster center sentence. It can be understood that the class cluster center sentence can be the sentence that best matches the keyword.
[0039] In one embodiment, the server can directly use the keyword as a seed keyword, retrieve a sentence semantically close to the seed keyword from the text data to obtain a class cluster center sentence. The seed keyword contains the key information of the category label. It can be understood that the seed keyword can represent a category label to some extent. The semantics contained in the seed keyword can point to a category label. The class cluster center sentence can be a sentence including the seed keyword, or a sentence semantically consistent with the seed keyword.
[0040] In one embodiment, the text data includes data under a newly added business scenario. The server can determine a historical category label in a historical business scenario, determine a keyword that does not match the historical category label by comparing the historical category label and the keyword, and obtain a seed keyword. It can be understood that the keyword that does not match the historical category label is likely to reflect a new category label.
[0041] In one embodiment, the keyword evaluation standard can include at least one of the growth rate and the term frequency-inverse document frequency (TF-IDF).
[0042] Step 204, retrieving a similar sentence of the class cluster center sentence from the text data; obtaining a first class cluster based on the class cluster center sentence and the similar sentence.
[0043] Specifically, the server can retrieve similar sentences of the cluster center sentence from the text data by comparing the similarity between each sentence in the text data and the cluster center sentence. The server can form a first cluster by combining the cluster center sentence and the similar sentences. It can be understood that the cluster center sentence and the similar sentences can belong to the same category label. The higher the similarity between the cluster center sentence and the similar sentences, the greater the possibility of belonging to the same category label.
[0044] In an embodiment, the server can vectorize the cluster center sentence and each sentence in the text data to obtain a sentence vector and a center sentence vector. The server can retrieve a similar sentence vector matching the center sentence vector from a plurality of sentence vectors to obtain a similar sentence. It can be understood that the server can obtain the similar sentence vector by calculating the similarity between the sentence vector and the center sentence vector.
[0045] In an embodiment, the server can input the cluster center sentence and each sentence in the text data into a sentence vectorization model to obtain a sentence vector and a center sentence vector. For example, the sentence vectorization model can be a pre-training model based on a self-attention model (transformer) and contrastive learning. It can be understood that the server can use at least one of a sentence-bert (semantic similarity model) and a sim-bert (short text semantic matching model) pre-training model to vectorize the cluster center sentence and each sentence in the text data.
[0046] Step 206, clustering the sentences in the text data except the first cluster to obtain at least one second cluster; determining the category label corresponding to the text data based on the first cluster and the second cluster.
[0047] Specifically, the server can preprocess the text data in multiple dimensions, and cluster the sentences in the preprocessed text data except the first cluster to obtain at least one second cluster. The server can return the obtained first cluster and second cluster to the terminal, and manually remove invalid clusters from the first cluster and the second cluster through the terminal, and mark the category label of the valid clusters except the invalid clusters. The server can obtain the valid clusters marked with the category label, and determine the category label corresponding to the text data.
[0048] In an embodiment, the server can use the valid class cluster labeled with the historical category label as training data of the existing classification model to improve the function of the existing classification model. It can be understood that the text data to be classified can be data that cannot be classified by the existing classification model. If the category label of the valid class cluster is a historical category label, i.e., the category label of the valid class cluster belongs to the historical label system, the existing classification model cannot completely identify the text data under the historical label system, and the server can use the valid class cluster that is not identified by the existing classification model to improve the function of the existing classification model and improve the identification accuracy. If the category label of the valid class cluster does not belong to the historical label system, it means that a new category label is found, and the server can enrich and improve the historical label system to obtain a new label system.
[0049] In an embodiment, the server can preprocess the text data from at least one of the dialogue dimension and the sentence dimension. The text data can be dialogue type data, and the server can first perform dialogue screening on the text data, then perform sentence screening, and then perform sentence cleaning to obtain preprocessed text data. It can be understood that the purpose of dialogue screening and sentence screening is to select valid dialogues expected to be classified from a large amount of text data, and to select valid sentences expected to be classified from the valid dialogues. The server can perform dialogue screening and sentence screening according to at least one of the following screening dimensions: keyword combination, dialogue object role, and dialogue round. For example, if the first sentence in the dialogue does not include the keyword of the customer service representative, the corresponding dialogue is excluded; if the dialogue round of the dialogue is too few, the corresponding dialogue is excluded. The server can only keep the sentences of the fixed dialogue object role.
[0050] In an embodiment, the server can perform sentence cleaning on the text data that has completed dialogue screening and sentence screening. It can be understood that the server can remove stop words and regular expressions to reduce the noise of the sentence itself. For example, the server can filter each sentence in the text data through a predefined regular expression. It can be understood that sentence cleaning can reduce noise in the sentence, which can improve the effect of subsequent text classification.
[0051] In the text classification method, a sentence matching a keyword in the text data is retrieved from the text data to obtain a cluster center sentence; a similar sentence of the cluster center sentence is retrieved from the text data; based on the cluster center sentence and the similar sentence, a first cluster is obtained; sentences in the text data except the first cluster are clustered to obtain at least one second cluster; and based on the first cluster and the second cluster, a category label corresponding to the text data is determined. First, the first cluster is retrieved based on the keyword in the text data, then the second cluster is obtained by clustering the sentences except the first cluster, and finally the corresponding category label is determined based on the first cluster and the second cluster. Therefore, the category label of the text data can be determined unsupervisedly, so that even if a new business scenario is involved in the text data, it can be well adapted, and compared with the traditional way based on a classification model, the cost is reduced.
[0052] In one embodiment, the method further comprises: if the text data is streaming data, extracting a keyword from the text data based on a growth of each word in the text data; and if the text data is non-streaming data, extracting a keyword from the text data based on a proportion of the number of each word in the text data.
[0053] Specifically, if the text data is streaming data, the server can extract a keyword from the text data by calculating the growth of each word in the text data based on a keyword extraction algorithm based on the growth rate; and if the text data is non-streaming data, the server can extract a keyword from the text data by calculating the proportion of the number of each word in the text data based on a keyword extraction algorithm based on the frequency-inverse document frequency.
[0054] In one embodiment, the server can count the frequency of occurrence of each word in each preset period, and determine the growth of each word by comparing the frequency of occurrence of each word in the current preset period and the frequency of occurrence of each word in the next preset period. It can be understood that in the case of streaming data, there will be a lot of data in each period, and the burstiness of the word is an important indicator for measuring whether a word is key. The growth of the word can be used to represent the burstiness of the word, and the higher the growth of the word, the more key the word is. For example, the frequency of occurrence of a word from 9:00 to 10:00 is 10, and the frequency of occurrence of the word from 10:00 to 11:00 is increased to 100. Therefore, this suddenly increased word may have certain business meaning, and the server can take this word as a key word.
[0055] In one embodiment, the server can count the total occurrence frequency of each word in the text data to be classified, and calculate the inverse document frequency of each word in the first corpus, to determine the word frequency-inverse document frequency of each word. It can be understood that the text data in each embodiment of the present application refers to the text data to be classified, which can be denoted as first text data. The first corpus can be a pre-set corpus, or a corpus related to the first text data composed of at least part of the corpus acquired in the scenario of collecting the first text data to be classified. It can be understood that the at least part of the corpus acquired in the scenario of collecting the first text data to be classified can be constructed from the text data acquired in the scenario of collecting the first text data to be classified and other than the first text data, or can be constructed from the total corpus acquired in the scenario of collecting the first text data to be classified. It can be understood that the total corpus can include the first text data to be classified itself and the second text data other than the first text data acquired in the same scenario. The present application does not limit the specific composition of the corpus of the first corpus. For ease of understanding, an example is given as follows: a lot of text data is acquired in a scenario, the user can select the text data to be classified from them, i.e. the first text data, and then the first corpus is constructed based on the remaining other text data (i.e. the second text data) as the corpus.
[0056] In the present embodiment, if the text data is streaming data, the keywords are extracted from the text data based on the growth of each word in the text data; if the text data is non-streaming data, the keywords are extracted from the text data based on the proportion of the number of each word in the text data. Different keyword evaluation criteria are adopted for text data of different data formats, and the keywords are extracted pertinently to improve the accuracy of the first type of cluster.
[0057] In one embodiment, the method further comprises: extracting keywords from the text data; determining seed keywords selected from the extracted keywords; retrieving sentences matching the keywords in the text data from the text data to obtain the cluster center sentence, comprising: retrieving sentences semantically close to the seed keywords from the text data to obtain the cluster center sentence.
[0058] Specifically, the server can extract keywords from the text data based on the keyword extraction algorithm of the growth rate or the word frequency-inverse document frequency, and determine seed keywords selected from the extracted keywords. The server can retrieve sentences semantically close to the seed keywords from the text data based on at least one of the word retrieval algorithm and the semantic vector retrieval algorithm to obtain the cluster center sentence.
[0059] In an embodiment, the server can perform word segmentation on the seed keyword and the text data respectively to obtain words of the text data and words of the seed keyword. The server can obtain a matching score between each sentence in the text data and the seed keyword by calculating the similarity between the words of the text data and the words of the seed keyword respectively. It can be understood that the higher the similarity, the higher the matching score, and the closer the semantics of the corresponding sentence and the seed keyword. For example, the server can use a bm25 (Best Matching) retrieval algorithm to retrieve sentences with similar semantics to the seed keyword from the text data. The server can use an elasiticsearch to retrieve sentences with similar semantics to the seed keyword from the text data.
[0060] In an embodiment, the server can obtain a sentence semantic vector of a sentence in the text data and a word semantic vector of the seed keyword. The server can retrieve a sentence with similar semantics to the seed keyword by comparing the sentence semantic vector and the word semantic vector. For example, the server can use at least one pre-trained model in sentence-bert (semantic similarity model) and sim-bert (short text semantic matching model) to implement retrieval of semantic vectors.
[0061] In an embodiment, the server can first retrieve word-related sentences with high matching scores with the seed keyword based on a word-based retrieval algorithm, and then retrieve a sentence with similar semantics to the seed keyword from the multiple word-related sentences based on a semantic vector-based retrieval algorithm to obtain a cluster center sentence. It can be understood that the advantage of the word-based retrieval algorithm is that it is fast, but the disadvantage is that it requires word segmentation and less consideration of semantic information, so the retrieval quality is relatively low. Therefore, the use of semantic vector-based retrieval algorithm can improve the retrieval quality. For example, the server can first use an elasiticsearch to retrieve word-related sentences from the text data, and then use a semantic vector model (bert) to retrieve a sentence with similar semantics to the seed keyword from the multiple word-related sentences to obtain a cluster center sentence.
[0062] In an embodiment, the server can return the extracted keywords to the terminal, and the terminal can display the keywords to the user. The user can select the keywords of interest through the terminal, and the terminal can send the keywords selected by the user to the server, and the server can use the keywords selected by the user as the seed keyword.
[0063] In this embodiment, keywords are extracted from the text data, a seed keyword is determined from the extracted keywords, a sentence with similar semantics to the seed keyword is retrieved from the text data to obtain a cluster center sentence, and the seed keyword is filtered through the keywords, and the cluster center sentence is retrieved, without relying on existing classification models, to complete the word granularity class label mining, thereby reducing the cost of text classification.
[0064] In an embodiment, the clustering the sentences in the text data other than the first type of cluster to obtain at least one second type of cluster comprises: clustering the sentences in the text data other than the first type of cluster to obtain at least one initial type of cluster; determining, for each initial type of cluster, a cluster center sentence of the initial type of cluster from the plurality of sentences in the initial type of cluster; determining, based on distances between the cluster center sentence and the plurality of sentences in the initial type of cluster, noise sentences of the initial type of cluster; filtering the sentences in the initial type of cluster according to the noise sentences to obtain the second type of cluster.
[0065] Specifically, the server can take the sentences in the text data other than the first type of cluster as clustering sentences. The server can select at least one initial cluster center sentence from the plurality of clustering sentences, and calculate distances between the clustering sentences and the initial cluster center sentence, and cluster each clustering sentence to the initial cluster center sentence with the smallest distance to obtain at least one initial type of cluster. The server can determine the cluster center sentence of the initial type of cluster by calculating the center of gravity (average distance center) of each initial type of cluster. The server can calculate distances between the cluster center sentence and the plurality of clustering sentences in the initial type of cluster, and take the clustering sentences far away from the cluster center sentence as noise sentences of the initial type of cluster. The server can filter out the noise sentences from the initial type of cluster to obtain the second type of cluster.
[0066] In an embodiment, the server can take the clustering sentences with distances greater than a noise distance threshold from the cluster center sentence as noise sentences. It can be understood that removing the noise sentences belongs to intra-class filtering, and the purpose of intra-class filtering is to reduce the tail noise in the cluster. The server can remove the clustering sentences far away from the cluster center sentence by comparing with the noise distance threshold.
[0067] In an embodiment, the server can use the mean clustering algorithm (K-means) to cluster the sentences in the text data other than the first type of cluster to obtain at least one second type of cluster. It can be understood that when the amount of data in the text data is large, the server can use an optimization algorithm of the mean clustering algorithm. For example, the server can extract a first part of data from the text data in batches, use the mean clustering algorithm to construct an initial cluster for the part of data, and continue to extract a second part of data, and assign the second part of data to the nearest cluster center sentence to add to the initial cluster. The server can use the mini-batch-kmeans algorithm to cluster the sentences in the text data other than the first type of cluster to obtain at least one second type of cluster.
[0068] In this embodiment, at least one initial cluster is obtained by clustering the sentences in the text data except the first cluster, and sentence granularity clustering is achieved; and the second cluster is obtained by filtering the noise sentences in the initial cluster based on the distance between the cluster center sentence in the initial cluster and the multiple sentences, and the quality of the second cluster is ensured.
[0069] In one embodiment, clustering the sentences in the text data except the first cluster to obtain at least one second cluster includes: clustering the sentences in the text data except the first cluster to obtain at least one initial cluster; determining the cluster density of each initial cluster; and performing cluster filtering on the at least one initial cluster based on the cluster density to obtain the second cluster remaining after filtering.
[0070] Specifically, the server can cluster the sentences in the text data except the first cluster to obtain at least one initial cluster. The server can determine the density-related sentences from the initial cluster. The density-related sentences are the sentences related to the density of the initial cluster. The server can determine the cluster density of the initial cluster based on the distance between the density-related sentences and the cluster center sentence. The server can filter out the initial cluster with low cluster density to obtain the second cluster remaining after filtering.
[0071] In one embodiment, the server can calculate the variance of the distance between the multiple density-related sentences and the cluster center sentence to obtain the cluster density of the initial cluster. It can be understood that the server can directly obtain the cluster density of the initial cluster by calculating the variance of the distance between each sentence in the initial cluster and the cluster center sentence.
[0072] In one embodiment, the server can take the first preset number of sentences closest to the cluster center sentence in the initial cluster as the density-related sentences. It can be understood that filtering out the initial cluster with low cluster density is inter-cluster filtering, and the cluster density is obtained by calculating the variance of the distance between the cluster center sentence and the closest topN sentences.
[0073] In one embodiment, the server can use the mean clustering algorithm to cluster the sentences in the text data except the first cluster to obtain at least one initial cluster. The server can determine the noise sentences in the initial cluster and determine the cluster density of each initial cluster. The server can first filter out the noise sentences in the initial cluster, and then filter out the initial cluster with low cluster density to obtain the second cluster remaining after filtering. It can be understood that the server can first filter out the initial cluster with low cluster density, and then filter out the noise sentences in the initial cluster with high cluster density.
[0074] In this embodiment, at least one initial cluster is obtained by clustering the sentences in the text data except the first cluster, and sentence granularity clustering is achieved. The second cluster is obtained by performing cluster filtering on the at least one initial cluster based on the cluster density, the cluster density of the obtained second cluster is high, and the quality of the second cluster is ensured.
[0075] In an embodiment, determining the category label corresponding to the text data based on the first type of cluster and the second type of cluster comprises: determining a cluster keyword corresponding to each type of cluster in the text data; the types of clusters in the text data include the first type of cluster and the second type of cluster; determining a similar type of cluster corresponding to each type of cluster from the multiple types of clusters in the text data; and determining the category label corresponding to the text data based on the similar type of cluster corresponding to each type of cluster and the cluster keyword.
[0076] Specifically, the server can extract a cluster keyword from a cluster based on the proportion of the number of words in the cluster. The server can determine a similar type of cluster corresponding to each type of cluster from the multiple types of clusters in the text data by calculating the similarity between the clusters. The server can send the similar type of cluster corresponding to each type of cluster and the cluster keyword to the terminal, and the terminal can display the similar type of cluster and the cluster keyword of each type of cluster. It can be understood that when labeling by artificial through the terminal in a big data scenario, a cluster may contain many sentences, and the cluster keyword facilitates the artificial to quickly understand the cluster information and mark the category label of the cluster. The terminal can recommend a similar type of cluster to the artificial for each cluster, reducing the screening cost. The terminal can send the category label marked by the artificial to the server, and the server can determine the category label corresponding to the text data.
[0077] In an embodiment, the server can use the seed keyword of the first type of cluster as the cluster keyword of the first type of cluster. It can be understood that the server can also extract a cluster keyword from the first type of cluster based on the proportion of the number of words in the first type of cluster.
[0078] In an embodiment, the server can count the total frequency of each word in the current cluster and calculate the inverse document frequency of each word in the second corpus to determine the term frequency-inverse document frequency of each word in the current cluster. The second corpus can be constructed by taking the sentences in the first type of cluster and the second type of cluster in the text data as corpus, or by taking the sentences in the first type of cluster and the second type of cluster except the current cluster as corpus. The server can take the word with high term frequency-inverse document frequency as the cluster keyword. The server can take the next type of cluster as the current cluster to determine the term frequency-inverse document frequency of each word in the current cluster, until all clusters in the text data are traversed.
[0079] In an embodiment, the server can perform part-of-speech filtering on the cluster keyword to retain important parts of speech such as verbs and nouns to obtain the final cluster keyword.
[0080] In the embodiment, the class cluster keywords corresponding to each class cluster in the text data are determined, the similar class clusters corresponding to each class cluster are determined from the multiple class clusters in the text data, and the class labels corresponding to the text data are determined based on the similar class clusters and the class cluster keywords corresponding to each class cluster. The class cluster keywords can represent the key information in the class cluster, which facilitates manual understanding of the class cluster. The similar class clusters can reduce the cost of manual screening of the class cluster.
[0081] In one embodiment, determining the similar class clusters corresponding to each class cluster from the multiple class clusters in the text data includes: determining the class cluster center sentences of each class cluster respectively; and determining the similar class clusters corresponding to each class cluster from the multiple class clusters in the text data by comparing the similarities between the class cluster center sentences of each class cluster.
[0082] Specifically, the server can determine the class cluster center sentences of each class cluster respectively. The server can calculate the similarities between the class cluster center sentences of each class cluster, and determine the similar class clusters corresponding to each class cluster from the multiple class clusters in the text data by comparing the similarities between the class cluster center sentences of each class cluster. The server can send the similar class clusters corresponding to each class cluster to the terminal, and the terminal can recommend the similar class clusters corresponding to the current class cluster to the human, thereby reducing the cost of manual screening.
[0083] In the embodiment, the class cluster center sentences of each class cluster are determined respectively, and the similar class clusters corresponding to each class cluster are determined from the multiple class clusters in the text data by comparing the similarities between the class cluster center sentences of each class cluster. It can be understood that the clustering algorithm is unsupervised, and the effect is often difficult to guarantee. Therefore, there are usually many class clusters under the same class label in the clustering result, which reduces the efficiency of manual analysis of the class cluster. By determining the similar class clusters corresponding to the class cluster, the cost of manual screening can be reduced.
[0084] Figure 3a A simple flowchart of the text classification method of one embodiment is shown. The server can preprocess the text data, and vectorize the sentences in the preprocessed text data. The server can retrieve the sentences used as the center of the first class cluster from the text data based on the vectorization result, that is, retrieve the class cluster center sentence of the first class cluster. Figure 3b A simple flowchart of retrieving the class cluster center sentence of the first class cluster in one embodiment is shown. As shown in Figure 3b The keywords are extracted from the text data, and the sentences matching the keywords are retrieved in the manner of vector retrieval, that is, the class cluster center sentence of the first class cluster is obtained.
[0085] Further, the server can cluster to obtain each cluster of the text data. It can be understood that different clustering manners can be adopted to obtain the first cluster and the second cluster. Specifically, for the cluster center sentence of the first cluster that has been retrieved, the server can retrieve similar sentences of the cluster center sentence from the text data to obtain the first cluster based on the cluster center sentence and the similar sentences. In addition, the server can directly cluster the sentences in the text data other than the first cluster to obtain the second cluster.
[0086] It can be understood that the first cluster obtained based on the keyword retrieval of the cluster center sentence of the first cluster is a label mining result based on a word granularity. The server can not perform label mining based on a word granularity, but directly cluster the sentences in the text data other than the first cluster to obtain the second cluster.
[0087] The server can determine the cluster keywords and similar clusters corresponding to each cluster of the text data, and send each cluster of the text data and the corresponding cluster keywords and the corresponding similar clusters to the terminal. The artificial can sort each cluster of the text data through the terminal, quickly understand the cluster information according to the cluster keywords, facilitate the marking of the cluster labels, the terminal can recommend similar clusters to the artificial, reduce the screening cost of the artificial, and facilitate the marking of the clusters under the same category label. The terminal can send the cluster marked by the artificial to the server, and the server can determine the category labels corresponding to the text data.
[0088] In the embodiment, the text data is subjected to label mining based on a word granularity and a sentence granularity. Compared with a traditional clustering model based on a single algorithm, a set of interactive label mining processes are constructed by combining the keywords, retrieval and clustering of an unsupervised algorithm, a single clustering algorithm is effectively optimized, and new category labels can be accurately mined. In addition, in terms of a classification model, label mining usually depends on the effect of an existing classification model. By focusing on the landing and optimization of the unsupervised algorithm, the strong dependence on the effect of the classification model is reduced.
[0089] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0090] Based on the same inventive concept, the embodiments of the present application also provide a text classification device for implementing the above-mentioned text classification method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more text classification device embodiments provided below can be referred to the limitations of the text classification method in the above, which will not be described here again.
[0091] In one embodiment, as shown in Figure 4 A text classification device 400 is provided, comprising a clustering module 402 and a determination module 404, wherein:
[0092] The clustering module 402 is configured to retrieve a sentence matching a keyword in the text data from the text data to obtain a cluster center sentence; retrieve a similar sentence of the cluster center sentence from the text data; obtain a first cluster based on the cluster center sentence and the similar sentence; and cluster sentences in the text data except the first cluster to obtain at least one second cluster.
[0093] The determination module 404 is configured to determine a category label corresponding to the text data based on the first cluster and the second cluster.
[0094] In one embodiment, the clustering module 402 is further configured to extract the keyword from the text data based on a growth of each word in the text data if the text data is streaming data; and extract the keyword from the text data based on a proportion of the number of each word in the text data if the text data is non-streaming data.
[0095] In one embodiment, the clustering module 402 is further configured to extract the keyword from the text data; determine a seed keyword filtered from the extracted keyword; and retrieve a sentence semantically close to the seed keyword from the text data to obtain the cluster center sentence.
[0096] In one embodiment, the clustering module 402 is further configured to cluster the sentences in the text data except the first cluster to obtain at least one initial cluster; determine, for each initial cluster, a cluster center sentence of the initial cluster from a plurality of sentences of the initial cluster; determine a noise sentence of the initial cluster based on a distance between the cluster center sentence and the plurality of sentences in the initial cluster; and filter the sentences in the initial cluster according to the noise sentence to obtain the second cluster.
[0097] In one embodiment, the clustering module 402 is further configured to cluster the sentences in the text data except the first cluster to obtain at least one initial cluster; determine a cluster density of each initial cluster; and perform cluster filtering on the at least one initial cluster based on the cluster density to obtain a second cluster remaining after filtering.
[0098] In one embodiment, the determining module 404 is further configured to determine the cluster keywords corresponding to each type of cluster in the text data; the types of clusters in the text data include a first type of cluster and a second type of cluster; determine the similar clusters corresponding to each type of cluster from multiple types of clusters in the text data; and determine the category label corresponding to the text data based on the similar clusters and cluster keywords corresponding to each type of cluster.
[0099] In one embodiment, the determining module 404 is further configured to determine the cluster center sentence of each type of cluster; and to determine the similar clusters corresponding to each type of cluster from multiple clusters of text data by comparing the similarity between the cluster center sentences of each type of cluster.
[0100] Each module in the aforementioned text classification device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0101] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores text data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a text classification method.
[0102] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6The computer device shown in the figure includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be realized through WIFI, mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by the processor to realize a text classification method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device. It can also be an external keyboard, touchpad or mouse, etc.
[0103] Those skilled in the art can understand that, Figure 5 and Figure 6 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. A specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0104] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the above method embodiments.
[0105] In one embodiment, a computer readable storage medium is provided, storing a computer program, and the computer program is executed by a processor to implement the steps in the above method embodiments.
[0106] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by a processor to implement the steps in the above method embodiments.
[0107] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of the country and region.
[0108] It can be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments of each method. In the embodiments provided in the present application, any reference to memory, database or other medium can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetic variable memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0109] The technical features of the above embodiments can be combined in any way. In order to make the description simple, not all possible combinations of the technical features in the above embodiments are described, but as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0110] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A method of text classification, characterized by, The method comprises: extracting keywords from text data; the text data comprises data under a newly-added business scenario; determining historical category labels in historical business scenarios, determining keywords that do not match the historical category labels by comparing the historical category labels and the keywords, and obtaining seed keywords; retrieving sentences that are semantically close to the seed keywords from the text data to obtain cluster center sentences; retrieving similar sentences of the cluster center sentences from the text data; obtaining a first cluster based on the cluster center sentences and the similar sentences; clustering sentences other than the first cluster in the text data to obtain at least one second cluster; determining a category label corresponding to the text data based on the first cluster and the second cluster.
2. The method of claim 1, wherein, The method further comprises: if the text data is streaming data, extracting keywords from the text data based on the growth of each word in the text data; if the text data is non-streaming data, extracting keywords from the text data based on the proportion of the number of each word in the text data.
3. The method of claim 1, wherein, The cluster center sentence is a standard sentence for reflecting cluster characteristics.
4. The method of claim 1, wherein, The clustering of sentences other than the first cluster in the text data to obtain at least one second cluster comprises: clustering sentences other than the first cluster in the text data to obtain at least one initial cluster; determining a cluster center sentence of each initial cluster from a plurality of sentences in the initial cluster; determining noise sentences of the initial cluster based on the distance between the cluster center sentence and the plurality of sentences in the initial cluster; filtering the sentences in the initial cluster according to the noise sentences to obtain a second cluster.
5. The method of claim 1, wherein, The clustering of sentences other than the first cluster in the text data to obtain at least one second cluster comprises: clustering sentences other than the first cluster in the text data to obtain at least one initial cluster; determining the cluster density of each initial cluster; performing cluster filtering on the at least one initial cluster based on the cluster density to obtain a second cluster remaining after filtering.
6. The method according to any one of claims 1 to 5, characterized in that, The determination of a category label corresponding to the text data based on the first cluster and the second cluster comprises: determining cluster keywords corresponding to each cluster in the text data; each cluster in the text data comprises the first cluster and the second cluster; determining similar clusters corresponding to each cluster in the text data; determining a category label corresponding to the text data based on the similar clusters and the cluster keywords corresponding to each cluster.
7. The method of claim 6, wherein, The determination of similar clusters corresponding to each cluster in the text data comprises: determining a cluster center sentence of each cluster; determining similar clusters corresponding to each cluster from a plurality of clusters in the text data by comparing the similarity between the cluster center sentences of each cluster.
8. A text classification apparatus characterized by comprising: The device comprises: The clustering module is configured to extract keywords from the text data, wherein the text data comprises data under a new business scenario; determine a historical category label in a historical business scenario; determine a seed keyword by comparing the historical category label and the keywords; retrieve sentences semantically close to the seed keyword from the text data to obtain a cluster center sentence; retrieve similar sentences of the cluster center sentence from the text data; and obtain a first cluster based on the cluster center sentence and the similar sentences; and cluster sentences other than the first cluster in the text data to obtain at least one second cluster. The determining module is configured to determine a category label corresponding to the text data based on the first cluster and the second cluster. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-8 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 7.
Citation Information
Patent Citations
Label extraction method based on short text clustering technology
CN111414479A
Text-based news importance evaluation method and apparatus, and electronic device
CN112016294A