Dependency phrase-based fast text classification method and device and computer equipment

CN118260420BActive Publication Date: 2026-08-28HANGZHOU CITY BRAIN CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410347810.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-26
Publication Date
2026-08-28
Estimated Expiration
2044-03-26

AI Technical Summary

Technical Problem

然而,这些方法在处理大规模数据时则存在维度灾难和特征选择困难的问题

Benefits of technology

[0033] In summary, the fast text classification method based on dependency phrases provided in this invention enables the autonomous classification of other related dependency phrases by configuring the mapping relationship between dependency phrases and categories when constructing the index database, thereby quickly achieving wide-ranging classification coverage based on dependency phrases. It reduces reliance on large amounts of manually labeled data during the initial data processing, lowering the cost of manual configuration and improving the algorithm's practicality. Furthermore, the weighting of each word within each dependency phrase better highlights semantic features to improve classification accuracy, while the storage of related words within dependency phrases based on a trie accelerates dependency element extraction, significantly improving the indexing hit efficiency of target dependency phrases within the text to be analyzed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118260420B_ABST
    Figure CN118260420B_ABST
Patent Text Reader

Abstract

The application provides a quick text classification method based on dependent phrases, which comprises the following steps: constructing an index database; parsing a text to be analyzed to obtain index words, searching for target dependent phrases matched with the index words in the constructed dependent phrase index database, determining the category to which each target dependent phrase belongs and the weight of each index word; calculating the single classification score of the category corresponding to each target dependent phrase based on the number of categories hit by the text to be analyzed and the weight of each index word; parsing the document frequency of the index words in the text to be analyzed, and fusing the document frequency weighting weight to form the document weighted score based on the single classification score of the category corresponding to the index words; determining whether to introduce a polynomial weighting factor to obtain the classification score of each category based on the number of target dependent phrases associated with each category; sorting the classification scores of the hit categories, and selecting the category with the highest score as the category to which the text to be analyzed belongs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of text classification in natural language, and particularly to a fast text classification method, apparatus, and computer device based on dependency phrases. Background Technology

[0002] With the rapid development of information technology, the generation and dissemination of massive amounts of text data has made text classification a key issue in the field of information processing. In early text classification research, traditional algorithms mainly relied on rules, feature engineering, and statistical methods. These methods could achieve classification to a certain extent, but they faced problems such as low algorithm efficiency, high manual configuration costs, and poor generalization performance.

[0003] Currently, several text classification technologies exist, including traditional machine learning methods and deep learning methods. Traditional machine learning methods, such as Naive Bayes and Support Vector Machines, classify text by extracting hand-designed features. However, these methods suffer from the curse of dimensionality and difficulty in feature selection when dealing with large-scale data. Deep learning methods, such as Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Transformers, classify text by learning abstract features from the data. This approach has achieved some success in various scenarios; however, it requires significant computational power for early data processing and abstract feature extraction, thus demanding substantial computing resources and high-performance computer equipment. Furthermore, both traditional machine learning and deep learning methods suffer from low efficiency when processing large-scale text, failing to complete classification tasks quickly and accurately. Summary of the Invention

[0004] In order to overcome the shortcomings of the prior art, the present invention provides a fast text classification method, apparatus and computer equipment based on dependency phrases.

[0005] To achieve the above objectives, the present invention provides a fast text classification method based on dependency phrases, comprising:

[0006] Build an index database: Obtain multiple dependency phrases related to the text sample, classify and map each dependency phrase, and configure the weight of each word in each dependency phrase;

[0007] The text to be analyzed is parsed to obtain index terms. The target dependency terms that match the index terms are searched in the constructed index database. The category of each target dependency term and the weight of each index term in its target dependency term are determined.

[0008] Based on the number of categories hit by the text to be analyzed and the weight of each index term within its respective target dependency term group, the single classification score for each target dependency term group is calculated using the following formula:

[0009]

[0010] Where min and max represent the cardinality boundaries of the classification probability, count represents the maximum number of categories that the text to be analyzed can hit, x represents the number of categories that the current text to be analyzed hits, n is the number of words in the target dependency phrase, and f(i) represents the weight of the i-th word.

[0011] The document frequency ω of the index term in the text to be analyzed is analyzed. Based on the single classification score y(x) of the category corresponding to the index term, the document frequency weighting weight f(ω) is fused to form the document weighting score y'(x).

[0012] The target dependency phrases associated with each hit category are summarized. For a category that is associated with only one target dependency phrase, the weighted score y'(x) of the documents corresponding to that target dependency phrase is used as the classification score of that category. For multiple target dependency phrases that hit the same category, a polynomial weighting factor is introduced to weight and merge the weighted scores y'(x) of the documents of multiple target dependency phrases to form a polynomial weighted score y''(x), and the polynomial weighted score y''(x) is used as the classification score of that category.

[0013] The classification scores of the multiple categories that were hit were sorted, and the category with the highest score was selected as the category to which the text to be analyzed belonged.

[0014] According to an embodiment of the present invention, constructing an index database further includes: after obtaining multiple dependency phrases, splitting the words in each dependency phrase and storing the split words as characters in a trie under the category corresponding to the dependency phrase;

[0015] After obtaining the index terms of the text to be analyzed, the target dependency terms and the category to which the target dependency terms belong are searched in the index database based on the trie.

[0016] According to one embodiment of the present invention, the text to be analyzed is parsed based on dependency parsing to extract index terms and inter-word relationships, wherein the index terms are single words or dependency phrases.

[0017] According to one embodiment of the present invention, a positive activation function is used to express the additive effect of document frequency ω on classification score, wherein the positive activation function is any one of a power function, a sigmoid function, a softmax function, or a Gaussian function.

[0018] According to one embodiment of the present invention, the positive activation function is a Sigmoid function. After obtaining the document frequency ω of the index term in the text to be analyzed, the document frequency weighting weight f(ω) corresponding to the index term is formed using the following formula:

[0019]

[0020] Where e is the base of the natural logarithm, ω is the document frequency of the index term in the text to be analyzed, and k is a constant used to adjust the slope of the curve of the document frequency weighting weight f(ω). The larger the value of k, the closer the curve is to 1.

[0021] Based on the single classification score y(x) of the category corresponding to each target dependency phrase, the document-weighted score y'(x) obtained after fusing the document frequency weighting weight f(ω) is shown below:

[0022] .

[0023] According to one embodiment of the present invention, for multiple target dependency phrases that hit the same category, the polynomial weighted score y''(x) is calculated using the following formula:

[0024]

[0025] Among them, the polynomial weighting factor It is in the form of the root of the mean. (x) represents the average of the document weighted scores y'(x) of multiple target dependency phrases, and α is an adjustable parameter used to control the skewness of the probability interval [min, max]. The skewness of the probability interval is positively correlated with α.

[0026] According to one embodiment of the present invention, a single classification score is calculated for the category corresponding to each target dependency phrase. Within the formula, the probability interval [min, max] is a dynamically adjustable confidence interval, and count is a positive integer less than or equal to 30.

[0027] On the other hand, the present invention also provides a fast text classification device based on dependency phrases, which includes a database construction unit, a text parsing unit, a single classification score calculation unit, a document frequency weighted calculation unit, and a multinomial weighted calculation unit. The database construction unit constructs an index database: it acquires multiple dependency phrases related to the text sample, performs classification mapping configuration on each dependency phrase, and configures the weight of each word within each dependency phrase. The text parsing unit parses the text to be analyzed to obtain index words, searches for target dependency phrases matching the index words in the constructed index database, and determines the category of each target dependency phrase and the weight of each index word within its respective target dependency phrase. The single classification score calculation unit, based on the number of categories matched by the text to be analyzed and the weight of each index word within its respective target dependency phrase, calculates the single classification score of the category corresponding to each target dependency phrase using the following formula:

[0028]

[0029] Where min and max represent the cardinality boundaries of the classification probabilities, count represents the maximum number of categories that the text to be analyzed can hit, x represents the number of categories that the current text to be analyzed hits, n is the number of words in the target dependency phrase, and f(i) represents the weight of the i-th word. The document frequency weighted calculation unit parses the document frequency ω of the index term in the text to be analyzed, and on the basis of the single classification score y(x) of the category corresponding to the index term, it integrates the document frequency weighted weight f(ω) to form the document weighted score y'(x). The multinomial weighted calculation unit summarizes the target dependency phrases associated with each hit category. For a category associated with only one target dependency phrase, the weighted score y'(x) of the documents corresponding to that target dependency phrase is used as the classification score for that category. For multiple target dependency phrases hitting the same category, a multinomial weighting factor is introduced to weight and merge the weighted scores y'(x) of the documents of multiple target dependency phrases, forming a multinomial weighted score y''(x), which is then used as the classification score for that category. The sorting output unit sorts the classification scores of the hit categories and selects the category with the highest score as the category to which the text to be analyzed belongs.

[0030] According to an embodiment of the present invention, the database construction unit further includes the following steps in constructing the index database: after obtaining multiple dependency phrases, splitting the words in each dependency phrase and storing the split words as characters in the trie under the category corresponding to the dependency phrase;

[0031] After obtaining the index terms of the text to be analyzed, the target dependency terms and the category to which the target dependency terms belong are searched in the index database based on the trie.

[0032] On the other hand, the present invention also provides a computer device including a memory and a processor, wherein the memory stores a computer program, characterized in that the processor executes the computer program to implement the steps of the above-described fast text classification method based on dependency phrases.

[0033] In summary, the fast text classification method based on dependency phrases provided in this invention enables the autonomous classification of other related dependency phrases by configuring the mapping relationship between dependency phrases and categories when constructing the index database, thereby quickly achieving wide-ranging classification coverage based on dependency phrases. It reduces reliance on large amounts of manually labeled data during the initial data processing, lowering the cost of manual configuration and improving the algorithm's practicality. Furthermore, the weighting of each word within each dependency phrase better highlights semantic features to improve classification accuracy, while the storage of related words within dependency phrases based on a trie accelerates dependency element extraction, significantly improving the indexing hit efficiency of target dependency phrases within the text to be analyzed.

[0034] After obtaining the number of categories hit by the analyzed text and the weight of each index term within its respective target dependency phrase, a single-class score is calculated for each target dependency phrase, taking into account factors such as the multi-class interference coefficient, index term weights, and the probability of the target dependency phrase being hit by the index term. Then, the single-class scores are weighted and fused from multiple dimensions, including document frequency and the probability of multiple target dependency phrases hitting the same category, to obtain the final score for each category. This setting correlates document frequency and classification probability and superimposes the probability of multinomial hits in the same category, thereby further improving classification accuracy.

[0035] To make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0036] Figure 1 The diagram shows the steps of a fast text classification method based on dependency phrases provided in an example of the present invention.

[0037] Figure 2 As shown Figure 1 The corresponding flowchart.

[0038] Figure 3 As shown Figure 2 A schematic diagram of the structure of storing words within a dependency phrase using a trie.

[0039] Figure 4 The figure shows the probability curves of the number of categories hit x and the single category score y(x) when min=0.5 and max=0.92. Figure 5The figure shows a schematic diagram of the change curve of the document weighted score y'(x) when k=4 and ω changes in a step size of 0.05.

[0040] Figure 6 The diagram shown is a structural schematic of a fast text classification device based on dependency phrases provided in an embodiment of the present invention.

[0041] Figure 7 The diagram shown is an internal structural diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0042] Among existing text classification methods, traditional machine learning methods suffer from problems such as high manual configuration requirements, low efficiency in early data processing, and poor classification accuracy; while deep learning methods, although they have certain significant advantages in classification accuracy, also suffer from problems such as excessive consumption of computing resources, high requirements for computing power of computer equipment, and low efficiency in early data processing.

[0043] In view of this, this embodiment provides a fast text classification method based on dependency phrases that balances classification efficiency and accuracy while consuming low computational power. The method includes: constructing an index database (step S10); parsing the text to be analyzed to obtain index words; searching for target dependency phrases that match the index words in the constructed index database; determining the category of each target dependency phrase and the weight of each index word within its respective target dependency phrase (step S20); and calculating the single classification score for each target dependency phrase's corresponding category based on the number of categories matched by the text to be analyzed and the weight of each index word within its respective target dependency phrase. (Step S30). Analyze the document frequency ω of the index term in the text to be analyzed. Based on the single classification score y(x) of the category corresponding to the index term, fuse the document frequency weighting weight f(ω) to form a document-weighted score y'(x) (Step S40). Based on the number of target dependency phrases associated with each category, determine whether to introduce a multinomial weighting factor to obtain the classification score for each category (Step S50). Sort the classification scores of the multiple matched categories and select the category with the highest score as the category to which the text to be analyzed belongs (Step S60). The following will combine... Figures 1 to 6 The fast text classification method based on dependency phrases provided in this embodiment is described in detail.

[0044] Specifically, such as Figure 1As shown, the fast text classification method based on dependency phrases provided in this embodiment begins with building an index database in step S10. Specifically, before building the index database, multiple text samples need to be obtained, such as social governance text samples formed by crawling social governance-related websites where citizens provide feedback based on natural language text. Then, a dependency parsing algorithm is used to parse the obtained text samples and extract multiple dependency phrases contained in each text sample. Specifically, the dependency parsing algorithm used in this step can be any one of the following: the spacy algorithm in the Python library, NLTK, Stanford CoreNLP, or NetworkX visualization.

[0045] After obtaining multiple dependency terms for each sample, a classification mapping configuration is performed for each dependency term, and the weight of each word within each dependency term is configured. Specifically, a classification mapping table is constructed based on the words within the dependency term to implement the classification mapping configuration. For example, for the dependency term "garbage dumping," "garbage" is used as the mapping word to construct a classification mapping relationship of "garbage" → "environmental sanitation"; for "mosquito breeding," "mosquitoes" is used as the mapping word to construct a classification mapping relationship of "mosquitoes" → "environmental sanitation"; and for the dependency term "damaged fire extinguisher," "fire extinguisher" is used as the mapping word to construct a classification mapping relationship of "fire extinguisher" → "fire safety." This classification mapping configuration allows multiple dependency terms containing the same mapping word to be quickly classified into the same category; for example, the two dependency terms "garbage dumping" and "garbage recycling" will be classified into the category of "environmental sanitation" based on the classification mapping relationship of "garbage" → "environmental sanitation." This setup, based on a small number of mapping relationships, can quickly achieve a wide range of classification coverage for dependency phrases, with a final coverage rate exceeding 90%. Furthermore, in other embodiments, the classification can be expanded by analyzing the similarity between words within dependency phrases and mapped words; for example, in the dependency phrases "noise is too loud" and "noise interference," "noise" and "noise" are similar words, and both can be classified under the category "noise interference" based on the classification mapping relationship "noise" → "noise disturbance," further broadening the classification coverage of the configuration. However, this invention does not limit this approach. In other embodiments, the classification mapping table can also be constructed directly based on dependency phrases; alternatively, if computing power allows, in step S10, existing deep learning-based algorithm model samples can be used for large-scale model classification to improve the generalization ability of the classification model. However, this invention does not limit this approach.

[0046] Furthermore, since there are differences in semantic strength among the words within a dependency phrase, the weight of each word within the dependency phrase is configured according to the dependency relationship when constructing the index database. For example, for the dependency phrase "expired food," it is a verb-object dependency structure, where "food" has higher semantic strength and is assigned a higher weight, such as 0.7, while "expired" is a semantically supplementary description and has a relatively lower weight, such as 0.3. Similarly, in the dependency phrase "property dispute," "property" has higher semantic strength and is assigned a weight of 0.8, while "dispute" has a weight of 0.2. Specifically, when configuring the weight of each word within a dependency phrase, the dependency relationship between the words within the dependency phrase is first parsed and the semantic strength is sorted. Then, according to a preset weight configuration rule related to the dependency relationship, the words after the semantic strength sorting are assigned weights sequentially. However, this invention does not impose any limitations on this. In other embodiments, the weights can be assigned directly based on the number of words without considering the semantic strength between dependency phrases. The weight of each word is 1 / N, where N is the number of words in the dependency phrase.

[0047] In this embodiment, constructing the index database further includes: after obtaining multiple dependency phrases, splitting the words within each dependency phrase and storing the split words as characters in the trie under the category corresponding to that dependency phrase, such as... Figure 3 As shown. By combining semantic dependencies with a trie to achieve fast storage and indexing of dependency phrases, the early processing of natural language text is greatly improved. However, this invention does not impose any limitations on this.

[0048] After completing the index database construction in step S10, proceed to step S20. Specifically, this step includes:

[0049] Step S201: Parse the text to be analyzed to obtain index terms. Specifically, the text to be analyzed is parsed using any one of the dependency parsing algorithms, such as Spacy, NLTK, Stanford CoreNLP, or NetworkX visualization, to extract index terms and inter-word relationships. For example, for the input social governance text "A convenience store sells expired food, and a lot of garbage is piled up outside, causing mosquitoes to breed and leading to a strong dispute. We hope to resolve the garbage problem," the analysis yields the words "expired," "food," "pile up," "garbage," "mosquitoes breed," and "dispute," as well as the inter-word relationship between "expired" and "food" and "garbage." However, this invention does not limit this. In other embodiments, other word segmentation methods can also be used to parse the text to be analyzed to obtain index terms, taking into account the computing power of the computing device, without considering inter-word relationships to reduce the consumption of computer computing resources.

[0050] Step S202: Based on the trie, search the index database for the target dependency phrase corresponding to each index term, determine the category of each target dependency phrase, and the weight of each index term within its target dependency phrase. In this embodiment, the parsed words "expired," "food," "pile up," "garbage," "mosquito breeding," and "dispute" are used as index terms. The index database constructed in step S10 is queried through the trie to obtain the target dependency phrase corresponding to each index term. For example... Figure 2 As shown, both the index terms "expired" and "food" fully match the target dependency phrase "expired food," so their weights in this target dependency phrase are 1. Similarly, both the index terms "pile up" and "garbage" fully match the target dependency phrase "garbage opponent," and "mosquito breeding" fully matches the target dependency phrase "mosquito breeding." Therefore, the weights of these two target dependency phrases are also 1. However, the index term "dispute" only partially matches the target dependency phrase, so it is necessary to determine the weight of "dispute" within the target dependency phrase "property dispute," as configured as 0.2 in step S10 of this embodiment.

[0051] Next, step S30 is executed: Based on the number of categories hit by the text to be analyzed and the weight of each index term within its respective target dependency phrase, the single classification score of the category corresponding to each target dependency phrase is calculated using the following formula:

[0052]

[0053] Where min and max represent the cardinality boundaries of the classification probability, count represents the maximum number of categories that the text to be analyzed can hit, x represents the number of categories that the current text to be analyzed hits, n is the number of words in the target dependency phrase, and f(i) represents the weight of the i-th word.

[0054] Single category score The score is determined by the sum of the weights of the index terms in the target dependency phrase and the number of categories matched (x). Generally, a higher number of categories matched (x) in the text being analyzed indicates weaker logical coherence, and a lower probability of being classified. Single category score. The calculation formula consists of two parts, the first part This describes how the probability of a text being classified into a single category gradually decreases as the number of hit categories increases. The min and max values ​​are adjusted to make the probability interval [min, max] a dynamically adjustable confidence interval; preferably, min is typically around 0.5, max around 0.9, and count is a positive integer less than or equal to 30. Figure 4 The diagram shows the probability curves of the number of classes hit (x) versus the single-class score (y(x)) when min=0.5 and max=0.92; from Figure 4 As can be seen, y(x) decreases as x increases.

[0055] Single category score The second part of the calculation formula is a summation function. Here, f(i) represents the weight of the i-th word to calculate the probability of hitting the indexed word in the dependency phrase. Taking a dependency phrase with three words and weights of 0.5, 0.3, and 0.2 as an example, the summation function is used to calculate the probability of hitting the indexed word in different hit scenarios. The values ​​are as follows (1 indicates a hit, 0 indicates a miss):

[0056]

[0057] In step S30, the single-class score y(x) is calculated based on the number of hit categories x and the dependency phrase hit rate, but it only represents a partial representation of the classification. In reality, besides being affected by other categories, the document frequency ω of the indexed terms is also a crucial factor in the classification score, and it can more accurately express the semantics of the text. Therefore, the fast text classification method based on dependency phrases provided in this embodiment incorporates the document frequency ω into the classification algorithm to further improve the accuracy of the classification. Specifically, the max and min values ​​in the single-class score calculation formula can be appropriately adjusted to dynamically adjust the confidence interval, and then the document frequency ω is weighted from it.

[0058] Specifically, this embodiment uses the Sigmoid function for weighted fusion of document frequencies ω. The Sigmoid function's output ranges from (0.5, 1), and its output can be interpreted as a probability belonging to the positive class. Furthermore, the derivative of the Sigmoid function is differentiable within its domain, allowing for parameter updates using optimization algorithms such as gradient descent during neural network training, reducing abrupt gradient changes and contributing to more stable model training. Additionally, the Sigmoid function is monotonically increasing, meaning that the output monotonically increases with the input. However, this invention does not impose any limitations on this. In other embodiments, other positive activation functions can also be used for weighted fusion of document frequencies ω, such as any one of the power function, softmax function, or Gaussian function.

[0059] The document frequency weighting weight f(ω) based on the Sigmoid function is shown below:

[0060]

[0061] Where e is the base of the natural logarithm, ω is the document frequency of the index term in the text to be analyzed, and k is a constant used to adjust the slope of the curve of the document frequency weighting weight f(ω). The larger the value of k, the closer the curve is to 1.

[0062] Based on the single classification score y(x) of each target dependency phrase corresponding to its category, the document frequency weighting weight f(ω) is fused to obtain the document weighted score y'(x) as shown below:

[0063]

[0064] Figure 5 The figure shows a schematic diagram of the change curve of the document weighted score y'(x) when k=4 and ω changes in a step size of 0.05; from Figure 5 It can also be concluded that the document frequency ω contributes positively to the classification score.

[0065] Steps S30 and S40 calculate the individual classification score y(x) and the document-weighted score y'(x) for each dependency term; that is, the calculation of the individual classification score y(x) among multiple dependency terms in the same category is isolated from each other. However, in actual classification, it is highly likely that multiple dependency terms will hit the same category; for example... Figure 2 In this case, both the dependency phrases "garbage dumping" and "mosquito breeding" fall under the category of "environmental sanitation." Based on this, the final classification score will definitely be higher than multiple [other possible categories]. The maximum value in Therefore, step S50 will consider the impact of multiple dependency phrases hitting the same category on the final score of that category. Specifically, for multiple target dependency phrases hitting the same category, a multinomial weighting factor is introduced to weight and fuse the document weighted scores y'(x) of multiple target dependency phrases to form a multinomial weighted score y''(x), and the multinomial weighted score y''(x) is used as the category score. Specifically, for multiple target dependency phrases hitting the same category, the multinomial weighted score y''(x) is calculated using the following formula:

[0066]

[0067] Among them, weighting factor It is in the form of the root of the mean. (x) represents the average of the document weighted scores y'(x) of multiple target dependency phrases, and α is an adjustable parameter used to control the skewness of the probability interval [min, max]. For example, α can be selected as a value of 2 or 3, and the skewness of the probability interval is positively correlated with α. Figure 2As shown, the weighted score of documents with the target dependency phrase "garbage dumping" is y'(x) = 0.82679; while the weighted score of documents with the target dependency phrase "mosquito breeding" in the same category is y'(x) = 0.82321. The polynomial weighted scores of the two are then calculated... =0.898673, this score will be used as the classification score for the "Environmental Hygiene" category.

[0068] For categories that are associated with only one target dependency term, the weighted score y'(x) of the documents corresponding to that target dependency term is used as the classification score for that category. For example... Figure 2 As shown, both "expired food" and "dispute" fall under the category of only one target dependency phrase. Therefore, the weighted score y'(x) = 0.82312 for the document "expired food" is used as the classification score for the category "food safety". The weighted score y'(x) = 0.08123 for the document "property dispute" is used as the classification score for the category "property dispute".

[0069] After obtaining the multi-dimensional weight fusion based on document frequency ω and multiple target dependency phrases hitting the same category, step S60 is executed to sort the classification scores of the multiple hit categories, and the category with the highest score is selected as the category to which the text to be analyzed belongs. For example... Figure 2 As shown, among the three categories of "food safety", "environmental hygiene" and "property disputes", "environmental hygiene" has the highest classification score, so it is identified as the category of the text to be analyzed and output.

[0070] Correspondingly, such as Figure 6 As shown, this embodiment also provides a fast text classification device based on dependency phrases, which includes a database construction unit 10, a text parsing unit 20, a single classification score calculation unit 30, a document frequency weighted calculation unit 40, a multinomial weighted calculation unit 50, and a sorting output unit 60. The database construction unit 10 constructs an index database: it acquires multiple dependency phrases related to the text sample, performs classification mapping configuration on each dependency phrase, and configures the weight of each word within each dependency phrase. The text parsing unit 20 parses the text to be analyzed to obtain index words, searches for target dependency phrases matching the index words in the constructed index database, and determines the category of each target dependency phrase and the weight of each index word within its target dependency phrase. The single classification score calculation unit 30 calculates the single classification score of the category corresponding to each target dependency phrase using the following formula, based on the number of categories hit by the text to be analyzed and the weight of each index word within its target dependency phrase:

[0071]

[0072] Where min and max represent the cardinality boundaries of the classification probabilities, count represents the maximum number of categories that the text to be analyzed can hit, x represents the number of categories that the current text to be analyzed hits, n is the number of words in the target dependency phrase, and f(i) represents the weight of the i-th word. The document frequency weighted calculation unit 40 parses the document frequency ω of the index term in the text to be analyzed, and on the basis of the single classification score y(x) of the category corresponding to the index term, it integrates the document frequency weighted weight f(ω) to form the document weighted score y'(x). The polynomial weighted calculation unit 50 summarizes the target dependency phrases associated with each hit category. For a category associated with only one target dependency phrase, the weighted score y'(x) of the documents corresponding to that target dependency phrase is used as the classification score for that category. For multiple target dependency phrases hitting the same category, a polynomial weighting factor is introduced to weight and fuse the weighted scores y'(x) of the documents of multiple target dependency phrases, forming a polynomial weighted score y''(x), which is then used as the classification score for that category. The sorting output unit 60 sorts the classification scores of the multiple hit categories and selects the category with the highest score as the category to which the text to be analyzed belongs.

[0073] In this embodiment, the database construction unit 10 further includes the following steps in constructing the index database: after obtaining multiple dependency terms, splitting the words within each dependency term and storing the split words as characters in the trie under the category corresponding to the dependency term. After obtaining the index terms of the text to be analyzed, the text parsing unit 20 searches for the target dependency term corresponding to the index term and the category to which the target dependency term belongs in the index database based on the trie.

[0074] Specific limitations regarding the fast text classification device based on dependency phrases can be found in the limitations of steps S10 to S60 of the fast text classification method based on dependency phrases above, and will not be repeated here. Each module in the aforementioned fast text classification device based on dependency phrases 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 in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0075] Figure 7An internal structural diagram of a computer device in one embodiment is shown. The computer device includes a processor, memory, and a network interface connected via a system bus. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and may also store a computer program that, when executed by the processor, enables the processor to implement a fast text classification method based on dependency phrases. The internal memory may also store a computer program that, when executed by the processor, enables the processor to implement a fast text classification method based on dependency phrases.

[0076] Those skilled in the art will understand that Figure 7 The 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.

[0077] In one embodiment, the fast text classification device based on dependency phrases provided in this application can be implemented as a computer program, which can be implemented in the form of, for example... Figure 7 The computer device shown operates on this device. The computer device's memory can store various program modules that make up the dependency-based fast text classification apparatus, such as a database construction unit 10, a text parsing unit 20, a single-classification score calculation unit 30, a document frequency weighted calculation unit 40, a multinomial weighted calculation unit 50, and a sorting output unit 60. The computer program, composed of these program modules, causes the processor to execute the steps in the dependency-based fast text classification methods of the various embodiments of this application described in this specification.

[0078] This invention provides a fast text classification method and apparatus based on dependency phrases, which has the following advantages: ① It focuses on social governance text classification, and can achieve classification coverage with a small number of classification configurations; it is not only simple to configure but also has low computational requirements for classification, achieving basic implementation capabilities and having the advantage of rapid deployment; ② It divides phrases according to dependency relationships, which can better highlight semantic features and cleverly uses trie to accelerate the extraction of dependency elements; ③ It calculates the cardinality of classification by multi-class interference coefficients, weight coefficients, and the hit rate of dependency phrases, and quickly and accurately obtains the basic probability of classification. ④ By utilizing the document frequency of dependency words and combining it with the sigmoid function for algorithm fine-tuning, the document frequency and classification probability are correlated to further improve classification accuracy; ⑤ By using a polynomial probability superposition algorithm for hitting the same category, the probability is calculated a second time to a certain extent, and the result is closer to the real situation; ⑥ The sixth advantage of this invention is that it supports dynamic adjustment of the confidence intervals min, max, sigmoid constant k, and polynomial superposition function α to achieve the same effect as other algorithms; ⑦ The data generated in each step has high credibility and only requires a small amount of manual screening, which can be used as high-quality sample data for training large models.

[0079] In summary, the fast text classification method based on dependency phrases provided in this invention enables the autonomous classification of other related dependency phrases by configuring the mapping relationship between dependency phrases and categories when constructing the index database, thereby quickly achieving wide-ranging classification coverage based on dependency phrases. It reduces reliance on large amounts of manually labeled data during the initial data processing, lowering the cost of manual configuration and improving the algorithm's practicality. Furthermore, the weighting of each word within each dependency phrase better highlights semantic features to improve classification accuracy, while the storage of related words within dependency phrases based on a trie accelerates dependency element extraction, significantly improving the indexing hit efficiency of target dependency phrases within the text to be analyzed.

[0080] After obtaining the number of categories hit by the analyzed text and the weight of each index term within its respective target dependency phrase, a single-class score is calculated for each target dependency phrase, taking into account factors such as the multi-class interference coefficient, index term weights, and the probability of the target dependency phrase being hit by the index term. Then, the single-class scores are weighted and fused from multiple dimensions, including document frequency and the probability of multiple target dependency phrases hitting the same category, to obtain the final score for each category. This setting correlates document frequency and classification probability and superimposes the probability of multinomial hits in the same category, thereby further improving classification accuracy.

[0081] Although the present invention has been disclosed above by way of preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art may make some modifications and refinements without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be determined by the scope of protection claimed in the claims.

Claims

1. A fast text classification method based on dependency phrases, characterized in that, include: Build an index database: Obtain multiple dependency phrases related to the text sample, classify and map each dependency phrase, and configure the weight of each word within each dependency phrase; The text to be analyzed is parsed to obtain index terms. The target dependency terms that match the index terms are searched in the constructed index database. The category of each target dependency term and the weight of each index term in its target dependency term are determined. Based on the number of categories hit by the text to be analyzed and the weight of each index term within its respective target dependency term group, the single classification score for each target dependency term group is calculated using the following formula: Where min and max represent the cardinality boundaries of the classification probability, count represents the maximum number of categories that the text to be analyzed can hit, x represents the number of categories that the current text to be analyzed hits, n is the number of words in the target dependency phrase, and f(i) represents the weight of the i-th word. The document frequency ω of the index term in the text to be analyzed is analyzed. Based on the single classification score y(x) of the category corresponding to the index term, the document frequency weighting weight f(ω) is fused to form the document weighting score y'(x). The target dependency phrases associated with each hit category are summarized. For a category that is associated with only one target dependency phrase, the weighted score y'(x) of the documents corresponding to that target dependency phrase is used as the classification score of that category. For multiple target dependency phrases that hit the same category, a polynomial weighting factor is introduced to weight and merge the weighted scores y'(x) of the documents of multiple target dependency phrases, and the polynomial weighted score y''(x) is used as the classification score of that category. The classification scores of the multiple categories that were hit were sorted, and the category with the highest score was selected as the category to which the text to be analyzed belonged.

2. The fast text classification method based on dependency phrases according to claim 1, characterized in that, Building the index database also includes: after obtaining multiple dependency phrases, splitting the words in each dependency phrase and storing the split words as characters in the trie corresponding to the category of the dependency phrase; After obtaining the index terms of the text to be analyzed, the target dependency terms and the category to which the target dependency terms belong are searched in the index database based on the trie.

3. The fast text classification method based on dependency phrases according to claim 1, characterized in that, The text to be analyzed is parsed using dependency parsing to extract index terms and inter-word relationships. The index terms are either single words or dependency phrases.

4. The fast text classification method based on dependency phrases according to claim 1, characterized in that, A positive activation function is used to express the additive effect of document frequency ω on the classification score. The positive activation function is any one of the following: power function, sigmoid function, softmax function, or Gaussian function.

5. The fast text classification method based on dependency phrases according to claim 4, characterized in that, The positive activation function is the Sigmoid function. After obtaining the document frequency ω of the index term in the text to be analyzed, the document frequency weighting weight f(ω) corresponding to the index term is formed using the following formula: Where e is the base of the natural logarithm, ω is the document frequency of the index term in the text to be analyzed, and k is a constant used to adjust the slope of the curve of the document frequency weighting weight f(ω). The larger the value of k, the closer the curve is to 1. Based on the single classification score y(x) of the category corresponding to each target dependency phrase, the document-weighted score y'(x) obtained after fusing the document frequency weighting weight f(ω) is shown below: 。 6. The fast text classification method based on dependency phrases according to claim 1, characterized in that, For multiple target dependency phrases that hit the same category, the multinomial weighted score y''(x) is calculated using the following formula: Among them, the polynomial weighting factor It is in the form of the root of the mean. (x) represents the average of the document weighted scores y'(x) of multiple target dependency phrases, and α is an adjustable parameter used to control the skewness of the probability interval [min, max]. The skewness of the probability interval is positively correlated with α. The maximum value of the weighted score y'(x) for documents with multiple target dependency terms.

7. The fast text classification method based on dependency phrases according to claim 1, characterized in that, Calculate the single-class score for the category corresponding to each target dependency phrase. Within the formula, the probability interval [min, max] is a dynamically adjustable confidence interval, and count is a positive integer less than or equal to 30.

8. A fast text classification device based on dependency phrases, characterized in that, include: Database building unit, building index database: obtain multiple dependency phrases related to text samples, classify and map each dependency phrase, and configure the weight of each word in each dependency phrase; The text parsing unit parses the text to be analyzed to obtain index terms, searches for target dependency terms that match the index terms in the constructed index database, and determines the category of each target dependency term and the weight of each index term in its target dependency term. The single-class score calculation unit calculates the single-class score for each target dependency word group based on the number of categories the text being analyzed falls into and the weight of each index word within its respective target dependency word group, using the following formula: Where min and max represent the cardinality boundaries of the classification probability, count represents the maximum number of categories that the text to be analyzed can hit, x represents the number of categories that the current text to be analyzed hits, n is the number of words in the target dependency phrase, and f(i) represents the weight of the i-th word. The document frequency weighted calculation unit analyzes the document frequency ω of the index term in the text to be analyzed. Based on the single classification score y(x) of the category corresponding to the index term, it integrates the document frequency weighting weight f(ω) to form the document weighted score y'(x). The multinomial weighted calculation unit summarizes the target dependency phrases associated with each hit category. For a category associated with only one target dependency phrase, the weighted score y'(x) of the documents corresponding to that target dependency phrase is used as the classification score of that category. For multiple target dependency phrases that hit the same category, a multinomial weighting factor is introduced to weight and merge the weighted scores y'(x) of the documents of multiple target dependency phrases to form a multinomial weighted score y''(x), and the multinomial weighted score y''(x) is used as the classification score of that category. The sorting output unit sorts the classification scores of the multiple categories hit and selects the category with the highest score as the category to which the text to be analyzed belongs.

9. The fast text classification device based on dependency phrases according to claim 8, characterized in that, The database construction unit also includes the following steps in building the index database: after obtaining multiple dependency phrases, splitting the words in each dependency phrase and storing the split words as characters in the trie under the category corresponding to the dependency phrase; After obtaining the index terms of the text to be analyzed, the text parsing unit searches the index database for the target dependency phrases corresponding to the index terms and the category to which the target dependency phrases belong, based on the trie.

10. 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 7.

Citation Information

Patent Citations

  • Classification method and device based on artificial intelligence, terminal and storage medium

    CN111708888A

  • Text classification method and device

    CN112328798A