A text classification method, device, equipment and storage medium

By constructing the Vino graph and identifying word node types, combined with the graph convolution neural network, the multi-dimensional semantic features in the text are extracted, solving the problem that local feature capture is difficult to obtain high-level information in the existing technology, and significantly improving text classification accuracy.

CN114091451BActive Publication Date: 2025-02-21华润数字科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111396144.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2025-02-21
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

The prior art mainly relies on the capture of local features in text classification, and it is difficult to obtain higher-level and more implicit information from the whole, resulting in limited accuracy of text classification.

Method used

By obtaining the collection of subject words in the text to be analyzed, the semantic distance between subject words and non-topic words is calculated, the Vino graph is constructed, the non-topic words are divided into the subject word grid with the nearest semantic distance, and the word node type is identified Calculate the semantic distance between word nodes, and finally classify the semantic distance input graph convolution neural network for text.

Benefits of technology

Through multi-dimensional extraction of semantic features, the accuracy of text classification is improved, the implicit connections between words can be captured more effectively, and the extraction ability of deep semantic features is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114091451B_ABST
    Figure CN114091451B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention belongs to the field of artificial intelligence, and in particular, relates to a text classification method, device, equipment and storage medium, wherein the method comprises: obtaining a text to be analyzed, segmenting the text to form a segmentation set, and obtaining the subject words of the text according to a subject model to form a subject word set; obtaining a word embedding vector of each word in the subject word set, reducing the dimension of the word embedding vector and mapping it to a plane, and constructing a Voronoi diagram according to the mapping points on the plane; calculating the semantic distance between non-subject words and subject words, and adding the non-subject words to the Voronoi diagram; identifying the word node type of each word in the Voronoi diagram, and calculating the semantic distance between the word nodes by a corresponding algorithm according to the word node type; inputting the semantic distance between the word nodes into a pre-constructed graph convolutional neural network output graph latent vector, and performing text classification according to the graph latent vector. The present invention improves the accuracy of text classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Text classification is a common task in the field of natural language processing. In recent years, from the traditional feature engineering + machine learning classification method, such as extracting features based on TF-IDF (term frequency-inverse document frequency) and then training machine learning classifiers, to the introduction of various deep learning methods based on CNN (convolutional neural network) and RNN (recurrent neural network) into text classification, such as fasttext, textCNN, TextRNN, etc. For example, in recent years, the emergence of pre-trained language models based on deep neural networks such as BERT (Bidirectional Encoder Representation Technology Based on Transformers) and ELMO (Embedding of Language Models), has greatly improved the accuracy of text classification.

[0003] However, the inventors found that the existing methods mainly focus on capturing local features, and the technical means to obtain higher-level and more implicit information as a whole are still limited. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to propose a text classification method, device, equipment and storage medium, which solves the problem of text classification based on capturing local features in the prior art, extracts semantic features from multiple dimensions, and improves the accuracy of text classification.

[0005] In order to solve the above technical problems, an embodiment of the present invention provides a text classification method, including: obtaining a text to be analyzed, segmenting the text to form a segmentation set, and obtaining the subject words of the text according to a topic model to form a subject word set; obtaining a word embedding vector for each word in the subject word set, reducing the dimension of the word embedding vector and mapping it to a plane, and constructing a Voronoi diagram according to the mapping points on the plane; calculating the semantic distance between non-subject words and the subject words, and adding the non-subject words to the Voronoi diagram according to the semantic distance; identifying the word node type of each word in the Voronoi diagram, and calculating the semantic distance between the word nodes according to the word node type through a corresponding algorithm; inputting the semantic distance between the word nodes into a pre-constructed graph convolutional neural network output graph latent vector, and performing text classification according to the graph latent vector.

[0006] Furthermore, the step of obtaining the word embedding vector of each word in the subject word set, reducing the dimension of the word embedding vector and mapping it onto a plane, and constructing a Voronoi diagram based on the mapping points on the plane includes: obtaining the word embedding vector of each word in the subject word set according to the word vector model; reducing the dimension of the word embedding vector of each word in the subject word set and mapping it onto a plane according to the t-random neighbor embedding method, and constructing a grid based on all the mapping points to form a Voronoi diagram.

[0007] Furthermore, the step of calculating the semantic distance between the non-topic words and the topic words and adding the non-topic words to the Voronoi diagram includes: forming a difference set based on the difference between the word segmentation set and the topic word set, calculating the semantic distance from each non-topic word in the difference set to each topic word in the topic word set, and dividing each non-topic word in the difference set into the grid of the Voronoi diagram where the nearest topic word is located according to the semantic distance.

[0008] Furthermore, the word node types include common word nodes and entity nodes; and identifying the word node type of each word in the Voronoi diagram includes: identifying the entity node through named entity recognition, and if it is not an entity node, determining it as a common word node.

[0009] Furthermore, the step of identifying the word node type of each word in the Voronoi diagram and calculating the semantic distance between the word nodes by a corresponding algorithm according to the word node type includes:

[0010] Determine whether the word node types of the two word nodes to be calculated are the same;

[0011] If the types are different, the cosine distance between the word embedding vector of the common word node and the word embedding vector of the entity node is calculated as the semantic distance between the two word nodes to be calculated;

[0012] If the types are the same, determine whether the word node is an ordinary node or an entity node. If it is an ordinary node, calculate the semantic distance between the word nodes according to the ordinary algorithm corresponding to the ordinary node. If it is an entity node, calculate the semantic distance between the word nodes according to the entity algorithm corresponding to the entity node.

[0013] Further, the step of determining whether the word node is a common node or an entity node, if it is a common node, calculating the semantic distance between the word nodes according to a common algorithm corresponding to the common node, and if it is an entity node, calculating the semantic distance between the word nodes according to an entity algorithm corresponding to the entity node, includes:

[0014] If the two word nodes to be calculated are both common word nodes, the positions of the two common word nodes to be calculated are determined, and the corresponding common algorithms are selected according to different positions to calculate the semantic distance between the word nodes;

[0015] If both word nodes to be calculated are entity nodes, the entity node E is calculated according to the following formula: i and E j The semantic distance between:

[0016]

[0017] in, is the level weight, sim(E i ,E j ) is the cosine similarity of the embedding vectors between entity nodes, ∑R Ei For entity node E i The sum of the embedding vectors of all connected edges, ∑R Ej For entity node E j The sum of the embedding vectors of all connected edges.

[0018] Furthermore, the step of determining the positions of the two common word nodes to be calculated and selecting corresponding common algorithms according to different positions to calculate the semantic distance between the word nodes includes: determining whether the positions of the two common word nodes to be calculated are in the same grid;

[0019] If they are in the same grid h k In the formula below, the word node w is calculated: i With w j Semantic distance between:

[0020]

[0021] If they are not in the same grid h k In the above formula, the common word node w is calculated as follows: i With w j The semantic distance between:

[0022]

[0023] Among them, Sum_word(h k ) is the total number of nodes in the grid, Sum_totalword is the total number of word nodes in the Voronoi graph, and cos(wi,wj) is w i With w j The cosine similarity between word embedding vectors.

[0024] In order to solve the above technical problems, an embodiment of the present invention also provides a text classification device, including: a first processing module, used to obtain a text to be analyzed, segment the text to form a segmentation set, and obtain the subject words of the text according to a topic model to form a subject word set; a second processing module, used to obtain a word embedding vector of each word in the subject word set, reduce the dimension of the word embedding vector and map it to a plane, and construct a Voronoi diagram according to the mapping points on the plane; a first calculation module, used to calculate the semantic distance between non-subject words and the subject words, and add the non-subject words to the Voronoi diagram according to the semantic distance; a second calculation module, used to identify the word node type of each word in the Voronoi diagram, and calculate the semantic distance between the word nodes according to the word node type through a corresponding algorithm; a text classification module, used to input the semantic distance between the word nodes into a pre-constructed graph convolutional neural network output graph latent vector, and perform text classification according to the graph latent vector.

[0025] In order to solve the above technical problems, an embodiment of the present invention further provides a text classification device, which includes a processor, a memory, and a text classification program stored in the memory. When the text classification program is executed by the processor, the steps of the text classification method as described above are implemented.

[0026] In order to solve the above technical problem, an embodiment of the present invention further provides a computer-readable storage medium, on which a text classification program is stored. When the text classification program is executed by a processor, the steps of the text classification method as described above are implemented.

[0027] Compared with the prior art, the embodiments of the present invention mainly have the following beneficial effects: by distinguishing subject words, and mapping the word embedding vectors of subject words to a plane to construct a Voronoi diagram, calculating the semantic distance between other words and subject words, and dividing other words into the grid of subject words with the closest semantic distance in the Voronoi diagram, the implicit connection between words is reflected in the first dimension; then, by identifying the word node type of each word in the Voronoi diagram, and calculating the semantic distance between word nodes according to the word node type, the implicit connection between words is reflected in the second dimension; further, the semantic distance between word nodes is input into the graph convolutional neural network to output the graph implicit vector, and text classification is performed according to the graph implicit vector. That is, the embodiments of the present invention extract different semantic features through multiple dimensions, and then use the graph convolutional neural network to extract deep semantic features, so that the text classification effect is more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the scheme in the present invention, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0029] Figure 1 A flowchart of an embodiment of a text classification method according to the present invention;

[0030] Figure 2 is a schematic diagram of an embodiment of constructing a Voronoi diagram according to the present invention;

[0031] Figure 3 is a structural schematic diagram of an embodiment of a text classification device according to the present invention;

[0032] Figure 4 FIG. 4 is a schematic diagram of the structure of an embodiment of a text classification device according to the present invention. DETAILED DESCRIPTION

[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present invention; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention; the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present invention or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0034] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0035] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.

[0036] The embodiment of the present invention proposes a text classification method, apparatus, device and storage medium. The text classification method of the embodiment of the present invention is generally executed by a terminal device, which can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop portable computers and desktop computers, etc.

[0037] like Figure 1 FIG. 1 is a flowchart of an embodiment of a text classification method according to the present invention. The text classification method comprises the following steps:

[0038] Step 101, obtaining a text to be analyzed, segmenting the text to form a segmentation set, and obtaining subject words of the text according to a subject model to form a subject word set.

[0039] In the embodiment of the present invention, a text to be analyzed is obtained, and if there is more than one text, all the texts are concatenated to form a new text to be analyzed.

[0040] According to a certain strategy, the analyzed text is segmented to form a segmentation set S w ={w1,w2,...,w m}. The selected word segmentation strategy can be dictionary-based word segmentation, for example, first divide the sentence into words according to the dictionary, and then find the best combination of words; the algorithm used can be the maximum matching word segmentation algorithm, the shortest path word segmentation algorithm, the word segmentation algorithm based on the n-gram model, etc. It can also be character-based word segmentation, for example, word formation by characters, first divide the sentence into individual characters, and then combine the characters into words to find the optimal segmentation strategy, and it can also be converted into sequence labeling; the algorithm used can be a generative model word segmentation algorithm, a discriminative model word segmentation algorithm, a neural network word segmentation algorithm, etc. The above various word segmentation algorithms are only examples, but are not limited to them.

[0041] According to the topic model, a topic word set S reflecting the central idea of ​​the text is obtained. wl ={w l1 ,w l2 ,...,w ln}, wherein the topic model can adopt Latent Dirichlet allocation (LDA). LDA is a bag-of-words model, that is, it considers that a document is a set of words, and there is no order or precedence between words. A document can contain multiple topics, and each word in the document is generated by one of the topics.

[0042] Step 102, obtaining a word embedding vector of each word in the subject word set, reducing the dimension of the word embedding vector and mapping it onto a plane, and constructing a Voronoi diagram based on the mapping points on the plane.

[0043] In an embodiment of the present invention, a word embedding vector of each word in the subject word set is obtained according to a word embedding model. The word embedding model can use the word2vec word embedding vector open sourced by Google, or randomly initialized. The word2vec open sourced by Google is a word embedding tool that can generate word embeddings, through which the similarity between words can be measured.

[0044] T-SNE (t-distributed stochastic neighbor embedding) is used to reduce the dimension of the word embedding vector of each word in the topic word set and map it to a 2-D plane for qualitative visualization observation. The effectiveness can be verified intuitively through visualization. Figure 2 As shown, the mapping point Xi mapped onto the plane represents a word, and one point corresponds to one word. A Voronoi diagram is constructed based on all the mapping points, and the area where each mapping point Xi is located in the diagram is defined as the grid where Xi is located.

[0045] Step 103, calculating the semantic distance between the non-topic word and the topic word, and adding the non-topic word to the Voronoi diagram according to the semantic distance.

[0046] In the embodiment of the present invention, a difference set is formed according to the difference set between the segmentation set and the subject word set, and the difference set is defined as is the word segmentation set S w With the subject word set S wl The difference of The words in the word segmentation set excluding the subject word set, that is, non-subject words. Set the grid where each subject word is located in the Voronoi diagram as hi. For each non-topic word in the set S, the cosine similarity between word embedding vectors can be used to calculate the non-topic word to the topic word set S wl The semantic distance of the topic words in the difference set is thus divided into each non-topic word in the difference set to the topic word w that is closest to it. liThe grid where the word is located. Set the i-th word w in the word set li The grid is h i .

[0047] Step 104, identifying the word node type of each word in the Voronoi diagram, and calculating the semantic distance between the word nodes by a corresponding algorithm according to the word node type.

[0048] In the embodiment of the present invention, the word node types include common word nodes and entity nodes, and whether it is an entity node can be identified by Named Entity Recognition (NER). If it is not an entity node, it is determined to be a common word node.

[0049] The semantic distance between word nodes is calculated according to the word node type by using a corresponding algorithm, specifically including: determining whether the word node types of two word nodes to be calculated are the same; if the types are different, calculating the cosine distance between the word embedding vector of the ordinary word node and the word embedding vector of the entity node as the semantic distance between the two word nodes to be calculated; if the types are the same, determining whether the word node is an ordinary node or an entity node, if it is an ordinary node, calculating the semantic distance between word nodes according to an ordinary algorithm corresponding to an ordinary node, and if it is an entity node, calculating the semantic distance between word nodes according to an entity algorithm corresponding to an entity node.

[0050] (1) For common word nodes, the corresponding word embedding vector is obtained by outputting a pre-trained language model, such as Bert. When calculating the semantic distance between common word nodes, it is also necessary to first identify whether the common word nodes are in the same network.

[0051] If the two word nodes to be calculated are both common word nodes w i With w j and are in the same grid h k , let the total number of nodes in the grid be Sum_word(h k ), the total number of word nodes is Sum_totalword, w i With w j The cosine similarity of the word embedding vectors is cos(wi,wj), so w is calculated according to the following formula: i With w j Semantic distance between:

[0052]

[0053] If the two word nodes to be calculated are both common word nodes w i With w j But not in the same grid h k, then calculate w according to the following formula i With w j Semantic distance between:

[0054]

[0055] (2) If both word nodes to be calculated are entity nodes, according to the entity nodes in the knowledge graph KG mapping The cosine similarity of the embedding vector of the level and entity node in the entity node is calculated by the following formula: i and E j The semantic distance Ds(E i ,E j ):

[0056]

[0057] In the above formula, is the level weight, sim(E i ,E j ) is the cosine similarity of the embedding vectors between entity nodes, ∑R Ei For entity node E i The sum of the embedding vectors of all connected edges, ∑R Ej For entity node E j The sum of the embedding vectors of all connected edges.

[0058] For example, entity node E at the same level i With E j of is defined as 1, such as apples and pears, Beijing and Shanghai; while for entity nodes such as cars and tires, which have top-down or bottom-up relationships, entity node E i For its upper / lower layer entity node E i of is 1, the next layer above / below is the pre-specified coefficient λ, and so on n For example, if λ = 0.8, the transmission shaft is is 0.8, for cars It is 0.64.

[0059] Among them, the knowledge graph is a structured semantic knowledge base used to describe concepts and their relationships in the physical world in symbolic form. Its basic components are Entity-Relationship-Entity Triples, entities and their related attribute-value pairs, entities are connected through relationships, forming a network of knowledge structures. Through knowledge graphs, the Web can be transformed from web page links to concept links, supporting users to search by topic rather than by string.

[0060] (3) If the two word nodes to be calculated are a common word node and an entity node, the semantic distance between them is the cosine distance between the word embedding vectors of the common word node and the entity node.

[0061] Step 105: input the semantic distance between the word nodes into a pre-built graph convolutional neural network to output a graph latent vector, and perform text classification according to the graph latent vector.

[0062] In the embodiment of the present invention, a graph convolutional neural network (GCN) is pre-constructed. An adjacency semantic distance matrix is ​​set in the graph convolutional neural network, and the elements in the adjacency semantic distance matrix are the semantic distances between word nodes i and j. The number of layers of the GCN can be set by oneself. Any graph convolutional layer is a nonlinear function: H l+1 =f(H l , A), where H 0 =X is the input of the first layer, X∈R N*D , N is the number of nodes in the graph, D is the dimension of the feature vector of each node, A is the adjacency matrix, and the difference between different models lies in the different implementations of the function f, where f is the σ nonlinear activation function.

[0063] The calculated semantic distances between all word nodes are input into the graph convolutional neural network, and the graph latent vector is output. The Softmax function is used for classification based on the graph latent vector, and the cross entropy function is used as the loss function.

[0064] In an embodiment of the present invention, by distinguishing subject words, and mapping the word embedding vector of the subject word to a plane to construct a Voronoi diagram, the semantic distance between other words and the subject word is calculated, and other words are divided into the grid of the subject word with the closest semantic distance in the Voronoi diagram, so as to reflect the implicit connection between words in the first dimension; then, by identifying the word node type of each word in the Voronoi diagram, and calculating the semantic distance between the word nodes according to the word node type, the implicit connection between words in the second dimension is reflected; further, the semantic distance between the word nodes is input into the graph convolutional neural network to output the graph implicit vector, and text classification is performed according to the graph implicit vector. That is, the embodiment of the present invention extracts different semantic features through multiple dimensions, and then uses the graph convolutional neural network to extract deep semantic features, so that the text classification effect is more accurate.

[0065] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0066] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0067] Further references Figure 3 , as a response to the above Figure 1 In order to realize the method shown in the figure, the present invention provides an embodiment of a text classification device 300, which is similar to Figure 1 The method embodiment shown corresponds to the embodiment shown in FIG. Figure 3 As shown, the embodiment of the present invention further provides a text classification device 300, including:

[0068] The first processing module 31 is used to obtain a text to be analyzed, segment the text to form a segmentation set, and obtain the subject words of the text according to the subject model to form a subject word set;

[0069] The second processing module 32 is used to obtain a word embedding vector of each word in the subject word set, reduce the dimension of the word embedding vector and map it onto a plane, and construct a Voronoi diagram according to the mapping points on the plane;

[0070] A first calculation module 33, used for calculating the semantic distance between the non-topic word and the topic word, and adding the non-topic word to the Voronoi diagram according to the semantic distance;

[0071] A second calculation module 34 is used to identify the word node type of each word in the Voronoi diagram, and calculate the semantic distance between the word nodes by a corresponding algorithm according to the word node type;

[0072] The text classification module 35 is used to input the semantic distance between the word nodes into a pre-built graph convolutional neural network output graph latent vector, and perform text classification according to the graph latent vector.

[0073] Among them, the second processing module includes an acquisition submodule and a graphics generation submodule, the acquisition submodule is used to obtain the word embedding vector of each word in the subject word set according to the word vector model; the graphics generation submodule is used to reduce the dimension of the word embedding vector of each word in the subject word set to a plane according to the t-random neighbor embedding method, and construct a grid based on all the mapping points to form a Voronoi diagram.

[0074] The first calculation module includes a set forming submodule, a first calculation submodule and an allocation submodule. The set forming module is used to form a difference set according to the difference between the word segmentation set and the subject word set; the calculation submodule is used to calculate the semantic distance from each non-subject word in the difference set to each subject word in the subject word set; the allocation submodule is used to divide each non-subject word in the difference set into the grid of the Voronoi diagram where the closest subject word is located according to the semantic distance.

[0075] The second calculation module includes an identification submodule and a second calculation submodule, the identification submodule is used to identify the entity node through named entity recognition, if it is not an entity node, it is determined to be an ordinary word node; the second calculation submodule is used to: determine whether the word node type of the two word nodes to be calculated is the same; if the types are different, calculate the cosine distance between the word embedding vector of the ordinary word node and the word embedding vector of the entity node as the semantic distance between the two word nodes to be calculated; if the types are the same, determine whether the word node is an ordinary node or an entity node, if it is an ordinary node, calculate the semantic distance between the word nodes according to the ordinary algorithm corresponding to the ordinary node, if it is an entity node, calculate the semantic distance between the word nodes according to the entity algorithm corresponding to the entity node.

[0076] If the two word nodes to be calculated are both common word nodes, the positions of the two common word nodes to be calculated are determined, and the corresponding common algorithms are selected according to different positions to calculate the semantic distance between the word nodes;

[0077] If both word nodes to be calculated are entity nodes, the entity node E is calculated according to the following formula: i and E j The semantic distance between:

[0078]

[0079] in, is the level weight, sim(E i ,Ej ) is the cosine similarity of the embedding vectors between entity nodes, ∑R Ei For entity node E i The sum of the embedding vectors of all connected edges, ∑R Ej For entity node E j The sum of the embedding vectors of all connected edges;

[0080] The steps of determining the positions of two common word nodes to be calculated and selecting corresponding common algorithms according to different positions to calculate the semantic distance between the word nodes include: judging whether the positions of the two common word nodes to be calculated are in the same grid; if the two word nodes to be calculated are in the same grid hk, calculating the word node w according to the following formula i With w j The semantic distance between:

[0081]

[0082] If the two word nodes to be calculated are not in the same grid hk, the common word node w is calculated according to the following formula i With w j The semantic distance between:

[0083]

[0084] Among them, Sum_word(h k ) is the total number of nodes in the grid, Sum_totalword is the total number of word nodes in the Voronoi graph, and cos(wi,wj) is w i With w j The cosine similarity between word embedding vectors.

[0085] The processing methods, calculation methods and classification methods involved in each module can refer to the various embodiments of the text classification method described above in the text of the present invention, and will not be repeated here.

[0086] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0087] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0088] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0089] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the text classification method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0090] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the text classification method.

[0091] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0092] The embodiment of the present invention further provides a computer-readable storage medium, on which a text classification program is stored. When the text classification program is executed by a processor, the steps of the text classification method described above are implemented. The method implemented when the text classification program is executed can refer to the various embodiments of the text classification method of the present invention, and will not be repeated here.

[0093] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0094] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific embodiments, or to perform equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of the present invention, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.

Claims

1. A text classification method, characterized in that: The steps include: Acquire a text to be analyzed, segment the text to form a segmentation set, and acquire subject words of the text according to a subject model to form a subject word set; Obtain a word embedding vector for each word in the subject word set, reduce the dimension of the word embedding vector and map it onto a plane, and construct a Voronoi diagram based on the mapping points on the plane; Calculating the semantic distance between the non-topic word and the topic word, and adding the non-topic word to the Voronoi diagram according to the semantic distance; Identify the word node type of each word in the Voronoi diagram, and calculate the semantic distance between the word nodes by a corresponding algorithm according to the word node type, wherein the word node type includes a common word node and an entity node; Inputting the semantic distance between the word nodes into a pre-built graph convolutional neural network to output a graph latent vector, and performing text classification according to the graph latent vector; The step of identifying the word node type of each word in the Voronoi graph specifically comprises the following steps: Identify entity nodes through named entity recognition. If they are not entity nodes, they are determined to be common word nodes. The step of calculating the semantic distance between word nodes by a corresponding algorithm according to the word node type comprises: Determine whether the word node types of the two word nodes to be calculated are the same; If the types are different, the cosine distance between the word embedding vector of the common word node and the word embedding vector of the entity node is calculated as the semantic distance between the two word nodes to be calculated; If the types are the same, determine whether the word node is an ordinary node or an entity node. If it is an ordinary node, calculate the semantic distance between the word nodes according to the ordinary algorithm corresponding to the ordinary node. If it is an entity node, calculate the semantic distance between the word nodes according to the entity algorithm corresponding to the entity node.

2. The text classification method according to claim 1, characterized in that: The step of obtaining a word embedding vector for each word in the subject word set, reducing the dimension of the word embedding vector and mapping it onto a plane, and constructing a Voronoi diagram according to the mapping points on the plane includes: According to the word vector model, a word embedding vector of each word in the subject word set is obtained; According to the t-random neighbor embedding method, the word embedding vector of each word in the topic word set is reduced in dimension and mapped to a plane, and a grid is constructed based on all the mapping points to form a Voronoi diagram.

3. The text classification method according to claim 2, characterized in that: The step of calculating the semantic distance between the non-topic word and the topic word, and adding the non-topic word to the Voronoi diagram according to the semantic distance comprises: A difference set is formed according to the difference between the word set and the subject word set, a semantic distance from each non-subject word in the difference set to each subject word in the subject word set is calculated, and each non-subject word in the difference set is divided into a grid of the Voronoi diagram where the nearest subject word is located according to the semantic distance.

4. The text classification method according to claim 1, characterized in that: The step of determining whether the word node is a common node or an entity node, and if it is a common node, calculating the semantic distance between the word nodes according to a common algorithm corresponding to the common node, and if it is an entity node, calculating the semantic distance between the word nodes according to an entity algorithm corresponding to the entity node, comprises: If the two word nodes to be calculated are both common word nodes, the positions of the two common word nodes to be calculated are determined, and the corresponding common algorithms are selected according to different positions to calculate the semantic distance between the word nodes; If both word nodes to be calculated are entity nodes, the entity node E is calculated according to the following formula: i and E j The semantic distance between: in, is the level weight, sim(E i ,E j ) is the cosine similarity of the embedding vectors between entity nodes, ∑R Ei For entity node E i The sum of the embedding vectors of all connected edges, ∑R Ej For entity node E j The sum of the embedding vectors of all connected edges.

5. The text classification method according to claim 1, characterized in that: The step of determining the positions of two common word nodes to be calculated, and selecting corresponding common algorithms according to different positions to calculate the semantic distance between the word nodes includes: Determine whether the positions of the two common word nodes to be calculated are in the same grid; If they are in the same grid h k In the formula below, the word node w is calculated: i With w j The semantic distance between: If they are not in the same grid h k In the above formula, the common word node w is calculated as follows: i With w j The semantic distance between: Among them, Sum_word(h k ) is the total number of nodes in the grid, Sum_totalword is the total number of word nodes in the Voronoi graph, and cos(wi,wj) is w i With w j The cosine similarity between word embedding vectors.

6. A text classification device, characterized in that: include: The first processing module is used to obtain a text to be analyzed, segment the text to form a segmentation set, and obtain the subject words of the text according to the subject model to form a subject word set; A second processing module is used to obtain a word embedding vector of each word in the subject word set, reduce the dimension of the word embedding vector and map it onto a plane, and construct a Voronoi diagram according to the mapping points on the plane; A first calculation module, used for calculating the semantic distance between the non-topic word and the topic word, and adding the non-topic word to the Voronoi diagram according to the semantic distance; A second calculation module is used to identify the word node type of each word in the Voronoi diagram, and calculate the semantic distance between the word nodes by a corresponding algorithm according to the word node type, wherein the word node type includes a common word node and an entity node; A text classification module, used for inputting the semantic distance between the word nodes into a pre-built graph convolutional neural network output graph latent vector, and performing text classification according to the graph latent vector; The second calculation module includes: an identification submodule, wherein: The recognition submodule is used to recognize an entity node through named entity recognition, and if it is not an entity node, it is determined to be a common word node; The second calculation module further includes: a second calculation submodule, wherein: The second calculation submodule is used to determine whether the word node types of the two word nodes to be calculated are the same; if the types are different, the cosine distance between the word embedding vector of the ordinary word node and the word embedding vector of the entity node is calculated as the semantic distance between the two word nodes to be calculated; if the types are the same, it is determined whether the word node is an ordinary node or an entity node. If it is an ordinary node, the semantic distance between the word nodes is calculated according to the ordinary algorithm corresponding to the ordinary node. If it is an entity node, the semantic distance between the word nodes is calculated according to the entity algorithm corresponding to the entity node.

7. A text classification device, characterized in that: The text classification device comprises a processor, a memory and a text classification program stored in the memory. When the text classification program is executed by the processor, the steps of the text classification method according to any one of claims 1 to 5 are implemented.

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

Citation Information

Patent Citations

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

    CN112818121A

  • Training sample masking method and device based on Voronoi diagram and related equipment

    CN113191158A

  • Combining semantic relationship information with entities and non-entities for predictive analytics in a cognitive system

    US20190340294A1