A sensitive word detection method and a sensitive word detection device

By constructing a sensitive word tree and combining context similarity calculation, the misjudgment and inefficiency of sensitive word detection in the prior art are solved, and efficient and accurate sensitive word recognition is achieved.

CN120163154BActive Publication Date: 2025-08-05SHANGHAI XIYU JIZHI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510646547.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-08-05
Estimated Expiration
2045-05-20

AI Technical Summary

Technical Problem

The existing sensitive word detection technology lacks the understanding of context semantics, resulting in a high misjudgment rate and low word-by-word comparison efficiency, making it difficult to deal with large-scale texts.

Method used

By classifying preset sensitive words, building a sensitive word tree, and combining context similarity calculations, the similarity of word segmentation units is determined, and whether sensitive words exist in the text are judged.

Benefits of technology

It greatly improves the accuracy and efficiency of sensitive word detection, and can identify conventional sensitive words and deformation, inversion, insertion and other situations, taking into account the balance between false alarm rate and missed rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120163154B_ABST
    Figure CN120163154B_ABST
Patent Text Reader

Abstract

The present application provides a sensitive word detection method and sensitive word detection device, the method comprising: classifying multiple preset sensitive words and constructing at least one sensitive word tree using the multiple preset sensitive words; splitting the acquired text to be detected to determine multiple split units; for each target sensitive word tree whose root node is the same as the split unit, determining the length of each branch link in the target sensitive word tree, and determining at least one first word segmentation unit from the multiple split units based on the length of the branch link; for each first word segmentation unit, comparing 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 determining whether the text to be detected contains sensitive words based on the first similarity. Through the method and device, the accuracy and efficiency of sensitive word detection are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a sensitive word detection method and a sensitive word detection device. Background Art

[0002] With the rapid development of the internet, it has become a vital platform for people to access information and exchange ideas. However, the openness and anonymity of the online environment also bring many challenges, one of which is the phenomenon of users deliberately using sensitive words to disrupt the online environment. To maintain a harmonious and healthy cyberspace and ensure the legality and appropriateness of online content, sensitive word detection in text content has become a critical technical requirement.

[0003] Currently, content review technology primarily relies on building a database of sensitive terms. This involves breaking down the text to be reviewed into phrases and then comparing them one by one against the sensitive terms in the database, thereby identifying and filtering out potentially sensitive content. While simple to implement, this approach has significant limitations in practice. First, it lacks contextual understanding and cannot accurately determine the true meaning of words in a specific context, which can easily lead to misjudgments. Second, word-by-word comparison is inefficient, particularly when processing large amounts of text, and is time-consuming, resulting in suboptimal detection results. Summary of the Invention

[0004] In light of this, the purpose of this application is to provide a sensitive word detection method and device. By grouping preset sensitive words and constructing a sensitive word tree, using the sensitive word tree to extract word segmentation units from the text to be detected, and combining it with the calculation of contextual similarity, the accuracy and efficiency of sensitive word detection are greatly improved. This method can not only quickly identify conventional sensitive words, but also handle various deformations, inversions, insertions, and other situations, while balancing the false positive rate and false negative rate.

[0005] In a first aspect, an embodiment of the present application provides a sensitive word detection method, the sensitive word detection method comprising:

[0006] Classifying multiple preset sensitive words and constructing at least one sensitive word tree using the multiple preset sensitive words;

[0007] Split the acquired text to be detected into multiple split units;

[0008] For each target sensitive word tree whose root node is the same 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 the multiple splitting units based on the length of the branch link;

[0009] For each first word segmentation unit, a node in the target sensitive word tree is compared with the first word segmentation unit to determine a first similarity corresponding to the first word segmentation unit, and based on the first similarity, it is determined whether sensitive words exist in the text to be detected.

[0010] Furthermore, the classifying of the plurality of preset sensitive words and constructing at least one sensitive word tree using the plurality of preset sensitive words includes:

[0011] Determine at least one sensitive phrase group from a plurality of preset sensitive words; wherein the first characters of each preset sensitive word in the sensitive phrase group have the same elements;

[0012] For each sensitive phrase, the element corresponding to the first character of the preset sensitive word in the sensitive phrase is used as the root node. According to the order of the characters contained in the preset sensitive word in the sensitive phrase, a corresponding child node is constructed for each root node to generate a sensitive word tree corresponding to the sensitive phrase.

[0013] Furthermore, the determining of at least one first word segmentation unit from a plurality of split units based on the length of the branch link includes:

[0014] Determine at least one target split unit from the plurality of split units that has the same elements as the root node of the target sensitive word tree;

[0015] For each target split unit, in the order of multiple split units in the text to be detected, multiple split units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward with the target split unit as the starting point, and then combined to obtain the first word segmentation unit.

[0016] Furthermore, comparing the nodes in the target sensitive word tree with the first word segmentation unit to determine a first similarity corresponding to the first word segmentation unit includes:

[0017] Comparing the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit, and determining 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;

[0018] 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;

[0019] or,

[0020] 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;

[0021] A first similarity corresponding to the first word segmentation unit is determined using the multiple branch similarities.

[0022] Furthermore, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0023] If the first similarity is greater than or equal to a first similarity threshold, determining a 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 exemption phrase;

[0024] If yes, then based on the phrase length of the exempted phrase, in accordance with the order of the multiple split units in the text to be detected, with each target split unit as a starting point, obtain multiple split units corresponding to the phrase length forward and / or backward and combine them to obtain a second word segmentation unit;

[0025] The exemption phrase is compared with the second word segmentation unit to determine a second similarity corresponding to the second word segmentation unit, so as to determine whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the second similarity and a second similarity threshold.

[0026] Furthermore, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0027] Determine from the target sensitive word tree a second sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered;

[0028] Based on a first preset word segmentation length, a 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 a pre-trained sensitivity value detection model to determine a third similarity corresponding to the third word segmentation unit, so as to judge whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the third similarity, or to judge whether to use 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.

[0029] Furthermore, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0030] Determine from the target sensitive word tree a second sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered;

[0031] An exclusion weight corresponding to the second sensitive word is determined, and the product of the exclusion weight and the first similarity is used as a fourth similarity, so as to determine whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the fourth similarity.

[0032] Furthermore, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0033] Determine from the target sensitive word tree a third sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a second similarity threshold and whose sensitive word category belongs to a combination phrase;

[0034] Based on the second preset word segmentation length, a 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 is a sensitive word in the text to be detected.

[0035] Furthermore, the method of classifying a plurality of preset sensitive words and constructing at least one sensitive word tree using the plurality of preset sensitive words includes:

[0036] Classify multiple preset sensitive words according to any one or more of pronunciation, character shape, and letter, and construct at least one sensitive word tree using the multiple preset sensitive words;

[0037] The method of splitting the acquired text to be detected to determine a plurality of split units includes:

[0038] The acquired text to be detected is split according to any one or more of the pronunciation, glyph, and letter of each character in the text to be detected, and a plurality of split units are determined.

[0039] In a second aspect, an embodiment of the present application further provides a sensitive word detection device, the sensitive word detection device comprising:

[0040] A 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;

[0041] A split unit determination module is used to split the acquired text to be detected and determine multiple split units;

[0042] a word segmentation unit determination module, configured to determine, for each target sensitive word tree whose root node is the same as the splitting unit, the length of each branch link in the target sensitive word tree, and determine at least one first word segmentation unit from the plurality of splitting units based on the length of the branch link;

[0043] The first detection module is used to compare each first word segmentation unit with the node in the target sensitive word tree, determine the first similarity corresponding to the first word segmentation unit, and determine whether there is a sensitive word in the text to be detected based on the first similarity.

[0044] The embodiments of the present application provide a sensitive word detection method and a sensitive word detection device. First, a plurality of preset sensitive words are classified, and at least one sensitive word tree is constructed using the plurality of preset sensitive words; then, the acquired text to be detected is split to determine a plurality of split units; for each target sensitive word tree whose root node is the same as the split 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 plurality of split units based on the length of the branch link; finally, for each first word segmentation unit, a node in the target sensitive word tree is compared with the first word segmentation unit to determine a first similarity corresponding to the first word segmentation unit, and based on the first similarity, it is determined whether sensitive words exist in the text to be detected.

[0045] This application significantly improves the accuracy and efficiency of sensitive word detection by grouping preset sensitive words and constructing a sensitive word tree. This tree is then used to obtain corresponding word segmentation units from the text to be detected. This is combined with the calculation of contextual similarity to significantly improve the accuracy and efficiency of sensitive word detection. This not only allows for rapid identification of conventional sensitive words, but also handles various variations, inversions, and insertions, while maintaining a balance between false positives and false negatives.

[0046] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 A flowchart of a sensitive word detection method provided in an embodiment of the present application;

[0049] Figure 2 A schematic diagram of the structure of a sensitive word tree provided in an embodiment of the present application;

[0050] Figure 3 A schematic diagram of the structure of a sensitive word tree with exempted phrases provided in an embodiment of the present application;

[0051] Figure 4 A schematic diagram of the structure of a sensitive word detection device provided in an embodiment of the present application;

[0052] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for which protection is claimed, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work falls within the scope of protection of the present application.

[0054] First, the application scenarios to which this application is applicable are introduced. This application can be applied in the field of computer technology.

[0055] With the rapid development of the internet, it has become a vital platform for people to access information and exchange ideas. However, the openness and anonymity of the online environment also bring many challenges, one of which is the phenomenon of users deliberately using sensitive words to disrupt the online environment. To maintain a harmonious and healthy cyberspace and ensure the legality and appropriateness of online content, sensitive word detection in text content has become a critical technical requirement.

[0056] Research has found that current content review technology primarily relies on building a database of sensitive terms. This involves breaking down the text to be reviewed into phrases, then comparing them one by one against the sensitive terms in the database to identify and filter out potentially sensitive content. While simple to implement, this approach has significant limitations in practice. First, it lacks contextual understanding and cannot accurately determine the true meaning of words in a specific context, which can easily lead to misjudgments. Second, word-by-word comparison is inefficient, particularly when processing large amounts of text, and is time-consuming, resulting in suboptimal detection results.

[0057] Based on this, the embodiment of the present application provides a sensitive word detection method, which greatly improves the accuracy and efficiency of sensitive word detection. It can not only quickly identify conventional sensitive words, but also cope with various deformations, inversions, insertions, etc., while taking into account the balance between false alarm rate and missed alarm rate.

[0058] See also Figure 1 , Figure 1 This is a flow chart of a sensitive word detection method provided in an embodiment of the present application. Figure 1 As shown in , the sensitive word detection method provided by the embodiment of the present application includes:

[0059] S101: Classify a plurality of preset sensitive words, and construct at least one sensitive word tree using the plurality of preset sensitive words.

[0060] Here, preset sensitive words are a pre-set set of words to be blocked, defined manually or algorithmically. A sensitive word tree is a multi-branch tree structure constructed by breaking down preset sensitive words into a tree-like hierarchy by character. A sensitive word tree consists of a root node and at least one child node. Each node is represented by one character. A character can be represented by a character, radical, phrase, pinyin, or even a letter in a node. The root node and its child nodes at each level form a preset sensitive word.

[0061] Regarding the above step S101, during specific implementation, a plurality of preset sensitive words are obtained, the plurality of preset sensitive words are classified, and at least one sensitive word tree is constructed using the plurality of preset sensitive words.

[0062] As an optional embodiment, with respect to the above step S101, the classifying of the plurality of preset sensitive words and the construction of at least one sensitive word tree using the plurality of preset sensitive words include:

[0063] Step 1011: Determine at least one sensitive word group from a plurality of preset sensitive words.

[0064] 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.

[0065] Regarding step 1011 above, during specific implementation, preset sensitive words with the same first character are determined from multiple preset sensitive words, and the preset sensitive words with the same first character are grouped as a sensitive phrase. Here, taking the example of the same first character being identical for each preset sensitive word, for example, if the preset sensitive words include ABB, ABC, BBA, BDA, CDA, DDA, AB, BD, ADCB, and CBAD, then classification is performed based on the first character of the preset sensitive words, and the preset sensitive words with the same first character are grouped into a sensitive phrase group, resulting in multiple sensitive phrase groups. The first sensitive phrase group includes ABB, ABC, AB, and ADCB; the second sensitive phrase group includes BBA, BDA, and BD; the third sensitive phrase group includes CDA and CBAD; and the fourth sensitive phrase group includes DDA. Here, as an optional embodiment, preset sensitive words with the same first character can be first grouped into a large category, and then the words with the same characters in subsequent corresponding positions can be grouped into the same sensitive phrase group, or the words with the same characters in subsequent corresponding positions and equal length can be grouped into the same sensitive phrase group.

[0066] Step 1012: For each sensitive phrase, the element corresponding to the first character of the preset sensitive word in the sensitive phrase is used as the root node, and corresponding child nodes are constructed for each root node according to the order of the characters contained in the preset sensitive word in the sensitive phrase to generate a sensitive word tree corresponding to the sensitive phrase.

[0067] Regarding the above step 1012, in the specific implementation, the preset sensitive words are grouped to obtain multiple sensitive words. For each sensitive phrase, each preset sensitive phrase in the sensitive phrase 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 phrase group as the root node. Here, when the sensitive phrases in the above step 1011 are grouped according to the same characters, 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 phrase group, corresponding child nodes are constructed for each root node to generate a sensitive word tree corresponding to the sensitive phrase group. Please refer to Figure 2 , Figure 2 This is a schematic diagram of the structure of a sensitive word tree provided in an embodiment of the present application. Continuing with the embodiment in step 1011 above, the preset sensitive words in each sensitive word group are broken down into a tree hierarchy by character, constructing 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.

[0068] S102: Split the acquired text to be detected into multiple split units.

[0069] Here, the text to be tested can refer to any text content entered by the user or any text content output by the large language model, and sensitive vocabulary needs to be detected through the sensitive word tree. For example, the text to be tested can be user-entered comments, chat messages, or other types of text data, which are not specifically limited in this application.

[0070] Regarding the above step S102, during the specific implementation, the text to be detected input by the user is obtained, and each character in the obtained text to be detected is split to determine multiple split units. Here, as an example, when the obtained text to be detected is "AC, DBDBA. CCA#BBCD@D*AA! B!", each character in the text to be detected is split to obtain multiple split units including: A, C, D, B, D, B, A, C, C, A, B, B, C, D, D, A, A, B. Among them, interference elements such as spaces, special characters, and punctuation marks can be filtered out, and only meaningful characters are retained for content review.

[0071] According to the sensitive word detection method provided in this application, preset sensitive words can also be classified according to the pronunciation, shape and / or letters of the characters. As another optional embodiment, with respect to the above step S101, the classification of multiple preset sensitive words and the construction of at least one sensitive word tree using the multiple preset sensitive words include:

[0072] Multiple preset sensitive words are classified according to any one or more of pronunciation, character shape, and letters, and at least one sensitive word tree is constructed using the multiple preset sensitive words.

[0073] Regarding the above steps, during specific implementation, the preset sensitive words are classified according to any one or more of pronunciation, glyph, and alphabet, and based on the classification results, at least one sensitive word tree is constructed using the multiple preset sensitive words. Here, for example, the preset sensitive words are classified based on the obtained pronunciation of the preset sensitive words, and the preset sensitive words with the same pronunciation of the first character are grouped together. The pronunciation of the first character of the preset sensitive words in each sensitive phrase group is exactly the same. In this way, 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 performed based on the pronunciation, solving the problem of identifying sensitive words with the same pronunciation but different characters.

[0074] Furthermore, with respect to the above step S102, the acquired text to be detected is split to determine a plurality of split units; including.

[0075] The acquired text to be detected is split according to any one or more of the pronunciation, glyph, and letter of each character in the text to be detected, and a plurality of split units are determined.

[0076] Here, after the preset sensitive words are classified according to any one or more of the pronunciation, glyph, and letters, the text to be detected also needs to be split according to any one or more of the pronunciation, glyph, and letters. For the above steps, in the specific implementation, the acquired text to be detected is split according to any one or more of the pronunciation, glyph, and letters of each character in the text to be detected, and multiple split units are determined. Continuing the example in the above steps, after the preset sensitive words are classified based on the pronunciation of the preset sensitive words, the text to be detected also needs to be split into multiple split units according to the pronunciation.

[0077] S103: For each target sensitive word tree whose root node is the same 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 the multiple splitting units based on the length of the branch link.

[0078] With respect to the above-mentioned step S103, in the specific implementation, first, based on the multiple splitting units obtained in the above-mentioned 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-mentioned embodiment, the target sensitive word trees screened out are the sensitive word tree with the root node A, the sensitive word tree with the root node B, the sensitive word tree with the root node C, and the sensitive word tree with the root node D. This can greatly reduce the matching workload of the audit content in the vocabulary, save matching time, and improve the efficiency of content auditing. 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 the 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 is determined from the multiple splitting units based on the maximum length.

[0079] As an optional embodiment, with respect to the above step S103, determining at least one first word segmentation unit from a plurality of split units based on the length of the branch link includes:

[0080] Step 1031: Determine at least one target splitting unit from the plurality of splitting units, which has the same elements as the root node of the target sensitive word tree.

[0081] Regarding step 1031, in a specific implementation, at least one target split unit is determined from the multiple split 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 split unit with A among the multiple split units is used as the target split unit.

[0082] Step 1032: For each target split unit, in the order of multiple split units in the text to be detected, multiple split units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward with the target split unit as the starting point, and then combined to obtain the first word segmentation unit.

[0083] For the above step 1032, in the specific implementation, for each target splitting unit, according to the order of multiple splitting units in the text to be detected, multiple splitting units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward with the target splitting unit as the starting point to be combined to obtain the first word segmentation unit. Here, for the multiple splitting units obtained, they can be combined in order, or they can be combined randomly without following the order to overcome the problem of deliberately confusing the order and avoiding sensitive word detection. Continuing with the above embodiment, when the splitting unit A among the multiple splitting units is used as the target splitting 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 combining in order, namely ACDB, ACCA, ABBC, AAB, AB.

[0084] S104: For each first word segmentation unit, compare the first word segmentation unit with the node in the target sensitive word tree to determine a first similarity corresponding to the first word segmentation unit, and determine whether there is a sensitive word in the text to be detected based on the first similarity.

[0085] For the above step S104, in the specific implementation, for each first word segmentation unit, the node in the target sensitive word tree is used to compare with the first word segmentation unit to determine the first similarity corresponding to the first word segmentation unit. Here, according to the embodiment provided by the present application, 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 to the target sensitive word tree. Then, based on the first similarity corresponding to the first word segmentation unit, it is judged whether there are sensitive words in the text to be detected. Specifically, the first similarity corresponding to the first word segmentation unit is compared with the preset first similarity threshold. If the first similarity is greater than or equal to the first similarity threshold, it is judged that there are sensitive words in the text to be detected.

[0086] Here, when determining the first similarity corresponding to the word segmentation unit, the embodiment of the present application provides two methods for determining the first similarity. Specifically, method one, for the above step S104, the method 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:

[0087] 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 elements as the nodes of each branch link in the target sensitive word tree.

[0088] For the above step A, when it is specifically implemented, 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 have the same elements 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 the nodes and characters, the comparison can be performed in sequence. Because the first character of the first word segmentation unit is the same as the root node of the target sensitive word tree when the above steps determine the first word segmentation unit, when the comparison is performed in sequence, each branch link node of the second layer in the target sensitive word tree is first used to compare with the second character in the first word segmentation unit, and so on. It is also possible not to compare in sequence. For example, each branch link node of the second layer in the target sensitive word tree is used to compare with the 2nd / 3rd / 4th character in the first word segmentation unit. This can avoid the problem of missing sensitive words due to word order. Alternatively, each branch link node may be compared with multiple characters in the first word segmentation unit. For example, each branch link node in the second layer of the target sensitive word tree may be compared with the second and third characters in the first word segmentation unit. Alternatively, only characters in corresponding positions may be compared. For example, each branch link node in the second layer of the target sensitive word tree may be compared with the second character in the first word segmentation unit.

[0089] B: 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.

[0090] 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 eliminates the need for sequential matching, as long as the characters can be matched one-to-one. This overcomes the problem of inverted word order and missing sensitive words.

[0091] Method 2, with respect to step S104 above, 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:

[0092] 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 elements as the nodes of each branch link in the target sensitive word tree.

[0093] Here, the description of the above step a can refer to the description of the above step A, and can achieve the same technical effect, so it will not be repeated here.

[0094] 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.

[0095] c: Determine a first similarity corresponding to the first word segmentation unit using the plurality of branch similarities.

[0096] For the above steps b-c, in the 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 have the same elements as the 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, and the average similarity value can be used as the first similarity corresponding to the first word segmentation unit. The maximum similarity, minimum similarity or median of multiple branch similarities can also be taken as the first similarity, and this application does not make specific restrictions on this.

[0097] According to the sensitive word detection method provided by the present application, 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 that needs to be blocked in the text to be detected. As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0098] I: If the first similarity is greater than or equal to a first similarity threshold, determine the first sensitive word corresponding to the first word segmentation unit from the target sensitive word tree, and determine whether there is an exemption phrase for the first sensitive word.

[0099] Here, exempted phrases refer to sensitive phrases that are extended from preset sensitive words and have more characters.

[0100] For the above step I, in the 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 exemption phrase. 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 used as the first sensitive word. For example, when the first word segmentation unit is ABBC, the first sensitive word ABB with a higher 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 , Figure 3 This is a structural diagram of a sensitive word tree with exempted phrases provided in an embodiment of the present application. Figure 3 As shown, the exemption phrase corresponds to the three groups of characters bound after the ABB branch, and the exemption phrase is bound to the last leaf node.

[0101] II: If so, based on the phrase length of the exempted phrase, in the order of multiple split units in the text to be detected, with each target split unit as the starting point, multiple split units corresponding to the phrase length are obtained forward and / or backward and combined to obtain a second word segmentation unit.

[0102] For the above-mentioned step II, in the specific implementation, when there is an exemption phrase for the first sensitive word, based on the phrase length of the exemption phrase, in accordance with the order of the multiple split units in the text to be detected, with each target split unit as the starting point, multiple split units corresponding to the phrase length are obtained forward and / or backward, and combined to obtain a second word segmentation unit. Here, for the multiple split units corresponding to the obtained phrase length, they can be combined in order, or they can be randomly combined without following the order, in order to overcome the problem of deliberately confusing the order and avoiding sensitive word detection. Here, continuing the example in the above-mentioned step I, the 3 exemption phrases bound by ABB are up to 8 characters long, then A is used as the target split unit, and the second word segmentation unit composed of the 8 characters before and after A, i.e. CDBDBACCABBCDDAAB, is obtained from the text to be detected.

[0103] III: Using the exemption phrase to compare with the second word segmentation unit, determine the second similarity corresponding to the second word segmentation unit, and judge whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the second similarity and the second similarity threshold.

[0104] For the above step III, when it is specifically implemented, the exemption phrase 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 the same technical effect can be achieved, so it will not be repeated here. Then, based on the second similarity threshold and the second similarity, it is determined whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected. Here, as an example, when there are 3 exemption phrases for the sensitive words ABB, the similarity between the second word segmentation unit and each exemption phrase 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, the first word segmentation unit is used as a sensitive word appearing in the text to be detected.

[0105] As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0106] i: Determine from the target sensitive word tree a second sensitive word whose first similarity corresponding to the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered.

[0107] Regarding step i above, during the specific implementation, a second sensitive word is determined from the target sensitive word tree, whose first similarity with 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. Here, as an example, when the first word segmentation unit is ABBC, a second sensitive word ABB is determined from the target sensitive word tree with the root node A, whose first similarity with 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.

[0108] 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 a pre-trained sensitivity value detection model to determine the third similarity corresponding to the third word segmentation unit, so as to judge whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the third similarity, or judge whether to use 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.

[0109] Here, the preset word segmentation length can be set to 8, and this application does not make any specific restrictions on this.

[0110] For the above step ii, in the specific implementation, based on the preset segmentation length, the third segmentation unit corresponding to the second sensitive word is determined from the text to be detected. Here, the phrase of the preset segmentation length before and / or after the second sensitive word in the text to be detected is used as the third segmentation unit. The third segmentation unit is then input into the pre-trained sensitivity value detection model to determine the third similarity corresponding to the third segmentation unit. Here, the sensitivity value detection module is obtained by training sample sensitive words and sample sensitivity values corresponding to the sample sensitive words. Its training method is the same as the training method for the neural network model in the prior art and will not be repeated here. Then, based on the third similarity of the third segmentation unit, it is judged whether the first segmentation unit is regarded as a sensitive word appearing in the text to be detected, or based on the first similarity of the first segmentation unit and the third similarity of the third segmentation unit, it is judged whether the first segmentation unit is regarded as a sensitive word appearing in the text to be detected. Here, as an optional embodiment, the third similarity of the third segmentation unit is compared with the threshold value. If it is greater than or equal to the threshold value, it is considered that the first segmentation unit is a sensitive word appearing in the text to be detected. Alternatively, the judgment result of the sensitive word detection model, that is, 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 multiplied similarity 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.

[0111] As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0112] Determine from the target sensitive word tree a second sensitive word whose first similarity corresponding to the first word segmentation unit is greater than or equal to the first similarity threshold and whose sensitive word category belongs to non-necessary filtering; 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 use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the fourth similarity.

[0113] For the above two steps, in the specific implementation, different exclusion weights can be set for sensitive words that belong to the category of non-essential filtering, and whether to exclude sensitive words is determined based on the exclusion weight, the first similarity and the exclusion threshold. Specifically, a second sensitive word is determined from the target sensitive word tree, whose first similarity corresponding to the first word segmentation unit is greater than or equal to the first similarity threshold and whose sensitive word category belongs to non-essential 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 word segmentation unit is used as the fourth similarity. If the fourth similarity is greater than or equal to the threshold, it is considered that the first word segmentation unit is a sensitive word that appears in the text to be detected.

[0114] As an optional embodiment, after determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes:

[0115] Determine from the target sensitive word tree a third sensitive word whose first similarity corresponding 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 phrase; based on the second preset word segmentation length, determine the 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 is a sensitive word in the text to be detected.

[0116] Here, when performing sensitive word detection, the present application also includes sensitive words in combination phrases. For the above two steps, in the specific implementation, first determine from the target sensitive word tree a third sensitive word whose first similarity corresponding to the first word segmentation unit is greater than or equal to the second similarity threshold and whose sensitive word category belongs to the combination phrase. Here, for example, AB...CD is set as the third sensitive word whose sensitive word category belongs to the combination phrase. Then, based on the second preset word segmentation length, determine the fourth word segmentation unit corresponding to the third sensitive word from the text to be detected. For example, if AB is detected in the text to be detected, the second preset word segmentation length is searched forward and / or backward with AB as the starting point in the text to be detected to determine whether there is character C. If there is character C, the second preset word segmentation length is continued forward and / or backward with C as the starting point in the text to be detected to determine whether there is character D. If there is character D, the found content is used as the fourth word segmentation unit. Alternatively, if AB is detected in the text to be tested, the text to be tested is searched forward and / or backward for a second preset segmentation length starting from AB to determine whether characters C and D are found, and the searched content is used as the fourth segmentation unit. Then, based on the result of determining whether the fourth segmentation unit contains the fourth sensitive word, it is determined whether the text to be tested contains sensitive words.

[0117] The sensitive word detection method provided in the embodiment of the present application first classifies multiple preset sensitive words and constructs at least one sensitive word tree using the multiple preset sensitive words; then, splits the acquired text to be detected to determine multiple split units; for each target sensitive word tree whose root node is the same as the split unit, determines the length of each branch link in the target sensitive word tree, and determines at least one first word segmentation unit from the multiple split units based on the length of the branch link; finally, for each first word segmentation unit, compares 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 determines whether the text to be detected contains sensitive words based on the first similarity.

[0118] This application significantly improves the accuracy and efficiency of sensitive word detection by grouping preset sensitive words and constructing a sensitive word tree. This tree is then used to obtain corresponding word segmentation units from the text to be detected. This is combined with the calculation of contextual similarity to significantly improve the accuracy and efficiency of sensitive word detection. This not only allows for rapid identification of conventional sensitive words, but also handles various variations, inversions, and insertions, while maintaining a balance between false positives and false negatives.

[0119] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of a sensitive word detection device provided in an embodiment of the present application. Figure 4 As shown in , the sensitive word detection device 400 includes:

[0120] 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;

[0121] The split unit determination module 402 is used to split the acquired text to be detected and determine multiple split units;

[0122] The word segmentation unit determination module 403 is configured to determine, for each target sensitive word tree whose root node is the same as the splitting unit, the length of each branch link in the target sensitive word tree, and determine at least one first word segmentation unit from the plurality of splitting units based on the length of the branch link;

[0123] The first detection module 404 is used to compare each first word segmentation unit with the node in the target sensitive word tree, determine the first similarity corresponding to the first word segmentation unit, and determine whether there is a sensitive word in the text to be detected based on the first similarity.

[0124] Furthermore, when the sensitive word tree construction module 401 is used to classify a plurality of preset sensitive words and construct at least one sensitive word tree using the plurality of preset sensitive words, the sensitive word tree construction module 401 is further used to:

[0125] Determine at least one sensitive phrase group from a plurality of preset sensitive words; wherein the first characters of each preset sensitive word in the sensitive phrase group have the same elements;

[0126] For each sensitive phrase, the element corresponding to the first character of the preset sensitive word in the sensitive phrase is used as the root node. According to the order of the characters contained in the preset sensitive word in the sensitive phrase, a corresponding child node is constructed for each root node to generate a sensitive word tree corresponding to the sensitive phrase.

[0127] Furthermore, when the word segmentation unit determination module 403 is used to determine at least one first word segmentation unit from a plurality of split units based on the length of the branch link, the word segmentation unit determination module 403 is further used to:

[0128] Determine at least one target split unit from the plurality of split units that has the same elements as the root node of the target sensitive word tree;

[0129] For each target split unit, in the order of multiple split units in the text to be detected, multiple split units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward with the target split unit as the starting point, and then combined to obtain the first word segmentation unit.

[0130] Furthermore, when the first detection module 404 is used to compare 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 further used to:

[0131] Comparing the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit, and determining 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;

[0132] 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;

[0133] or,

[0134] 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;

[0135] A first similarity corresponding to the first word segmentation unit is determined using the multiple branch similarities.

[0136] Furthermore, the sensitive word detection device 400 further includes a second detection module. After determining the first similarity corresponding to the first word segmentation unit, the second detection module is configured to:

[0137] If the first similarity is greater than or equal to a first similarity threshold, determining a 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 exemption phrase;

[0138] If yes, then based on the phrase length of the exempted phrase, in accordance with the order of the multiple split units in the text to be detected, with each target split unit as a starting point, obtain multiple split units corresponding to the phrase length forward and / or backward and combine them to obtain a second word segmentation unit;

[0139] The exemption phrase is compared with the second word segmentation unit to determine a second similarity corresponding to the second word segmentation unit, so as to determine whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the second similarity and a second similarity threshold.

[0140] Furthermore, the sensitive word detection device 400 further includes a third detection module. After determining the first similarity corresponding to the first word segmentation unit, the third detection module is configured to:

[0141] Determine from the target sensitive word tree a second sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered;

[0142] Based on a first preset word segmentation length, a 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 a pre-trained sensitivity value detection model to determine a third similarity corresponding to the third word segmentation unit, so as to judge whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the third similarity, or to judge whether to use 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.

[0143] Furthermore, the sensitive word detection device 400 further includes a fourth detection module. After determining the first similarity corresponding to the first word segmentation unit, the fourth detection module is configured to:

[0144] Determine from the target sensitive word tree a second sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered;

[0145] An exclusion weight corresponding to the second sensitive word is determined, and the product of the exclusion weight and the first similarity is used as a fourth similarity, so as to determine whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the fourth similarity.

[0146] Furthermore, the sensitive word detection device 400 further includes a fifth detection module. After determining the first similarity corresponding to the first word segmentation unit, the fifth detection module is configured to:

[0147] Determine from the target sensitive word tree a third sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a second similarity threshold and whose sensitive word category belongs to a combination phrase;

[0148] Based on the second preset word segmentation length, a 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 is a sensitive word in the text to be detected.

[0149] 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 further used to:

[0150] Classify multiple preset sensitive words according to any one or more of pronunciation, character shape, and letter, and construct at least one sensitive word tree using the multiple preset sensitive words;

[0151] When the split unit determination module 402 is used to split the acquired text to be detected and determine multiple split units, the split unit determination module 402 is further used to:

[0152] The acquired text to be detected is split according to any one or more of the pronunciation, glyph, and letter of each character in the text to be detected, and a plurality of split units are determined.

[0153] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown in FIG, the electronic device 500 includes a processor 510, a memory 520 and a bus 530.

[0154] The memory 520 stores machine-readable instructions executable by the processor 510. When the electronic device 500 is running, the processor 510 communicates with the memory 520 via the bus 530. When the machine-readable instructions are executed by the processor 510, the above-mentioned Figure 1 The steps of the sensitive word detection method in the method embodiment shown are specifically implemented in accordance with the method embodiment and will not be described in detail here.

[0155] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 The steps of the sensitive word detection method in the method embodiment shown are specifically implemented in accordance with the method embodiment and will not be described in detail here.

[0156] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0157] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. There may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interface, indirect coupling or communication connection of devices or units, which may be electrical, mechanical or other forms.

[0158] The units described as separate components may or may not be physically separate, and 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 these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0159] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0160] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0161] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-mentioned embodiments within the technical scope disclosed in the present application, or perform equivalent replacements for some of the technical features thereof. These modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A sensitive word detection method, characterized in that: The sensitive word detection method includes: Classifying multiple preset sensitive words and constructing at least one sensitive word tree using the multiple preset sensitive words; Split the acquired text to be detected into multiple split units; For each target sensitive word tree whose root node is the same 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 the multiple splitting units based on the length of the branch link; For each first word segmentation unit, compare the first word segmentation unit with a node in the target sensitive word tree to determine a first similarity corresponding to the first word segmentation unit, and determine whether the text to be detected contains sensitive words based on the first similarity; The determining of at least one first word segmentation unit from a plurality of splitting units based on the length of the branch link includes: Determine at least one target split unit from the plurality of split units that has the same elements as the root node of the target sensitive word tree; For each target split unit, in the order of multiple split units in the text to be detected, multiple split units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward with the target split unit as the starting point, and then combined to obtain the first word segmentation unit.

2. The sensitive word detection method according to claim 1, characterized in that: The classifying of the plurality of preset sensitive words and constructing at least one sensitive word tree using the plurality of preset sensitive words includes: Determine at least one sensitive phrase group from a plurality of preset sensitive words; wherein the first characters of each preset sensitive word in the sensitive phrase group have the same elements; For each sensitive phrase, the element corresponding to the first character of the preset sensitive word in the sensitive phrase is used as the root node. According to the order of the characters contained in the preset sensitive word in the sensitive phrase, a corresponding child node is constructed for each root node to generate a sensitive word tree corresponding to the sensitive phrase.

3. The sensitive word detection method according to claim 1, characterized in that: The 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: Comparing the nodes of each branch link in the target sensitive word tree with the characters in the first word segmentation unit, and determining 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; or, 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; A first similarity corresponding to the first word segmentation unit is determined using the multiple branch similarities.

4. The sensitive word detection method according to claim 1, characterized in that: 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 a first similarity threshold, determining a 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 exemption phrase; If yes, then based on the phrase length of the exempted phrase, in accordance with the order of the multiple split units in the text to be detected, with each target split unit as a starting point, obtain multiple split units corresponding to the phrase length forward and / or backward and combine them to obtain a second word segmentation unit; The exemption phrase is compared with the second word segmentation unit to determine a second similarity corresponding to the second word segmentation unit, so as to determine whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the second similarity and a second similarity threshold.

5. The sensitive word detection method according to claim 1, characterized in that: After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: Determine from the target sensitive word tree a second sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered; Based on a first preset word segmentation length, a 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 a pre-trained sensitivity value detection model to determine a third similarity corresponding to the third word segmentation unit, so as to judge whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the third similarity, or to judge whether to use 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.

6. The sensitive word detection method according to claim 1, characterized in that: After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: Determine from the target sensitive word tree a second sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a first similarity threshold and whose sensitive word category is not required to be filtered; An exclusion weight corresponding to the second sensitive word is determined, and the product of the exclusion weight and the first similarity is used as a fourth similarity, so as to determine whether to use the first word segmentation unit as a sensitive word appearing in the text to be detected based on the fourth similarity.

7. The sensitive word detection method according to claim 1, characterized in that: After determining the first similarity corresponding to the first word segmentation unit, the sensitive word detection method further includes: Determine from the target sensitive word tree a third sensitive word whose first similarity with the first word segmentation unit is greater than or equal to a second similarity threshold and whose sensitive word category belongs to a combination phrase; Based on the second preset word segmentation length, a 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 is a sensitive word in the text to be detected.

8. The sensitive word detection method according to claim 1, characterized in that: The method of classifying a plurality of preset sensitive words and constructing at least one sensitive word tree using the plurality of preset sensitive words includes: Classify multiple preset sensitive words according to any one or more of pronunciation, character shape, and letter, and construct at least one sensitive word tree using the multiple preset sensitive words; The method of splitting the acquired text to be detected to determine a plurality of split units includes: The acquired text to be detected is split according to any one or more of the pronunciation, glyph, and letter of each character in the text to be detected, and a plurality of split units are determined.

9. A sensitive word detection device, characterized in that: The sensitive word detection device includes: A 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; A split unit determination module is used to split the acquired text to be detected and determine multiple split units; a word segmentation unit determination module, configured to determine, for each target sensitive word tree whose root node is the same as the splitting unit, the length of each branch link in the target sensitive word tree, and determine at least one first word segmentation unit from the plurality of splitting units based on the length of the branch link; A first detection module is configured to compare each first word segmentation unit with a node in the target sensitive word tree to determine a first similarity corresponding to the first word segmentation unit, and determine whether a sensitive word exists in the text to be detected based on the first similarity; When the word segmentation unit determination module is used to determine at least one first word segmentation unit from a plurality of split units based on the length of the branch link, the word segmentation unit determination module is further used to: Determine at least one target split unit from the plurality of split units that has the same elements as the root node of the target sensitive word tree; For each target split unit, in the order of multiple split units in the text to be detected, multiple split units corresponding to the length of at least one branch link of the target sensitive word tree are obtained forward and / or backward with the target split unit as the starting point, and then combined to obtain the first word segmentation unit.

Citation Information

Patent Citations

  • Sensitive word detection method and device and sensitive word tree construction method and device

    CN112328732A

  • Sensitive word detection method and device, equipment and storage medium

    CN118069809A