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

By performing deep feature extraction and clustering operations on text data, the problem of low accuracy in large-scale text data processing is solved, and more accurate and efficient clustering results are achieved.

CN112989047BActive Publication Date: 2025-05-02华润数字科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110308370.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-23
Publication Date
2025-05-02
Estimated Expiration
2041-03-23

AI Technical Summary

Technical Problem

When processing large-scale text data, existing clustering algorithms are susceptible to outliers and extreme values, and fail to effectively utilize the implicit semantics brought about by word context associations, resulting in low accuracy of clustering results.

Method used

By preprocessing the text sequence to be classified, deep-level features are extracted and characterization vectors are generated, and clustering operations are performed based on these characterization vectors. The specific steps include confirming the current centroid of mass of each cluster, forming a node queue, selecting an edge node queue, and iteratively determine whether to expand the node queue and replace the centroid until the final edge node queue and centroid are determined.

Benefits of technology

Through deep feature extraction and iterative optimization, the accuracy and convergence speed of clustering results are improved, making clustering results more reliable and efficient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112989047B_ABST
    Figure CN112989047B_ABST
Patent Text Reader

Abstract

The present invention discloses a text clustering method, device, computer equipment and storage medium. The method pre-processes the text sequence to be classified and obtains the corresponding characterization vector, and divides the text sequence into different clusters according to the characterization vector, wherein each text sequence corresponds to a node in the cluster; confirms the current centroid of each cluster, arranges all nodes according to the distance from all nodes in each cluster to the current centroid of its own cluster, forms a node queue, and selects the current edge node queue from the node queue; for each cluster, executes the process of determining whether to expand the current edge node queue and replace the new centroid, until the final edge node queue and the final centroid are confirmed. The present invention performs clustering operation after deeply extracting the features of the text sequence, and through continuous iterative updates, the clustering result has the advantages of being more accurate and converging faster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of text data processing, and in particular to a text clustering method, device, computer equipment and storage medium. Background Art

[0002] At present, in the practice of machine learning, people are often faced with massive amounts of data that lack annotations, which greatly limits the application of supervised learning methods. Clustering methods allow computers to learn independently based on sample characteristics, which is very helpful in solving such problems. Among the many clustering methods, the K-Means (hard clustering algorithm) method is the most classic one, which is easy to use and has good results. However, this method requires a lot of computing resources when the amount of data is large.

[0003] In general, the K-Means method is easily affected by outliers or other extreme values. In order to solve this problem, most existing technologies use discrete features of text (TF-IDF) as input for clustering algorithms. Although this method is simple and easy to use, it does not consider the implicit semantics brought by the contextual association of words. In practice, its effect is greatly limited, resulting in low accuracy of clustering results. Summary of the invention

[0004] The purpose of the present invention is to provide a text clustering method, device, computer equipment and storage medium, aiming to solve the problem that the accuracy of clustering results of existing clustering algorithms needs to be improved.

[0005] In a first aspect, an embodiment of the present invention provides a text clustering method, which includes:

[0006] Preprocessing the text sequence to be classified and obtaining a corresponding representation vector, and dividing the text sequence into different clusters according to the representation vector, wherein each text sequence corresponds to a node in the cluster;

[0007] Determine the current centroid of each cluster, arrange all nodes in each cluster according to the distance from the current centroid of its own cluster to form a node queue, and select the current edge node queue from the node queue;

[0008] For each cluster, a process of determining whether to expand the current edge node queue and replace the new centroid is executed until the final edge node queue and the final centroid are confirmed.

[0009] In a second aspect, an embodiment of the present invention provides a method device of a text clustering mechanism, which includes:

[0010] A queue unit is used to confirm the current centroid of each cluster, arrange all nodes in each cluster according to the distance from the current centroid of its own cluster to form a node queue, and select the current edge node queue from the node queue;

[0011] The judgment unit is used to execute the process of judging whether to expand the current edge node queue and replace the new centroid for each cluster until the final edge node queue and the final centroid are confirmed.

[0012] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text clustering method described in the first aspect when executing the computer program.

[0013] In a fourth aspect, an embodiment of 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, the processor executes the text clustering method described in the first aspect.

[0014] The embodiment of the present invention discloses a text clustering method, device, computer equipment and storage medium. The method pre-processes the text sequence to be classified and obtains the corresponding characterization vector, and divides the text sequence into different clusters according to the characterization vector, wherein each text sequence corresponds to a node in the cluster; confirms the current centroid of each cluster, arranges all nodes according to the distance from all nodes in each cluster to the current centroid of its own cluster, and forms a node queue, and selects the current edge node queue from the node queue; for each cluster, executes the process of determining whether to expand the current edge node queue and replace the new centroid, until the final edge node queue and the final centroid are confirmed. The embodiment of the present invention performs clustering operation after deeply extracting the features of the text sequence, and through continuous iterative updates, the clustering result has the advantages of being more accurate and converging faster. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0016] Figure 1 A schematic diagram of a flow chart of a text clustering method provided by an embodiment of the present invention;

[0017] Figure 2 A schematic diagram of a sub-process of step S101 of the text clustering method provided in an embodiment of the present invention;

[0018] Figure 3 A schematic diagram of a sub-process of step S102 of the text clustering method provided in an embodiment of the present invention;

[0019] Figure 4 A schematic diagram of a sub-process of step S103 of the text clustering method provided in an embodiment of the present invention;

[0020] Figure 5 A schematic diagram of a sub-process of step S401 of the text clustering method provided in an embodiment of the present invention;

[0021] Figure 6 A schematic diagram of a sub-process of step S402 of the text clustering method provided in an embodiment of the present invention;

[0022] Figure 7 A schematic diagram of the structure of an initial cluster provided by an embodiment of the present invention;

[0023] Figure 8 A schematic diagram of an edge node queue and expansion provided by an embodiment of the present invention;

[0024] Fig. 9 A schematic block diagram of a text clustering device provided by an embodiment of the present invention;

[0025] Fig.10 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

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

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

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

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

[0030] See also Figure 1 , Figure 1 A flowchart of a text clustering method provided by an embodiment of the present invention;

[0031] like Figure 1 As shown, the method includes steps S101 to S103.

[0032] S101 , preprocessing a text sequence to be classified and obtaining a corresponding representation vector, and dividing the text sequence into different clusters according to the representation vector, wherein each text sequence corresponds to a node in the cluster.

[0033] In this embodiment, feature extraction is performed on the text sequence to be classified and the corresponding representation vector is obtained. Initial classification is performed based on the similarity of the representation vector of each text sequence, and different types of divisions can be achieved, thereby forming different clusters. For each cluster, a virtual node is set for each text sequence in the cluster to form a mapping pair between the text sequence and the node.

[0034] In one embodiment, if Figure 2 As shown, step S101 includes:

[0035] S201, inputting the text sequence into a pre-trained model, and outputting a corresponding representation vector;

[0036] S202: using a clustering algorithm to classify the representation vectors, and randomly assigning initial centroids so that the text sequences form different initial clusters, wherein each text sequence corresponds to a node in the cluster.

[0037] In this embodiment, the text sequence is input into a pre-trained model, deep-level feature extraction is performed on the text sequence through the pre-trained model, and a representation vector corresponding to each of the text sequences is output; and a clustering algorithm is used to classify the representation vectors, so as to divide the text sequence into different initial clusters; specifically, a plurality of initial centroids are randomly specified, and each initial centroid and all nodes are divided to form different initial clusters, wherein each initial cluster includes an initial centroid and a plurality of nodes (combined Figure 7 shown).

[0038] S102, confirming the current centroid of each cluster, arranging all nodes to form a node queue according to the distance from all nodes in each cluster to the current centroid of its own cluster, and selecting a current edge node queue from the node queue.

[0039] Specifically, Figure 3 As shown, step S102 includes:

[0040] S301, reconfirming the current centroid of each cluster according to the Euclidean distance from all nodes in each cluster to the initial centroid of its own cluster;

[0041] S302, according to the distances from all nodes in each cluster to the current centroid of the own cluster, all nodes in the own cluster are arranged in a manner of farther closer to the front to form a node queue, and a preset proportion of nodes are selected from the node queue in the order of arrangement as the current edge node queue.

[0042] In this embodiment, based on the initial centroid of its own cluster, the Euclidean distances from all nodes in its own cluster to the initial centroid are calculated. The Euclidean distance is the spatial straight-line distance between each node in its own cluster and the initial centroid. Based on the obtained distance, the current centroid of its own cluster is reconfirmed and obtained.

[0043] Combination Figure 8 As shown, based on the current centroid of its own cluster, the Euclidean distance from all nodes in its own cluster to the current centroid is calculated, so that all nodes in its own cluster can be arranged according to the current Euclidean distance and form a node queue. The specific arrangement method can be that the farther the distance, the closer the arrangement is, or other arrangement methods. Based on the arrangement method that the farther the distance, the closer the arrangement is, a preset proportion of nodes are selected from the node queue in the arrangement order as the current edge node queue. The value of the preset proportion here can be 5% or 10% or other proportions.

[0044] S103 . For each cluster, a process of determining whether to expand the current edge node queue and replace the new centroid is executed until a final edge node queue and a final centroid are confirmed.

[0045] Specifically, Figure 4 As shown, the step S103 includes:

[0046] S401, comparing the minimum distance between the nodes in the current edge node queue and the current centroid of its own cluster and the maximum distance between the nodes in the current edge node queue and the centroids of other clusters, and obtaining a first comparison result, and judging whether to expand the current edge node queue according to the first comparison result, if yes, expanding the current edge node queue to obtain the next edge node queue, and reconfirming the next centroid of its own cluster according to the next edge node queue, and continuing the comparison until the condition for stopping expansion is met;

[0047] S402. If otherwise, compare the maximum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the minimum distance from the nodes in the current edge node queue to the current centroids of other clusters, and obtain a second comparison result. According to the second comparison result, determine whether to replace the current centroid of its own cluster. If so, replace it and obtain a new centroid of its own cluster, and re-execute the process of determining whether to expand the current edge node queue and replace the new centroid until the iteration termination condition is met.

[0048] In this embodiment, for each cluster, in order to achieve more accurate clustering results, an iteration termination condition is set. Based on the condition for stopping expansion, the current edge node queue of each cluster is continuously iteratively optimized, and the current centroid of each cluster is continuously iteratively optimized until the current edge node queue and the current centroid meet the iteration termination condition, so that a cluster with more accurate clustering results can be obtained.

[0049] In one embodiment, if Figure 5 As shown, the step S401 includes:

[0050] S501, for each cluster, compare the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the maximum distance from the nodes in the current edge node queue to the current centroids of other clusters; if the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster is greater than the maximum distance from the nodes in the current edge node queue to the current centroids of other clusters, divide the nodes in the current edge node queue into other clusters, and select a preset proportion of nodes from the remaining nodes in the node queue in order of arrangement as the next edge node queue;

[0051] S502, reconfirming the next centroid of the own cluster according to the Euclidean distance from the node in the next edge node queue to the current centroid of the own cluster;

[0052] S503. Continue to compare the minimum distance from the nodes in the next edge node queue to the next centroid of its own cluster and the maximum distance from the nodes in the next edge node queue to the next centroid of other clusters until the maximum distance from the nodes in the next edge node queue to the next centroid of its own cluster is less than the minimum distance from the nodes in the next edge node queue to the next centroid of other clusters, then stop expanding the edge node queue.

[0053] In this embodiment, cluster C i and cluster C j To explain, define cluster C i The current edge node queue is C i _mq, the current center of mass is C i _com, cluster C i Ci _mq node k is C i _mq(k), node k to the current centroid C i The distance of _com is dis(C i _mq(k),C i _com).

[0054] For cluster C i The current edge node queue C i All nodes in _mq, if they satisfy min(dis(C i _mq(k),C i _com))>max(dis(C i _mq(k),C j _com)), that is, cluster C i The current edge node queue C i _mq node to cluster C i The current center of mass C i _com's minimum distance is greater than the distance to the current edge node queue C i _mq node to cluster C j The current center of mass C j _com, then the current edge node queue C i All nodes in _mq need to be re-divided into cluster C j , the current edge node queue C i All nodes in _mq directly join cluster C j Then, according to the order of arrangement, select the node from cluster C. i A preset proportion of nodes are selected from the remaining nodes in the node queue as the next edge node queue, where the preset proportion may be 5% or 10% or other proportions.

[0055] Based on the next edge node queue, according to the Euclidean distance from the node in the next edge node queue to the current centroid of the own cluster, the next centroid of the own cluster is reconfirmed, and the clustering result is gradually optimized by reconfirming the position of the centroid of the own cluster.

[0056] Based on the next centroid of its own cluster, continue with cluster C i and cluster C j To illustrate, for cluster C i The next edge node queue of cluster C i The node in the next edge node queue to cluster C i The maximum distance of the next centroid is less than the node in the next edge node queue to cluster C jIf the minimum distance to the next centroid of the edge node is reached, the edge node queue is stopped from being expanded, that is, all nodes in the next edge node queue do not need to be re-divided into cluster C. j , similarly for cluster C i The nodes in the non-edge node queue do not need to calculate the relationship with cluster C. j The distance to the centroid can be directly entered into the next iteration step.

[0057] In one embodiment, if Figure 6 As shown, the step S402 includes:

[0058] S601, comparing the maximum distance from the node in the current edge node queue to the centroid of its own cluster and the minimum distance from the node in the current edge node queue to the centroids of other clusters, if the maximum distance from the node in the current edge node queue to the centroid of its own cluster is less than the minimum distance to the centroids of other clusters, replacing the current centroid of its own cluster and obtaining a new centroid;

[0059] S602: re-execute the process of determining whether to expand the current edge node queue and replace the new centroid until a preset number of iterations is reached or the final centroid of each cluster is determined.

[0060] In this embodiment, cluster C i and cluster C j To illustrate, for cluster C i The current edge node queue C i All nodes in _mq, if max(dis(c i _mq(k),c i _com)) <min(dis(c i _mq(k),c j _com)), that is, cluster C i The current edge node queue C i The maximum distance from a node in _mq to the centroid of its own cluster is less than the distance from the centroid of cluster C j The current center of mass C j _com, then replace cluster C i The current centroid is obtained and a new centroid is obtained, and a new round of iteration is restarted, that is, for each cluster, the iterative process of determining whether to expand the current edge node queue and replace the new centroid is re-executed until the preset number of iterations is reached or the final centroid of each cluster is determined, and the final clustering result can be obtained.

[0061] In one embodiment, the text clustering method further includes:

[0062] If the current edge node queue fails to meet the conditions for expanding the edge node queue and re-changing the current centroid, the distances from all nodes in the current edge node queue to the current centroid of each cluster are calculated, and each node is divided into the nearest cluster according to the distance.

[0063] In this embodiment, the condition for expanding the edge node queue is: the minimum distance from the nodes in the current edge node queue to the current center of mass of its own cluster is greater than the maximum distance from the nodes in the current edge node queue to the current center of mass of other clusters; and the condition for re-replacing the current center of mass is: if the maximum distance from the nodes in the current edge node queue to the center of mass of its own cluster is less than the minimum distance to the center of mass of other clusters; if the current edge node queue fails to meet the above two conditions, then the distance from all nodes in the current edge node queue to the current center of mass of each cluster is calculated, and each node is divided into the nearest cluster according to the distance.

[0064] The embodiment of the present invention further provides a text clustering device, which is used to execute any embodiment of the above-mentioned text clustering method. Fig. 9 , Fig. 9 It is a schematic block diagram of a text clustering device provided by an embodiment of the present invention.

[0065] like Fig. 9 As shown, the text clustering device 900 includes: a preprocessing unit 901, a queue unit 902 and a judgment unit 903.

[0066] A preprocessing unit 901 is used to preprocess the text sequence to be classified and obtain a corresponding representation vector, and divide the text sequence into different clusters according to the representation vector, wherein each text sequence corresponds to a node in the cluster;

[0067] The queue unit 902 is used to confirm the current centroid of each cluster, arrange all nodes in each cluster according to the distance from the current centroid of its own cluster to form a node queue, and select the current edge node queue from the node queue;

[0068] The judgment unit 903 is used to execute the process of judging whether to expand the current edge node queue and replace the new centroid for each cluster until the final edge node queue and the final centroid are confirmed.

[0069] The device performs clustering operations after deeply extracting the features of text sequences, and through continuous iterative updates, the clustering results have the advantages of being more accurate and converging faster.

[0070] In one embodiment, the preprocessing unit 901 includes:

[0071] A training unit, used for inputting the text sequence into a pre-trained model and outputting a corresponding representation vector;

[0072] The classification unit is used to classify the representation vectors by using a clustering algorithm and randomly assign initial centroids so that the text sequences form different initial clusters, wherein each text sequence corresponds to a node in the cluster.

[0073] In one embodiment, the queue unit 902 includes:

[0074] A first confirmation unit is used to reconfirm the current centroid of each cluster according to the Euclidean distance from all nodes in each cluster to the initial centroid of its own cluster;

[0075] The arrangement unit is used to arrange all nodes in its own cluster according to the distance from all nodes in each cluster to the current centroid of its own cluster in a manner of farther closer to the front and form a node queue, and select a preset proportion of nodes from the node queue in the arrangement order as the current edge node queue.

[0076] In one embodiment, the determining unit 903 includes:

[0077] A first comparison unit is used to compare the minimum distance between the nodes in the current edge node queue and the current centroid of its own cluster and the maximum distance between the nodes in the current edge node queue and the centroids of other clusters, and obtain a first comparison result, and determine whether to expand the current edge node queue according to the first comparison result, and if so, expand the current edge node queue to obtain the next edge node queue, and reconfirm the next centroid of its own cluster according to the next edge node queue, and continue to compare until the condition for stopping expansion is met;

[0078] The second comparison unit is used to compare the maximum distance between the nodes in the current edge node queue and the current centroid of its own cluster and the minimum distance between the nodes in the current edge node queue and the current centroid of other clusters, and obtain a second comparison result, and determine whether to replace the current centroid of its own cluster according to the second comparison result. If so, replace and obtain a new centroid of its own cluster, and re-execute the process of determining whether to expand the current edge node queue and replace the new centroid until the iteration termination condition is met.

[0079] In one embodiment, the first comparison unit comprises:

[0080] A first result acquisition unit is used to compare, for each cluster, the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the maximum distance from the nodes in the current edge node queue to the current centroids of other clusters, and if the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster is greater than the maximum distance from the nodes in the current edge node queue to the current centroids of other clusters, select a preset proportion of nodes from the remaining nodes in the node queue in order of arrangement as the next edge node queue;

[0081] A second confirmation unit, configured to reconfirm a next centroid of its own cluster according to the Euclidean distance from the node in the next edge node queue to the current centroid of its own cluster;

[0082] A continuing comparison unit is used to continue comparing the minimum distance from the nodes in the next edge node queue to the next centroid of its own cluster and the maximum distance from the nodes in the next edge node queue to the next centroid of other clusters, until the maximum distance from the nodes in the next edge node queue to the next centroid of its own cluster is less than the minimum distance from the nodes in the next edge node queue to the next centroid of other clusters, then stop expanding the edge node queue.

[0083] In one embodiment, the second comparison unit comprises:

[0084] A second result acquisition unit is used to compare the maximum distance from the node in the current edge node queue to the centroid of its own cluster and the minimum distance from the node in the current edge node queue to the centroid of other clusters, and if the maximum distance from the node in the current edge node queue to the centroid of its own cluster is less than the minimum distance to the centroid of other clusters, replace the current centroid of its own cluster and obtain a new centroid;

[0085] The re-execution unit is used to re-execute the process of determining whether to expand the current edge node queue and replace the new centroid until a preset number of iterations is reached or the final centroid of each cluster is determined.

[0086] In one embodiment, the text clustering device 900 further includes:

[0087] The calculation unit calculates the distance from all nodes in the current edge node queue to the current centroid of each cluster if the current edge node queue fails to meet the conditions for expanding the edge node queue and re-changing the current centroid, and divides each node into the nearest cluster according to the distance.

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

[0089] The above-mentioned text clustering device can be implemented in the form of a computer program. The computer program can be used in Fig.10 Runs on the computer device shown.

[0090] See also Fig.10 , Fig.10 1 is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device 1000 is a server, which may be an independent server or a server cluster composed of multiple servers.

[0091] See also Fig.10 The computer device 1000 includes a processor 1002 , a memory and a network interface 1005 connected via a system bus 1001 , wherein the memory may include a non-volatile storage medium 1003 and an internal memory 1004 .

[0092] The non-volatile storage medium 1003 may store an operating system 10031 and a computer program 10032. When the computer program 10032 is executed, the processor 1002 may execute a text clustering method.

[0093] The processor 1002 is used to provide computing and control capabilities to support the operation of the entire computer device 1000.

[0094] The internal memory 1004 provides an environment for the operation of the computer program 10032 in the non-volatile storage medium 1003 . When the computer program 10032 is executed by the processor 1002 , the processor 1002 can execute the text clustering method.

[0095] The network interface 1005 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device 1000 to which the solution of the present invention is applied. The specific computer device 1000 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0096] Those skilled in the art will understand that Fig.10 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Fig.10 The embodiments shown are consistent and will not be described again here.

[0097] It should be understood that in the embodiment of the present invention, the processor 1002 may be a central processing unit (CPU), and the processor 1002 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0098] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the text clustering method of the embodiment of the present invention is implemented.

[0099] The storage medium is a physical, non-transient storage medium, for example, it can be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, etc., which can store program codes.

[0100] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0101] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A text clustering method, characterized in that: include: Preprocessing the text sequence to be classified and obtaining a corresponding representation vector, and dividing the text sequence into different clusters according to the representation vector, wherein each text sequence corresponds to a node in the cluster; Determine the current centroid of each cluster, arrange all nodes in each cluster according to the distance from the current centroid of its own cluster to form a node queue, and select the current edge node queue from the node queue; For each cluster, executing the process of determining whether to expand the current edge node queue and replace the new centroid until the final edge node queue and the final centroid are determined; Specifically, it includes: comparing the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the maximum distance from the nodes in the current edge node queue to the centroids of other clusters, and obtaining a first comparison result, and judging whether to expand the current edge node queue according to the first comparison result, if yes, expanding the current edge node queue to obtain the next edge node queue, and reconfirming the next centroid of its own cluster according to the next edge node queue, and continuing the comparison until the condition for stopping expansion is met; otherwise, comparing the maximum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the minimum distance from the nodes in the current edge node queue to the current centroids of other clusters, and obtaining a second comparison result, judging whether to replace the current centroid of its own cluster according to the second comparison result, if yes, replacing and obtaining a new centroid of its own cluster, and re-executing the process of judging whether to expand the current edge node queue and replace the new centroid, until the iteration termination condition is met.

2. The text clustering method according to claim 1, characterized in that: The text sequence to be classified is preprocessed to obtain a corresponding representation vector, and the text sequence is divided into different clusters according to the representation vector, wherein each text sequence corresponds to a node in the cluster, including: Input the text sequence into a pre-trained model and output a corresponding representation vector; A clustering algorithm is used to classify the representation vectors, and initial centroids are randomly assigned so that the text sequences form different initial clusters, wherein each text sequence corresponds to a node in the cluster.

3. The text clustering method according to claim 1, characterized in that: The step of confirming the current centroid of each cluster, arranging all nodes in each cluster according to the distances from the current centroid of the cluster itself, and forming a node queue, and selecting a current edge node queue from the node queue includes: Reconfirm the current centroid of each cluster based on the Euclidean distance from all nodes in each cluster to the initial centroid of its own cluster; According to the distance from all nodes in each cluster to the current centroid of its own cluster, all nodes in its own cluster are arranged in a way that the farther the better and closer the nodes are, forming a node queue, and a preset proportion of nodes are selected from the node queue in the order of arrangement as the current edge node queue.

4. The text clustering method according to claim 1, characterized in that: The comparing the minimum distance between the nodes in the current edge node queue and the current centroid of the own cluster and the maximum distance between the nodes in the current edge node queue and the centroids of other clusters, and obtaining a first comparison result, and judging whether to expand the current edge node queue according to the first comparison result, and if so, expanding the current edge node queue to obtain the next edge node queue, and reconfirming the next centroid of the own cluster according to the next edge node queue, and continuing the comparison until the condition for stopping the expansion is met, including: For each cluster, compare the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the maximum distance from the nodes in the current edge node queue to the current centroids of other clusters; if the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster is greater than the maximum distance from the nodes in the current edge node queue to the current centroids of other clusters, divide the nodes in the current edge node queue into other clusters, and select a preset proportion of nodes from the remaining nodes in the node queue in order of arrangement as the next edge node queue; Reconfirming the next centroid of the own cluster according to the Euclidean distance from the node in the next edge node queue to the current centroid of the own cluster; Continue to compare the minimum distance from the nodes in the next edge node queue to the next centroid of its own cluster and the maximum distance from the nodes in the next edge node queue to the next centroid of other clusters until the maximum distance from the nodes in the next edge node queue to the next centroid of its own cluster is less than the minimum distance from the nodes in the next edge node queue to the next centroid of other clusters, then stop expanding the edge node queue.

5. The text clustering method according to claim 4, characterized in that: If not, compare the maximum distance between the nodes in the current edge node queue and the current centroid of the own cluster and the minimum distance between the nodes in the current edge node queue and the current centroids of other clusters, and obtain a second comparison result, and determine whether to replace the current centroid of the own cluster according to the second comparison result. If so, replace and obtain a new centroid of the own cluster, and re-execute the process of determining whether to expand the current edge node queue and replace the new centroid until the iteration termination condition is met, including: Compare the maximum distance from the node in the current edge node queue to the centroid of its own cluster and the minimum distance from the node in the current edge node queue to the centroids of other clusters. If the maximum distance from the node in the current edge node queue to the centroid of its own cluster is less than the minimum distance to the centroids of other clusters, replace the current centroid of its own cluster and obtain a new centroid. The process of determining whether to expand the current edge node queue and replace the new centroid is re-executed until a preset number of iterations is reached or the final centroid of each cluster is determined.

6. The text clustering method according to claim 1, characterized in that: Also includes: If the current edge node queue fails to meet the conditions for expanding the edge node queue and re-changing the current centroid, the distances from all nodes in the current edge node queue to the current centroid of each cluster are calculated, and each node is divided into the nearest cluster according to the distance.

7. A text clustering device, characterized in that: include: A preprocessing unit, used for preprocessing the text sequence to be classified and obtaining a corresponding representation vector, and dividing the text sequence into different clusters according to the representation vector, wherein each text sequence corresponds to a node in the cluster; A queue unit is used to confirm the current centroid of each cluster, arrange all nodes in each cluster according to the distance from the current centroid of its own cluster to form a node queue, and select the current edge node queue from the node queue; A judgment unit, configured to execute, for each cluster, a process of judging whether to expand the current edge node queue and replace the new centroid, until a final edge node queue and a final centroid are confirmed; Specifically, it includes: comparing the minimum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the maximum distance from the nodes in the current edge node queue to the centroids of other clusters, and obtaining a first comparison result, and judging whether to expand the current edge node queue according to the first comparison result, if yes, expanding the current edge node queue to obtain the next edge node queue, and reconfirming the next centroid of its own cluster according to the next edge node queue, and continuing the comparison until the condition for stopping expansion is met; otherwise, comparing the maximum distance from the nodes in the current edge node queue to the current centroid of its own cluster and the minimum distance from the nodes in the current edge node queue to the current centroids of other clusters, and obtaining a second comparison result, judging whether to replace the current centroid of its own cluster according to the second comparison result, if yes, replacing and obtaining a new centroid of its own cluster, and re-executing the process of judging whether to expand the current edge node queue and replace the new centroid, until the iteration termination condition is met.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the text clustering method according to any one of claims 1 to 6 is implemented.

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

Citation Information

Patent Citations

  • Method and device for detecting noise points

    CN106991436A

  • Wireless sensor network clustering method and system

    CN108990129A