Text classification method, device and electronic device

By extracting target keywords in text and generating feature vectors, combined with preset neural networks, the problem of limited application scope of existing text classification methods is solved, and text classification is implemented suitable for a variety of business scenarios is improved, and the flexibility and efficiency of the method are improved.

CN112765357BActive Publication Date: 2025-04-25LYNXI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110164085.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-05
Publication Date
2025-04-25
Estimated Expiration
2041-02-05

AI Technical Summary

Technical Problem

The scope of application of existing text classification methods is limited, and it is difficult to adapt to text classification needs in different business scenarios.

Method used

By extracting the target keywords in the pending text, and determining the target vocabulary nodes matching the target keywords from the preset knowledge graph, generating feature vectors based on the target correlation coefficient, and inputting them into the preset neural network to determine the text classification results.

Benefits of technology

It has improved the scope of application of text classification methods, enabled it to be applicable to text classification in many different business scenarios, simplified the difficulty of obtaining training samples, and realized flexible text classification through the adjustment of knowledge graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112765357B_ABST
    Figure CN112765357B_ABST
Patent Text Reader

Abstract

The present application discloses a text classification method, device and electronic device, which belongs to the field of computer technology. Among them, the text classification method includes: extracting target keywords from the text to be processed; determining the target vocabulary node matching the target keyword from the preset knowledge graph; generating a first feature vector according to the target correlation coefficient in the preset knowledge graph, wherein the preset knowledge graph also includes a keyword node, and the target correlation coefficient includes the correlation coefficient between the target vocabulary node and the keyword node; based on the preset neural network and the first feature vector, determining the classification result of the text to be processed. The text classification method provided in the embodiment of the present application can be applied to text classification in a variety of business scenarios and has good applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a text classification method, device and electronic device. Background Art

[0002] Text classification is a typical natural language processing task. Through a pre-trained text classification model, we can predict the probability that the text to be classified belongs to each specific category under a specific classification system, and classify the text into a specific category with a higher probability.

[0003] In related technologies, algorithm models such as Bi-directional Long Short-Term Memory (Bi-LSTM) and Bidirectional Encoder Representation from Transformers (BERT) are often used to classify specific texts. These methods are based on deep learning technology and require a large number of text data sets associated with the corresponding text classification results to train the neural network in advance. Only then can the neural network be used to analyze the classification results of new texts.

[0004] However, in the field of Natural Language Processing (NLP) technology, training data sets are closely related to the application business field, making it difficult to determine a universal training data set such as ImageNet (a computer vision system recognition project, the largest database for image recognition in the world) in Computer Vision (CV). This limits the application of deep learning-based algorithms such as Bi-LSTM and BERT in text classification.

[0005] It can be seen from this that the text classification method in the related art has the defect of limited scope of application. Summary of the invention

[0006] The purpose of the embodiments of the present application is to provide a text classification method, device and electronic device, which can improve the scope of application of the text classification method.

[0007] In order to solve the above technical problems, this application is implemented as follows:

[0008] In a first aspect, an embodiment of the present application provides a text classification method, the method comprising:

[0009] Extract target keywords from the text to be processed;

[0010] Determine a target vocabulary node matching the target keyword from a preset knowledge graph;

[0011] Generate a first feature vector according to a target correlation coefficient in the preset knowledge graph, wherein the preset knowledge graph also includes a keyword node, and the target correlation coefficient includes a correlation coefficient between the target vocabulary node and the keyword node;

[0012] Based on the preset neural network and the first feature vector, a classification result of the text to be processed is determined.

[0013] In a second aspect, an embodiment of the present application provides a text classification device, the device comprising:

[0014] An extraction module, used to extract target keywords from the text to be processed;

[0015] A matching module, used to determine a target vocabulary node matching the target keyword from a preset knowledge graph;

[0016] A generating module, configured to generate a first feature vector according to a target correlation coefficient in the preset knowledge graph, wherein the preset knowledge graph further includes a keyword node, and the target correlation coefficient includes a correlation coefficient between the target vocabulary node and the keyword node;

[0017] The first determination module is used to determine the classification result of the text to be processed based on a preset neural network and the first feature vector.

[0018] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0020] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0021] In an embodiment of the present application, by extracting the target keyword in the text to be processed, the semantics of the text to be processed is simply represented by the target keyword, and then a first feature vector is generated according to the correlation coefficient between the target keyword and each keyword node in the preset knowledge graph, so that the feature description of the text to be processed is input into the preset neural network, and the classification result of the text feature of the text to be processed can be obtained. In view of the fact that the preset neural network only needs to derive which classification it belongs to among multiple preset text classifications according to the feature description of the above-mentioned text to be processed, so that the preset neural network is based on the shallow learning technology route, that is, in the training stage of the preset neural network, only a small amount of training samples are needed to train the above-mentioned preset neural network, which can simplify the difficulty of obtaining training samples; in addition, for text classification in different business scenarios, the preset knowledge graph can be adjusted accordingly according to the semantic features in each business scenario, and the text in each business scenario is respectively input into the corresponding preset knowledge graph, and then the obtained feature vectors are respectively input into the preset neural network, that is, the preset neural network can be applied to text classification in multiple different business scenarios to improve the scope of application of text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a flowchart of a text classification method provided in an embodiment of the present application;

[0023] Figure 2 It is a schematic diagram of a preset knowledge graph in a text classification method provided in an embodiment of the present application;

[0024] Figure 3 is a schematic diagram of a preset neural network in a text classification method provided in an embodiment of the present application;

[0025] Figure 4 is a structural diagram of a text classification device provided in an embodiment of the present application;

[0026] Figure 5 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0028] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0029] The text classification method, text classification device, electronic device, and computer-readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0030] See also Figure 1 , is a flowchart of a text classification method provided in an embodiment of the present application, such as Figure 1 As shown, the text classification method may include the following steps:

[0031] Step 101: extract target keywords from the text to be processed.

[0032] In a specific implementation, the above-mentioned extraction of target keywords in the text to be processed may be processing the text to be processed such as word segmentation, removal of stop words and part-of-speech tagging, so as to retain the keywords that carry clear semantics in the text to be processed, that is, the above-mentioned target keywords may be the keywords that carry clear semantics in the text to be processed.

[0033] Step 102: Determine a target vocabulary node that matches the target keyword from a preset knowledge graph.

[0034] In this step, the above-mentioned determination of the target vocabulary node matching the target keyword from the preset knowledge graph can be understood as: searching the preset knowledge graph for the same vocabulary as the target keyword or the vocabulary whose similarity is greater than or equal to the threshold, so as to determine that the node associated with the vocabulary is the target vocabulary node.

[0035] In implementation, a plurality of keyword nodes and a plurality of preset vocabulary nodes may be pre-set in the above-mentioned preset knowledge graph, each keyword node has an associated first vocabulary, and each preset vocabulary node has an associated second vocabulary. In implementation, the above-mentioned first vocabulary may be predetermined according to the business relationship in the business scenario in which the text to be processed is located, and it remains unchanged in the preset knowledge graph. The above-mentioned second vocabulary may be modified in the preset knowledge graph by adding, deleting, etc., so as to improve or update the vocabulary in the preset knowledge graph according to the actual situation of the business scenario.

[0036] In addition, since the semantics expressed by different words may be the same or similar, similar words in the above-mentioned preset knowledge graph have a correlation coefficient greater than 0.

[0037] As an optional implementation, the method further includes:

[0038] Add the target vocabulary node to the preset knowledge graph;

[0039] Determine the correlation coefficient between the nodes in the preset knowledge graph.

[0040] In implementation, the preset knowledge graph is pre-established according to the business scenario of the text to be processed. The establishment process of the preset knowledge graph includes the following steps:

[0041] Step 1: Generate N keyword nodes.

[0042] The above N is an integer greater than 0, for example, 100, 200, etc., and is not specifically limited here.

[0043] In addition, the number N and content of the keyword nodes are predetermined according to the business relationship in the business scenario of the text to be processed, and remain unchanged in the subsequent use process (for example: Figure 2 Keywords 1 to N) shown in .

[0044] Step 2: Add new vocabulary nodes to the knowledge graph.

[0045] In implementation, the new vocabulary node may be a vocabulary added by a user, or a common vocabulary in a business scenario where the text to be processed is located.

[0046] Step three: Generate a correlation coefficient between the new vocabulary node and the m existing nodes in the preset knowledge graph.

[0047] Among them, the above m can be equal to the sum of existing keyword nodes and existing vocabulary nodes in the preset knowledge graph.

[0048] In implementation, the determining of the correlation coefficient between the nodes in the preset knowledge graph includes:

[0049] The correlation coefficient between the nodes in the preset knowledge graph is determined according to a preset relationship function, wherein the preset relationship function is associated with the business scenario corresponding to the text to be processed.

[0050] Specifically, a relationship function can be used to calculate the correlation coefficient between the new vocabulary node and the m existing nodes in the preset knowledge graph, and the relationship function can be determined based on the business relationship in the business scenario corresponding to the text to be processed. For example: the same vocabulary has different meanings in different industries. Therefore, the relationship functions corresponding to different industries also need to be adjusted accordingly. The specific calculation method of the relationship function is not specifically limited here.

[0051] In implementation, the value of the above correlation coefficient is between 0 and 1, and the closer the new vocabulary associated with the new vocabulary node is to the existing vocabulary concept in the preset knowledge graph, the greater the value of the correlation coefficient between the two.

[0052] In actual applications, when it is necessary to classify the text to be processed in different business scenarios, the keyword nodes, vocabulary nodes, relationship functions, etc. in the preset knowledge graph can be adjusted accordingly. For example, new vocabulary can be added to make the preset knowledge graph more compatible with the business scenario corresponding to the text to be processed.

[0053] Furthermore, after determining the correlation coefficients between the nodes in the preset knowledge graph, the method further includes:

[0054] Display the above preset knowledge graph.

[0055] In implementation, the above-mentioned display of the preset knowledge graph may specifically include: highlighting the target vocabulary node in the preset knowledge graph, and the shortest path between the target vocabulary node and each keyword node.

[0056] In this way, the user can intuitively view the specific process of feature description in the text to be processed through the above preset knowledge graph. Compared with the prior art, which uses the neural network as a "black box" to infer the classification of the text to be processed, in the embodiment of the present application, the reasoning process of feature description is explained to the user through the above preset knowledge graph, so that the text classification method provided by the embodiment of the present application has a causal relationship that can be understood by humans.

[0057] Step 103: Generate a first feature vector according to a target correlation coefficient in the preset knowledge graph, wherein the preset knowledge graph also includes a keyword node, and the target correlation coefficient includes a correlation coefficient between the target vocabulary node and the keyword node.

[0058] In implementation, in the preset knowledge graph, the path between the target vocabulary node and the keyword node may include other vocabulary nodes. At this time, the correlation coefficient between the target vocabulary node and the keyword node may include: the correlation coefficient between the target vocabulary node and the other vocabulary node, the correlation coefficient between any adjacent nodes in the other vocabulary nodes, and the correlation coefficient between the nodes adjacent to the keyword node in the other vocabulary nodes and the keyword node.

[0059] For example: Figure 2 As shown, assuming that the target vocabulary node is associated with vocabulary 12, the above target correlation coefficients include: the correlation coefficient between vocabulary 12 and vocabulary 6 (0.25) and the correlation coefficient between vocabulary 6 and keyword 3 (0.87).

[0060] It should be noted that, in implementation, there may be multiple paths between the target vocabulary node and the keyword node, for example: Figure 2 As shown, there are two paths from word 8 to keyword 1, one of which is: word 8-word 1-keyword 1, and the other is: word 8-word 2-keyword 1. And the correlation coefficients on different paths are often different. In implementation, one path can be selected from the multiple paths to generate the first feature vector according to the correlation coefficient on the path, while the correlation coefficients on other paths are not considered, so that the calculation amount of feature description can be reduced.

[0061] As an optional implementation manner, generating a first feature vector according to a target correlation coefficient in the preset knowledge graph includes:

[0062] According to the correlation coefficients between the nodes in the preset knowledge graph, the shortest path between the target vocabulary node and each keyword node is determined, wherein the shortest path means that the target vocabulary node passes through the least vocabulary nodes from the keyword node;

[0063] Based on the target correlation coefficient included in the shortest path, an N-dimensional feature vector is generated, wherein the number of keyword nodes included in the preset knowledge graph is N, and the N-dimensional feature vector includes N elements corresponding to the N keyword nodes one by one;

[0064] Normalizing the N elements in the N-dimensional feature vector to obtain a first feature vector.

[0065] In a specific implementation, the above-mentioned generation of an N-dimensional feature vector based on the correlation coefficients on the shortest paths from the target vocabulary node to each keyword node can be that the sum of the correlation coefficients on the shortest paths from the target vocabulary node to the target keyword node is used as the value of the element corresponding to the target keyword node in the N-dimensional feature vector. In this way, by calculating the sum of the correlation coefficients on the shortest paths from the target vocabulary node to each keyword node, the value of each element in the N-dimensional feature vector can be determined, and the N-dimensional feature vector is obtained.

[0066] It should be noted that there can be multiple paths from each word to the keyword in the preset knowledge graph. In this implementation, the value of the element in the feature vector is determined only based on the correlation coefficient on the shortest path (i.e., the path with the best number of hops or the least number of words). Figure 2 As shown, there are three paths from vocabulary 10 to keyword 2, namely: vocabulary 10-vocabulary 3-keyword 2; vocabulary 10-vocabulary 3-vocabulary 11-vocabulary 4-keyword 2; vocabulary 10-vocabulary 3-vocabulary 11-vocabulary 5-keyword 2. At this time, only the correlation coefficients of 0.35 and 0.91 on the path vocabulary 10-vocabulary 3-keyword 2 are selected to calculate the value of the element corresponding to keyword 2 in the first eigenvector.

[0067] In implementation, given that the greater the number of correlation coefficients on the path, the greater the value of the element obtained by summing the correlation coefficients on the path, for example: Figure 2 As shown, assuming that the target vocabulary node includes the node corresponding to vocabulary 8 and the node corresponding to vocabulary 3, the value of the element corresponding to keyword 1 in the N-dimensional feature vector is: 0.2+0.83=1.03, and the value of the element corresponding to keyword 2 in the N-dimensional feature vector is: 0.91. At this time, the value of the element corresponding to keyword 1 is obviously greater than the value of the element corresponding to keyword 2. However, in actual applications, it does not mean that the similarity between vocabulary 8 and keyword 1 is greater than the similarity between vocabulary 3 and keyword 2. In this embodiment, the value of the element corresponding to keyword 1 and the value of the element corresponding to keyword 2 are normalized so that the larger the element value obtained after normalization, the more similar the target vocabulary node is to the keyword corresponding to the element.

[0068] It should be noted that, in implementation, the above-mentioned N-dimensional feature vector is generated according to the correlation coefficients on the shortest paths from the target vocabulary node to each keyword node. The product of the correlation coefficients on the shortest paths from the target vocabulary node to the target keyword node can also be used as the value of the element corresponding to the target keyword node in the N-dimensional feature vector. Correspondingly, after obtaining the N-dimensional feature vector, the elements in the N-dimensional feature vector also need to be normalized, which will not be repeated here.

[0069] In this implementation, an N-dimensional feature vector is generated only based on the correlation coefficients on the shortest paths from the target vocabulary node to each keyword node, thereby reducing the amount of calculation.

[0070] In implementation, the process of generating an N-dimensional feature vector based on the correlation coefficients on the shortest paths from the target vocabulary node to each keyword node may specifically include the following steps:

[0071] Step 1: Preset an N-dimensional feature vector F, where each element in F corresponds one-to-one to a keyword in the knowledge graph.

[0072] The knowledge graph includes N keyword nodes, and each keyword node has an associated vocabulary.

[0073] Step 2: Find the shortest path from each target vocabulary node to each keyword in the knowledge graph, as well as the correlation coefficient on the shortest path.

[0074] In practice, the number of target keywords extracted from the text to be processed is often multiple, assuming that it is 200, and the target vocabulary nodes matching the 200 target keywords in the preset knowledge graph are often less than 200. Here, assuming that the number of target vocabulary nodes is 50, and assuming that the knowledge graph includes 100 keyword nodes, the N-dimensional feature vector F can be expressed as [N1, N2, …, N 100 ], where N1 to N 100 They are the 100 elements in the N-dimensional feature vector corresponding to the 100 keyword nodes.

[0075] Step 3: Calculate the value of each element in F.

[0076] In practice, the value of each element in F can be calculated by the following formula:

[0077]

[0078] Among them, the N i represents the value of the i-th element in F, i can be any integer from 1 to N, where N is the total number of keyword nodes included in the preset knowledge graph, and ω j represents the value of the jth correlation coefficient, j can be any integer between 1 and m, and m represents the value of i The number of correlation coefficients included in the shortest path associated with the corresponding keyword node.

[0079] That is, the above formula indicates that the value of the i-th element in F is the value of the same as N iThe sum of the correlation coefficients included in the shortest path related to the corresponding keyword node, in other words, N i It is equal to the concatenation of all m coefficients on the shortest path that can be traced back to the corresponding preset keyword in the preset knowledge graph.

[0080] It should be noted that, in another implementation, the value of the i-th element in F may be determined as the value of the i-th element in F. i The product of the correlation coefficients included in the shortest path related to the corresponding keyword node, that is, N i It is equal to the product of all m coefficients on the shortest path that can be traced back in the preset knowledge graph corresponding to the preset keyword, so that the shorter the path, the greater the N i The larger the value of , the specific method for calculating the value of each element in F is not specifically limited here.

[0081] Step 4: Normalize each element in F to obtain the first eigenvector.

[0082] Of course, in a specific implementation, the elements in the above-mentioned preset N-dimensional feature vector may also be determined through other processes.

[0083] For example, for each keyword node, determine its corresponding target vocabulary node, and determine the shortest path from each keyword node to its corresponding target vocabulary node, so as to determine the feature vector of the element corresponding to the keyword node based on the correlation coefficient on the shortest path. Determine the corresponding element for each keyword node, and obtain an N-dimensional feature vector F.

[0084] Among them, the target vocabulary node corresponding to the above-mentioned keyword node can be: a vocabulary node in the preset knowledge graph that matches the target keyword in the text to be processed and is closest to the keyword node, and / or a vocabulary node in the preset knowledge graph that matches the target keyword in the text to be processed and has the largest correlation coefficient with the keyword node.

[0085] Finally, the N elements in the above N-dimensional feature vector F are normalized to obtain the above first feature vector.

[0086] Step 104: Determine a classification result of the text to be processed based on a preset neural network and the first feature vector.

[0087] In implementation, the above-mentioned determination of the classification result of the text to be processed based on the preset neural network and the first feature vector may be: inputting the first feature vector into the preset neural network, and determining the classification result of the text to be processed according to the output of the preset neural network.

[0088] As an optional implementation manner, determining the classification result of the text to be processed based on the preset neural network and the first feature vector includes:

[0089] Inputting the first feature vector into a preset neural network to output a second feature vector, wherein the preset classification results included in the preset text classification set corresponding to the preset neural network include K, and the second feature vector includes K elements corresponding to the K preset classification results one by one;

[0090] A target element with the largest value in the second feature vector is determined, and a preset classification result corresponding to the target element is determined as the classification result of the text to be processed.

[0091] In practice, the above-mentioned preset text classification set includes a variety of possible classification results. For example, in the case classification of the Public Security Bureau, it can include classification results such as theft cases, robbery cases, and personal injury cases.

[0092] In addition, the input dimension of the above-mentioned preset neural network is N (that is, the dimension of the first eigenvector), and the output dimension is K. Assuming that the preset neural network is a fully connected network, the model structure of the fully connected network can be as follows: Figure 3 The model structure shown.

[0093] In practice, only a small amount of training data is needed to complete the training of the fully connected network. Even if the elements in the knowledge graph are dynamically adjusted according to business development, this adjustment will not affect the trained fully connected network, that is, the fully connected network can be applied to text classification in a variety of business scenarios.

[0094] It should be noted that the above-mentioned preset neural network can be not only the above-mentioned fully connected neural network, but also any shallow neural network or even a deep neural network, which is not specifically limited here.

[0095] The larger the value of the element in the above-mentioned second feature vector, the more the content of the text to be processed matches the preset classification result corresponding to the element. In this embodiment, by using the preset classification result corresponding to the target element with the largest value in the second feature vector as the classification result of the text to be processed, a classification result that best matches the semantic content of the text to be processed can be output.

[0096] Of course, in implementation, multiple classification results can be output for the text to be processed, for example: the top n preset classification results are output so that the user can select one as the classification result of the text to be processed, where n is an integer greater than or equal to 1.

[0097] In an embodiment of the present application, by extracting the target keyword in the text to be processed, the semantics of the text to be processed is simply represented by the target keyword, and then a first feature vector is generated according to the correlation coefficient between the target keyword and each keyword node in the preset knowledge graph, so that the feature description of the text to be processed is input into the preset neural network, and the classification result of the text feature of the text to be processed can be obtained. In view of the fact that the preset neural network only needs to derive which classification it belongs to among multiple preset text classifications according to the feature description of the above-mentioned text to be processed, so that the preset neural network is based on the shallow learning technology route, that is, in the training stage of the preset neural network, only a small amount of training samples are needed to train the above-mentioned preset neural network, which can simplify the difficulty of obtaining training samples; in addition, for text classification in different business scenarios, the preset knowledge graph can be adjusted accordingly according to the semantic features in each business scenario, and the text in each business scenario is respectively input into the corresponding preset knowledge graph, and then the obtained feature vectors are respectively input into the preset neural network, that is, the preset neural network can be applied to text classification in multiple different business scenarios to improve the scope of application of text classification.

[0098] It should be noted that the text classification method provided in the embodiment of the present application can be executed by a text classification device or a control module in the text classification device for executing the text classification method. In the embodiment of the present application, the text classification device provided in the embodiment of the present application is described by taking the text classification method executed by the text classification device as an example.

[0099] See also Figure 4 , is a structural diagram of a text classification device provided in an embodiment of the present application, such as Figure 4 As shown, the text classification device 400 may include:

[0100] Extraction module 401, used to extract target keywords from the text to be processed;

[0101] A matching module 402 is used to determine a target vocabulary node matching the target keyword from a preset knowledge graph;

[0102] A generating module 403 is used to generate a first feature vector according to a target correlation coefficient in the preset knowledge graph, wherein the preset knowledge graph also includes a keyword node, and the target correlation coefficient includes a correlation coefficient between the target vocabulary node and the keyword node;

[0103] The first determination module 404 is used to determine the classification result of the text to be processed based on a preset neural network and the first feature vector.

[0104] Optionally, the text classification device 400 further includes:

[0105] An adding module, used for adding the target vocabulary node to the preset knowledge graph;

[0106] The second determination module is used to determine the correlation coefficient between each node in the preset knowledge graph.

[0107] Optionally, the second determining module is specifically configured to:

[0108] The correlation coefficient between the nodes in the preset knowledge graph is determined according to a preset relationship function, wherein the preset relationship function is associated with the business scenario corresponding to the text to be processed.

[0109] Optionally, the generating module 403 includes:

[0110] A first determining unit is used to determine the shortest path between the target vocabulary node and each keyword node according to the correlation coefficient between each node in the preset knowledge graph, wherein the shortest path indicates that the target vocabulary node passes through the least vocabulary nodes from the keyword node;

[0111] A generating unit, configured to generate an N-dimensional feature vector based on the target correlation coefficient included in the shortest path, wherein the number of keyword nodes included in the preset knowledge graph is N, and the N-dimensional feature vector includes N elements corresponding to the N keyword nodes one by one;

[0112] The normalization processing unit is used to perform normalization processing on the N elements in the N-dimensional feature vector to obtain a first feature vector.

[0113] Optionally, the first determining module 404 includes:

[0114] A neural network calculation unit, configured to input the first feature vector into a preset neural network to output a second feature vector, wherein the preset classification results included in the preset text classification set corresponding to the preset neural network include K pieces, and the second feature vector includes K elements corresponding one-to-one to the K pieces of preset classification results;

[0115] The second determining unit is used to determine the target element with the largest value in the second feature vector, and determine the preset classification result corresponding to the target element as the classification result of the text to be processed.

[0116] The text classification device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a palm computer, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0117] The text classification device provided in the embodiment of the present application can achieve Figure 1 The various processes implemented by the illustrated method embodiment can achieve the same beneficial effects, and will not be described again here to avoid repetition.

[0118] Optional, such as Figure 5 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501, a memory 502, and a program or instruction stored in the memory 502 and executable on the processor 501. When the program or instruction is executed by the processor 501, each process of the above-mentioned text classification method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0119] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0120] The embodiment of the present application also provides a computer-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned text classification method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0121] The processor is the processor in the electronic device described in the above embodiment. The computer readable storage medium may be a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0122] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned text classification method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0123] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0124] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0125] 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 application, 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 a terminal (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 application.

[0126] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A text classification method, characterized in that: The method comprises: Extract target keywords from the text to be processed; Determine a target vocabulary node matching the target keyword from a preset knowledge graph; According to the correlation coefficient between each node in the preset knowledge graph, determine the shortest path between the target vocabulary node and each keyword node, wherein the preset knowledge graph also includes a keyword node, the value of the correlation coefficient between two related vocabulary nodes in the preset knowledge graph is positively correlated with the conceptual closeness of the two vocabulary nodes, and the shortest path indicates that the vocabulary nodes passed from the target vocabulary node to the keyword node are the least; Based on the target correlation coefficient included in the shortest path, an N-dimensional feature vector is generated, wherein the N-dimensional feature vector includes N elements corresponding to N keyword nodes one by one, N is the number of keyword nodes in the preset knowledge graph, and the target correlation coefficient includes the correlation coefficient between the target vocabulary node and the keyword node; Normalizing the N elements in the N-dimensional feature vector to obtain a first feature vector; Based on a preset neural network and the first feature vector, determining a classification result of the text to be processed, wherein the preset neural network is a fully connected network, the input dimension of the preset neural network is N, and the output dimension is K, and the preset classification results included in the preset text classification set corresponding to the preset neural network include K; The method further comprises: The preset knowledge graph is displayed, wherein the target vocabulary node and the shortest path between the target vocabulary node and each keyword node in the preset knowledge graph are highlighted.

2. The method according to claim 1, characterized in that The method further comprises: Add the target vocabulary node to the preset knowledge graph; Determine the correlation coefficient between the nodes in the preset knowledge graph.

3. The method according to claim 2, characterized in that The determining of the correlation coefficient between the nodes in the preset knowledge graph includes: The correlation coefficient between the nodes in the preset knowledge graph is determined according to a preset relationship function, wherein the preset relationship function is associated with the business scenario corresponding to the text to be processed.

4. The method according to claim 1, characterized in that: The step of determining the classification result of the text to be processed based on the preset neural network and the first feature vector includes: Inputting the first feature vector into a preset neural network to output a second feature vector, wherein the second feature vector includes K elements corresponding one-to-one to the K preset classification results; A target element with the largest value in the second feature vector is determined, and a preset classification result corresponding to the target element is determined as the classification result of the text to be processed.

5. A text classification device, characterized in that: The device comprises: An extraction module, used to extract target keywords from the text to be processed; A matching module, used to determine a target vocabulary node matching the target keyword from a preset knowledge graph; A first determination unit is used to determine the shortest path between the target vocabulary node and each keyword node according to the correlation coefficient between each node in the preset knowledge graph, wherein the preset knowledge graph also includes a keyword node, the correlation coefficient between two related vocabulary nodes in the preset knowledge graph is positively correlated with the conceptual closeness of the two vocabulary nodes, and the shortest path indicates that the vocabulary nodes passed from the target vocabulary node to the keyword node are the least; A generating unit, configured to generate an N-dimensional feature vector based on a target correlation coefficient included in the shortest path, wherein the N-dimensional feature vector includes N elements corresponding to N keyword nodes one by one, N is the number of keyword nodes in the preset knowledge graph, and the target correlation coefficient includes a correlation coefficient between the target vocabulary node and the keyword node; A normalization processing unit, used for performing normalization processing on the N elements in the N-dimensional feature vector to obtain a first feature vector; A first determination module is used to determine the classification result of the text to be processed based on a preset neural network and the first feature vector, wherein the preset neural network is a fully connected network, the input dimension of the preset neural network is N, and the output dimension is K, and the preset classification results included in the preset text classification set corresponding to the preset neural network include K; The device also includes: A display module is used to display the preset knowledge graph, wherein the target vocabulary node in the preset knowledge graph and the shortest path between the target vocabulary node and each keyword node are highlighted.

6. The device according to claim 5, characterized in that The device also includes: An adding module, used for adding the target vocabulary node to the preset knowledge graph; The second determination module is used to determine the correlation coefficient between each node in the preset knowledge graph.

7. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the text classification method according to any one of claims 1 to 4.

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

Citation Information

Patent Citations

  • Method and device for determining text categories

    CN110245228A