Sensitive word detection method, sensitive word detection apparatus, electronic device, and storage medium
By constructing a sensitive word tree and combining it with contextual similarity calculation, the problems of misjudgment and low efficiency in sensitive word detection in existing technologies are solved, and efficient and accurate sensitive word recognition is achieved.
Patent Information
- Application Number
- PCT/CN2025/133277
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-20
- Filing Date
- 2025-11-07
- Publication Date
- 2026-11-26
AI Technical Summary
Existing technologies lack contextual semantic understanding in sensitive word detection, leading to misjudgments and inefficiency, especially when processing large-scale texts, which is time-consuming.
By classifying multiple preset sensitive words, a sensitive word tree is constructed. The sensitive word tree is used to obtain word segmentation units from the text to be detected, and the presence of sensitive words is determined by combining the calculation of context similarity.
It significantly improves the accuracy and efficiency of sensitive word detection, can quickly identify common sensitive words and deal with variations, inversions, insertions, etc., while balancing the false positive rate and the false negative rate.
Smart Images

Figure CN2025133277_26112026_PF_FP_ABST
Abstract
Description
A method, device, electronic device, and storage medium for detecting sensitive words.
[0001] Cross-references to related applications
[0002] This disclosure claims priority to Chinese Patent Application No. 2025106465477, filed on May 20, 2025, entitled "A Sensitive Word Detection Method and Sensitive Word Detection Device", the entire contents of which are incorporated herein by reference. Technical Field
[0003] This disclosure relates to the field of computer technology, and in particular to a sensitive word detection method, a sensitive word detection device, an electronic device, and a storage medium. Background Technology
[0004] With the rapid development of the internet, it has become an important platform for people to obtain information and exchange ideas. However, the openness and anonymity of the online environment have also brought many challenges, one of which is the phenomenon of users deliberately using sensitive words to disrupt the online environment. In order to maintain the harmony and health of cyberspace and ensure the legality and appropriateness of online content, sensitive word detection of text content has become an important technical requirement.
[0005] Currently, content moderation technology mainly relies on building a sensitive word lexicon. This involves breaking down the text to be reviewed into word groups and comparing them one by one with the sensitive words in the lexicon to identify and filter out potentially sensitive content. While this method is simple to implement, it has significant limitations in practical applications. First, it lacks an understanding of contextual semantics, making it unable to accurately determine the true meaning of words in a specific context, easily leading to misjudgments. Second, the word-by-word comparison method is inefficient, especially when processing large-scale texts, consuming a lot of time and resulting in unsatisfactory detection results. Summary of the Invention
[0006] In view of this, the purpose of this disclosure is to provide a sensitive word detection method, a sensitive word detection device, an electronic device, and a storage medium. By grouping preset sensitive words and constructing a sensitive word tree, the method uses the sensitive word tree to obtain word segmentation units from the text to be detected, and combines this with the calculation of context similarity, significantly improving the accuracy and efficiency of sensitive word detection. It can not only quickly identify common sensitive words, but also handle various transformations, inversions, insertions, etc., while balancing the false positive rate and the false negative rate.
[0007] In a first aspect, an optional embodiment of this disclosure provides a sensitive word detection method, the sensitive word detection method comprising:
[0008] Classify multiple preset sensitive words and construct at least one sensitive word tree using these preset sensitive words;
[0009] The obtained text to be detected is split into multiple splitting units;
[0010] For each target sensitive word tree with the same root node as the splitting unit, the length of each branch link in the target sensitive word tree is determined, and at least one first word segmentation unit is determined from multiple splitting units based on the length of the branch link;
[0011] For each first word segmentation unit, the nodes in the target sensitive word tree are compared with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit, and the presence of sensitive words in the text to be detected is determined based on the first similarity.
[0012] Secondly, another optional embodiment of this disclosure also provides a sensitive word detection device, the sensitive word detection device comprising:
[0013] The sensitive word tree construction module is used to classify multiple preset sensitive words and construct at least one sensitive word tree using the multiple preset sensitive words;
[0014] The splitting unit determination module is used to split the acquired text to be detected and determine multiple splitting units;
[0015] The word segmentation unit determination module is used to determine the length of each branch link in each target sensitive word tree for which the root node is the same as the segmentation unit, and to determine at least one first word segmentation unit from multiple segmentation units based on the length of the branch link.
[0016] The first detection module is used to compare each first word segmentation unit with the nodes in the target sensitive word tree to determine the first similarity corresponding to the first word segmentation unit, and to determine whether there are sensitive words in the text to be detected based on the first similarity.
[0017] This disclosure provides a sensitive word detection method, device, electronic device, and storage medium. First, multiple preset sensitive words are classified, and at least one sensitive word tree is constructed using these preset sensitive words. Then, the acquired text to be detected is split to determine multiple splitting units. For each target sensitive word tree with the same root node as the splitting unit, the length of each branch link in the target sensitive word tree is determined, and at least one first word segmentation unit is determined from the multiple splitting units based on the length of the branch link. Finally, for each first word segmentation unit, the nodes in the target sensitive word tree are compared with the first word segmentation unit to determine a first similarity corresponding to the first word segmentation unit, and the presence of sensitive words in the text to be detected is determined based on the first similarity.
[0018] This disclosure significantly improves the accuracy and efficiency of sensitive word detection by grouping preset sensitive words into a sensitive word tree, using the sensitive word tree to obtain corresponding word segmentation units from the text to be detected, and combining this with the calculation of context similarity. It can not only quickly identify common sensitive words, but also handle various variations, inversions, and insertions, while balancing false positives and false negatives.
[0019] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of this disclosure and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 is a flowchart of a sensitive word detection method provided in an optional embodiment of this disclosure;
[0022] Figure 2 is a schematic diagram of a sensitive word tree structure provided in an optional embodiment of this disclosure;
[0023] Figure 3 is a schematic diagram of a sensitive word tree carrying exemption phrases provided in an optional embodiment of this disclosure;
[0024] Figure 4 is a schematic diagram of a sensitive word detection device provided in an optional embodiment of this disclosure;
[0025] Figure 5 is a schematic diagram of the structure of an electronic device provided in an optional embodiment of this disclosure. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. Based on the embodiments of this disclosure, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this disclosure.
[0027] First, the applicable scenarios for this disclosure are introduced. This disclosure can be applied to the field of computer technology.
[0028] With the rapid development of the internet, it has become an important platform for people to obtain information and exchange ideas. However, the openness and anonymity of the online environment have also brought many challenges, one of which is the phenomenon of users deliberately using sensitive words to disrupt the online environment. In order to maintain the harmony and health of cyberspace and ensure the legality and appropriateness of online content, sensitive word detection of text content has become an important technical requirement.
[0029] Research has found that current content moderation technology primarily relies on building a sensitive word lexicon. This involves breaking down the text to be reviewed into word groups and comparing them one by one with the sensitive words in the lexicon to identify and filter out potentially sensitive content. While this method is simple to implement, it has significant limitations in practical applications. First, it lacks an understanding of contextual semantics, making it unable to accurately determine the true meaning of words in a specific context, easily leading to misjudgments. Second, the word-by-word comparison method is inefficient, especially when processing large-scale texts, consuming a lot of time and resulting in unsatisfactory detection results.
[0030] Based on this, the present disclosure provides a sensitive word detection method that significantly improves the accuracy and efficiency of sensitive word detection. It can not only quickly identify common sensitive words, but also deal with various transformations, inversions, insertions, etc., while balancing the false alarm rate and the false negative rate.
[0031] Please refer to Figure 1, which is a flowchart of a sensitive word detection method provided by an optional embodiment of this disclosure. As shown in Figure 1, the sensitive word detection method provided by an optional embodiment of this disclosure includes:
[0032] S101, classify multiple preset sensitive words, and construct at least one sensitive word tree using the multiple preset sensitive words.
[0033] Here, preset sensitive words are pre-defined sets of words that need to be blocked, either manually or by algorithms. A sensitive word tree is a multi-branch tree structure constructed by breaking down preset sensitive words into hierarchical tree structures based on characters. A sensitive word tree contains a root node and at least one child node. A node is represented by a character, which can be a letter, radical, phrase, or pinyin. The root node and its child nodes at all levels form a preset sensitive word.
[0034] In specific implementation of step S101, multiple preset sensitive words are obtained, the multiple preset sensitive words are classified, and at least one sensitive word tree is constructed using the multiple preset sensitive words.
[0035] As an optional embodiment, regarding step S101 above, classifying multiple preset sensitive words and constructing at least one sensitive word tree using the multiple preset sensitive words includes:
[0036] Step 1011: Identify at least one sensitive word group from a plurality of preset sensitive words.
[0037] Here, the first character of each preset sensitive word in the sensitive word group has the same element. Specifically, the same element can be that the first character of each preset sensitive word in the same sensitive word group is exactly the same.
[0038] Regarding step 1011 above, in specific implementation, preset sensitive words with the same first character are identified from multiple preset sensitive words, and these preset sensitive words with the same first character are grouped into one sensitive word group. Here, taking the case where the first character of each preset sensitive word is completely identical as an example, for instance, if the preset sensitive words are ABB, ABC, BBA, BDA, CDA, DDA, AB, BD, ADCB, and CBAD, then based on the first character of the preset sensitive words, the preset sensitive words with the same first character are grouped into one sensitive word group, resulting in multiple sensitive word groups. The first sensitive word group includes ABB, ABC, AB, and ADCB; the second sensitive word group includes BBA, BDA, and BD; the third sensitive word group includes CDA and CBAD; and the fourth sensitive word group includes DDA. Alternatively, as an optional embodiment, preset sensitive words with the same first character can be grouped into one category first, and then those with the same characters at subsequent corresponding positions can be grouped into the same sensitive word group, or those with the same characters at subsequent corresponding positions and equal character length can be grouped into the same sensitive word group.
[0039] Step 1012: For each sensitive word group, take the element corresponding to the first character of the preset sensitive word in the sensitive word group as the root node, and construct corresponding child nodes for each root node according to the order of the characters contained in the preset sensitive word in the sensitive word group to generate the sensitive word tree corresponding to the sensitive word group.
[0040] Regarding step 1012 above, in specific implementation, the preset sensitive words are grouped to obtain multiple sensitive words. For each sensitive word group, each preset sensitive word in the sensitive word group is split into characters, and then a tree structure is constructed layer by layer, with the element corresponding to the first character of the preset sensitive word in the sensitive word group as the root node. Here, when the sensitive word group in step 1011 above is grouped according to the same character, the root node is the first character of the preset sensitive word. Then, according to the order of the characters contained in the preset sensitive words in the sensitive word group, corresponding child nodes are constructed for each root node to generate the sensitive word tree corresponding to the sensitive word group. Please refer to Figure 2, which is a schematic diagram of the structure of a sensitive word tree provided by an optional embodiment of this disclosure. Continuing the embodiment in step 1011 above, the preset sensitive words in each sensitive word group are decomposed into a tree-like hierarchy according to characters to construct a multi-branch tree structure. Each node in the sensitive word tree represents a character, and the path from the root node to the leaf node forms a complete sensitive word.
[0041] S102, the obtained text to be detected is split into multiple splitting units.
[0042] Here, the text to be detected can be any text content input by the user or any text content output by a large language model. Sensitive words need to be detected through a sensitive word tree. For example, the text to be detected can be user-input comments, chat messages, or other types of text data. This disclosure does not make specific limitations on this.
[0043] Regarding step S102 above, in specific implementation, the text to be inspected input by the user is obtained, and each character in the obtained text is split to determine multiple splitting units. Here, as an example, when the obtained text to be inspected is "AC,DBDBA.CCA#BBCD@D*AA!B!", each character in the text to be inspected is split into multiple splitting units including: A, C, D, B, D, B, A, C, C, A, B, B, C, D, D, A, A, B. Among these, spaces, special characters, punctuation marks, and other interfering elements can be filtered out, retaining only meaningful characters for content review.
[0044] According to the sensitive word detection method provided in this disclosure, preset sensitive words can also be classified according to the pronunciation, shape, and / or letters of characters. As another optional embodiment, regarding step S101 above, classifying multiple preset sensitive words and constructing at least one sensitive word tree using these multiple preset sensitive words includes:
[0045] Multiple preset sensitive words are classified according to one or more of the following: pronunciation, character shape, and letters. At least one sensitive word tree is constructed using the multiple preset sensitive words.
[0046] Regarding the above steps, in specific implementation, preset sensitive words are classified according to one or more of the following: pronunciation, character shape, and letters. Based on the classification results, at least one sensitive word tree is constructed using multiple preset sensitive words. For example, preset sensitive words are classified based on their pronunciation, grouping those with the same pronunciation for their first character into one category. Within each sensitive word group, the first character of all preset sensitive words has the same pronunciation. Thus, the root node of the generated sensitive word tree is the pronunciation of the first character of the preset sensitive word. Subsequent sensitive word judgment is based on pronunciation, resolving the problem of identifying homophones.
[0047] Furthermore, regarding step S102 above, the step of segmenting the acquired text to be detected to determine multiple segmentation units includes:
[0048] Based on one or more of the pronunciation, glyphs, and letters of each character in the text to be detected, the obtained text to be detected is split into multiple splitting units.
[0049] Here, after classifying the preset sensitive words according to one or more of the following criteria—pronunciation, glyph, and letter—the text to be detected also needs to be segmented according to one or more of these criteria. In practice, based on the pronunciation, glyph, and letter of each character in the text to be detected, the obtained text is segmented to determine multiple segmentation units. Continuing with the example above, after classifying the preset sensitive words based on their pronunciation, the text to be detected also needs to be segmented into multiple segmentation units according to their pronunciation.
[0050] S103, for each target sensitive word tree with the same root node as the splitting unit, determine the length of each branch link in the target sensitive word tree, and determine at least one first word segmentation unit from multiple splitting units based on the length of the branch link.
[0051] Regarding step S103 above, in specific implementation, firstly, based on the multiple splitting units obtained in step S102, a target sensitive word tree with the same root node as the splitting unit is determined from multiple sensitive word trees. Here, continuing the above embodiment, the selected target sensitive word trees are the sensitive word tree with root node A, the sensitive word tree with root node B, the sensitive word tree with root node C, and the sensitive word tree with root node D. This can significantly reduce the workload of matching the content in the word library, save matching time, and improve content review efficiency. Then, for each target sensitive word tree, the length of each branch link in the target sensitive word tree is determined, and at least one first word segmentation unit is determined from multiple splitting units based on the length of each branch link. As an optional embodiment, the maximum length can also be determined from the lengths of multiple branch links, and the first word segmentation unit can be determined from multiple splitting units based on the maximum length.
[0052] As an optional embodiment, regarding step S103 above, determining at least one first word segmentation unit from multiple segmentation units based on the length of the branch link includes:
[0053] Step 1031: Identify at least one target splitting unit from the multiple splitting units that has the same elements as the root node of the target sensitive word tree.
[0054] Regarding step 1031 above, in specific implementation, at least one target splitting unit is determined from multiple splitting units that has the same elements as the root node of the target sensitive word tree. Here, as an example, when the root node of the target sensitive word tree is A, the splitting unit that is A among the multiple splitting units is taken as the target splitting unit.
[0055] Step 1032: For each target segmentation unit, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward from the target segmentation unit as the starting point and combined to obtain the first word segmentation unit.
[0056] Regarding step 1032 above, in specific implementation, for each target segmentation unit, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward from the target segmentation unit as the starting point and combined to obtain the first word segmentation unit. Here, the multiple segmentation units obtained can be combined in order or randomly without order to overcome the problem of deliberately disordering the order and evading sensitive word detection. Continuing the above embodiment, when the segmentation unit with A among the multiple segmentation units is taken as the target segmentation unit, and the length of each branch link is 2, 3 and 4 respectively, multiple first word segmentation units can be extracted from the text to be detected by sequential combination, namely ACDB, ACCA, ABBC, AAB, AB.
[0057] S104, for each first word segmentation unit, compare the node in the target sensitive word tree with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit, and determine whether there are sensitive words in the text to be detected based on the first similarity.
[0058] Regarding step S104 above, in specific implementation, for each first word segmentation unit, the nodes in the target sensitive word tree are compared with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit. Here, according to the embodiments provided in this disclosure, the first similarity can be the similarity of the first word segmentation unit to each specific branch in the target sensitive word tree, or it can be the similarity of the target sensitive word tree. Then, based on the first similarity corresponding to the first word segmentation unit, it is determined whether there are sensitive words in the text to be detected. Specifically, the first similarity corresponding to the determined first word segmentation unit is compared with a preset first similarity threshold. If the first similarity is greater than or equal to the first similarity threshold, it is determined that there are sensitive words in the text to be detected.
[0059] Here, in determining the first similarity corresponding to the word segmentation unit, this embodiment of the disclosure provides two methods for determining the first similarity. Specifically, method one, regarding step S104 above, involves comparing the nodes in the target sensitive word tree with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit, including:
[0060] A: Compare the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that have the same element as the nodes of each branch link in the target sensitive word tree.
[0061] Regarding step A above, in specific implementation, the nodes of each branch link in the target sensitive word tree are compared with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that share the same element as the nodes of each branch link in the target sensitive word tree. Here, the nodes of each branch link include the root node of the target sensitive word tree. Specifically, when comparing nodes and characters, the comparison can be performed sequentially. Since the first character of the first word segmentation unit is the same as the root node of the target sensitive word tree when determining the first word segmentation unit, the sequential comparison first uses each branch link node of the second level in the target sensitive word tree to compare with the second character in the first word segmentation unit, and so on. Alternatively, the comparison can be performed out of order. For example, each branch link node of the second level in the target sensitive word tree can be compared with the 2nd / 3rd / 4th character in the first word segmentation unit. This avoids the problem of missed sensitive words due to word order. Alternatively, each branch node in the target sensitive word tree can be compared with multiple characters in the first word segmentation unit. For example, each branch node in the second layer of the target sensitive word tree can be compared with the second and third characters in the first word segmentation unit. Or, only characters at corresponding positions can be compared. For example, each branch node in the second layer of the target sensitive word tree can be compared with the second character in the first word segmentation unit.
[0062] B: The ratio between the number and the length of the corresponding branch link of the target sensitive word tree is taken as the first similarity.
[0063] Regarding step B above, in practice, the first similarity is determined by dividing the number of identical characters by the length of the corresponding branch link in the target sensitive word tree. This disregards the order of character appearance, as long as they can be matched one by one, eliminating the need for sequential matching and overcoming the problems of word order inversion and missed sensitive words.
[0064] Method 2, regarding step S104 above, the step of comparing the nodes in the target sensitive word tree with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit includes:
[0065] a: Compare the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that have the same element as the nodes of each branch link in the target sensitive word tree.
[0066] Here, the description of step a above can be referred to the description of step A above, and the same technical effect can be achieved, so it will not be repeated here.
[0067] b: For each branch link in the target sensitive word tree, the ratio between the number and the length of the branch link is used as the branch similarity.
[0068] c: Determine the first similarity corresponding to the first word segmentation unit using multiple branch similarities.
[0069] Regarding steps b-c above, in specific implementation, for each branch link in the target sensitive word tree, the ratio between the number of characters in the first word segmentation unit that share the same element as a node in the target sensitive word tree and the length of the branch link is used as the branch similarity. Then, the first similarity corresponding to the first word segmentation unit is determined using multiple branch similarities. Here, as an example, the average of multiple branch similarities can be taken as the first similarity corresponding to the first word segmentation unit, or the maximum similarity, minimum similarity, or median among multiple branch similarities can be taken as the first similarity. This disclosure does not specifically limit this approach.
[0070] According to the sensitive word detection method provided in this disclosure, after determining the similarity corresponding to the first word segmentation unit, the first word segmentation unit can be further detected based on the sensitive word tree to determine whether the first word segmentation unit is a sensitive word in the text to be detected that needs to be blocked. As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:
[0071] I: If the first similarity is greater than or equal to the first similarity threshold, then the first sensitive word corresponding to the first word segmentation unit is determined from the target sensitive word tree, and it is determined whether the first sensitive word has an exempted word group.
[0072] Here, exempted phrases refer to sensitive phrases that are extended from preset sensitive words and have a larger number of characters.
[0073] Regarding step I above, in specific implementation, when the first similarity of the determined first word segmentation unit is greater than the first similarity threshold, the first sensitive word corresponding to the first word segmentation unit is determined from the target sensitive word tree, and it is determined whether the first sensitive word has an exempted word group. Here, as an example, the first sensitive word is obtained by the similarity between each sensitive word in the target sensitive word tree and the first word segmentation unit. When the similarity between a certain sensitive word in the target sensitive word tree and the first word segmentation unit is greater than or equal to a certain value, the sensitive word is taken as the first sensitive word. For example, when the first word segmentation unit is ABBC, the first sensitive word ABB with a high similarity to the first word segmentation unit can be determined from the target sensitive word tree with the root node A. Please refer to Figure 3, which is a schematic diagram of the structure of a sensitive word tree carrying an exempted word group provided by an optional embodiment of this disclosure. As shown in Figure 3, the exempted word group corresponds to the three sets of characters bound after the ABB branch, and the exempted word group is bound to the last leaf node.
[0074] II: If so, based on the length of the exempted phrase, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the phrase length are obtained forward and / or backward from each target segmentation unit and combined to obtain the second word segmentation unit.
[0075] Regarding step II above, in specific implementation, when there is an exempted phrase for the first sensitive word, based on the phrase length of the exempted phrase, multiple segmentation units corresponding to the phrase length are obtained forward and / or backward from each target segmentation unit, according to the order of multiple segmentation units in the text to be detected, and combined to obtain the second word segmentation unit. Here, the multiple segmentation units corresponding to the obtained phrase length can be combined in order or randomly to overcome the problem of deliberately disordering the order and evading sensitive word detection. Here, continuing the example in step I above, the three exempted phrases bound to ABB have a maximum length of 8 characters. Therefore, A is used as the target segmentation unit, and the second word segmentation unit composed of the 8 characters before and after A in order is obtained from the text to be detected, namely CDBDBACCABBCDDAAB.
[0076] III: By comparing the exempted word group with the second word segmentation unit, the second similarity corresponding to the second word segmentation unit is determined, and based on the second similarity and the second similarity threshold, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
[0077] Regarding step III above, in specific implementation, the exempted word group is compared with the second word segmentation unit to determine the second similarity corresponding to the second word segmentation unit. Here, the method for calculating the second similarity is the same as the method for calculating the first similarity in the above embodiment, and can achieve the same technical effect, so it will not be described again here. Then, based on the second similarity threshold and the second similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected. Here, as an example, when the sensitive word ABB has 3 exempted word groups, the similarity between the second word segmentation unit and each exempted word group is calculated respectively, and then the average of the three similarities is taken as the second similarity, or the maximum similarity, minimum similarity, or median of the three similarities is taken as the second similarity. At this time, the second similarity is compared with the second similarity threshold. If the second similarity is greater than or equal to the second similarity threshold, then the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
[0078] As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:
[0079] i: Determine from the target sensitive word tree a second sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the first similarity threshold, and whose sensitive word category belongs to non-must-filter.
[0080] Regarding step i above, in specific implementation, a second sensitive word is determined from the target sensitive word tree that has a first similarity greater than or equal to a first similarity threshold corresponding to the first word segmentation unit, and whose sensitive word category belongs to non-mandatory filtering. Here, as an example, when the first word segmentation unit is ABBC, a second sensitive word ABB can be determined from the target sensitive word tree with root node A that has a first similarity greater than or equal to the first similarity threshold corresponding to the first word segmentation unit, and whose sensitive word category belongs to non-mandatory filtering.
[0081] ii: Based on the first preset word segmentation length, determine the third word segmentation unit corresponding to the second sensitive word from the text to be detected, and input the third word segmentation unit into the pre-trained sensitivity value detection model to determine the third similarity corresponding to the third word segmentation unit. Based on the third similarity, determine whether to regard the first word segmentation unit as a sensitive word appearing in the text to be detected, or determine whether to regard the first word segmentation unit as a sensitive word appearing in the text to be detected based on the first similarity and the third similarity.
[0082] Here, the preset word segmentation length can be set to 8, and this disclosure does not make specific limitations on this.
[0083] Regarding step ii above, in specific implementation, based on a preset word segmentation length, the third word segmentation unit corresponding to the second sensitive word is determined from the text to be detected. Here, the phrases before and / or after the second sensitive word in the text to be detected are taken as the third word segmentation unit. Then, the third word segmentation unit is input into a pre-trained sensitivity value detection model to determine the third similarity corresponding to the third word segmentation unit. Here, the sensitivity value detection module is trained using sample sensitive words and their corresponding sample sensitivity values. Its training method is the same as the training method for neural network models in existing technologies. Based on the semantics of the third word segmentation unit, i.e., the semantics of the context of the second sensitive word, the sensitivity of the second sensitive word is determined, and the corresponding third similarity is obtained, which will not be elaborated here. Then, based on the third similarity of the third word segmentation unit, it is determined whether the first word segmentation unit is considered a sensitive word appearing in the text to be detected, or based on the first similarity of the first word segmentation unit and the third similarity of the third word segmentation unit, it is determined whether the first word segmentation unit is considered a sensitive word appearing in the text to be detected. Here, as an optional embodiment, the third similarity of the third word segmentation unit is compared with a threshold. If it is greater than or equal to the threshold, the first word segmentation unit is considered to be a sensitive word appearing in the text to be detected. Alternatively, the judgment result of the sensitive word detection model, i.e., the third similarity of the third word segmentation unit, can be multiplied with the first similarity of the first word segmentation unit, and it can be determined whether the similarity after multiplication is greater than the threshold. If so, the first word segmentation unit is considered to be a sensitive word appearing in the text to be detected.
[0084] As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:
[0085] From the target sensitive word tree, identify a second sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the first similarity threshold and whose sensitive word category is not required to be filtered; determine the exclusion weight corresponding to the second sensitive word, and use the product of the exclusion weight and the first similarity as the fourth similarity, so as to determine whether to regard the first word segmentation unit as a sensitive word appearing in the text to be detected based on the fourth similarity.
[0086] In the implementation of the above two steps, different exclusion weights can be assigned to sensitive words whose category is not subject to mandatory filtering. The exclusion weight, the first similarity, and the exclusion threshold are used to determine whether to exclude a sensitive word. Specifically, from the target sensitive word tree, a second sensitive word is identified whose first similarity to the first segmentation unit is greater than or equal to the first similarity threshold, and whose category is not subject to mandatory filtering. The exclusion weight corresponding to the second sensitive word is determined, and the product of the exclusion weight and the first similarity of the first segmentation unit is used as the fourth similarity. If the fourth similarity is greater than or equal to the threshold, the first segmentation unit is considered a sensitive word appearing in the text to be detected.
[0087] As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:
[0088] From the target sensitive word tree, identify a third sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the second similarity threshold and whose sensitive word category belongs to a combination of words; based on the second preset word segmentation length, identify a fourth word segmentation unit corresponding to the third sensitive word from the text to be detected, and based on the judgment result of whether the fourth word segmentation unit contains the fourth sensitive word, determine whether there are sensitive words in the text to be detected.
[0089] Here, this disclosure also includes sensitive words in combination phrases when performing sensitive word detection. Regarding the above two steps, in specific implementation, firstly, a third sensitive word is determined from the target sensitive word tree that has a first similarity greater than or equal to a second similarity threshold corresponding to the first word segmentation unit and whose sensitive word category belongs to a combination phrase. Here, for example, AB...CD are set as the third sensitive words whose sensitive word category belongs to a combination phrase. Then, based on the second preset word segmentation length, the fourth word segmentation unit corresponding to the third sensitive word is determined from the text to be detected. For example, if AB is detected in the text to be detected, the text is searched forward and / or backward by a second preset word segmentation length starting from AB to determine if the character C exists. If the character C exists, the text is searched forward and / or backward by a second preset word segmentation length starting from C to determine if the character D exists. The search results are used as the fourth word segmentation unit. That is, the length of the fourth word segmentation unit is not fixed. If, after searching forward and / or backward by a second preset word segmentation length starting from AB, it is determined that the character C does not exist, then the content searched forward and / or backward by a second preset word segmentation length starting from AB is the fourth word segmentation unit. If, after searching forward and / or backward by a second preset word segmentation length starting from AB, it is determined that the character C exists, then the text is searched forward and / or backward by a second preset word segmentation length starting from C to determine if the character D exists. The content searched twice is used as the fourth word segmentation unit. Alternatively, if AB is detected in the text to be detected, the text is searched forward and / or backward by a second preset word segmentation length starting from AB. The search is then performed to determine if characters C and D are found, and the found content is used as the fourth word segmentation unit. In this case, the length of the fourth word segmentation unit is fixed; that is, the search is performed forward and / or backward by a second preset word segmentation length starting from AB, and the found content is used as the fourth word segmentation unit. Then, based on the result of determining whether the fourth word segmentation unit contains the fourth sensitive word (i.e., characters C and D, or adjacent characters CD), it is determined whether there are sensitive words in the text to be detected.
[0090] This disclosure discloses an optional embodiment of a sensitive word detection method. First, multiple preset sensitive words are classified, and at least one sensitive word tree is constructed using these preset sensitive words. Then, the obtained text to be detected is split to determine multiple splitting units. For each target sensitive word tree with the same root node as the splitting unit, the length of each branch link in the target sensitive word tree is determined, and at least one first word segmentation unit is determined from the multiple splitting units based on the length of the branch link. Finally, for each first word segmentation unit, the nodes in the target sensitive word tree are compared with the first word segmentation unit to determine a first similarity corresponding to the first word segmentation unit, and the presence of sensitive words in the text to be detected is determined based on the first similarity.
[0091] This disclosure significantly improves the accuracy and efficiency of sensitive word detection by grouping preset sensitive words into a sensitive word tree, using the sensitive word tree to obtain corresponding word segmentation units from the text to be detected, and combining this with the calculation of context similarity. It can not only quickly identify common sensitive words, but also handle various variations, inversions, and insertions, while balancing false positives and false negatives.
[0092] Please refer to Figure 4, which is a schematic diagram of a sensitive word detection device provided in an optional embodiment of this disclosure. As shown in Figure 4, the sensitive word detection device 400 includes:
[0093] The sensitive word tree construction module 401 is used to classify multiple preset sensitive words and construct at least one sensitive word tree using the multiple preset sensitive words;
[0094] The splitting unit determination module 402 is used to split the acquired text to be detected and determine multiple splitting units;
[0095] The word segmentation unit determination module 403 is used to determine the length of each branch link in each target sensitive word tree for each target sensitive word tree with the same root node as the splitting unit, and to determine at least one first word segmentation unit from multiple splitting units based on the length of the branch link.
[0096] The first detection module 404 is used to compare each first word segmentation unit with the nodes in the target sensitive word tree to determine the first similarity corresponding to the first word segmentation unit, and to determine whether there are sensitive words in the text to be detected based on the first similarity.
[0097] Furthermore, when the sensitive word tree construction module 401 is used to classify multiple preset sensitive words and construct at least one sensitive word tree using the multiple preset sensitive words, the sensitive word tree construction module 401 is also used to:
[0098] At least one sensitive word group is determined from a plurality of preset sensitive words; wherein the first character of each preset sensitive word in the sensitive word group has the same element;
[0099] For each sensitive word group, the element corresponding to the first character of the preset sensitive word in the sensitive word group is taken as the root node. According to the order of the characters contained in the preset sensitive word in the sensitive word group, corresponding child nodes are constructed for each root node to generate the sensitive word tree corresponding to the sensitive word group.
[0100] Furthermore, when determining at least one first word segmentation unit from multiple segmentation units based on the length of the branch link, the word segmentation unit determining module 403 is also used to:
[0101] Identify at least one target splitting unit from multiple splitting units that has the same elements as the root node of the target sensitive word tree;
[0102] For each target segmentation unit, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward from the target segmentation unit as the starting point and combined to obtain the first word segmentation unit.
[0103] Furthermore, when the first detection module 404 compares the nodes in the target sensitive word tree with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit, the first detection module 404 is also used to:
[0104] Compare the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that have the same elements as each branch link node in the target sensitive word tree;
[0105] The ratio between the number and the length of the corresponding branch link of the target sensitive word tree is used as the first similarity.
[0106] or,
[0107] For each branch link in the target sensitive word tree, the ratio between the number and the length of the branch link is used as the branch similarity;
[0108] The first similarity corresponding to the first word segmentation unit is determined by using multiple branch similarities.
[0109] Furthermore, the sensitive word detection device 400 also includes a second detection module. After determining the first similarity corresponding to the first word segmentation unit, the second detection module is used to:
[0110] If the first similarity is greater than or equal to the first similarity threshold, then the first sensitive word corresponding to the first word segmentation unit is determined from the target sensitive word tree, and it is determined whether the first sensitive word has an exempted word group;
[0111] If so, based on the length of the exempted phrase, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the phrase length are obtained forward and / or backward from each target segmentation unit and combined to obtain the second word segmentation unit.
[0112] By comparing the exempted word group with the second word segmentation unit, the second similarity corresponding to the second word segmentation unit is determined, and based on the second similarity and the second similarity threshold, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
[0113] Furthermore, the sensitive word detection device 400 also includes a third detection module. After determining the first similarity corresponding to the first word segmentation unit, the third detection module is used to:
[0114] From the target sensitive word tree, identify the second sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the first similarity threshold, and whose sensitive word category belongs to non-must-filter;
[0115] Based on the first preset word segmentation length, the third word segmentation unit corresponding to the second sensitive word is determined from the text to be detected, and the third word segmentation unit is input into the pre-trained sensitivity value detection model to determine the third similarity corresponding to the third word segmentation unit. Based on the third similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected, or based on the first similarity and the third similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
[0116] Furthermore, the sensitive word detection device 400 also includes a fourth detection module. After determining the first similarity corresponding to the first word segmentation unit, the fourth detection module is used to:
[0117] From the target sensitive word tree, identify the second sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the first similarity threshold, and whose sensitive word category belongs to non-must-filter;
[0118] The exclusion weight corresponding to the second sensitive word is determined, and the product of the exclusion weight and the first similarity is used as the fourth similarity. Based on the fourth similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
[0119] Furthermore, the sensitive word detection device 400 also includes a fifth detection module, which, after determining the first similarity corresponding to the first word segmentation unit, is used to:
[0120] From the target sensitive word tree, identify the third sensitive word that has a first similarity greater than or equal to the second similarity threshold corresponding to the first word segmentation unit and whose sensitive word category belongs to the combined word group;
[0121] Based on the second preset word segmentation length, the fourth word segmentation unit corresponding to the third sensitive word is determined from the text to be detected, and based on the judgment result of whether the fourth word segmentation unit contains the fourth sensitive word, it is determined whether there are sensitive words in the text to be detected.
[0122] When the sensitive word tree construction module 401 is used to classify multiple preset sensitive words and construct at least one sensitive word tree using the multiple preset sensitive words, the sensitive word tree construction module 401 is also used to:
[0123] Multiple preset sensitive words are classified according to one or more of the following: pronunciation, character shape, and letters; and at least one sensitive word tree is constructed using the multiple preset sensitive words.
[0124] When the splitting unit determining module 402 is used to split the acquired text to be detected and determine multiple splitting units, the splitting unit determining module 402 is also used for:
[0125] Based on one or more of the pronunciation, glyphs, and letters of each character in the text to be detected, the obtained text to be detected is split into multiple splitting units.
[0126] Please refer to Figure 5, which is a schematic diagram of the structure of an electronic device provided in an optional embodiment of this disclosure. As shown in Figure 5, the electronic device 500 includes a processor 510, a memory 520, and a bus 530.
[0127] The memory 520 stores machine-readable instructions that can be executed by the processor 510. When the electronic device 500 is running, the processor 510 and the memory 520 communicate via the bus 530. When the machine-readable instructions are executed by the processor 510, the steps of the sensitive word detection method in the method embodiment shown in Figure 1 above can be executed. For specific implementation methods, please refer to the method embodiment, which will not be repeated here.
[0128] An optional embodiment of this disclosure also provides a computer-readable storage medium storing a computer program. When the computer program is run by a processor, it can execute the steps of the sensitive word detection method in the method embodiment shown in FIG1 above. For specific implementation details, please refer to the method embodiment, which will not be repeated here.
[0129] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0130] In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0131] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0132] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0133] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0134] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A method for detecting sensitive words, the method comprising: Classify multiple preset sensitive words and construct at least one sensitive word tree using these preset sensitive words; The obtained text to be detected is split into multiple splitting units; For each target sensitive word tree with the same root node as the splitting unit, the length of each branch link in the target sensitive word tree is determined, and at least one first word segmentation unit is determined from multiple splitting units based on the length of the branch link; For each first word segmentation unit, the nodes in the target sensitive word tree are compared with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit, and the presence of sensitive words in the text to be detected is determined based on the first similarity.
2. The sensitive word detection method according to claim 1, wherein, The step of classifying multiple preset sensitive words and constructing at least one sensitive word tree using these preset sensitive words includes: At least one sensitive word group is determined from a plurality of preset sensitive words; wherein the first character of each preset sensitive word in the sensitive word group has the same element; For each sensitive word group, the element corresponding to the first character of the preset sensitive word in the sensitive word group is taken as the root node. According to the order of the characters contained in the preset sensitive word in the sensitive word group, corresponding child nodes are constructed for each root node to generate the sensitive word tree corresponding to the sensitive word group.
3. The sensitive word detection method according to claim 1, wherein, The process of determining at least one first word segmentation unit from multiple segmentation units based on the length of the branch link includes: Identify at least one target splitting unit from multiple splitting units that has the same elements as the root node of the target sensitive word tree; For each target segmentation unit, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward from the target segmentation unit as the starting point and combined to obtain the first word segmentation unit.
4. The sensitive word detection method according to claim 1, wherein, The step of comparing the nodes in the target sensitive word tree with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit includes: Compare the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that have the same elements as each branch link node in the target sensitive word tree; The ratio between the number and the length of the corresponding branch link of the target sensitive word tree is used as the first similarity.
5. The sensitive word detection method according to claim 1, wherein, The step of comparing the nodes in the target sensitive word tree with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit includes: Compare the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that have the same elements as each branch link node in the target sensitive word tree; For each branch link in the target sensitive word tree, the ratio between the number and the length of the branch link is used as the branch similarity; The first similarity corresponding to the first word segmentation unit is determined by using multiple branch similarities.
6. The sensitive word detection method according to claim 3, wherein, After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: If the first similarity is greater than or equal to the first similarity threshold, then the first sensitive word corresponding to the first word segmentation unit is determined from the target sensitive word tree, and it is determined whether the first sensitive word has an exempted word group; If so, based on the length of the exempted phrase, according to the order of multiple segmentation units in the text to be detected, multiple segmentation units corresponding to the phrase length are obtained forward and / or backward from each target segmentation unit and combined to obtain the second word segmentation unit. By comparing the exempted word group with the second word segmentation unit, the second similarity corresponding to the second word segmentation unit is determined, and based on the second similarity and the second similarity threshold, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
7. The sensitive word detection method according to claim 1, wherein, After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: From the target sensitive word tree, identify the second sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the first similarity threshold, and whose sensitive word category belongs to non-must-filter; Based on the first preset word segmentation length, the third word segmentation unit corresponding to the second sensitive word is determined from the text to be detected, and the third word segmentation unit is input into the pre-trained sensitivity value detection model to determine the third similarity corresponding to the third word segmentation unit. Based on the third similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected, or based on the first similarity and the third similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
8. The sensitive word detection method according to claim 1, wherein, After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: From the target sensitive word tree, identify the second sensitive word whose first similarity to the first word segmentation unit is greater than or equal to the first similarity threshold, and whose sensitive word category belongs to non-must-filter; The exclusion weight corresponding to the second sensitive word is determined, and the product of the exclusion weight and the first similarity is used as the fourth similarity. Based on the fourth similarity, it is determined whether the first word segmentation unit is regarded as a sensitive word appearing in the text to be detected.
9. The sensitive word detection method according to claim 1, wherein, After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: From the target sensitive word tree, identify the third sensitive word that has a first similarity greater than or equal to the second similarity threshold corresponding to the first word segmentation unit and whose sensitive word category belongs to the combined word group; Based on the second preset word segmentation length, the fourth word segmentation unit corresponding to the third sensitive word is determined from the text to be detected, and based on the judgment result of whether the fourth word segmentation unit contains the fourth sensitive word, it is determined whether there are sensitive words in the text to be detected.
10. The sensitive word detection method according to claim 1, wherein, The process of classifying multiple preset sensitive words and constructing at least one sensitive word tree using these preset sensitive words includes: Multiple preset sensitive words are classified according to one or more of the following: pronunciation, character shape, and letters. Based on the classification results, at least one sensitive word tree is constructed using the multiple preset sensitive words. The process of segmenting the acquired text to be detected to determine multiple segmentation units includes: Based on one or more of the pronunciation, glyphs, and letters of each character in the text to be detected, the obtained text to be detected is split into multiple splitting units.
11. The sensitive word detection method according to claim 1, wherein, The process of segmenting the acquired text to be detected to determine multiple segmentation units includes: Each character in the obtained text to be detected is split, and at least one of the following interfering elements, namely spaces, special characters, and punctuation marks, is filtered out to determine multiple splitting units; wherein, the text to be detected includes at least one of the following: arbitrary text content input by the user and arbitrary text content output by the large language model.
12. The sensitive word detection method according to claim 1, wherein, The determination of at least one first word segmentation unit from multiple segmentation units based on the length of the branch link includes: The maximum length is determined from the length of the branch link; At least one first word segmentation unit is determined from multiple segmentation units based on the maximum length.
13. The sensitive word detection method according to claim 3, wherein, The first word segmentation unit is obtained by combining multiple segmentation units corresponding to the lengths of at least one branch link of the target sensitive word tree obtained forward and / or backward from the target segmentation unit. This includes: The first word segmentation unit is obtained by combining multiple segmentation units in sequence and / or by randomly combining multiple segmentation units.
14. The sensitive word detection method according to claim 4, wherein, The step of comparing the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit to determine the number of characters in the first word segmentation unit that share the same element as each branch link node in the target sensitive word tree includes: The number of characters in the first word segmentation unit that share the same element as each branch link node in the target sensitive word tree is determined by comparing the nodes of each branch link with the characters at the corresponding positions in the first word segmentation unit, comparing the nodes of each branch link with characters at any position in the first word segmentation unit, and comparing the nodes of each branch link with multiple characters at multiple positions in the first word segmentation unit.
15. The sensitive word detection method according to claim 5, wherein, The step of determining the first similarity corresponding to the first word segmentation unit using multiple branch similarities includes: The average similarity of the multiple branches is taken as the first similarity corresponding to the first word segmentation unit; or, the maximum similarity, minimum similarity or median among the multiple branch similarities is taken as the first similarity corresponding to the first word segmentation unit.
16. The sensitive word detection method according to claim 6, wherein, The step of determining the first sensitive word corresponding to the first word segmentation unit from the target sensitive word tree and determining whether the first sensitive word has an exempted word group includes: The first sensitive word is obtained by the similarity between each sensitive word in the target sensitive word tree and the first word segmentation unit, and it is determined whether the last leaf node of the first sensitive word in the target sensitive word tree is bound to an exemption word group; wherein, the exemption word group is a sensitive word group that is extended from the preset sensitive word and has more characters than the preset sensitive word, and the exemption word group is bound to the last leaf node of the first sensitive word.
17. The sensitive word detection method according to claim 9, wherein, The step of determining the fourth segmentation unit corresponding to the third sensitive word from the text to be detected based on the second preset segmentation length, and determining whether there are sensitive words in the text to be detected based on the judgment result of whether the fourth segmentation unit contains the fourth sensitive word; includes: In the text to be detected, starting from the third sensitive word, search forward and / or backward for the second preset word segmentation length to determine if there are any characters of a fourth sensitive word. If so, continue searching forward and / or backward for the second preset word segmentation length in the text to be detected, starting from the characters of the fourth sensitive word, to determine if there are any remaining characters of the fourth sensitive word. The searched content is used as the fourth word segmentation unit; or, In the text to be detected, starting from the third sensitive word, search forward and / or backward for the second preset word segmentation length, determine whether the fourth sensitive word exists, and take the searched content as the fourth word segmentation unit; Based on the judgment result of whether the fourth sensitive word exists in the fourth word segmentation unit, it is determined whether there are sensitive words in the text to be detected.
18. A sensitive word detection device, the sensitive word detection device comprising: The sensitive word tree construction module is used to classify multiple preset sensitive words and construct at least one sensitive word tree using the multiple preset sensitive words; The splitting unit determination module is used to split the acquired text to be detected and determine multiple splitting units; The word segmentation unit determination module is used to determine the length of each branch link in each target sensitive word tree for which the root node is the same as the segmentation unit, and to determine at least one first word segmentation unit from multiple segmentation units based on the length of the branch link. The first detection module is used to compare each first word segmentation unit with the nodes in the target sensitive word tree to determine the first similarity corresponding to the first word segmentation unit, and to determine whether there are sensitive words in the text to be detected based on the first similarity.
19. An electronic device comprising: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. The machine-readable instructions are executed by the processor to perform the steps of the sensitive word detection method as described in any one of claims 1 to 17.
20. A computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the sensitive word detection method as described in any one of claims 1 to 17.
