Text classification method and device, computer readable storage medium and electronic equipment
By combining the BTM model and the FastText model to classify short texts, the problems of poor accuracy and low efficiency of short text classification are solved, and more efficient and accurate short text classification is achieved.
Patent Information
- Application Number
- CN202411418335.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the classification of short texts is poor and the efficiency is low, mainly due to the semantic sparsity and ambiguity of short texts, resulting in poor classification effect, and deep neural network models and large-scale pre-trained models are being trained or predicted. Low efficiency and high calculation cost.
A combination of BTM model and Fasttext model is used to classify short text classification. First of all, pre -processing classified texts, including segmentation processing, and obtaining word vector. Then, use the BTM model to analyze the word vector to obtain the theme feature vector, and use the Fasttext model to analyze the word vector to obtain the word feature vector. Enter the classifier for classification.
Get rich potential theme characteristics through the BTM model, use the FastText model to quickly and efficiently extract the characteristics of the word feature vector, combined with the efficiency and accuracy of the short text classification, solve the poor accuracy and low efficiency of the short text classification in the existing technology. Question.
Smart Images

Figure CN119336911A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text classification, and in particular, to a text classification method, device, computer-readable storage medium, computer program product, and electronic device. Background Art
[0002] In the current complaint content classification process, the complaint content is short in length. When using traditional classification models for classification, it will face problems such as sentence sparsity and ambiguity, which will lead to unclear semantic features during classification and poor classification results. At the same time, deep neural network models such as RNNs and large-scale pre-trained models such as Bert have poor efficiency during training or prediction due to complex structures and high computational costs, and have high hardware requirements. Summary of the invention
[0003] The main purpose of the present application is to provide a text classification method, device, computer-readable storage medium, computer program product and electronic device to at least solve the problem of poor accuracy and low efficiency of short text classification in the prior art.
[0004] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a text classification method is provided, comprising: upon receiving a text to be classified, preprocessing the text to be classified to obtain a plurality of word vectors, wherein the number of characters of the text to be classified is less than 255 characters, and the preprocessing includes word segmentation processing; using a BTM model to analyze the plurality of word vectors to determine a topic feature vector of the text to be classified; using a FastText model to analyze the plurality of word vectors to obtain a word feature vector of the text to be classified; concatenating the topic feature vector and the word feature vector to obtain a concatenated vector, and inputting the concatenated vector into a classifier for classification to obtain a category of the text to be classified.
[0005] Optionally, the text to be classified is preprocessed, including: performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words in the first intermediate text to obtain a second intermediate text; performing word segmentation on the second intermediate text to obtain a plurality of word vectors.
[0006] Optionally, a BTM (BitermTopic Model) model is used to analyze the multiple word vectors to determine the topic feature vector of the text to be classified, including: inputting the multiple word vectors into the BTM model to obtain multiple topic vectors and the occurrence probabilities corresponding to the multiple topic vectors; determining at least one target probability from the multiple occurrence probabilities, wherein the target probability is greater than the other occurrence probabilities; and determining that at least one topic vector corresponding to the target probability constitutes the topic feature vector.
[0007] Optionally, before using the BTM model to analyze the multiple word vectors to determine the topic feature vectors of the text to be classified, the method also includes: obtaining multiple initial short text training documents; adding category labels to the multiple initial short text training documents, and performing random merging operations and shuffling operations on the initial short text training documents with the category labels added in sequence to obtain intermediate short text training documents; performing stop word removal operations and word segmentation operations on the intermediate short text training documents in sequence to obtain multiple short text training documents; and modeling the BTM model based on the multiple short text training documents and a preset number of topics.
[0008] Optionally, before using the FastText (shallow network) model to analyze the multiple word vectors to obtain the word feature vector of the text to be classified, the method also includes: establishing the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive the multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vector.
[0009] Optionally, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector includes: concatenating the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the concatenated vector.
[0010] According to another aspect of the present application, a text classification device is provided, comprising: a processing unit, for preprocessing the text to be classified upon receiving the text to be classified to obtain a plurality of word vectors, wherein the character amount of the text to be classified is less than 255 characters, and the preprocessing includes word segmentation processing; a first analysis unit, for analyzing the plurality of word vectors using a BTM model to determine a topic feature vector of the text to be classified; a second analysis unit, for analyzing the plurality of word vectors using a FastText model to obtain a word feature vector of the text to be classified; a splicing unit, for splicing the topic feature vector and the word feature vector to obtain a spliced vector, and inputting the spliced vector into a classifier for classification to obtain a category of the text to be classified.
[0011] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the methods described.
[0012] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, wherein when the computer instructions are executed by a processor, any one of the methods described above is implemented.
[0013] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the methods described.
[0014] By applying the technical solution of the present application, when receiving the text to be classified, the text to be classified is first processed in a predetermined manner including word segmentation to obtain multiple word vectors; then the BTM model is used to analyze the multiple word vectors to obtain the topic feature vector, and the FastText model is used to analyze the multiple word vectors to obtain the word feature vector; finally, the topic feature vector and the word feature vector are spliced and input into the classifier for classification, thereby obtaining the category to which the text to be classified belongs. The present application fuses and splices the topic feature vector obtained by the BTM topic model with the word feature vector obtained by the FastText model to determine the category, uses the BTM model that is more suitable for short texts to solve the semantic sparsity and ambiguity problems existing in short texts, and can obtain richer document-level potential topic features; and uses the FastText model with a simple structure, low computational complexity and high speed to extract word feature vectors, which can efficiently and quickly obtain word feature vectors, thereby ensuring that the classification results are obtained quickly. The present application adopts the BTM model fused with FastText to classify short texts, taking into account the efficiency and accuracy of short text classification, and solves the problem of poor accuracy and low efficiency of short text classification in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0016] Figure 1 A hardware structure block diagram of a mobile terminal for executing a text classification method provided in an embodiment of the present application is shown;
[0017] Figure 2 A schematic diagram of a flow chart of a text classification method provided according to an embodiment of the present application is shown;
[0018] Figure 3 A schematic diagram of the structure of a BTM model provided according to an embodiment of the present application is shown;
[0019] Figure 4 A schematic diagram of the structure of a FastText model provided according to an embodiment of the present application is shown;
[0020] Figure 5 A schematic diagram of a text classification process provided according to an embodiment of the present application is shown;
[0021] Figure 6 A structural block diagram of a text classification device provided according to an embodiment of the present application is shown.
[0022] The drawings include the following reference numerals:
[0023] 102, processor; 104, memory; 106, transmission device; 108, input and output devices. DETAILED DESCRIPTION
[0024] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only 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 should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the accompanying drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] As introduced in the background technology, the prior art has the problem of poor accuracy and low efficiency in short text classification. To solve the above problems, the embodiments of the present application provide a text classification method, device, computer-readable storage medium, computer program product and electronic device.
[0028] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0029] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a text classification method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0030] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the text classification method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the method described is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof. The transmission device 106 is used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] In this embodiment, a text classification method running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0032] Figure 2 is a flowchart of a text classification method according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0033] Step S201, when receiving a text to be classified, preprocessing the text to be classified to obtain multiple word vectors, the text to be classified has less than 255 characters, and the preprocessing includes word segmentation processing;
[0034] Specifically, the character quantity of the text to be classified is less than 255 characters, so the text to be classified is a short text. Word segmentation is the process of recombining a continuous word sequence into a word sequence according to a certain specification. A word segmentation tool can be used to perform word segmentation on the text to be classified to obtain multiple word vectors. The word segmentation tool includes but is not limited to jieba, nltk, etc.
[0035] Step S202, using the BTM model to analyze the multiple word vectors to determine the topic feature vector of the text to be classified;
[0036] Specifically, the BTM model is based on Biterms (big word pairs) in text data. It assumes that each document in the text data is composed of many big word pairs, and each big word pair represents the situation where two words appear at the same time in the document. By counting and modeling big word pairs, the BTM model can infer the topic distribution in the document.
[0037] Step S203, using the FastText model to analyze the plurality of word vectors to obtain word feature vectors of the text to be classified;
[0038] Specifically, the FastText model represents the text as a bag-of-words model, decomposing words into character-level n-gram features to capture the semantic information in the words and calculate the word vector. The word feature vector is a feature vector representation of multiple word vectors (or the text to be classified), which may include the semantic information and vocabulary information of the text to be classified.
[0039] Step S204, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector, and inputting the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
[0040] Specifically, the classifier may be a deep learning classifier such as a Softmax classifier, or may be a logistic regression classifier, a decision tree classifier, a support vector machine classifier, a K-nearest neighbor classifier, a naive Bayes classifier, a random forest classifier, or other types of classifiers.
[0041] Through the embodiment, when receiving the text to be classified, the text to be classified is first processed including word segmentation to obtain multiple word vectors; then the BTM model is used to analyze the multiple word vectors to obtain the topic feature vector, and the FastText model is used to analyze the multiple word vectors to obtain the word feature vector; finally, the topic feature vector and the word feature vector are spliced and input into the classifier for classification, so as to obtain the category to which the text to be classified belongs. This application fuses and splices the topic feature vector obtained by the BTM topic model with the word feature vector obtained by the FastText model to determine the category, uses the BTM model that is more suitable for short texts to solve the semantic sparsity and ambiguity problems existing in short texts, and can obtain richer document-level potential topic features; and uses the FastText model with a simple structure, low computational complexity and high speed to extract word feature vectors, which can efficiently and quickly obtain word feature vectors, thereby ensuring that the classification results are obtained quickly. This application uses the BTM model to fuse FastText to classify short texts, taking into account the efficiency and accuracy of short text classification, and solves the problem of poor accuracy and low efficiency of short text classification in the prior art.
[0042] Specifically, the categories of the text to be classified may include: consultation, suggestion, feedback and complaint, etc. The text to be classified may also be a complaint text, and its corresponding categories include: personal finance line, agriculture, rural areas and farmers line, online finance line, consumer loan line, credit card line and transportation management line.
[0043] In an optional solution, the text to be classified is preprocessed, including: performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words in the first intermediate text to obtain a second intermediate text; performing word segmentation on the second intermediate text to obtain a plurality of word vectors. In this embodiment, data cleaning of the text to be classified can identify and correct errors, missing values, duplicate values and inconsistencies in the text data to be classified. The stop word removal operation can remove irrelevant information such as special characters and punctuation marks in the text, reduce the impact of noise on subsequent text analysis, and facilitate subsequent word segmentation processing. By sequentially performing data cleaning, stop word removal and word segmentation on the text, the quality and accuracy of the obtained word vectors are guaranteed to be high, laying a good data foundation for subsequent data analysis and modeling.
[0044] In the actual application process, data cleaning includes the following steps: 1) Missing value processing: Identify missing values in the text and select appropriate methods to process them, such as deleting rows or columns containing missing values, filling missing values, etc.; 2) Outlier processing: Identify and process outliers in the text, which can be processed using statistical methods, visualization methods or professional knowledge; 3) Duplicate value processing: Identify and delete duplicate values in the text to ensure the uniqueness of the data; 4) Data format unification: Unify the formats of different fields in the text, such as date format, unit format, etc.; 5) Data consistency processing: Ensure consistency between different fields in the text, such as merging fields with the same meaning, unifying names, etc.; 6) Data type conversion: Convert incorrect data types in the text to correct data types, such as converting character data to numeric data.
[0045] In order to further solve the problem that when processing short texts, due to the sparsity and ambiguity of the text, there is less co-occurrence information of words, which leads to inaccurate topic information, in another exemplary embodiment, a BTM model is used to analyze multiple word vectors to determine the topic feature vector of the text to be classified, including: inputting multiple word vectors into the BTM model to obtain multiple topic vectors and the corresponding occurrence probabilities of the multiple topic vectors; determining at least one target probability from the multiple occurrence probabilities, the target probability is greater than the other occurrence probabilities; determining at least one topic vector corresponding to the target probability to constitute the topic feature vector. By analyzing multiple word vectors through the BTM model, the topic distribution of the text to be classified is analyzed from the multiple word vectors, and according to the analysis results, the topic vector with a higher probability is selected to constitute the topic feature vector, so as to achieve the effect of mining hidden topic features from short text data and enriching the semantic information of short texts, further solving the problem of semantic sparsity and ambiguity, and further ensuring that the obtained topic feature vector is more accurate, thereby further ensuring that the category of the text to be classified determined later according to the topic feature vector is more accurate.
[0046] Specifically, at least one target probability is determined from the multiple occurrence probabilities, including: arranging the topic vectors corresponding to the occurrence probabilities in order from large to small; splicing the first m topic vectors into the topic feature vector in the order of arrangement, where m>1 and m is an integer.
[0047] To obtain a more accurate BTM model, according to some further embodiments of the present application, before analyzing the multiple word vectors using the BTM model to determine the topic feature vector of the text to be classified, the method further includes: obtaining multiple initial short text training documents; adding category labels to the multiple initial short text training documents, and sequentially performing a random merging operation and a shuffling operation on the initial short text training documents with the added category labels to obtain intermediate short text training documents; sequentially performing a stop word removal operation and a word segmentation operation on the intermediate short text training documents to obtain multiple short text training documents; and modeling the BTM model according to the multiple short text training documents and a preset number of topics. In this embodiment, adding category labels to the initial short text training documents according to the topic or category of the text content facilitates subsequent classification or analysis; through the operations of merging, shuffling, stop word removal, and word segmentation, the quality of the obtained short text training documents is ensured to be relatively high, making the BTM model obtained according to these short text training documents relatively accurate.
[0048] Specifically, the merging operation can be performed according to the acquisition time of the initial short text training documents, that is, merging the documents acquired in the same period into one document, which is convenient for unified processing and management and reduces the data processing volume at the same time; the shuffling operation randomly shuffles the order of the text data to avoid the model overfitting to data in a specific order; the stop word removal operation can remove irrelevant information such as special characters and punctuation marks in the text, retain the main information of the text content, and remove stop words in the text, such as common words like "of" and "is", to reduce the impact of noise on text analysis; the word segmentation operation performs word segmentation on the text, splitting the text into words to facilitate subsequent text analysis and mining.
[0049] In addition to the random merging operation, the shuffling operation, the stop word removal operation, and the word segmentation operation, it may also include predetermined processes such as a data cleaning operation and a standard format operation.
[0050] Specifically, the structure of the BTM model is as Figure 3 shown, where θ represents the document-topic distribution matrix, φ represents the topic-word distribution matrix, z represents the topic label, w i and w j represent the labels of the words in a pair of binary word pairs, |B| represents the set of binary word pairs, K represents the number of topics, and α and β are the parameters of the prior Dirichlet distribution.
[0051] Optionally, before using the FastText model to analyze the multiple word vectors to obtain the word feature vectors of the text to be classified, the method further includes: establishing the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vectors. In this embodiment, a FastText model including an input layer and a hidden layer is established. Compared with deep neural network models such as CNN and RNN, the FastText model has a simpler structure, a faster model speed, and a shorter model training time, which avoids the model occupying a large amount of memory and computing resources, and can further improve classification efficiency.
[0052] Those skilled in the art can flexibly set the specific value of the weight of each word vector, and the weight of each word vector can be the same or different.
[0053] In one embodiment, the weight of each word vector is the same, which is the inverse of the number of the word vectors, that is, the hidden layer is used to perform addition and averaging operations on multiple word vectors.
[0054] Among them, Figure 4 As shown, the classifier can be regarded as the output layer of the FastText model. The output of the BTM model and the output of the hidden layer of the FastText model are concatenated as the input of the output layer of the FastText model. That is, the topic feature vector obtained by the BTM model is fused with the output of the hidden layer of the FastText model, and the concatenated vector is input into the output layer of the FastText model for short text classification. On the basis of ensuring the classification efficiency, the short text classification effect can be improved by enriching the semantic information of the short text.
[0055] Those skilled in the art can perform vector splicing on the topic feature vector and the word feature vector according to actual needs. In an exemplary embodiment, the topic feature vector and the word feature vector are spliced to obtain a spliced vector, including: performing vector splicing on the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the spliced vector.
[0056] In addition to the splicing method, in other embodiments, the topic feature vector and the word feature vector are spliced to obtain a spliced vector, including: in the order of the topic feature vector first and the word feature vector second, the word feature vector and the topic feature vector are vector spliced to obtain the spliced vector.
[0057] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the text classification method of the present application will be described in detail below in conjunction with specific embodiments.
[0058] This embodiment relates to a specific text classification method, and the text to be classified is specifically a complaint text, such as Figure 5 As shown, the following steps are included:
[0059] Step S1: Collect the original text data of the complaint content, a total of 30,000, of which 70% are used as the training set, 20% as the test set, and 10% as the validation set for model training. According to the business line category to which the complaint belongs, the data can be divided into 6 categories, namely, personal finance line, agriculture, rural areas and farmers line, online finance line, consumer loan line, credit card line and transportation management line, and perform data preprocessing operations on the original text of the complaint content, that is, add labels to the data, merge files, shuffle the data order and other data cleaning preprocessing operations, and then remove stop words according to the Chinese stop word list (including removing numbers, spaces, etc.), and then use the jieba word segmentation toolkit to perform Chinese word segmentation;
[0060] Step S2: Model the BTM topic model for the short text training set, obtain the document-topic distribution matrix and topic-word distribution matrix of the complaint text corpus, and arrange the probability distribution of each topic vector in descending order, and take the top m topic vectors ranked by probability value as the topic feature vector. The BTM topic model establishment process is as follows: Figure 3 As shown;
[0061] Step S3: Construct Figure 4 The FastText model shown in the figure consists of an input layer, a hidden layer, and an output layer, which is equivalent to a shallow neural network. N is the word vector, and the hidden layer performs the operation:
[0062]
[0063] Step S4: directly concatenate the topic feature vector obtained in step S2 with the output vector of the hidden layer of the FastText model to obtain the final vector;
[0064] Step S5: Send the final vector to the SoftMax classifier (i.e., the output layer of the FastText model) for classification prediction to obtain the predicted classification result.
[0065] This application can improve the efficiency and accuracy of the complaint short text classification process and achieve better classification results in a shorter time. The model structure after splicing the BTM model of this application with the FastText model output can be named FastText_BTM.
[0066] The FastText_BTM model is used to predict and classify complaint short texts, and compared with the FastText model and the FastText_LDA model (i.e., a model that uses the inscription vector obtained by the LDA topic model and FastText to classify short texts). The results are shown in Table 1:
[0067] Table 1
[0068] Model Accuracy (%) Recall rate (%) F1 value (%) FastText 77.7% 78.0% 79.5% FastText_LDA 78.4% 78.4% 78.5% FastText_BTM 86.1% 82.6% 82.7%
[0069] From the classification results of each model in Table 1, the FastText_BTM model that integrates the BTM potential topic word vector features has achieved better classification prediction results. It can be seen that the BTM topic model is more suitable for short texts than the same type of topic models such as LDA. At the same time, it also proves that the FastText_BTM model of this application can better alleviate the semantic sparsity and ambiguity problems existing in short texts.
[0070] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0071] The embodiment of the present application also provides a text classification device. It should be noted that the text classification device of the embodiment of the present application can be used to execute the text classification method provided by the embodiment of the present application. The device is used to implement the embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0072] The following is an introduction to the text classification device provided in the embodiment of the present application.
[0073] Figure 6 is a schematic diagram of a text classification device according to an embodiment of the present application. Figure 6 As shown, the device comprises:
[0074] The processing unit 10 is used to pre-process the text to be classified to obtain multiple word vectors when receiving the text to be classified, wherein the number of characters in the text to be classified is less than 255 characters, and the pre-processing includes word segmentation processing;
[0075] Specifically, the character quantity of the text to be classified is less than 255 characters, so the text to be classified is a short text. Word segmentation is the process of recombining a continuous word sequence into a word sequence according to a certain specification. A word segmentation tool can be used to perform word segmentation on the text to be classified to obtain multiple word vectors. The word segmentation tool includes but is not limited to jieba, nltk, etc.
[0076] A first analysis unit 20 is used to analyze the plurality of word vectors using a BTM model to determine a topic feature vector of the text to be classified;
[0077] Specifically, the BTM model is based on Biterm in text data. It assumes that each document in the text data consists of many bigram word pairs, and each bigram word pair represents the co-occurrence of two words in the document. By counting and modeling bigram word pairs, the BTM model can infer the topic distribution in the document.
[0078] A second analysis unit 30 is used to analyze the plurality of word vectors using a FastText model to obtain a word feature vector of the text to be classified;
[0079] Specifically, the FastText model represents the text as a bag-of-words model, decomposing words into character-level n-gram features to capture the semantic information in the words and calculate the word vector. The word feature vector is a feature vector representation of multiple word vectors (or the text to be classified), which may include the semantic information and vocabulary information of the text to be classified.
[0080] The concatenation unit 40 is used to concatenate the topic feature vector and the word feature vector to obtain a concatenated vector, and input the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
[0081] Specifically, the classifier may be a deep learning classifier such as a Softmax classifier, or may be a logistic regression classifier, a decision tree classifier, a support vector machine classifier, a K-nearest neighbor classifier, a naive Bayes classifier, a random forest classifier, or other types of classifiers.
[0082] According to the embodiment, when a text to be classified is received, a processing unit performs predetermined processing including word segmentation on the text to be classified to obtain a plurality of word vectors; a first analysis unit uses a BTM model to analyze the plurality of word vectors to obtain a topic feature vector, and a second analysis unit uses a FastText model to analyze the plurality of word vectors to obtain a word feature vector; a splicing unit splices the topic feature vector and the word feature vector and inputs the splicing unit into a classifier for classification, thereby obtaining a category to which the text to be classified belongs. This application fuses and splices the topic feature vector obtained by the BTM topic model with the word feature vector obtained by the FastText model to determine the category, and uses the BTM model that is more suitable for short texts to solve the semantic sparsity and ambiguity problems in short texts, so as to obtain richer document-level potential topic features; and uses the FastText model with a simple structure, low computational complexity and high speed to extract word feature vectors, so as to obtain word feature vectors efficiently and quickly, thereby ensuring that the classification results are obtained faster. This application uses the BTM model to fuse FastText to classify short texts, taking into account the efficiency and accuracy of short text classification, and solving the problems of poor accuracy and low efficiency of short text classification in the prior art.
[0083] Specifically, the categories of the text to be classified may include: consultation, suggestion, feedback and complaint, etc. The text to be classified may also be a complaint text, and its corresponding categories include: personal finance line, agriculture, rural areas and farmers line, online finance line, consumer loan line, credit card line and transportation management line.
[0084] In an optional solution, the processing unit includes: a cleaning module for performing data cleaning on the text to be classified to obtain a first intermediate text; a removal module for removing stop words in the first intermediate text to obtain a second intermediate text; and a processing module for performing word segmentation on the second intermediate text to obtain a plurality of word vectors. In this embodiment, data cleaning of the text to be classified can identify and correct errors, missing values, duplicate values, and inconsistencies in the text data to be classified. The stop word removal operation can remove irrelevant information such as special characters and punctuation marks in the text, reduce the impact of noise on subsequent text analysis, and facilitate subsequent word segmentation processing. By sequentially performing data cleaning, stop word removal, and word segmentation processing on the text, the quality and accuracy of the obtained word vectors are guaranteed to be high, laying a good data foundation for subsequent data analysis and modeling.
[0085] In the actual application process, data cleaning includes the following steps: 1) Missing value processing: Identify missing values in the text and select appropriate methods to process them, such as deleting rows or columns containing missing values, filling missing values, etc.; 2) Outlier processing: Identify and process outliers in the text, which can be processed using statistical methods, visualization methods or professional knowledge; 3) Duplicate value processing: Identify and delete duplicate values in the text to ensure the uniqueness of the data; 4) Data format unification: Unify the formats of different fields in the text, such as date format, unit format, etc.; 5) Data consistency processing: Ensure consistency between different fields in the text, such as merging fields with the same meaning, unifying names, etc.; 6) Data type conversion: Convert incorrect data types in the text to correct data types, such as converting character data to numeric data.
[0086] In order to further solve the problem that the co-occurrence information of words is less due to the sparsity and ambiguity of the text when processing short texts, thereby resulting in inaccurate topic information, in another exemplary embodiment, the first analysis unit includes: an input module, which is used to input multiple word vectors into the BTM model to obtain multiple topic vectors and the occurrence probabilities corresponding to the multiple topic vectors; a first determination module, which is used to determine at least one target probability from the multiple occurrence probabilities, and the target probability is greater than the other occurrence probabilities; a second determination module, which is used to determine that at least one topic vector corresponding to the target probability constitutes the topic feature vector. By analyzing multiple word vectors through the BTM model, the topic distribution of the text to be classified is analyzed from the multiple word vectors, and according to the analysis results, the topic vector with a higher probability is selected to form the topic feature vector, so as to achieve the effect of mining hidden topic features from short text data and enriching the semantic information of short texts, further solve the problem of semantic sparsity and ambiguity, further ensure that the obtained topic feature vector is more accurate, and thus further ensure that the category of the text to be classified determined according to the topic feature vector is more accurate.
[0087] Specifically, the first determination module includes: an arrangement submodule, used to arrange the topic vectors corresponding to each occurrence probability in order from large to small; a splicing submodule, used to splice the first m topic vectors into the topic feature vector in the arrangement order, where m>1 and m is an integer.
[0088] To obtain a more accurate BTM model, according to some further embodiments of the present application, the device further includes: an acquisition unit, configured to acquire a plurality of initial short text training documents before analyzing the plurality of word vectors using the BTM model to determine the topic feature vector of the text to be classified; an addition unit, configured to add category labels to the plurality of initial short text training documents, and perform a random merging operation and a shuffling operation on the initial short text training documents with the category labels added in sequence to obtain intermediate short text training documents; an operation unit, configured to perform a stop word removal operation and a word segmentation operation on the intermediate short text training documents in sequence to obtain a plurality of short text training documents; and a modeling unit, configured to perform modeling on the BTM model according to the plurality of short text training documents and a preset number of topics. In this embodiment, category labels are added to the initial short text training documents according to the topic or category of the text content, which facilitates subsequent classification or analysis; through operations such as merging, shuffling, stop word removal, and word segmentation, the quality of the obtained short text training documents is ensured to be relatively high, making the BTM model obtained based on these short text training documents more accurate.
[0089] Specifically, the merging operation can be performed according to the acquisition time of the initial short text training documents, that is, the documents acquired in the same period are merged into one document, which is convenient for unified processing and management, and at the same time reduces the data processing volume; the shuffling operation randomly shuffles the order of the text data to prevent the model from overfitting to data in a specific order; the stop word removal operation can remove irrelevant information such as special characters and punctuation marks in the text, retain the main information of the text content, and remove stop words in the text, such as common words like "de" (of), "shi" (is), etc., to reduce the influence of noise on text analysis; the word segmentation operation performs word segmentation on the text, splitting the text into words, which is convenient for subsequent text analysis and mining.
[0090] In addition to the random merging operation, shuffling operation, stop word removal operation, and word segmentation operation, it may also include predetermined processes such as data cleaning operation and standardized format operation.
[0091] Specifically, the structure of the BTM model is as Figure 3 shown, where θ represents the document-topic distribution matrix, φ represents the topic-word distribution matrix, z represents the topic label, w i and w j represent the labels of the words in a pair of binary word pairs, |B| represents the set of binary word pairs, K represents the number of topics, and α and β are parameters of the prior Dirichlet distribution.
[0092] Optionally, the device further includes: an establishment unit for establishing the FastText model including an input layer and a hidden layer before adopting the FastText model to analyze the multiple word vectors to obtain the word feature vector of the text to be classified, wherein the input layer is used to receive multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vector. In this embodiment, a FastText model including an input layer and a hidden layer is established. Compared with deep neural network models such as CNN and RNN, the FastText model has a simpler structure, a faster model speed and a shorter model training time, which avoids the model occupying a large amount of memory and computing resources, and can further improve classification efficiency.
[0093] Those skilled in the art can flexibly set the specific value of the weight of each word vector, and the weight of each word vector can be the same or different.
[0094] In one embodiment, the weight of each word vector is the same, which is the inverse of the number of the word vectors, that is, the hidden layer is used to perform addition and averaging operations on multiple word vectors.
[0095] Among them, Figure 4 As shown, the classifier can be regarded as the output layer of the FastText model. The output of the BTM model and the output of the hidden layer of the FastText model are concatenated as the input of the output layer of the FastText model. That is, the topic feature vector obtained by the BTM model is fused with the output of the hidden layer of the FastText model, and the concatenated vector is input into the output layer of the FastText model for short text classification. On the basis of ensuring the classification efficiency, the short text classification effect can be improved by enriching the semantic information of the short text.
[0096] Those skilled in the art may perform vector splicing on the topic feature vector and the word feature vector according to actual needs. In an exemplary embodiment, the splicing unit includes: a first splicing module, used to perform vector splicing on the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the spliced vector.
[0097] In addition to the splicing method, in other embodiments, the splicing unit includes: a second splicing module, used to perform vector splicing on the word feature vector and the topic feature vector in the order of the topic feature vector first and the word feature vector second to obtain the spliced vector.
[0098] The text classification device includes a processor and a memory, the processing unit, the first analysis unit, the second analysis unit, and the splicing unit are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. The modules are all located in the same processor; or, the modules are located in different processors in any combination.
[0099] The processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be provided, and the problem of poor accuracy and low efficiency of short text classification in the prior art can be at least solved by adjusting kernel parameters.
[0100] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0101] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the text classification method.
[0102] Specifically, text classification methods include:
[0103] Step S201, when receiving a text to be classified, preprocessing the text to be classified to obtain multiple word vectors, the text to be classified has less than 255 characters, and the preprocessing includes word segmentation processing;
[0104] Specifically, the character quantity of the text to be classified is less than 255 characters, so the text to be classified is a short text. Word segmentation is the process of recombining a continuous word sequence into a word sequence according to a certain specification. A word segmentation tool can be used to perform word segmentation on the text to be classified to obtain multiple word vectors. The word segmentation tool includes but is not limited to jieba, nltk, etc.
[0105] Step S202, using the BTM model to analyze the multiple word vectors to determine the topic feature vector of the text to be classified;
[0106] Specifically, the BTM model is based on Biterms (big word pairs) in text data. It assumes that each document in the text data is composed of many big word pairs, and each big word pair represents the situation where two words appear at the same time in the document. By counting and modeling big word pairs, the BTM model can infer the topic distribution in the document.
[0107] Step S203, using the FastText model to analyze the plurality of word vectors to obtain word feature vectors of the text to be classified;
[0108] Specifically, the FastText model represents the text as a bag-of-words model, decomposing words into character-level n-gram features to capture the semantic information in the words and calculate the word vector. The word feature vector is a feature vector representation of multiple word vectors (or the text to be classified), which may include the semantic information and vocabulary information of the text to be classified.
[0109] Step S204, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector, and inputting the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
[0110] Specifically, the classifier may be a deep learning classifier such as a Softmax classifier, or may be a logistic regression classifier, a decision tree classifier, a support vector machine classifier, a K-nearest neighbor classifier, a naive Bayes classifier, a random forest classifier, or other types of classifiers.
[0111] Optionally, the text to be classified is preprocessed, including: performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words in the first intermediate text to obtain a second intermediate text; performing word segmentation on the second intermediate text to obtain a plurality of word vectors.
[0112] Optionally, a BTM (BitermTopic Model) model is used to analyze the multiple word vectors to determine the topic feature vector of the text to be classified, including: inputting the multiple word vectors into the BTM model to obtain multiple topic vectors and the occurrence probabilities corresponding to the multiple topic vectors; determining at least one target probability from the multiple occurrence probabilities, wherein the target probability is greater than the other occurrence probabilities; and determining that at least one topic vector corresponding to the target probability constitutes the topic feature vector.
[0113] Optionally, before using the BTM model to analyze the multiple word vectors to determine the topic feature vectors of the text to be classified, the method also includes: obtaining multiple initial short text training documents; adding category labels to the multiple initial short text training documents, and performing random merging operations and shuffling operations on the initial short text training documents with the category labels added in sequence to obtain intermediate short text training documents; performing stop word removal operations and word segmentation operations on the intermediate short text training documents in sequence to obtain multiple short text training documents; and modeling the BTM model based on the multiple short text training documents and a preset number of topics.
[0114] Optionally, before using the FastText (shallow network) model to analyze the multiple word vectors to obtain the word feature vector of the text to be classified, the method also includes: establishing the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive the multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vector.
[0115] Optionally, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector includes: concatenating the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the concatenated vector.
[0116] An embodiment of the present invention provides a processor, which is used to run a program, wherein the text classification method is executed when the program is run.
[0117] Specifically, text classification methods include:
[0118] Step S201, when receiving a text to be classified, preprocessing the text to be classified to obtain multiple word vectors, the text to be classified has less than 255 characters, and the preprocessing includes word segmentation processing;
[0119] Specifically, the character quantity of the text to be classified is less than 255 characters, so the text to be classified is a short text. Word segmentation is the process of recombining a continuous word sequence into a word sequence according to a certain specification. A word segmentation tool can be used to perform word segmentation on the text to be classified to obtain multiple word vectors. The word segmentation tool includes but is not limited to jieba, nltk, etc.
[0120] Step S202, using the BTM model to analyze the multiple word vectors to determine the topic feature vector of the text to be classified;
[0121] Specifically, the BTM model is based on Biterms (big word pairs) in text data. It assumes that each document in the text data is composed of many big word pairs, and each big word pair represents the situation where two words appear at the same time in the document. By counting and modeling big word pairs, the BTM model can infer the topic distribution in the document.
[0122] Step S203, using the FastText model to analyze the plurality of word vectors to obtain word feature vectors of the text to be classified;
[0123] Specifically, the FastText model represents the text as a bag-of-words model, decomposing words into character-level n-gram features to capture the semantic information in the words and calculate the word vector. The word feature vector is a feature vector representation of multiple word vectors (or the text to be classified), which may include the semantic information and vocabulary information of the text to be classified.
[0124] Step S204, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector, and inputting the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
[0125] Specifically, the classifier may be a deep learning classifier such as a Softmax classifier, or may be a logistic regression classifier, a decision tree classifier, a support vector machine classifier, a K-nearest neighbor classifier, a naive Bayes classifier, a random forest classifier, or other types of classifiers.
[0126] Optionally, the text to be classified is preprocessed, including: performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words in the first intermediate text to obtain a second intermediate text; performing word segmentation on the second intermediate text to obtain a plurality of word vectors.
[0127] Optionally, a BTM (Biterm Topic Model) model is used to analyze the multiple word vectors to determine the topic feature vector of the text to be classified, including: inputting the multiple word vectors into the BTM model to obtain multiple topic vectors and the occurrence probabilities corresponding to the multiple topic vectors; determining at least one target probability from the multiple occurrence probabilities, wherein the target probability is greater than the other occurrence probabilities; and determining that at least one topic vector corresponding to the target probability constitutes the topic feature vector.
[0128] Optionally, before using the BTM model to analyze the multiple word vectors to determine the topic feature vectors of the text to be classified, the method also includes: obtaining multiple initial short text training documents; adding category labels to the multiple initial short text training documents, and performing random merging operations and shuffling operations on the initial short text training documents with the category labels added in sequence to obtain intermediate short text training documents; performing stop word removal operations and word segmentation operations on the intermediate short text training documents in sequence to obtain multiple short text training documents; and modeling the BTM model based on the multiple short text training documents and a preset number of topics.
[0129] Optionally, before using the FastText (shallow network) model to analyze the multiple word vectors to obtain the word feature vector of the text to be classified, the method also includes: establishing the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive the multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vector.
[0130] Optionally, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector includes: concatenating the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the concatenated vector.
[0131] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0132] Step S201, when receiving a text to be classified, preprocessing the text to be classified to obtain multiple word vectors, the text to be classified has less than 255 characters, and the preprocessing includes word segmentation processing;
[0133] Step S202, using the BTM model to analyze the multiple word vectors to determine the topic feature vector of the text to be classified;
[0134] Step S203, using the FastText model to analyze the plurality of word vectors to obtain word feature vectors of the text to be classified;
[0135] Step S204, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector, and inputting the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
[0136] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0137] Optionally, the text to be classified is preprocessed, including: performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words in the first intermediate text to obtain a second intermediate text; performing word segmentation on the second intermediate text to obtain a plurality of word vectors.
[0138] Optionally, a BTM (Biterm Topic Model) model is used to analyze the multiple word vectors to determine the topic feature vector of the text to be classified, including: inputting the multiple word vectors into the BTM model to obtain multiple topic vectors and the occurrence probabilities corresponding to the multiple topic vectors; determining at least one target probability from the multiple occurrence probabilities, wherein the target probability is greater than the other occurrence probabilities; and determining that at least one topic vector corresponding to the target probability constitutes the topic feature vector.
[0139] Optionally, before using the BTM model to analyze the multiple word vectors to determine the topic feature vectors of the text to be classified, the method also includes: obtaining multiple initial short text training documents; adding category labels to the multiple initial short text training documents, and performing random merging operations and shuffling operations on the initial short text training documents with the category labels added in sequence to obtain intermediate short text training documents; performing stop word removal operations and word segmentation operations on the intermediate short text training documents in sequence to obtain multiple short text training documents; and modeling the BTM model based on the multiple short text training documents and a preset number of topics.
[0140] Optionally, before using the FastText (shallow network) model to analyze the multiple word vectors to obtain the word feature vector of the text to be classified, the method also includes: establishing the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive the multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vector.
[0141] Optionally, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector includes: concatenating the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the concatenated vector.
[0142] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement at least the following method steps:
[0143] Step S201, when receiving a text to be classified, preprocessing the text to be classified to obtain multiple word vectors, the text to be classified has less than 255 characters, and the preprocessing includes word segmentation processing;
[0144] Step S202, using the BTM model to analyze the multiple word vectors to determine the topic feature vector of the text to be classified;
[0145] Step S203, using the FastText model to analyze the plurality of word vectors to obtain word feature vectors of the text to be classified;
[0146] Step S204, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector, and inputting the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
[0147] Optionally, the text to be classified is preprocessed, including: performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words in the first intermediate text to obtain a second intermediate text; performing word segmentation on the second intermediate text to obtain a plurality of word vectors.
[0148] Optionally, a BTM (Biterm Topic Model) model is used to analyze the multiple word vectors to determine the topic feature vector of the text to be classified, including: inputting the multiple word vectors into the BTM model to obtain multiple topic vectors and the occurrence probabilities corresponding to the multiple topic vectors; determining at least one target probability from the multiple occurrence probabilities, wherein the target probability is greater than the other occurrence probabilities; and determining that at least one topic vector corresponding to the target probability constitutes the topic feature vector.
[0149] Optionally, before using the BTM model to analyze the multiple word vectors to determine the topic feature vectors of the text to be classified, the method also includes: obtaining multiple initial short text training documents; adding category labels to the multiple initial short text training documents, and performing random merging operations and shuffling operations on the initial short text training documents with the category labels added in sequence to obtain intermediate short text training documents; performing stop word removal operations and word segmentation operations on the intermediate short text training documents in sequence to obtain multiple short text training documents; and modeling the BTM model based on the multiple short text training documents and a preset number of topics.
[0150] Optionally, before using the FastText (shallow network) model to analyze the multiple word vectors to obtain the word feature vector of the text to be classified, the method also includes: establishing the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive the multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation of the multiple word vectors according to the weights to obtain the word feature vector.
[0151] Optionally, concatenating the topic feature vector and the word feature vector to obtain a concatenated vector includes: concatenating the word feature vector and the topic feature vector in the order of the word feature vector first and the topic feature vector second to obtain the concatenated vector.
[0152] Obviously, those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0153] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0154] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0155] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0157] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0158] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0159] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0160] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0161] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A text classification method, characterized in that: include: When receiving a text to be classified, preprocessing the text to be classified to obtain a plurality of word vectors, wherein the text to be classified has less than 255 characters, and the preprocessing includes word segmentation processing; Using the BTM model to analyze the multiple word vectors to determine the topic feature vector of the text to be classified; Using the FastText model to analyze the plurality of word vectors to obtain word feature vectors of the text to be classified; The topic feature vector and the word feature vector are concatenated to obtain a concatenated vector, and the concatenated vector is input into a classifier for classification to obtain the category of the text to be classified.
2. The method according to claim 1, characterized in that Preprocessing the text to be classified includes: Performing data cleaning on the text to be classified to obtain a first intermediate text; removing stop words from the first intermediate text to obtain a second intermediate text; The second intermediate text is subjected to word segmentation processing to obtain a plurality of word vectors.
3. The method according to claim 1, characterized in that The BTM model is used to analyze the multiple word vectors to determine the topic feature vector of the text to be classified, including: Inputting the plurality of word vectors into the BTM model to obtain a plurality of topic vectors and occurrence probabilities corresponding to the plurality of topic vectors; Determining at least one target probability from the plurality of occurrence probabilities, the target probability being greater than the other occurrence probabilities; Determine that at least one of the topic vectors corresponding to the target probability constitutes the topic feature vector.
4. The method according to claim 3, characterized in that Before analyzing the plurality of word vectors by using the BTM model to determine the topic feature vector of the text to be classified, the method further includes: Obtain multiple initial short text training documents; Adding category labels to the plurality of the initial short text training documents, and sequentially performing random merging operations and shuffling operations on the initial short text training documents to which the category labels have been added, to obtain intermediate short text training documents; Performing a stop word removal operation and a word segmentation operation on the intermediate short text training document in sequence to obtain a plurality of short text training documents; The BTM model is modeled according to the multiple short text training documents and the preset number of topics.
5. The method according to any one of claims 1 to 4, characterized in that Before analyzing the plurality of word vectors by using the FastText model to obtain the word feature vectors of the text to be classified, the method further includes: Establish the FastText model including an input layer and a hidden layer, wherein the input layer is used to receive multiple word vectors and assign weights to the multiple word vectors; the output end of the input layer is connected to the input end of the hidden layer, and the hidden layer is used to perform weighted summation on the multiple word vectors according to the weights to obtain the word feature vector.
6. The method according to claim 1, characterized in that The topic feature vector and the word feature vector are concatenated to obtain a concatenated vector, including: The word feature vector and the topic feature vector are concatenated in the order of the word feature vector in front and the topic feature vector in the back to obtain the concatenated vector.
7. A text classification device, characterized in that: include: A processing unit, configured to pre-process the text to be classified to obtain a plurality of word vectors when receiving the text to be classified, wherein the number of characters in the text to be classified is less than 255 characters, and the pre-processing includes word segmentation processing; A first analysis unit is used to analyze the plurality of word vectors using a BTM model to determine a topic feature vector of the text to be classified; A second analysis unit is used to analyze the plurality of word vectors using a FastText model to obtain a word feature vector of the text to be classified; The concatenation unit is used to concatenate the topic feature vector and the word feature vector to obtain a concatenated vector, and input the concatenated vector into a classifier for classification to obtain the category of the text to be classified.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
9. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of claims 1 to 6.