Text classification method and device, computer device and storage medium
By constructing a target domain ontology and generating a topic feature vocabulary from the training set, and calculating the similarity of text feature vectors, the problem of low accuracy in short text classification is solved, and more efficient text topic recognition is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHAOLIAN CONSUMER FINANCE CO LTD
- Filing Date
- 2022-10-26
- Publication Date
- 2026-06-09
AI Technical Summary
Traditional text classification methods have low accuracy in classifying short texts and cannot effectively utilize the semantic features of short texts, resulting in poor classification performance.
Construct a target domain ontology, generate a target topic feature vocabulary using the target domain ontology and training set, calculate the feature vector similarity between the text to be classified and the candidate topics, and obtain the target topic feature vector to determine the target topic of the text to be classified.
By expanding the semantic features of the text, the accuracy of short text classification was improved, and more accurate topic identification was achieved.
Smart Images

Figure CN115795030B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a text classification method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] With the development of domain ontology technology, text classification technology based on domain ontology has emerged. This technology calculates the cosine similarity between the feature words of the text topic feature vector and the domain ontology, extracts words with a similarity greater than a threshold to expand the text topic feature vector and correct the weights of the topic feature vector, thereby achieving the purpose of expanding the semantic features of the text.
[0003] Traditional text classification processes are mainly based on keyword matching. However, keyword matching techniques have poor support for semantic matching, and their performance depends on the user's understanding of the method, which has significant limitations.
[0004] However, due to the characteristics of short texts, such as short length, limited information content, and sparse features expressing the text's theme, traditional text classification methods cannot be well applied to short text classification, resulting in low accuracy in short text classification. Summary of the Invention
[0005] Therefore, it is necessary to provide a text classification method, apparatus, computer device, computer-readable storage medium, and computer program product that can perform topic classification of short texts, thereby improving the accuracy of short text classification, in order to address the aforementioned technical problems.
[0006] A text classification method, the method comprising:
[0007] The text to be classified is obtained, and a target topic feature vocabulary is obtained. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0008] Calculate the feature vector of the text to be classified;
[0009] Obtain the topic feature vector corresponding to each candidate topic, wherein the topic feature vector is calculated based on the feature word set corresponding to the candidate topic;
[0010] Calculate the similarity between the feature vector of the text to be classified and the feature vectors of each topic, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0011] The candidate topics corresponding to the feature vector of the target topic are obtained as the target topics of the text to be classified.
[0012] In one embodiment, before obtaining the target topic feature vocabulary, the method further includes:
[0013] Obtain the thesaurus of the target domain and determine the application purpose of the domain ontology;
[0014] Based on the application purpose of the domain ontology, the terms in the target domain thesaurus are converted into concepts in the domain ontology to obtain the target concept.
[0015] Based on the hierarchical relationship between the terms in the target domain thesaurus, the hierarchical relationship between the target concepts is determined, and the target hierarchical relationship is obtained;
[0016] Based on the limited meanings and annotations of the terms in the thesaurus of the target domain, attributes are added to the target concept to obtain target attributes;
[0017] Based on the inter-word relationships between the terms in the target domain thesaurus, inter-word relationships are added to the target concept to obtain the target inter-word relationships;
[0018] A target concept model is constructed based on the aforementioned target concept, target hierarchy, target attributes, and relationships between target terms;
[0019] Based on the target concept model, an instance corresponding to the target concept is created to obtain the target instance;
[0020] The target domain ontology is constructed based on the target concept model and target instances.
[0021] In one embodiment, before obtaining the target topic feature vocabulary, the method further includes:
[0022] Obtain the application scope of the domain ontology, obtain a term list corresponding to the domain ontology based on the application scope, establish the conceptual structure of the domain ontology based on the term list, and obtain the target conceptual structure of the domain ontology;
[0023] Based on the target concept structure, the conceptual attributes and class constraints of the domain ontology are defined, and the target concept attributes and target class constraints of the domain ontology are obtained. Based on the target concept structure, target concept attributes and target class constraints, the target concept model of the domain ontology is formed.
[0024] Based on the target conceptual model, instances corresponding to each class in the domain ontology are created to obtain the target instance of the domain ontology. The target domain ontology is then constructed based on the target conceptual model and the target instance.
[0025] In one embodiment, after constructing the target domain ontology based on the target conceptual model and target instances, the method further includes:
[0026] The amount of historical text data obtained;
[0027] When the amount of data exceeds the first threshold, two-thirds of the historical text is used as the training set and one-third of the historical text is used as the test set to obtain the training set and the test set.
[0028] When the amount of data is less than or equal to the first threshold and greater than the second threshold, the historical text is first divided into a preset number of sample sets of the same size. Each sample set is used as a test set in turn, and the set of all sample sets other than the test set is used as the training set to obtain the training set and the test set.
[0029] When the amount of data is less than the second threshold, a sample set of the same size as the historical text is randomly extracted from the historical text as a training set, and the data in the historical text that does not appear in the training set is used as a test set to obtain the training set and the test set. The first threshold is greater than the second threshold.
[0030] The test set is used to test the accuracy of the target topic corresponding to the text to be classified.
[0031] In one embodiment, after obtaining the training set and the test set, the method further includes:
[0032] The training set is preprocessed by word segmentation and stop word removal to obtain the target historical text;
[0033] Calculate the weight of each word in the target historical text, and represent the target historical text based on the weight;
[0034] A topic is selected sequentially from the candidate topics corresponding to the target historical text. The total weight and average weight of each word in the selected topic are calculated. The words are sorted in descending order based on the total weight. A preset number of sorted words are selected as feature words of the selected topic. The average weight of each feature word is used as the weight of the feature word. The topic feature vector of the selected topic is obtained based on each feature word and its corresponding weight. This process is repeated until each candidate topic of the target historical text has a corresponding topic feature vector. Each topic feature vector is used as the first topic feature vector.
[0035] Feature filtering is performed on each first topic feature vector to obtain a second topic feature vector corresponding to each candidate topic. The topic feature vocabulary is obtained based on the second topic feature vector. The topic feature vocabulary stores each candidate topic in the target historical text and the feature word set corresponding to the candidate topic. The feature word set includes the feature word and the weight corresponding to the feature word.
[0036] In one embodiment, after obtaining the topic feature vocabulary based on the second topic feature vector, the method further includes:
[0037] Obtain the threshold, parse the target domain ontology, and analyze the instance words with negative information in the target domain ontology;
[0038] A topic is selected sequentially from the candidate topics in the topic feature vocabulary list. The similarity between each feature word in the feature word set corresponding to the selected topic and each instance word is calculated pairwise. The maximum similarity corresponding to each instance word is selected based on the similarity.
[0039] Based on the comparison results of the maximum similarity and threshold of each instance word, the instance words with the maximum similarity greater than the threshold are taken as feature-related words, and each of the feature-related words is added to the feature word set corresponding to the selected topic to obtain an updated feature word set. The weight of each feature-related word is equal to the weight of the feature word corresponding to the instance word. Based on the updated feature word set, the first target topic feature vector corresponding to the selected topic is obtained.
[0040] When each candidate topic in the topic feature vocabulary has been selected, a first target topic feature vector corresponding to each candidate topic is obtained. The first target topic feature vectors are then subjected to feature filtering to obtain a target topic feature vector corresponding to each candidate topic. Based on the target topic feature vectors, a target topic feature vocabulary is obtained.
[0041] In one embodiment, after obtaining the candidate topic corresponding to the target topic feature vector as the target topic corresponding to the text to be classified, the method further includes:
[0042] Obtain the subject information corresponding to the target object;
[0043] Based on the topic criteria corresponding to the target object, the initial historical text of the target is obtained. The target topic corresponding to the initial historical text of the target is consistent with the topic criteria. The initial historical text of the target is then sent to the terminal corresponding to the target object.
[0044] A text classification device, the device comprising:
[0045] The data acquisition module is used to acquire the text to be classified and to acquire a target topic feature vocabulary. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to provide feature words for the extended topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0046] The unclassified text feature vector generation module is used to calculate the unclassified text feature vector corresponding to the unclassified text.
[0047] The topic feature vector acquisition module is used to acquire the topic feature vectors corresponding to each candidate topic, wherein the topic feature vectors are calculated based on the feature word set corresponding to the candidate topic.
[0048] The target topic feature vector determination module is used to calculate the similarity between the feature vector of the text to be classified and each topic feature vector, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0049] The target topic determination module is used to obtain candidate topics corresponding to the target topic feature vector as the target topic corresponding to the text to be classified.
[0050] A computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0051] The text to be classified is obtained, and a target topic feature vocabulary is obtained. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0052] Calculate the feature vector of the text to be classified;
[0053] Obtain the topic feature vector corresponding to each candidate topic, wherein the topic feature vector is calculated based on the feature word set corresponding to the candidate topic;
[0054] Calculate the similarity between the feature vector of the text to be classified and the feature vectors of each topic, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0055] The candidate topics corresponding to the feature vector of the target topic are obtained as the target topics of the text to be classified.
[0056] A computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0057] The text to be classified is obtained, and a target topic feature vocabulary is obtained. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0058] Calculate the feature vector of the text to be classified;
[0059] Obtain the topic feature vector corresponding to each candidate topic, wherein the topic feature vector is calculated based on the feature word set corresponding to the candidate topic;
[0060] Calculate the similarity between the feature vector of the text to be classified and the feature vectors of each topic, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0061] The candidate topics corresponding to the feature vector of the target topic are obtained as the target topics of the text to be classified.
[0062] A computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0063] The text to be classified is obtained, and a target topic feature vocabulary is obtained. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0064] Calculate the feature vector of the text to be classified;
[0065] Obtain the topic feature vector corresponding to each candidate topic, wherein the topic feature vector is calculated based on the feature word set corresponding to the candidate topic;
[0066] Calculate the similarity between the feature vector of the text to be classified and the feature vectors of each topic, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0067] The candidate topics corresponding to the feature vector of the target topic are obtained as the target topics of the text to be classified.
[0068] The aforementioned text classification method, apparatus, computer equipment, storage medium, and computer program product acquire the text to be classified, obtain a target topic feature vocabulary, wherein the target topic feature vocabulary stores each candidate topic and the corresponding feature word set, and a feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on a target domain ontology and a topic feature vocabulary, wherein the target domain ontology is used to expand the feature words of the topic feature vocabulary, and the topic feature vocabulary is obtained based on a training set, which is partitioned from historical text. The method calculates the text feature vector corresponding to the text to be classified, obtains the topic feature vectors corresponding to each candidate topic, wherein the topic feature vectors are calculated based on the feature word set corresponding to the candidate topic, calculates the similarity between the text feature vector to be classified and each topic feature vector, obtains the target topic feature vector corresponding to the text to be classified based on the similarity, and obtains the candidate topic corresponding to the target topic feature vector as the target topic corresponding to the text to be classified. By constructing a target domain ontology, obtaining a target topic feature vocabulary based on the target domain ontology and the training set, calculating the topic feature vector of the text to be classified, calculating the similarity between the text feature vector and each topic feature vector based on the topic feature vector of the text to be classified and the topic feature vectors of each candidate topic in the target topic feature vocabulary, obtaining the target topic vector of the text to be classified based on the similarity, and obtaining the target topic of the text to be classified based on the target topic vector, the semantic features of the text are expanded, thereby improving the accuracy of short text classification. Attached Figure Description
[0069] Figure 1 This is a diagram illustrating the application environment of a text classification method in one embodiment.
[0070] Figure 2 This is a flowchart illustrating a text classification method in one embodiment;
[0071] Figure 3 This is a flowchart illustrating the composition of the target domain ontology in one embodiment;
[0072] Figure 4 This is a flowchart illustrating the process of constructing a domain ontology based on a thesaurus.
[0073] Figure 5 This is a flowchart illustrating the composition of the target domain ontology in one embodiment;
[0074] Figure 6 This is a schematic diagram illustrating the process of determining the training and test sets in one embodiment;
[0075] Figure 7 This is a schematic diagram illustrating the process of generating a topic feature vocabulary in one embodiment.
[0076] Figure 8 This is a flowchart illustrating the process of determining a target topic feature vocabulary in one embodiment;
[0077] Figure 9 This is a schematic diagram of the process of pushing the initial historical text of the target in one embodiment;
[0078] Figure 10 This is a structural block diagram of a text classification device in one embodiment;
[0079] Figure 11 This is an internal structural diagram of a computer device in one embodiment;
[0080] Figure 12 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0081] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0082] The text classification method provided in this application can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on the cloud or other network servers. Terminal 102 is used to acquire and display the initial historical text of the target, wherein the target topic corresponding to the initial historical text is consistent with the topic corresponding to the target object. Server 104 is used to acquire the text to be classified and the target topic feature vocabulary, calculate the text feature vector corresponding to the text to be classified, obtain the target topic feature vector based on the text feature vector to be classified and the topic feature vectors corresponding to each candidate topic in the target topic feature vocabulary, and use the candidate topic corresponding to the target topic feature vector as the target topic corresponding to the text to be classified. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0083] In one embodiment, such as Figure 2 As shown, a text classification method is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:
[0084] Step S200: Obtain the text to be classified and obtain the target topic feature vocabulary. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes each feature word corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0085] The text to be classified refers to short texts that meet the preset conditions. The target topic feature vocabulary refers to a vocabulary containing topics, corresponding feature words, and their corresponding weights. The feature word set refers to a set of words that can express the same topic, where each word has its corresponding weight. The target domain ontology refers to a vocabulary that can be used to describe concepts and relationships between concepts in the target domain, providing a vocabulary of concepts in the target domain and the relationships between concepts, or a dominant theory in the target domain, where the target domain ontology considers both Chinese and English. The topic feature vocabulary refers to a vocabulary that has not yet been expanded with the target domain ontology for each topic. A feature word refers to a word that can express a certain type of topic. The training set refers to a portion of historical texts allocated from historical texts. Historical texts refer to short texts that meet the preset conditions and are collected and stored in the database.
[0086] Specifically, before obtaining the target topic features, it is necessary to construct a target domain ontology. The construction of the target domain ontology can be done in two ways: building it from scratch and building it based on an existing thesaurus. Furthermore, a topic feature vocabulary needs to be obtained through the training set. Then, instance words are provided by the target domain ontology. The similarity between these instance words and the feature words corresponding to each candidate topic in the topic feature vocabulary is calculated. Based on the similarity, the topics corresponding to the instance words are classified, and the instance words are added as feature-related words to the corresponding topics, thereby expanding the topic feature vocabulary and obtaining the target topic feature vocabulary.
[0087] Step S202: Calculate the feature vector of the text to be classified.
[0088] Among them, the text feature vector to be classified refers to the text to be classified as a mathematical vector, and the text feature vector to be classified has the weights corresponding to the text to be classified.
[0089] Specifically, to calculate the similarity between the feature vector of the text to be classified and the feature vectors of each candidate topic, it is necessary to calculate the weight of the text to be classified and to use a vector space model to represent the text to be classified.
[0090] Step S202: Obtain the topic feature vector corresponding to each candidate topic. The topic feature vector is calculated based on the feature word set corresponding to the candidate topic.
[0091] Here, candidate topics refer to topics included in the target topic feature vocabulary. A topic feature vector represents each topic as a mathematical vector, containing corresponding feature words and their corresponding weights.
[0092] Specifically, before calculating the similarity between the feature vector of the text to be classified and the topic feature vectors corresponding to each candidate topic, it is necessary to obtain the data required for the calculation. The topic feature vectors are mainly used to prepare data for subsequent processes.
[0093] Step S204: Calculate the similarity between the feature vector of the text to be classified and the feature vectors of each topic, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0094] Similarity refers to a metric used to comprehensively assess the degree of semantic similarity between the text to be classified and various topics. The target topic feature vector refers to the topic feature vector corresponding to the topic that is most semantically similar to the text to be classified.
[0095] Specifically, the similarity between the feature vector of the text to be classified and each topic feature vector is calculated, and the topic feature vector corresponding to the maximum similarity among the various similarities is selected as the target topic feature vector corresponding to the text to be classified. The similarity calculation method uses the word similarity method provided by HowNet. HowNet is a common sense knowledge base that uses the concepts represented by Chinese and English words as its description objects and aims to reveal the relationships between concepts and the attributes possessed by concepts. The specific calculation formula is shown in formula (1), where C... i T represents the feature vector of topic i. j Let w represent the feature vector of complaint document j. ik It is the feature word weight in the topic feature vector, v jk These are the weights in the feature vector of the text to be classified.
[0096]
[0097] Step S206: Obtain the candidate topic corresponding to the target topic feature vector as the target topic corresponding to the text to be classified.
[0098] The target topic refers to the topic that is most similar in meaning to the text to be classified. The target topic can be used to obtain various semantic information in the text to be classified, or the corresponding historical text can be sent to the terminal based on the target topic.
[0099] In the above text classification method, the text to be classified is obtained, and a target topic feature vocabulary is obtained. The target topic feature vocabulary stores each candidate topic and the corresponding feature word set. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text. The feature vector of the text to be classified is calculated, and the topic feature vectors corresponding to each candidate topic are obtained. The topic feature vectors are calculated based on the feature word set corresponding to the candidate topic. The similarity between the feature vector of the text to be classified and each topic feature vector is calculated. Based on the similarity, the target topic feature vector of the text to be classified is obtained, and the candidate topic corresponding to the target topic feature vector is obtained as the target topic of the text to be classified. By constructing a target domain ontology, obtaining a target topic feature vocabulary based on the target domain ontology and the training set, calculating the topic feature vector of the text to be classified, calculating the similarity between the text feature vector and each topic feature vector based on the topic feature vector of the text to be classified and the topic feature vectors of each candidate topic in the target topic feature vocabulary, obtaining the target topic vector of the text to be classified based on the similarity, and obtaining the target topic of the text to be classified based on the target topic vector, the semantic features of the text are expanded, thereby improving the accuracy of short text classification.
[0100] In one embodiment, such as Figure 3 As shown, before step S200, the following steps are also included:
[0101] Step S300: Obtain the target domain thesaurus and determine the application purpose of the domain ontology.
[0102] The thesaurus refers to a tool for controlling vocabulary, used to collect words that can represent a specific discipline. These words are arranged in a specific structure to show the relationships between them. A domain ontology refers to a tool that can describe concepts and relationships within a specific domain, providing a thesaurus of concepts and relationships between them in a particular discipline, or a dominant theory in the corresponding domain. The application purpose refers to the scope and scenarios in which the domain ontology is applied, and the goals it aims to achieve.
[0103] Step S302: Based on the application purpose of the domain ontology, the terms in the target domain thesaurus are converted into concepts in the domain ontology to obtain the target concept.
[0104] Among them, the concept of target refers to the concept that is related to the target domain.
[0105] Specifically, the existing thesaurus of the target domain may contain terms that do not conform to the relevant concepts of the target domain. In order to ensure that the concepts contained in the constructed domain ontology are consistent with the application scope of the target domain ontology, it is necessary to convert the terms in the target domain thesaurus into concepts in the domain ontology.
[0106] Step S304: Based on the hierarchical relationship between the terms in the target domain thesaurus, determine the hierarchical relationship between the target concepts to obtain the target hierarchical relationship.
[0107] Among them, hierarchical relationship refers to the breadth of a descriptive concept, similar to the relationship of inclusion and exclusion. Rank relationship refers to the relationship between target concepts based on the breadth of the concept. Target-rank relationship refers to the hierarchical relationship existing between target concepts corresponding to the target domain.
[0108] Specifically, identifying and improving important concepts related to the target domain in the thesaurus and finding the relationships between these concepts is also an important step in constructing the target domain ontology. The hierarchical relationship between the target concepts is the basis for clarifying the concept structure.
[0109] Step S306: Based on the limited meanings and annotations of the terms in the target domain thesaurus, add attributes to the target concept to obtain target attributes.
[0110] Among them, limiting words refer to words that can serve to specify, classify, or indicate definite or indefinite quantities. Annotations refer to information about the explanation or expansion of words. Target attributes refer to attributes that can describe the inherent structure between target concepts in the target domain ontology.
[0111] Specifically, describing the target domain is not enough; it is also necessary to describe the internal structure of the concepts. Target attributes are used to describe the internal structure of the concepts in the target domain, hence the addition of conceptual attributes to the target concepts.
[0112] Step S308: Based on the inter-word relationships between the terms in the target domain thesaurus, add inter-word relationships to the target concept to obtain target inter-word relationships.
[0113] Among them, inter-word relationships refer to the relationships that exist between the terms. Target inter-word relationships refer to the relationships between related terms in the thesaurus obtained based on the target domain analysis.
[0114] Specifically, in order to better describe the target domain, it is also necessary to analyze the relationships between words and find the constraints between words (or the classes to which the words correspond) in order to better construct the target domain ontology.
[0115] Step S310: Construct a target concept model based on the target concept, target hierarchy relationship, target attributes, and target word relationship.
[0116] The target conceptual model refers to the initial domain ontology that has not yet had instances added.
[0117] Step S312: Create an instance corresponding to the target concept based on the target concept model to obtain the target instance.
[0118] Among them, target instances refer to the discourses created for each thesaurus that can most accurately express the target domain application scenario.
[0119] Step S314: Construct the target domain ontology based on the target concept model and target instances.
[0120] Specifically, the flowchart for constructing a domain ontology based on a thesaurus is as follows: Figure 4 As shown.
[0121] In this embodiment, the target domain is constructed using the existing thesaurus of the target domain, which greatly reduces the workload of constructing the target domain ontology, eliminating the need to re-collect important terms in the target domain. Furthermore, the thesaurus is very helpful in clarifying the relationships between important terms, thereby improving the usefulness of the target domain ontology.
[0122] In one embodiment, such as Figure 5 As shown, before step S200, the following steps are also included:
[0123] Step S500: Obtain the application scope of the domain ontology, obtain a terminology list corresponding to the domain ontology based on the application scope, establish the conceptual structure of the domain ontology based on the terminology list, and obtain the target conceptual structure of the domain ontology.
[0124] The application scope refers to the domain range that the target domain ontology can use. The terminology list refers to a list of words related to the target domain ontology. The concept structure refers to the relational structure constructed by subdividing terms into categories based on the breadth of their concepts using a top-down approach. The target concept structure refers to the relational structure constructed by subdividing terms in the target domain into categories based on the breadth of their concepts using a top-down approach.
[0125] Specifically, before constructing the target domain ontology, it is necessary to first determine the application scope of the target domain ontology. Then, based on the application scope, important terms related to the target domain ontology are collected. This application constructs a credit ontology concerning credit, so the collected terms mainly focus on those related to credit complaint texts. These terms are primarily collected from credit-related literature and patents, national and institutional standard documents, consultations with financial experts, relevant websites, and complaints. Then, based on the collected important terms, a corresponding term list is compiled. The term list is analyzed to clarify the relationships between terms, removing terms with concepts irrelevant to the target domain. The established conceptual relationships between terms are formally encoded. Then, a top-down approach is adopted, starting from the most generalized concepts, and each term is further subdivided into categories to construct the target concept structure.
[0126] Step S502: Define the conceptual attributes and set class constraints of the domain ontology based on the target conceptual structure to obtain the target conceptual attributes and target class constraints of the domain ontology. Based on the target conceptual structure, target conceptual attributes and target class constraints, form the target conceptual model of the domain ontology.
[0127] Here, "conceptual attributes" refers to attributes that describe the inherent structure between concepts in a domain ontology. These attributes are divided into data attributes and object attributes. Data attributes refer to the characteristics corresponding to data, while object attributes refer to the features that distinguish the current object from other objects. "Class constraints" refers to the constraints imposed on the attributes of a class. "Target conceptual attributes" refers to attributes that describe the inherent structure between concepts in the target domain ontology. "Target class constraints" refers to the constraints imposed on the attributes of each class in the target domain ontology. "Target conceptual model" refers to the initial domain ontology before any instances have been added.
[0128] Specifically, the attributes of the target domain ontology can describe the inherent structure between concepts. To create a target domain, it is necessary to first define the corresponding attributes for the target concepts. After defining common attributes in the parent concept, the child concepts can either inherit all the attributes of the parent concept or define attributes unique to the parent concept, that is, define the private attributes of the parent concept. By defining the attributes, constraints are set for the classes, that is, certain classes are required to have certain attributes as constraints for these classes, and the corresponding subclasses will also inherit the constraints of the corresponding parent class. Thus, the target concept attributes and target class constraints corresponding to the target domain ontology are obtained. Based on the obtained target concepts, target class constraints, and target concept structure, the preliminary target domain ontology, that is, the target concept structure, is formed.
[0129] Step S504: Create instances corresponding to each class in the domain ontology based on the target conceptual model to obtain the target instance of the domain ontology. The target domain ontology is constructed based on the target conceptual model and the target instance.
[0130] In this context, "instance" refers to a specific expression created for each class based on a particular application scenario, capable of conveying the most precise concept. "Target instance" refers to the most precise expression created for each class in the target domain, based on the target domain's application scenario.
[0131] Specifically, the possible ways in which the association between classes and instances may exist are also one of the elements constituting the domain ontology, because it is also necessary to create instances corresponding to each class according to the specific application in order to obtain instances that can be expressed most accurately, thereby constructing the target domain ontology based on instances and the target conceptual model.
[0132] In this embodiment, by autonomously collecting important terms in the target domain, the relevance of the collected terms to the application scope of the target domain can be better ensured. The entire process of constructing the target domain ontology is done from scratch, giving the resulting target domain ontology a degree of novelty.
[0133] In one embodiment, such as Figure 6 As shown, after step S314 or S504, the following steps are also included:
[0134] Step S600: Obtain the amount of historical text data.
[0135] Step S602: When the amount of data is greater than the first threshold, two-thirds of the historical text is used as the training set and one-third of the historical text is used as the test set to obtain the training set and the test set.
[0136] The first threshold refers to the boundary for determining historical text as large-scale data.
[0137] Step S604: When the amount of data is less than or equal to the first threshold and greater than the second threshold, the historical text is first divided into a preset number of sample sets of the same size. Each sample set is used as a test set in turn, and the set of all sample sets other than the test set is used as the training set to obtain the training set and the test set.
[0138] The second threshold refers to the boundary for classifying historical text as small-scale data. When the data falls between the first and second thresholds, it is classified as medium-scale data. The preset quantity refers to a manually defined number.
[0139] Step S606: When the amount of data is less than the second threshold, repeatedly and randomly extract a sample set of the same size as the historical text from the historical text as the training set, and use the data in the historical text that does not appear in the training set as the test set to obtain the training set and the test set, wherein the first threshold is greater than the second threshold.
[0140] The sample set refers to a collection of samples that are repeatedly and randomly drawn from historical texts.
[0141] Step S608: The test set is used to test the accuracy of the target topic corresponding to the text to be classified.
[0142] In this embodiment, by defining the method of dividing the training set and the test set according to the size of the historical text data, it is possible to avoid the significant impact of too much or too little historical text on the classification results, which is beneficial to improving the accuracy of text classification.
[0143] In one embodiment, such as Figure 7 As shown, after step S602, S604, or S606, the method further includes:
[0144] Step S700: Perform word segmentation and stop word removal preprocessing on the training set to obtain the target historical text.
[0145] Among these, word segmentation refers to the process of scanning out words in a sentence and further segmenting long words. Stop words refer to certain characters or words that are automatically filtered out before or after text processing in information retrieval to save storage space and improve search efficiency. Stop word removal refers to the process of removing stop words contained in historical text after word segmentation. Target historical text refers to the text obtained after word segmentation and stop word removal on the training set.
[0146] Specifically, the ICTCLAS word segmentation tool developed by the Chinese Academy of Sciences was used for word segmentation. After word segmentation, words that appeared frequently but had little practical significance were removed from the training set after word segmentation, based on the Chinese stop word list that is generally accepted on the Internet. These words mainly include adverbs, function words and modal particles.
[0147] Step S702: Calculate the weight of each word in the target historical text, and represent the target historical text based on the weight.
[0148] Here, weight refers to the TF-IDF value of each word in each document within a given topic. Text representation refers to the operation of representing each word in a text as a mathematical vector.
[0149] Specifically, the TF-IDF method is used for calculation. The TF-IDF calculation formula is shown in formula (2), where w ij tf represents the weight of the j-th word in the i-th text. ij df represents the number of times the j-th word in the i-th text appears in the i-th text. ijLet represent the number of texts containing the j-th word of the i-th text among all texts corresponding to the selected topic, and N represent the total number of texts in the target historical texts corresponding to the selected topic. After calculating the weight of each word using the TF-IDF method, a vector space model is used to represent the target historical text, representing each word in the target historical text as a mathematical vector. Furthermore, considering that words in the text title highlight the text topic more effectively than words in the text body, when calculating the weights, words in the text body are counted normally according to their frequency of occurrence in the text, while words in the title are calculated as a multiple of their frequency of occurrence λ (λ is a manually set parameter). The value of λ can be determined by first appropriately increasing the weight of words in the title, then analyzing the classification effect of the current λ value on a subset of datasets, and then adjusting the value of λ based on the classification effect.
[0150]
[0151] Step S704: Select a topic from the candidate topics corresponding to the target historical text in sequence, calculate the total weight and average weight of each word in the selected topic, sort the words in descending order of total weight, select a preset number of sorted words as feature words of the selected topic, and use the average weight of each feature word as the weight of the feature word, obtain the topic feature vector of the selected topic based on each feature word and the weight of each feature word, until each candidate topic of the target historical text has obtained a corresponding topic feature vector, and use each topic feature vector as the first topic feature vector.
[0152] The total weight refers to the sum of the weights of each word in each document within the target historical text corresponding to the selected topic. The average weight refers to the average weight of each word in each document within the target historical text corresponding to the selected topic. The first topic feature vector refers to the topic feature vector containing many feature terms unrelated to the topic, and for which no filtering process has yet been performed.
[0153] Specifically, constructing a topic feature vector requires calculating the weight of each word, and then filtering out feature words corresponding to each topic based on these weights. The total weight of each word determines which words are used as feature words, and the average weight of each feature word across all documents is used as its corresponding weight. A topic feature vector is constructed based on the feature words and their weights. However, this topic feature vector still contains many feature terms unrelated to the topic, so it cannot yet be used as the topic feature vector for each candidate topic in the topic feature vocabulary. Therefore, feature filtering processing is still required on the first topic feature vector.
[0154] Step S706: Perform feature filtering on each first topic feature vector to obtain a second topic feature vector corresponding to each candidate topic. Based on the second topic feature vector, obtain the topic feature vocabulary. The topic feature vocabulary stores each candidate topic in the target historical text and the feature word set corresponding to the candidate topic. The feature word set includes the feature word and the weight corresponding to the feature word.
[0155] The second topic feature vector refers to the topic feature vector obtained after feature filtering the first topic feature vector.
[0156] Specifically, to avoid the influence of many irrelevant feature terms in the first topic feature vector on the classification results, feature filtering is required. For the constructed first topic feature vector, feature words that appear in the first topic feature vector of the currently selected topic and also in the first topic feature vectors of any three other candidate topics are discarded. Each feature term in the first topic feature vector is independent and non-overlapping with any other feature term in the first topic feature vector, thus ensuring the independence of feature terms among the second topic feature vectors and achieving feature dimensionality reduction. Feature terms include feature words and their corresponding weights.
[0157] In this embodiment, the training set is first preprocessed by word segmentation and stop word removal to obtain the target historical text. Then, the weight of each word in the target historical text is calculated and the text is represented. Feature words are selected based on the weights of each word. Finally, a topic feature vector is constructed based on the feature words and their weights to obtain a topic feature vocabulary. This lays a very important data foundation for the subsequent construction of the target topic feature vocabulary and is conducive to improving the accuracy of short text classification.
[0158] In one embodiment, such as Figure 8 As shown, after step S706, the following steps are also included:
[0159] Step S800: Obtain the threshold, parse the target domain ontology, and analyze to obtain instance words with negative information in the target domain ontology.
[0160] Here, the threshold refers to the minimum similarity value required to determine similarity between words. Instance words refer to words within instances of the target domain ontology.
[0161] Specifically, the expansion of the topic feature vocabulary requires the use of the target domain ontology to provide feature-related words. Since this method targets short complaint texts, it selects instance words with negative information.
[0162] Step S802: Select a topic from the candidate topics in the topic feature vocabulary list in sequence, calculate the similarity between each feature word in the feature word set corresponding to the selected topic and each instance word, and select the maximum similarity corresponding to each instance word based on each similarity.
[0163] Specifically, the similarity between each instance word and each feature word is calculated. The similarity calculation method adopts the word similarity method provided by HowNet. The comparison results of the similarity are used to identify instance words similar to the feature words as feature-related words.
[0164] Step S804: Based on the comparison results of the maximum similarity and threshold corresponding to each instance word, the instance words with the maximum similarity greater than the threshold are taken as feature-related words, and each of the feature-related words is added to the feature word set corresponding to the selected topic to obtain an updated feature word set. The weight of each feature-related word is equal to the weight of the feature word corresponding to the instance word. Based on the updated feature word set, the first target topic feature vector corresponding to the selected topic is obtained.
[0165] Among them, the feature-related words refer to the instance words that are most similar to a certain feature word in the selected topic. The first target topic feature vector refers to the topic feature vector calculated after updating the corresponding feature words and feature word weights according to each topic.
[0166] Specifically, based on the threshold definition, instance words similar to the feature words in each original topic are selected to expand the feature word set corresponding to each topic. By expanding the topic feature word list, the classification of short texts becomes more accurate and efficient.
[0167] Step S806: When each candidate topic in the topic feature vocabulary has been selected, the first target topic feature vector corresponding to each candidate topic is obtained. The first target topic feature vector is subjected to feature filtering to obtain the target topic feature vector corresponding to each candidate topic. The target topic feature vocabulary is obtained based on the target topic feature vector.
[0168] The target topic feature vector refers to the topic feature vector obtained after feature filtering of the first target topic feature vector. This target topic feature vector is used to calculate the similarity with the feature vector of the text to be classified.
[0169] Specifically, to avoid the influence of irrelevant feature terms in the first target topic feature vector on the classification results, feature filtering is required. This involves discarding feature words that appear in both the first and any other three first target topic feature vectors, thus ensuring the independence of feature terms among the target topic feature vectors and improving the accuracy of text classification.
[0170] In this embodiment, instance words of an extended topic feature vocabulary are provided by the target domain ontology. Then, based on the word similarity method provided by HowNet, instance words that meet the preset conditions are selected as feature-related words, and the feature-related words are added to the corresponding topic feature vectors to obtain the target topic feature vocabulary. This makes the similarity calculation more accurate, thereby improving the accuracy of short text classification.
[0171] In one embodiment, such as Figure 9 As shown, after step S206, the following steps are also included:
[0172] Step S900: Obtain the subject information corresponding to the target object;
[0173] The topic refers to the topic corresponding to the text required by the target object.
[0174] Step S902: Based on the topic criteria corresponding to the target object, obtain the target initial historical text. The target topic corresponding to the target initial historical text is consistent with the topic criteria. Send the target initial historical text to the terminal corresponding to the target object.
[0175] The target initial historical text refers to the text stored in the database that has not undergone any text processing.
[0176] Specifically, the database stores data information on the topic classification of historical texts. Based on the topic criteria, the server can find the target topic that matches the topic criteria, and then send the historical text corresponding to the target topic to the terminal.
[0177] In this embodiment, by obtaining historical text corresponding to the target topic that matches the topic, the target object can obtain the information it wants to know more quickly and conveniently, thereby improving the target object's experience.
[0178] In one embodiment, in addition to applying the HowNet general ontology mentioned in the method of this application, WordNet, Euro WordNet, and CoreNet general ontology can also be used. The semantic relations in these general ontology are used as a bridge to provide the same functionality as knowledge in the human brain, linking classes and unlabeled documents to achieve automatic text classification.
[0179] In one embodiment, important terms needed to construct the domain ontology are collected through channels such as literature and patents related to the application domain of the domain ontology, national and institutional standard documents, consultation with financial experts, and comments and complaints on relevant websites. A term list is compiled based on these important terms, the relationships between terms are analyzed and clarified, and the conceptual structure of the domain ontology is constructed. In addition, the conceptual attributes of the domain ontology are defined and class constraints are set. Based on the conceptual structure, conceptual attributes and class constraints, instances corresponding to each class are created, and finally the target domain ontology, namely the credit domain ontology, is constructed. Then, the complaint texts collected by merchants are used as historical texts. These historical texts undergo word segmentation and stop word removal preprocessing to obtain target historical texts. A topic feature vocabulary related to credit is constructed based on these historical texts. A target domain vocabulary is then obtained based on this topic feature vocabulary and a credit domain ontology, where the credit domain ontology provides feature-related words to expand the topic feature vocabulary. When new text is obtained and it is necessary to know which topics it belongs to, the feature vector of the new text can be calculated. This feature vector is used as the feature vector of the text to be classified. The similarity between the feature vector of the text to be classified and the topic feature vectors corresponding to each candidate topic in the target topic feature vocabulary is then calculated. The topic corresponding to the topic feature vector with the highest similarity is selected as the target topic of the new text, thus allowing for faster extraction of important information from the new text. Distinguishing important information from the complaint texts and knowing the topics corresponding to this important information is beneficial for identifying problems from the complaint texts, thus facilitating merchants to make corresponding solutions. Furthermore, these large numbers of complaint texts can reveal potential loopholes in credit products, which can serve as early warnings for financial lending. In addition, users can search for complaint texts related to the topics they want to know about, thereby obtaining the information they need from the complaint texts and the merchants' responses to them. This reduces the time users spend searching through massive amounts of information and improves the user experience. The method described in this application uses a domain ontology to expand the semantic features of the text, solving the inherent feature deficiency of short texts, thereby improving the classification performance of short texts and significantly increasing the accuracy of short text classification.
[0180] Based on the same inventive concept, this application also provides a text classification apparatus for implementing the text classification method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more text classification apparatus embodiments provided below can be found in the limitations of the text classification method described above, and will not be repeated here.
[0181] In one embodiment, such as Figure 10As shown, a text classification device is provided, including: a data acquisition module 1000, a feature vector generation module 1002 for the text to be classified, a topic feature vector acquisition module 1004, a target topic feature vector determination module 1006, and a target topic determination module 1008, wherein:
[0182] The data acquisition module 1000 is used to acquire the text to be classified and to acquire a target topic feature vocabulary. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to provide feature words for the extended topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text.
[0183] The text feature vector generation module 1002 is used to calculate the text feature vector corresponding to the text to be classified.
[0184] The topic feature vector acquisition module 1004 is used to acquire the topic feature vectors corresponding to each candidate topic, wherein the topic feature vectors are calculated based on the feature word set corresponding to the candidate topic.
[0185] The target topic feature vector determination module 1006 is used to calculate the similarity between the feature vector of the text to be classified and each topic feature vector, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity.
[0186] The target topic determination module 1008 is used to obtain the candidate topics corresponding to the target topic feature vector as the target topic corresponding to the text to be classified.
[0187] In one embodiment, the text classification device further includes a first target domain ontology generation module 1010. The first target domain ontology generation module 1010 is used to: acquire a target domain thesaurus; determine the application purpose of the domain ontology; based on the application purpose of the domain ontology, convert the terms in the target domain thesaurus into concepts in the domain ontology to obtain target concepts; determine the hierarchical relationship between the target concepts based on the hierarchical relationship between the terms in the target domain thesaurus to obtain target hierarchical relationships; add attributes to the target concepts based on the limiting words and annotations of the terms in the target domain thesaurus to obtain target attributes; add inter-word relationships to the target concepts based on the inter-word relationships between the terms in the target domain thesaurus to obtain target inter-word relationships; construct a target concept model based on the target concepts, target hierarchical relationships, target attributes, and target inter-word relationships; create instances corresponding to the target concepts based on the target concept model to obtain target instances; and construct a target domain ontology based on the target concept model and target instances.
[0188] In one embodiment, the text classification device further includes a second target domain ontology generation module 1012. The second target domain ontology generation module 1012 is used to obtain the application scope of the domain ontology, obtain a term list corresponding to the domain ontology based on the application scope, establish a conceptual structure of the domain ontology based on the term list, and obtain a target conceptual structure of the domain ontology; define conceptual attributes and set class constraints of the domain ontology based on the target conceptual structure, and obtain target conceptual attributes and target class constraints of the domain ontology; form a target conceptual model of the domain ontology based on the target conceptual structure, target conceptual attributes, and target class constraints; create instances corresponding to each class in the domain ontology based on the target conceptual model, and obtain target instances of the domain ontology; and constitute a target domain ontology based on the target conceptual model and target instances.
[0189] In one embodiment, the text classification device further includes a training set and test set determination module 1014, which is used to acquire the amount of historical text data; when the amount of data is greater than a first threshold, two-thirds of the historical text is used as the training set and one-third of the historical text is used as the test set to obtain the training set and test set; when the amount of data is less than or equal to the first threshold and greater than a second threshold, the historical text is first divided into a preset number of sample sets of the same size, each sample set is used as the test set in turn, and the set of all sample sets other than the test set is used as the training set to obtain the training set and test set; when the amount of data is less than the second threshold, a sample set of the same size as the historical text is repeatedly and randomly extracted from the historical text as the training set, and data in the historical text that does not appear in the training set is used as the test set to obtain the training set and test set, wherein the first threshold is greater than the second threshold; the test set is used to test the accuracy of the target topic corresponding to the text to be classified.
[0190] In one embodiment, the text classification device further includes a topic feature vocabulary generation module 1016. The topic feature vocabulary generation module 1016 is used to perform word segmentation and stop word removal preprocessing on the training set to obtain target historical text; calculate the weight of each word in the target historical text; represent the target historical text based on the weights; sequentially select a topic from the candidate topics corresponding to the target historical text; calculate the total weight and average weight of each word in the selected topic; sort the words in descending order based on the total weight; sequentially select a preset number of sorted words as feature words of the selected topic; and assign each feature word to a corresponding... The average weight of each feature word is used as the weight of the corresponding feature word. Based on each feature word and its corresponding weight, the topic feature vector of the selected topic is obtained until each candidate topic of the target historical text has a corresponding topic feature vector. Each topic feature vector is used as a first topic feature vector. Feature filtering is performed on each first topic feature vector to obtain a second topic feature vector corresponding to each candidate topic. The topic feature vocabulary is obtained based on the second topic feature vector. The topic feature vocabulary stores each candidate topic in the target historical text and the set of feature words corresponding to the candidate topics. The set of feature words includes the feature words and their corresponding weights.
[0191] In one embodiment, the text classification device further includes a target topic feature vocabulary determination module 1018. This module 1018 is used to obtain a threshold, parse the target domain ontology, and analyze instance words with negative information in the target domain ontology; sequentially select a topic from the candidate topics of the topic feature vocabulary, calculate the pairwise similarity between each feature word in the feature word set corresponding to the selected topic and each instance word, and select the maximum similarity corresponding to each instance word based on the similarity; based on the comparison result between the maximum similarity corresponding to each instance word and the threshold, classify the instance words whose maximum similarity is greater than the threshold as... The feature-related words are identified and added to the feature word set corresponding to the selected topic to obtain an updated feature word set. The weight of each feature-related word is equal to the weight of the feature word corresponding to the instance word. Based on the updated feature word set, a first target topic feature vector corresponding to the selected topic is obtained. When each candidate topic in the topic feature vocabulary has been selected, a first target topic feature vector corresponding to each candidate topic is obtained. The first target topic feature vectors are then subjected to feature filtering to obtain target topic feature vectors corresponding to each candidate topic. Based on the target topic feature vectors, a target topic feature vocabulary is obtained.
[0192] In one embodiment, the text classification device further includes a historical text push module 1020, which is used to obtain the topic basis corresponding to the target object; based on the topic basis corresponding to the target object, obtain the target initial historical text, wherein the target topic corresponding to the target initial historical text is consistent with the topic basis, and send the target initial historical text to the terminal corresponding to the target object.
[0193] Each module in the aforementioned text classification device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0194] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores historical text data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a text classification method.
[0195] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 12 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a text classification method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0196] Those skilled in the art will understand that Figure 11 and Figure 12The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0197] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method examples.
[0198] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0199] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0200] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0201] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0202] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0203] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A text classification method, characterized in that, The method includes: The text to be classified is obtained, and a target topic feature vocabulary is obtained. The target topic feature vocabulary stores each candidate topic and the feature word set corresponding to the candidate topic. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to expand the feature words of the topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text. Calculate the feature vector of the text to be classified; Obtain the topic feature vector corresponding to each candidate topic, wherein the topic feature vector is calculated based on the feature word set corresponding to the candidate topic; Calculate the similarity between the feature vector of the text to be classified and the feature vectors of each topic, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity. The candidate topics corresponding to the target topic feature vector are obtained as the target topics corresponding to the text to be classified. Before obtaining the target topic feature vocabulary, the method further includes: Obtain the application scope of the domain ontology, obtain a term list corresponding to the domain ontology based on the application scope, establish the conceptual structure of the domain ontology based on the term list, and obtain the target conceptual structure of the domain ontology; Based on the target concept structure, the conceptual attributes and class constraints of the domain ontology are defined, and the target concept attributes and target class constraints of the domain ontology are obtained. Based on the target concept structure, target concept attributes and target class constraints, the target concept model of the domain ontology is formed. Based on the target conceptual model, instances corresponding to each class in the domain ontology are created to obtain the target instance of the domain ontology. The target domain ontology is then constructed based on the target conceptual model and the target instance.
2. The method according to claim 1, characterized in that, Before obtaining the target topic feature vocabulary, the process also includes: Obtain the thesaurus of the target domain and determine the application purpose of the domain ontology; Based on the application purpose of the domain ontology, the terms in the target domain thesaurus are converted into concepts in the domain ontology to obtain the target concept. Based on the hierarchical relationship between the terms in the target domain thesaurus, the hierarchical relationship between the target concepts is determined, and the target hierarchical relationship is obtained; Based on the limited meanings and annotations of the terms in the thesaurus of the target domain, attributes are added to the target concept to obtain target attributes; Based on the inter-word relationships between the terms in the target domain thesaurus, inter-word relationships are added to the target concept to obtain the target inter-word relationships; A target concept model is constructed based on the aforementioned target concept, target hierarchy, target attributes, and relationships between target terms; Based on the target concept model, an instance corresponding to the target concept is created to obtain the target instance; The target domain ontology is constructed based on the target concept model and target instances.
3. The method according to claim 1 or claim 2, characterized in that, After constructing the target domain ontology based on the target conceptual model and target instances, it also includes: The amount of historical text data obtained; When the amount of data exceeds the first threshold, two-thirds of the historical text is used as the training set and one-third of the historical text is used as the test set to obtain the training set and the test set. When the amount of data is less than or equal to the first threshold and greater than the second threshold, the historical text is first divided into a preset number of sample sets of the same size, each sample set is used as a test set in turn, and the set of all sample sets other than the test set is used as the training set to obtain the training set and the test set. When the amount of data is less than the second threshold, a sample set of the same size as the historical text is randomly extracted from the historical text repeatedly as a training set, and the data in the historical text that does not appear in the training set is used as a test set to obtain the training set and the test set, wherein the first threshold is greater than the second threshold. The test set is used to test the accuracy of the target topic corresponding to the text to be classified.
4. The method according to claim 3, characterized in that, After obtaining the training set and the test set, the process also includes: The training set is preprocessed by word segmentation and stop word removal to obtain the target historical text; Calculate the weight of each word in the target historical text, and represent the target historical text based on the weight; A topic is selected sequentially from the candidate topics corresponding to the target historical text. The total weight and average weight of each word in the selected topic are calculated. The words are sorted in descending order based on the total weight. A preset number of sorted words are selected as feature words of the selected topic. The average weight of each feature word is used as the weight of the feature word. The topic feature vector of the selected topic is obtained based on each feature word and its corresponding weight. This process is repeated until each candidate topic of the target historical text has a corresponding topic feature vector. Each topic feature vector is used as the first topic feature vector. Feature filtering is performed on each first topic feature vector to obtain a second topic feature vector corresponding to each candidate topic. The topic feature vocabulary is obtained based on the second topic feature vector. The topic feature vocabulary stores each candidate topic in the target historical text and the feature word set corresponding to the candidate topic. The feature word set includes the feature word and the weight corresponding to the feature word.
5. The method according to claim 4, characterized in that, After obtaining the topic feature vocabulary based on the second topic feature vector, the process further includes: Obtain the threshold, parse the target domain ontology, and analyze the instance words with negative information in the target domain ontology; A topic is selected sequentially from the candidate topics in the topic feature vocabulary list. The similarity between each feature word in the feature word set corresponding to the selected topic and each instance word is calculated pairwise. The maximum similarity corresponding to each instance word is selected based on the similarity. Based on the comparison results of the maximum similarity and threshold of each instance word, the instance words with the maximum similarity greater than the threshold are taken as feature-related words, and each of the feature-related words is added to the feature word set corresponding to the selected topic to obtain an updated feature word set. The weight of each feature-related word is equal to the weight of the feature word corresponding to the instance word. Based on the updated feature word set, the first target topic feature vector corresponding to the selected topic is obtained. When each candidate topic in the topic feature vocabulary has been selected, a first target topic feature vector corresponding to each candidate topic is obtained. The first target topic feature vectors are then subjected to feature filtering to obtain a target topic feature vector corresponding to each candidate topic. Based on the target topic feature vectors, a target topic feature vocabulary is obtained.
6. The method according to claim 1, characterized in that, After obtaining the candidate topic corresponding to the target topic feature vector as the target topic corresponding to the text to be classified, the method further includes: Obtain the subject information corresponding to the target object; Based on the topic criteria corresponding to the target object, the initial historical text of the target is obtained. The target topic corresponding to the initial historical text of the target is consistent with the topic criteria. The initial historical text of the target is then sent to the terminal corresponding to the target object.
7. A text classification device, characterized in that, The device includes: The data acquisition module acquires the text to be classified and obtains a target topic feature vocabulary. The target topic feature vocabulary stores each candidate topic and the corresponding feature word set. A feature word set includes all feature words corresponding to the same candidate topic. The target topic feature vocabulary is obtained based on the target domain ontology and the topic feature vocabulary. The target domain ontology is used to provide feature words for the extended topic feature vocabulary. The topic feature vocabulary is obtained based on the training set, which is divided from historical text. The unclassified text feature vector generation module is used to calculate the unclassified text feature vector corresponding to the unclassified text. The topic feature vector acquisition module is used to acquire the topic feature vectors corresponding to each candidate topic, wherein the topic feature vectors are calculated based on the feature word set corresponding to the candidate topic. The target topic feature vector determination module is used to calculate the similarity between the feature vector of the text to be classified and each topic feature vector, and obtain the target topic feature vector corresponding to the text to be classified based on the similarity. The target topic determination module is used to obtain candidate topics corresponding to the target topic feature vector as the target topic corresponding to the text to be classified. The data acquisition module is further configured to acquire the application scope of the domain ontology, obtain a terminology list corresponding to the domain ontology based on the application scope, establish a conceptual structure of the domain ontology based on the terminology list, and obtain a target conceptual structure of the domain ontology; define conceptual attributes and set class constraints of the domain ontology based on the target conceptual structure, and obtain target conceptual attributes and target class constraints of the domain ontology; form a target conceptual model of the domain ontology based on the target conceptual model; create instances corresponding to each class in the domain ontology based on the target conceptual model, and obtain target instances of the domain ontology; and construct a target domain ontology based on the target conceptual model and target instances.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.