Text semantic classification method and device, computer equipment and storage medium
Through the two-level classification method, the combination of the first and second classification engines is used to solve the problems of low classification accuracy and inability to classify samples in the prior art, and achieve higher classification accuracy and user experience.
Patent Information
- Application Number
- CN202411773851.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-14
AI Technical Summary
Existing semantic classification methods are difficult to cover all scenarios in a comprehensive manner, which may lead to a decrease in classification accuracy or some samples cannot be correctly classified.
The two-level classification method is adopted, and first one classification is performed through the first classification engine, and if it fails, it switches to the second classification engine for secondary classification, which improves the flexibility and efficiency of classification.
It improves the accuracy of semantic classification and the possibility of classification success, reduces the number of samples that cannot be classified, and improves the user experience.
Smart Images

Figure CN119621985A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of semantic classification technology, and more specifically to a text semantic classification method, device, computer equipment and storage medium. Background Art
[0002] With the rapid development of artificial intelligence and natural language processing (NLP) technology, text semantic classification has been widely used in intelligent customer service, intelligent outbound calls, text retrieval, sentiment analysis and other fields. The core of text semantic classification technology is to accurately classify text into specified categories by performing semantic analysis on the input text information and combining it with predefined rules or models. However, due to the diversity and complexity of text content in actual scenarios, a single classification method is difficult to fully cover all scenarios, which may lead to a decrease in classification accuracy or some samples cannot be correctly classified. Summary of the invention
[0003] The present invention provides a text semantic classification method, apparatus, computer equipment and storage medium to solve the technical problem that the existing semantic classification method is difficult to comprehensively cover all scenarios, which may result in a decrease in classification accuracy or some samples cannot be correctly classified.
[0004] In a first aspect, a text semantic classification method is provided, comprising:
[0005] Get the input text information;
[0006] Classifying the text information once through a first classification engine;
[0007] Determine whether a classification is successful;
[0008] If a classification is successful, the corresponding classification result is output;
[0009] If the first classification is unsuccessful, the text information is classified again by a second classification engine;
[0010] Determine whether the secondary classification is successful;
[0011] If the secondary classification is successful, the corresponding secondary classification result is output.
[0012] In a second aspect, a text semantic classification device is provided, comprising:
[0013] The acquisition module is used to obtain the input text information;
[0014] A first classification module, used for classifying the text information once through a first classification engine;
[0015] The first judgment module is used to judge whether a classification is successful;
[0016] The first output module is used to output the corresponding first classification result if the first classification is successful;
[0017] A second classification module, configured to perform secondary classification of the text information through a second classification engine if the first classification is unsuccessful;
[0018] The second judgment module is used to judge whether the secondary classification is successful;
[0019] The second output module is used to output the corresponding secondary classification result if the secondary classification is successful.
[0020] In a third aspect, a computer device is provided. The computer device includes a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the above method is implemented.
[0021] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0022] The beneficial effects of the present invention compared with the prior art are: by introducing a first classification engine and a second classification engine, when the first classification engine cannot successfully classify text information, it can automatically switch to the second classification engine, thereby improving the flexibility and efficiency of classification. At the same time, introducing two classification engines means that even if some texts do not conform to the classification rules of the first classification engine, they still have the opportunity to be correctly classified by the second classification engine, so that the present invention can better adapt to different types of text content, thereby improving the accuracy of semantic classification and the possibility of successful classification, and also improving the classification processing capabilities of the present invention for complex text content, which significantly reduces the number of samples that cannot be classified and improves user experience.
[0023] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0025] Figure 1 A schematic diagram of an application scenario of the text semantic classification method provided by an embodiment of the present invention;
[0026] Figure 2 A flowchart of a text semantic classification method provided by an embodiment of the present invention;
[0027] Figure 3 A schematic diagram of a sub-process of a text semantic classification method provided by an embodiment of the present invention;
[0028] Figure 4 Another sub-process diagram of the text semantic classification method provided by an embodiment of the present invention;
[0029] Figure 5 A schematic block diagram of a text semantic classification device provided by an embodiment of the present invention;
[0030] Figure 6 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0031] Figure 7 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of the text semantic classification method provided in an embodiment of the present invention. Figure 2 The text semantic classification method provided by the embodiment of the present invention can be applied in the following aspects: Figure 1In the application environment, the client communicates with the server through the network. The server can obtain the input text information through the client, and semantically classify the input text information through the first classification engine and the second classification engine, and finally feed back the result of the semantic classification to the client, and the client outputs the final semantic classification result. The present invention introduces the first classification engine and the second classification engine. When the first classification engine cannot successfully classify, it can automatically switch to the second classification engine, thereby improving the flexibility and efficiency of classification. At the same time, the introduction of two classification engines means that even if some texts do not meet the classification rules of the first classification engine, they still have the opportunity to be correctly classified by the second classification engine, so that the present invention can better adapt to different types of text content, thereby improving the accuracy of semantic classification and the possibility of successful classification, and also improving the classification processing ability of the present invention for complex text content, which significantly reduces the number of samples that cannot be classified and improves user experience. Among them, the client can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0034] Figure 2 FIG. 1 is a flow chart of a text semantic classification method provided by an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S170.
[0035] S110: Acquire input text information.
[0036] Specifically, obtaining text information is the basis of the entire classification process. In practical applications, the input text information may come from the user's natural language input, such as user voice transcription text received by AI outbound call robots, user messages in customer service systems, user comments on social media platforms, etc. When obtaining text information, the text information can be pre-processed, such as removing redundant symbols, cleaning punctuation marks, and uniformly processing full-width and half-width characters, to provide clean and standardized data input for subsequent classification.
[0037] S120: Classify the text information once using a first classification engine.
[0038] Specifically, the first classification engine is the first classification mechanism of the whole method, which is mainly used to perform efficient semantic classification processing on simple texts. In this embodiment, the rule engine technology is used to perform efficient semantic classification on short texts with a string length of 1 to 8 characters, and the classification results are quickly obtained through exact matching and wildcard matching.
[0039] In one embodiment, see Figure 3, the above-mentioned step S120 may include steps S121 to S124.
[0040] S121. Build a variant Trie tree and initialize a matching queue.
[0041] Specifically, step S121 may include the following steps:
[0042] Parse the preset rule configuration file to obtain the parsing file. The rule configuration file records the set of semantic classification rules, including category information, corresponding template statements, and wildcard rules. By parsing the rule configuration file, the statements in the rule configuration file can be converted into word segmentation or wildcards suitable for building a variant Trie tree, and the obtained word segmentation or wildcards are saved in the parsing file.
[0043] A variant Trie tree is constructed according to the parsed file. A variant Trie tree is constructed based on the principle of breadth-first search (BFS) according to the word segmentation or wildcard obtained by converting the statements in the rule configuration file, which removes the first word segmentation or wildcard of all the statements in the rule configuration file as the first layer of internal nodes of the variant Trie tree, and then constructs the word segmentation or wildcard associated with the first word segmentation or wildcard in the second layer of the variant Trie tree, and so on. All external nodes of the variant Trie tree store category information of semantic classification. The recall rate of existing rule engines for texts with more than 5 characters decreases exponentially. In this embodiment, by introducing a wildcard template (the format is [W:mn], indicating that the position of this wildcard can match any character from m to n), the length of the recallable text is extended, some corpora with similar structures in the training samples are classified into one category, and verbs, auxiliary words, etc. with the same semantics are extracted from them. These synonyms are replaced with wildcards of a certain length, which can increase the recall rate of the rule engine for samples within 8 characters, that is, the sample length that the rule engine is good at identifying is increased to about 8 characters. More specifically, the root node of the variant Trie tree does not contain any template, and the internal node contains a wildcard WildWord (that is, the internal node is a wildcard node) or a specific word NormalText (that is, the internal node is an exact match node). The external node of each branch stores the corresponding category information. It can be seen that starting from the root node and reaching the external node along any path will correspond to a category information. During the matching process, the input text information is matched along the nodes of the variant Trie tree until an external node of a branch is found, indicating that the text information belongs to the category information indicated by the external node.
[0044] Create a matching queue. In this embodiment, the created matching queue is a first-in-first-out unidirectional matching queue (i.e., a FIFO queue), so that when performing semantic classification, the FIFO queue will follow the "first-in-first-out" principle, so that the matching tasks are performed in a predetermined order, avoiding confusion and disorder in task execution. In addition, the FIFO queue can also batch process and concurrently execute matching tasks according to system resources and task requirements, thereby improving resource utilization and matching efficiency.
[0045] The matching elements of the matching queue are set according to the variant Trie tree and the text information. In the present embodiment, the first matching element of the matching queue includes the initial current word segmentation, the initial remaining text and the initial current node, wherein the initial current word segmentation is empty, the initial remaining text is the text information, and the initial current node is the root node of the variant Trie tree (i.e., empty), thereby ensuring that the matching starts from the starting position of the text information, and ensuring that the entire text information is included in the matching consideration range, avoiding the situation of missing or repeated matching, starting from the root node, and using the hierarchical structure of the variant Trie tree, unmatched word segmentation or wildcards can be efficiently excluded, thereby avoiding unnecessary calculations. In addition, the structure of the variant Trie tree also supports adding new word segmentation or wildcard templates, thereby expanding the processing power of the algorithm.
[0046] In addition, in this embodiment, a common Trie tree is constructed according to the parsing file obtained by parsing the rule configuration file. The word segmentation corresponding to the sentence in the rule configuration file is extracted, and multiple groups of substrings are generated for all consecutive characters in each word segmentation. Each substring is inserted into the Trie tree character by character, the root node is empty, and the characters are added as internal nodes of the Trie tree in sequence. Each node stores whether it is an external node of a complete word segmentation, so as to quickly determine whether the match is successful. For repeated word segmentations, it is only stored once to avoid redundancy. By constructing the above-mentioned common Trie tree, in the matching process of the variant Trie tree, when a certain internal node needs to confirm whether the current word segmentation exists in the rule base, the common Trie tree is called for a quick query. If the word segmentation exists, the branch at the corresponding position is returned; otherwise it is determined to be mismatched. At the same time, the common Trie tree can also assist in judging whether the consecutive characters (such as some middle characters) of the current word segmentation match the wildcard node. For example: in the wildcard [W:0-3], if it is necessary to confirm whether a legal word segmentation is contained, the common Trie tree can provide an accurate reference.
[0047] By using the common Trie tree in conjunction with the variant Trie tree, the following effects can be achieved:
[0048] (1) Improve matching efficiency;
[0049] Fast search: The ordinary Trie tree provides efficient search capabilities, which is significantly faster than directly traversing the rule configuration file to search for word segments.
[0050] Reduce the probability of mismatch: Through word segmentation verification, mismatched branches can be eliminated in advance and unnecessary search paths can be reduced.
[0051] (2) Enhance rule coverage;
[0052] Support for partial matching: Ordinary Trie trees allow discovering potential statements by matching partial consecutive characters.
[0053] Dynamic adaptation: If the rules are updated or expanded (new word segmentation), the Trie tree can be flexibly adjusted without the need to reconstruct the entire rule configuration file.
[0054] (3) Improve the adaptability of wildcard templates;
[0055] Verify the validity of wildcard matching: When the definition range of the wildcard [W:mn] is too large, the ordinary Trie tree can limit whether the word matched by the wildcard actually exists in the rule base, thereby avoiding matching false word segments.
[0056] Improve classification accuracy: Filter invalid branches through the common Trie tree to make the categories matched by the variant Trie tree more accurate.
[0057] (4) Reduce redundant storage;
[0058] Deduplication storage: Ordinary Trie trees use word segmentation and substring deduplication mechanisms to avoid wasting storage space due to duplicate rules, especially when the rule base is large.
[0059] (5)Support long text segmentation;
[0060] The ordinary Trie tree assists in matching the words in the long text, which helps improve the rule engine's ability to adapt to texts exceeding 5 to 8 words.
[0061] S122: Use the variant Trie tree and the matching queue to match the text information.
[0062] Specifically, step S122 may include the following steps:
[0063] Obtain a matching element from the matching queue, the matching element including the current word segmentation, the remaining text, and the current node. When matching for the first time, the first matching element of the matching queue includes the initial current word segmentation, the initial remaining text, and the initial current node, wherein the initial current word segmentation is empty, the initial remaining text is the text information, and the initial current node is the root node of the variant Trie tree (i.e., empty).
[0064] Match the current word segmentation with the current node. If the current node is a wildcard node wildWord, then based on the wildcard character range, characters that meet the range are cut out from the remaining text as the new current word segmentation. If characters that meet the range cannot be cut out further, the current node fails to match. If the current node is an exact match node normalText, the current word segmentation is compared with the text of the current node to determine whether it is a complete match. If it is not a complete match, the current node fails to match. If the current node fails to match, the branch with the current node as the root node is abandoned, and the branches with other internal nodes are continued to match. If all branches of the variant Trie tree fail to match, the text information is not successfully classified at one time.
[0065] If the match is successful, the remaining text is segmented to obtain a segmentation result, which includes a new current text and a new remaining text. The remaining text is decomposed into multiple words and wildcards, wherein the first word or wildcard extracted from the remaining text is used as the new current word (currentWord), and the remaining part after removing the new current word is used as the new remaining text. In this segmentation step, multiple segmentation results will be obtained according to the different segmentation results of the current word and the remaining text, and these segmentation results will be matched in sequence to avoid missing or repeated matching.
[0066] The next internal node of the current node is used as the new current node, and the segmentation result and the new current node are added to the end of the matching queue so that the segmentation result and the new current node continue to be matched. The above steps of obtaining, matching, segmenting, and updating the matching queue are repeated until the matching queue is empty.
[0067] If the new current text matches the external node, the match is successful.
[0068] S123: If the match is successful, update the corresponding matching result, which includes category information and matching times.
[0069] Specifically, the matching results are recorded in the map corresponding to the variant Trie tree (a data structure used to store and track the category information of successful matches and their corresponding matching times during the traversal of the variant Trie tree). The category information is the category information stored in the successfully matched external node. Since in the variant Trie tree, an external node may correspond to multiple branches, an external node may be matched multiple times. Each time the external node is matched, the corresponding matching times are updated in the map. After the matching is completed, the number of times the external node is matched is the final matching number.
[0070] S124. When the matching is completed, the category information with the largest number of matches is selected as a classification result.
[0071] Specifically, when all matching elements in the matching queue are taken out, the matching process ends. At this time, the map is traversed to find the category information with the most matching times, that is, the first classification result of the text information is determined to be the category information. If the number of matching times of multiple category information is the same, the first category information is selected as the first classification result of the text information in the order in which the category information is added to the map.
[0072] S130: Determine whether a classification is successful.
[0073] If there is at least one matching result (i.e. the number of matches of any category of information is greater than 0), then the classification is considered successful. Otherwise, the classification fails.
[0074] S140: If a classification is successful, output the corresponding classification result.
[0075] If the first classification engine successfully outputs a classification result, the classification process is terminated, and the classification result is directly used as the final classification of the text information.
[0076] S150: If the first classification is unsuccessful, the text information is classified again by a second classification engine.
[0077] For text information that is not successfully processed by the first classification engine, the second classification engine is entered to continue classifying the text information.
[0078] In one embodiment, see Figure 4 , the above-mentioned step S150 may include steps S151 to S153.
[0079] S151: Use the text information as query information to recall texts similar to the text information in the second classification engine.
[0080] Specifically, in this embodiment, the second classification engine is an ESIM node model, which consists of a corpus recalled from the ElasticSearch database, a sentence similarity comparison of the Jaccard coefficient + LCS, and an ESIM two-classification model of semantic similarity. In this embodiment, the text information is stored in the ElasticSearch database in the form of {corpus, category}, and the recalled text is recalled in the form of {corpus, category, similarity}, and is arranged from high to low according to the similarity, wherein the category information corresponding to the recalled text with the highest similarity to the text information can be regarded as the category information corresponding to the text information. This embodiment uses the recall mechanism of ElasticSearch. When the number of characters in the input text information is more, the number of its segmentation is more, and the proportion of the segmentation of the recalled text recalled from ElasticSearch and the segmentation of the text information is the same as the text information is also greater. Therefore, in theory, the longer the text information is, the more similar the recalled text recalled by ElasticSearch is to the text information, thereby achieving the goal of making the ESIM node model more suitable for long sentence classification. Preferably, in order to ensure the accuracy and reliability of classification and reduce unnecessary computational overhead, in this embodiment, the number of recalled texts is set to 100. It is understandable that in other embodiments, the number of recalled texts can be set to other values, thereby improving the flexibility and scalability of secondary classification.
[0081] S152: Determine whether the similarity index between the recalled text and the text information reaches a preset similarity threshold.
[0082] Specifically, S152 may include the following steps:
[0083] Calculate the similarity index between the recalled text and the text information.
[0084] In this embodiment, in the step of calculating the similarity index between the recalled text and the text information, the similarity index is determined using the following formula:
[0085] Similarity index = max{Jaccard coefficient, LCS / length of the longer sentence in the two sentences}.
[0086] The Jaccard coefficient is the ratio of the character intersection length to the character union length of the recalled text and the text information, and LCS is the longest common subsequence of the recalled text and the text information.
[0087] If the similarity index is lower than the preset similarity threshold, the recalled text is filtered out.
[0088] If the similarity index reaches the preset similarity threshold, the recalled text is retained.
[0089] This embodiment screens the recalled texts by calculating the Jaccard coefficient and the longest common subsequence (LCS) similarity, thereby eliminating texts with low similarity to the input texts, and reducing the performance overhead caused by the need for a large number of recalled texts to enter the ESIM binary classification model for calculation; and by using "similarity index = max{Jaccard coefficient, LCS / length of the longer sentence of the two sentences} ≥ preset similarity threshold" as the screening criterion, it is ensured that the retained recalled texts have high semantic relevance.
[0090] More specifically, in the present application, the preset similarity threshold is set to 1 according to previous experimental results. When the similarity index corresponding to the recalled text is ≥ 1, it is considered that the recalled text has a high similarity with the text information, that is, the recalled text is retained; when the similarity index corresponding to the recalled text is < 1, it is considered that the recalled text has a low similarity with the text information, that is, the recalled text is filtered out. It can be understood that in other embodiments, the preset similarity threshold can also be set to other values, thereby improving the flexibility and scalability of secondary classification.
[0091] S153: Determine the category information corresponding to the recalled text having the highest similarity index and reaching the preset similarity threshold as the second classification result.
[0092] Specifically, the retained recall text is input into the ESIM binary classification model, and the ESIM binary classification model recalculates the similarity index of the retained recall text, and determines that the recall text with the largest similarity index has the highest similarity with the text information, and the category information corresponding to the recall text is used as the secondary classification result. This step combines the advantages of ElasticSearch retrieval and ESIM model calculation to ensure the accuracy of the classification results at the semantic level while reducing unnecessary computational overhead. In addition, a similarity threshold (for example, similarity threshold = 2) can also be set in the ESIM binary classification model. When the similarity index calculated again is ≥ the similarity threshold, the match is considered successful. If the similarity index calculated again is < the similarity threshold, the match is considered to have failed. It can be understood that the similarity threshold is ≥ the preset similarity threshold, thereby further improving the accuracy of the secondary classification, and in other embodiments, the similarity threshold can also be set to other values, thereby improving the flexibility and scalability of the secondary classification.
[0093] S160: Determine whether the secondary classification is successful.
[0094] When a similarity threshold is set in the ESIM binary classification model, if the similarity index between any recalled text and the text information is ≥ the similarity threshold, the secondary classification is successful; otherwise, the secondary classification fails.
[0095] When no similarity threshold is set in the ESIM binary classification model, if the similarity index between any recalled text and the text information is ≥ the preset similarity threshold, the secondary classification is successful; otherwise, the secondary classification fails.
[0096] S170: If the secondary classification is successful, output the corresponding secondary classification result.
[0097] When the secondary classification is successful, the secondary classification result is output as the final classification result of the text information.
[0098] It can be seen that in the above scheme, through the combined application of the first classification engine and the second classification engine, the semantic classification requirements of texts of various lengths and complexities can be effectively covered, and a balance between high accuracy and high coverage can be achieved, so that the present invention can better adapt to different types of text content, thereby improving the semantic classification accuracy and the possibility of successful classification, and also improving the classification processing capabilities of the present invention for complex text content, which significantly reduces the number of samples that cannot be classified and improves the user experience.
[0099] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0100] In one embodiment, a text semantic classification device is provided, which corresponds one-to-one to the text semantic classification method in the above embodiment. Figure 5 As shown, the text semantic classification device includes an acquisition module 301, a first classification module 302, a first judgment module 303, a first output module 304, a second classification module 305, a second judgment module 306 and a second output module 307. The functional modules are described in detail as follows:
[0101] The acquisition module 301 is used to acquire input text information;
[0102] A first classification module 302, used to classify the text information once through a first classification engine;
[0103] The first judging module 303 is used to judge whether a classification is successful;
[0104] A first output module 304 is used to output the corresponding first classification result if the first classification is successful;
[0105] The second classification module 305 is used to perform secondary classification on the text information through a second classification engine if the first classification is unsuccessful;
[0106] The second judgment module 306 is used to judge whether the secondary classification is successful;
[0107] The second output module 307 is used to output the corresponding secondary classification result if the secondary classification is successful.
[0108] In one embodiment, the first classification module 302 is specifically configured to:
[0109] Build a variant Trie tree and initialize the matching queue;
[0110] Matching the text information using the variant Trie tree and the matching queue;
[0111] If the match is successful, the corresponding matching result is updated, and the matching result includes category information and matching times;
[0112] When the matching is completed, the category information with the most matches is selected as the classification result.
[0113] In one embodiment, the first classification module 302 is specifically configured to:
[0114] Parse the preset rule configuration file to obtain the parsing file;
[0115] Construct a variant Trie tree according to the parsed file;
[0116] Create a matching queue;
[0117] The matching elements of the matching queue are set according to the variant Trie tree and the text information.
[0118] In one embodiment, the first classification module 302 is further configured to:
[0119] Obtain matching elements from the matching queue, wherein the matching elements include the current word segmentation, the remaining text, and the current node;
[0120] Matching the current word segment with the current node;
[0121] If the match is successful, the remaining text is segmented to obtain a segmentation result, wherein the segmentation result includes a new current text and a new remaining text;
[0122] Taking the next internal node of the current node as a new current node, adding the segmentation result and the new current node to the end of a matching queue so that the segmentation result and the new current node continue to be matched;
[0123] If the new current text matches the external node, the match is successful.
[0124] In one embodiment, the second classification module 305 is specifically configured to:
[0125] Recalling the recalled text similar to the text information in the second classification engine using the text information as query information;
[0126] Determining whether the similarity index between the recalled text and the text information reaches a preset similarity threshold;
[0127] The category information corresponding to the recalled text having the highest similarity index and reaching the preset similarity threshold is determined as the second classification result.
[0128] In one embodiment, the second classification module 305 is further configured to:
[0129] Calculating a similarity index between the recalled text and the text information;
[0130] If the similarity index is lower than the preset similarity threshold, the recalled text is filtered out;
[0131] If the similarity index reaches the preset similarity threshold, the recalled text is retained.
[0132] In this embodiment, the similarity index is determined using the following formula:
[0133] Similarity index = max{Jaccard coefficient, LCS / length of the longer sentence of the two sentences};
[0134] The Jaccard coefficient is the ratio of the character intersection length to the character union length of the recalled text and the text information, and LCS is the longest common subsequence of the recalled text and the text information.
[0135] The present invention provides a text semantic classification device, which semantically classifies text information by adopting a first classification engine and a second classification engine. When the first classification engine cannot successfully classify, it can automatically switch to the second classification engine, thereby improving the flexibility and efficiency of classification. The introduction of two classification engines at the same time means that even if some texts do not conform to the classification rules of the first classification engine, they still have the opportunity to be correctly classified by the second classification engine, so that the present invention can better adapt to different types of text content, thereby improving the accuracy of semantic classification and the possibility of successful classification, and also improving the classification processing ability of the present invention for complex text content, which significantly reduces the number of samples that cannot be classified and improves user experience.
[0136] For the specific definition of the text semantic classification device, please refer to the definition of the text semantic classification method above, which will not be repeated here. The various modules in the above-mentioned text semantic classification device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0137] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the server side of a text semantic classification method.
[0138] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a client side of a text semantic classification method.
[0139] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0140] Get the input text information;
[0141] Classifying the text information once through a first classification engine;
[0142] Determine whether a classification is successful;
[0143] If a classification is successful, the corresponding classification result is output;
[0144] If the first classification is unsuccessful, the text information is classified again by a second classification engine;
[0145] Determine whether the secondary classification is successful;
[0146] If the secondary classification is successful, the corresponding secondary classification result is output.
[0147] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0148] Get the input text information;
[0149] Classifying the text information once through a first classification engine;
[0150] Determine whether a classification is successful;
[0151] If a classification is successful, the corresponding classification result is output;
[0152] If the first classification is unsuccessful, the text information is classified again by a second classification engine;
[0153] Determine whether the secondary classification is successful;
[0154] If the secondary classification is successful, the corresponding secondary classification result is output.
[0155] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0156] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0157] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0158] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A text semantic classification method, characterized in that: include: Get the input text information; Classifying the text information once through a first classification engine; Determine whether a classification is successful; If a classification is successful, the corresponding classification result is output; If the first classification is unsuccessful, the text information is classified again by a second classification engine; Determine whether the secondary classification is successful; If the secondary classification is successful, the corresponding secondary classification result is output.
2. The text semantic classification method according to claim 1, characterized in that: The step of classifying the text information once through a first classification engine includes: Build a variant Trie tree and initialize the matching queue; Matching the text information using the variant Trie tree and the matching queue; If the match is successful, the corresponding matching result is updated, and the matching result includes category information and matching times; When the matching is completed, the category information with the most matches is selected as the classification result.
3. The text semantic classification method according to claim 2, characterized in that: The steps of constructing a variant Trie tree and initializing a matching queue include: Parse the preset rule configuration file to obtain the parsing file; Construct a variant Trie tree according to the parsed file; Create a matching queue; The matching elements of the matching queue are set according to the variant Trie tree and the text information.
4. The text semantic classification method according to claim 3, characterized in that: The step of using the variant Trie tree and the matching queue to match the text information includes: Obtain matching elements from the matching queue, wherein the matching elements include the current word segmentation, the remaining text, and the current node; Matching the current word segment with the current node; If the match is successful, the remaining text is segmented to obtain a segmentation result, wherein the segmentation result includes a new current text and a new remaining text; Taking the next internal node of the current node as a new current node, adding the segmentation result and the new current node to the end of a matching queue so that the segmentation result and the new current node continue to be matched; If the new current text matches the external node, the match is successful.
5. The text semantic classification method according to claim 1, characterized in that: If the first classification is unsuccessful, the step of performing a second classification on the text information through a second classification engine comprises: Recalling the recalled text similar to the text information in the second classification engine using the text information as query information; Determining whether the similarity index between the recalled text and the text information reaches a preset similarity threshold; The category information corresponding to the recalled text having the highest similarity index and reaching the preset similarity threshold is determined as the second classification result.
6. The text semantic classification method according to claim 5, characterized in that: The step of determining whether the similarity index between the recalled text and the text information reaches a preset similarity threshold comprises: Calculating a similarity index between the recalled text and the text information; If the similarity index is lower than the preset similarity threshold, the recalled text is filtered out; If the similarity index reaches the preset similarity threshold, the recalled text is retained.
7. The text semantic classification method according to claim 6, characterized in that: In the step of calculating the similarity index between the recalled text and the text information, the similarity index is determined using the following formula: Similarity index = max{Jaccard coefficient, LCS / length of the longer sentence of the two sentences}; The Jaccard coefficient is the ratio of the character intersection length to the character union length of the recalled text and the text information, and LCS is the longest common subsequence of the recalled text and the text information.
8. A text semantic classification device, characterized in that: include: The acquisition module is used to obtain the input text information; A first classification module, used for classifying the text information once through a first classification engine; The first judgment module is used to judge whether a classification is successful; The first output module is used to output the corresponding first classification result if the first classification is successful; A second classification module, configured to perform secondary classification of the text information through a second classification engine if the first classification is unsuccessful; The second judgment module is used to judge whether the secondary classification is successful; The second output module is used to output the corresponding secondary classification result if the secondary classification is successful.
9. A computer device, characterized in that: The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 can be implemented.
Citation Information
Cited By
Data resource classification method and device based on rule and semantic approximation in combination with AI
CN121456535A