Sensitive word detection method, device, computer equipment and storage medium
By constructing a homophone lexicon and indexer and combining it with a sensitive lexicon for filtering, the problem of low accuracy in identifying sensitive words in the existing technology is solved, and effective identification of sensitive words, homophone words and redundant inserted words is achieved.
Patent Information
- Application Number
- CN202010688343.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-16
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2040-07-16
AI Technical Summary
Existing sensitive word filtering methods cannot effectively identify deformed words, homophones, and redundant inserted words of sensitive words, resulting in low recognition accuracy.
Construct a homophone lexicon corresponding to the sensitive lexicon, and build a sensitive word indexer and a homophonic word indexer based on the sensitive lexicon and the homophonic word database respectively. Use these indexers to filter the text to be tested, remove non-Chinese characters, and identify sensitive words, Homophones and redundant insertions.
It significantly improves the recognition accuracy of sensitive words and can identify the sensitive words themselves, homophones and redundant inserted words in the text to be tested.
Smart Images

Figure CN111831785B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sensitive word filtering, and in particular to a sensitive word detection method, device, computer equipment and storage medium. Background Art
[0002] Sensitive word filtering refers to the use of advanced artificial intelligence technology to accurately and efficiently identify illegal content such as politics, pornography, insults, prohibited content, and junk advertising in various scenarios, to prevent content risks in advance and improve user experience. At present, the commonly used sensitive word filtering algorithms include the finite automaton matching algorithm based on the sensitive word library, and the classification and sequence labeling algorithm based on the machine learning model.
[0003] The disadvantage of the above existing sensitive word filtering methods is that they can only identify the sensitive words themselves, and cannot filter out the variant words of the sensitive words, such as homophonic words and redundant inserted words, which leads to low accuracy in sensitive word recognition. Summary of the invention
[0004] The embodiments of the present invention provide a sensitive word detection method, apparatus, computer equipment and storage medium, aiming to solve the problem of low accuracy in sensitive word recognition in existing sensitive word filtering methods.
[0005] In a first aspect, an embodiment of the present invention provides a sensitive word detection method, which includes:
[0006] Obtain the sensitive word library from the preset sensitive word server;
[0007] Constructing a homophonic word library corresponding to the sensitive word library;
[0008] Constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively;
[0009] If a text to be tested is received, the text to be tested is filtered by the sensitive word indexer to obtain a first sensitive word set;
[0010] Removing non-Chinese characters from the text to be tested to obtain a de-redundant text, and filtering the de-redundant text through the sensitive word indexer to obtain a second sensitive word set;
[0011] Filtering the text to be tested by the homophonic word indexer to obtain a third sensitive word set;
[0012] Filtering the de-redundant text by the homophonic word indexer to obtain a fourth sensitive word set;
[0013] The first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set are deduplicated and merged to obtain a total sensitive word set.
[0014] In a second aspect, an embodiment of the present invention further provides a sensitive word detection device, which includes:
[0015] A first acquisition unit, used to acquire a sensitive word library from a preset sensitive word server;
[0016] A first construction unit is used to construct a homophonic word library corresponding to the sensitive word library;
[0017] A second construction unit is used to construct a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively;
[0018] A first filtering unit, configured to filter the text to be tested by the sensitive word indexer to obtain a first sensitive word set upon receiving the text to be tested;
[0019] A second filtering unit, configured to remove non-Chinese characters in the text to be tested to obtain a de-redundant text, and filter the de-redundant text through the sensitive word indexer to obtain a second sensitive word set;
[0020] A third filtering unit, configured to filter the text to be tested by using the homophonic word indexer to obtain a third sensitive word set;
[0021] a fourth filtering unit, configured to filter the de-redundant text through the homophonic word indexer to obtain a fourth sensitive word set;
[0022] The merging unit is used to remove duplications from the first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set and merge them to obtain a total sensitive word set.
[0023] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.
[0024] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0025] The embodiment of the present invention provides a sensitive word detection method, device, computer equipment and storage medium. The method includes: obtaining a sensitive word library from a preset sensitive word server; constructing a homophonic word library corresponding to the sensitive word library; constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively; if a text to be tested is received, filtering the text to be tested through the sensitive word indexer to obtain a first sensitive word set; removing non-Chinese characters in the text to be tested to obtain a de-redundant text, and filtering the de-redundant text through the sensitive word indexer to obtain a second sensitive word set; filtering the text to be tested through the homophonic word indexer to obtain a third sensitive word set; filtering the de-redundant text through the homophonic word indexer to obtain a fourth sensitive word set; de-duplicating the first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set and merging them to obtain a total sensitive word set. The technical solution of the embodiment of the present invention is to construct a homophonic word library corresponding to the sensitive word library; construct a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively; if a text to be tested is received, the text to be tested and the de-redundant text after non-Chinese characters are removed from the text to be tested are respectively filtered for sensitive words by the sensitive word indexer and the homophonic word indexer, so that not only the sensitive words themselves in the text to be tested can be identified, but also the homophonic words and redundant inserted words of the sensitive words can be identified, which greatly improves the accuracy of recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0027] Figure 1 A schematic diagram of an application scenario of a sensitive word detection method provided by an embodiment of the present invention;
[0028] Figure 2 A schematic diagram of a process flow of a sensitive word detection method provided by an embodiment of the present invention;
[0029] Figure 3 A schematic diagram of a sub-process of a sensitive word detection method provided by an embodiment of the present invention;
[0030] Figure 4 A schematic diagram of a sub-process of a sensitive word detection method provided by an embodiment of the present invention;
[0031] Figure 5 A schematic diagram of a sub-process of a sensitive word detection method provided by an embodiment of the present invention;
[0032] Figure 6 A schematic diagram of a sub-process of a sensitive word detection method provided by an embodiment of the present invention;
[0033] Figure 7 A schematic block diagram of a sensitive word detection device provided by an embodiment of the present invention;
[0034] Figure 8 A schematic block diagram of a first construction unit of a sensitive word detection device provided by an embodiment of the present invention;
[0035] Fig. 9 A schematic block diagram of a second construction unit of a sensitive word detection device provided by an embodiment of the present invention;
[0036] Fig.10 A schematic block diagram of a third filtering unit of a sensitive word detection device provided by an embodiment of the present invention;
[0037] Fig.11 A schematic block diagram of a fourth filtering unit of a sensitive word detection device provided by an embodiment of the present invention;
[0038] Fig.12 A schematic block diagram of a first acquisition unit of a sensitive word detection device provided by an embodiment of the present invention;
[0039] Fig.13 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0042] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0043] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0044] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0045] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of the sensitive word detection method provided in an embodiment of the present invention. Figure 2 A schematic flow chart of a sensitive word detection method provided by an embodiment of the present invention. The sensitive word detection method is applied to a sensitive word detection server 10. The sensitive word detection server 10 refers to a server for detecting sensitive words. The sensitive word detection server 10 obtains a sensitive word library from a preset sensitive word server 20.
[0046] Figure 2 1 is a flow chart of a sensitive word detection method provided by an embodiment of the present invention. As shown in the figure, the method includes the following steps S1-S8.
[0047] S1, obtain the sensitive word library from the preset sensitive word server.
[0048] In a specific implementation, a sensitive word library is obtained from a preset sensitive word server, where the sensitive word server refers to a server for providing a sensitive word library.
[0049] In one embodiment, the above step S1 specifically includes: if a sensitive word library update reminder message sent by the sensitive word server is received, obtaining a download address of an updated sensitive word library from the sensitive word library update reminder message, and the sensitive word library update reminder message includes the download address; downloading the updated sensitive word library from the download address.
[0050] In a specific implementation, when the sensitive word library is updated, the sensitive word server will send a sensitive word library update reminder message to the sensitive word detection server, and the sensitive word library update reminder message includes the download address of the updated sensitive word library.
[0051] If the sensitive word library update reminder message sent by the sensitive word server is received, the sensitive word detection server obtains the download address of the updated sensitive word library from the sensitive word library update reminder message, and downloads the updated sensitive word library from the download address. Through the above steps, the sensitive word library can be updated.
[0052] It should be noted that, in the embodiment of the present invention, the sensitive word server obtains the sensitive word library in the following manner.
[0053] First, a training corpus is constructed. The corpus is automatically annotated according to the sensitive word library and the homophonic word library. At the same time, sensitive words with redundant components are randomly generated according to the redundant regularization to perform corresponding text enhancement.
[0054] Secondly, the sensitive word discovery model is trained through training corpus.
[0055] Finally, the acquired corpus, including network corpus and business corpus, is regularly input into the sensitive word discovery model for prediction, and the predicted new sensitive words are added to the sensitive word library after redundant filtering.
[0056] In the embodiment of the present invention, the detection of sensitive words and the update of the vocabulary are separated from each other. The update of the vocabulary is an offline task and therefore will not affect the online retrieval and filtering speed. Therefore, the BERT+BI-LSTM+CRF model is selected as the sensitive word discovery model, which has higher accuracy.
[0057] S2, constructing a homophonic word library corresponding to the sensitive word library.
[0058] In the specific implementation, first, each word in the sensitive word library is converted into the corresponding pinyin, such as high pure ice is converted into gaochunbing. In order to expand the search scope, the pinyin tone can be removed.
[0059] Then, the converted pinyin of all sensitive words are deduplicated to obtain the corresponding homophonic word library.
[0060] See also Figure 3 In one embodiment, the above step S2 specifically includes the following steps S21-S22.
[0061] S21, obtaining the pinyin of the sensitive words in the sensitive word library.
[0062] In a specific implementation, the pinyin of the sensitive words in the sensitive word library is obtained, and the tones are removed.
[0063] S22, taking the pinyin of the sensitive words in the sensitive word library as homophonic sensitive words, and storing the homophonic sensitive words in a preset blank database to obtain the homophonic word library.
[0064] In a specific implementation, the pinyin of the sensitive words in the sensitive word library is used as the homophonic sensitive words, and after the homophonic sensitive words are deduplicated, they are stored in a preset blank database to obtain the homophonic word library. A blank database refers to a database without data stored therein.
[0065] S3, constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively.
[0066] In a specific implementation, a sensitive word indexer and a homophonic word indexer are constructed according to the sensitive word library and the homophonic word library respectively.
[0067] It should be noted that the sensitive word indexer and the homophonic word indexer can be constructed through data structures such as a trie tree or a double-array trie tree.
[0068] The trie tree is a tree structure and a variant of the hash tree. Its advantages are: using the common prefix of the string to reduce the query time, minimizing unnecessary string comparisons, and being able to implement insertion and query operations. It is a data structure that trades space for time and is widely used in the fields of word frequency statistics and input statistics.
[0069] The dual-array trie tree can store the Trie tree that originally required multiple arrays to represent using only two data, which can greatly reduce the space complexity. Specifically:
[0070] Two arrays, base and check, are used to maintain the trie tree. The base array is responsible for recording the state, and the check array is responsible for checking whether each string is transferred from the same state. When check[i] is a negative value, it means that this state is the end of the string.
[0071] See also Figure 4 In one embodiment, the above step S3 specifically includes the following steps S31-S32.
[0072] S31, using a double array tire tree to construct a sensitive word indexer corresponding to the sensitive word library.
[0073] In a specific implementation, a double-array tire tree is used to construct a sensitive word indexer corresponding to the sensitive word library.
[0074] S32, using a double array tire tree to construct a homophonic word indexer corresponding to the homophonic word library.
[0075] In a specific implementation, a double array tire tree is used to construct a homophonic word indexer corresponding to the homophonic word library.
[0076] It should be noted that, since the tire tree structure has large data sparsity, resulting in space waste, this embodiment, based on the tire tree structure, proposes a dual-array trie tree after upgrading. The dual-array trie tree has the advantages of high query efficiency and space saving, and can effectively reduce space waste.
[0077] S4: If the text to be tested is received, the text to be tested is filtered by the sensitive word indexer to obtain a first sensitive word set.
[0078] In a specific implementation, if a text to be tested is received, the text to be tested is filtered by the sensitive word indexer to obtain a first sensitive word set.
[0079] Specifically, the text to be tested is input into the sensitive word indexer, and the sensitive word indexer searches for sensitive words contained in the text to be tested, and adds the searched sensitive words to the first sensitive word set.
[0080] S5, removing non-Chinese characters in the text to be tested to obtain a de-redundant text, and filtering the de-redundant text through the sensitive word indexer to obtain a second sensitive word set.
[0081] In the specific implementation, firstly, the non-Chinese characters in the test text are removed to obtain the redundant text. The non-Chinese characters include redundant components such as Martian characters, symbols and numbers. These redundant components will interfere with the retrieval of the sensitive word indexer.
[0082] Then, the de-redundant text is filtered by the sensitive word indexer to obtain a second sensitive word set.
[0083] Specifically, the de-redundant text is input into the sensitive word indexer, and the sensitive word indexer searches for sensitive words included in the de-redundant text, and adds the searched sensitive words to the second sensitive word set.
[0084] S6, filtering the text to be tested by the homophonic word indexer to obtain a third sensitive word set.
[0085] In a specific implementation, the Chinese characters of the test text are first converted into pinyin, and then the converted test text is input into the homophonic word indexer, so that the homophonic word indexer searches for corresponding homophonic sensitive words.
[0086] See also Figure 5 In one embodiment, the above step S6 specifically includes the following steps S61-S63.
[0087] S61, converting Chinese characters in the text to be tested into pinyin to obtain a homophonic text to be tested.
[0088] In a specific implementation, the Chinese characters in the text to be tested are converted into pinyin to obtain the homophonic text to be tested. In order to increase the search scope, the tones of the pinyin can be removed.
[0089] S62: Filter the homophonic text to be tested by the homophonic word indexer to obtain a first homophonic sensitive word set.
[0090] In a specific implementation, the homophonic text to be tested is filtered by the homophonic word indexer to obtain a first homophonic sensitive word set.
[0091] Specifically, the homophonic text to be tested is input into the homophonic word indexer, the homophonic word indexer searches for homophonic sensitive words contained in the homophonic text to be tested, and adds the searched homophonic sensitive words to the first homophonic sensitive word set.
[0092] S63: Acquire words in the test text corresponding to the homophonic sensitive words in the first homophonic sensitive word set to obtain the third sensitive word set.
[0093] In a specific implementation, a mapping relationship between Chinese and Pinyin is established when converting Chinese in the test text into Pinyin, and then the words corresponding to the homophonic sensitive words in the first homophonic sensitive word set are searched in the test text according to the mapping relationship. And the searched words are added as sensitive words to the third sensitive word set.
[0094] S7, filtering the de-redundant text by the homophonic word indexer to obtain a fourth sensitive word set.
[0095] In a specific implementation, the Chinese characters of the de-redundant text are first converted into pinyin, and then the converted de-redundant text is input into the homophonic word indexer, so that the homophonic word indexer searches for corresponding homophonic sensitive words.
[0096] See also Figure 6 In one embodiment, the above step S7 specifically includes the following steps S71-S73.
[0097] S71, converting Chinese characters in the de-redundant text into pinyin to obtain a de-redundant homophonic text.
[0098] In a specific implementation, the Chinese characters in the de-redundant text are converted into pinyin to obtain the de-redundant homophonic text. In order to improve the search scope, the pinyin tones can be removed.
[0099] S72: Filter the de-redundant homophonic text by the homophonic word indexer to obtain a second homophonic sensitive word set.
[0100] In a specific implementation, the de-redundant homophonic text is filtered by the homophonic word indexer to obtain a second homophonic sensitive word set.
[0101] Specifically, the de-redundant homophonic text is input into the homophonic word indexer, and the homophonic word indexer searches for homophonic sensitive words contained in the de-redundant homophonic text, and adds the searched homophonic sensitive words to the second homophonic sensitive word set.
[0102] S73: Acquire words in the de-redundant text that correspond to the homophonic sensitive words in the second homophonic sensitive word set to obtain the fourth sensitive word set.
[0103] In a specific implementation, a mapping relationship between Chinese and Pinyin is established when converting Chinese in the de-redundant text into Pinyin, and then the words corresponding to the homophonic sensitive words in the second homophonic sensitive word set are searched in the de-redundant text according to the mapping relationship. And the searched words are added as sensitive words to the fourth sensitive word set.
[0104] S8, deduplicate the first sensitive word set, the second sensitive word set, the third sensitive word set, and the fourth sensitive word set, and merge them to obtain a total sensitive word set.
[0105] In a specific implementation, first, the first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set are deduplicated, that is, repeated sensitive words are removed.
[0106] Then, the first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set are combined to obtain a total sensitive word set, which includes all sensitive words contained in the text to be tested.
[0107] The technical solution of the embodiment of the present invention is to construct a homophonic word library corresponding to the sensitive word library; construct a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively; if a text to be tested is received, the text to be tested and the de-redundant text after non-Chinese characters are removed from the text to be tested are respectively filtered for sensitive words by the sensitive word indexer and the homophonic word indexer, so that not only the sensitive words themselves in the text to be tested can be identified, but also the homophonic words and redundant inserted words of the sensitive words can be identified, which greatly improves the accuracy of recognition.
[0108] Figure 7 is a schematic block diagram of a sensitive word detection device 60 provided in an embodiment of the present invention. Figure 7 As shown, corresponding to the above sensitive word detection method, the present invention also provides a sensitive word detection device 60. The sensitive word detection device 60 includes a unit for executing the above sensitive word detection method, and the sensitive word detection device 60 can be configured in a server. Figure 7The sensitive word detection device 60 includes a first acquisition unit 61, a first construction unit 62, a second construction unit 63, a first filtering unit 64, a second filtering unit 65, a third filtering unit 66, a fourth filtering unit 67 and a merging unit 68.
[0109] A first acquisition unit 61 is used to acquire a sensitive word library from a preset sensitive word server;
[0110] A first constructing unit 62 is used to construct a homophonic word library corresponding to the sensitive word library;
[0111] A second construction unit 63 is used to construct a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively;
[0112] A first filtering unit 64 is configured to filter the text to be tested by the sensitive word indexer to obtain a first sensitive word set if the text to be tested is received;
[0113] A second filtering unit 65 is used to remove non-Chinese characters in the text to be tested to obtain a de-redundant text, and filter the de-redundant text through the sensitive word indexer to obtain a second sensitive word set;
[0114] A third filtering unit 66, configured to filter the text to be tested through the homophonic word indexer to obtain a third sensitive word set;
[0115] A fourth filtering unit 67, configured to filter the de-redundant text through the homophonic word indexer to obtain a fourth sensitive word set;
[0116] The merging unit 68 is used to remove duplicates from the first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set and merge them to obtain a total sensitive word set.
[0117] In one embodiment, if Figure 8 As shown, the first constructing unit 62 includes a second acquiring unit 621 and a storage unit 622 .
[0118] The second acquisition unit 621 is used to acquire the pinyin of the sensitive words in the sensitive word library.
[0119] The storage unit 622 is used to use the pinyin of the sensitive words in the sensitive word library as homophonic sensitive words, and store the homophonic sensitive words in a preset blank database to obtain the homophonic word library.
[0120] In one embodiment, if Fig. 9 As shown, the second building unit 63 includes a third building unit 631 and a fourth building unit 632 .
[0121] The third construction unit 631 is used to construct a sensitive word indexer corresponding to the sensitive word library using a double array tire tree;
[0122] The fourth construction unit 632 is used to construct a homophonic word indexer corresponding to the homophonic word library by using a double array tire tree.
[0123] In one embodiment, if Fig.10 As shown, the third filtering unit 66 includes a first conversion unit 661 , a fifth filtering unit 662 and a third acquisition unit 663 .
[0124] The first conversion unit 661 is used to convert Chinese characters in the text to be tested into pinyin to obtain a homophonic text to be tested;
[0125] A fifth filtering unit 662, configured to filter the homophonic text to be tested through the homophonic word indexer to obtain a first homophonic sensitive word set;
[0126] The third acquisition unit 663 is used to acquire words in the test text corresponding to the homophonic sensitive words in the first homophonic sensitive word set to obtain the third sensitive word set.
[0127] In one embodiment, if Fig.11 As shown, the fourth filtering unit 67 includes a second conversion unit 671 , a sixth filtering unit 672 and a fourth acquiring unit 673 .
[0128] The second conversion unit 671 is used to convert the Chinese characters in the de-redundant text into pinyin to obtain a de-redundant homophonic text;
[0129] A sixth filtering unit 672, configured to filter the de-redundant homophonic text through the homophonic word indexer to obtain a second homophonic sensitive word set;
[0130] The fourth acquisition unit 673 is configured to acquire words in the de-redundant text corresponding to the homophonic sensitive words in the second homophonic sensitive word set to obtain the fourth sensitive word set.
[0131] In one embodiment, if Fig.12 As shown, the first obtaining unit 61 includes a downloading unit 611 .
[0132] The download unit 611 is used to obtain a download address of an updated sensitive word library from the sensitive word library update reminder message if a sensitive word library update reminder message sent by the sensitive word server is received, and the sensitive word library update reminder message includes the download address; and download the updated sensitive word library from the download address.
[0133] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned sensitive word detection device 60 and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0134] The above-mentioned sensitive word detection device can be implemented in the form of a computer program. The computer program can be used in Fig.13 Runs on the computer device shown.
[0135] See also Fig.13 , Fig.13 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 is a server, which may be an independent server or a server cluster composed of multiple servers.
[0136] See also Fig.13 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0137] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 may execute a sensitive word detection method.
[0138] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0139] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a sensitive word detection method.
[0140] The network interface 505 is used to communicate with other devices over the network. Fig.13 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0141] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:
[0142] Obtain the sensitive word library from the preset sensitive word server;
[0143] Constructing a homophonic word library corresponding to the sensitive word library;
[0144] Constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively;
[0145] If a text to be tested is received, the text to be tested is filtered by the sensitive word indexer to obtain a first sensitive word set;
[0146] Removing non-Chinese characters from the text to be tested to obtain a de-redundant text, and filtering the de-redundant text through the sensitive word indexer to obtain a second sensitive word set;
[0147] Filtering the text to be tested by the homophonic word indexer to obtain a third sensitive word set;
[0148] Filtering the de-redundant text by the homophonic word indexer to obtain a fourth sensitive word set;
[0149] The first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set are deduplicated and merged to obtain a total sensitive word set.
[0150] In one embodiment, when implementing the step of building a homophonic word library corresponding to the sensitive word library, the processor 502 specifically implements the following steps:
[0151] Obtaining the pinyin of the sensitive words in the sensitive word library;
[0152] The pinyin of the sensitive words in the sensitive word library is used as a homophonic sensitive word, and the homophonic sensitive word is stored in a preset blank database to obtain the homophonic word library.
[0153] In one embodiment, when the processor 502 implements the step of respectively constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library, the processor 502 specifically implements the following steps:
[0154] Use a double array tire tree to construct a sensitive word indexer corresponding to the sensitive word library;
[0155] A homophonic word indexer corresponding to the homophonic word library is constructed using a double array tire tree.
[0156] In one embodiment, when the processor 502 implements the step of filtering the test text by the homophonic word indexer to obtain the third sensitive word set, the processor 502 specifically implements the following steps:
[0157] Converting Chinese characters in the text to be tested into pinyin to obtain a homophonic text to be tested;
[0158] The homophonic text to be tested is filtered by the homophonic word indexer to obtain a first homophonic sensitive word set;
[0159] Acquire words in the test text corresponding to the homophonic sensitive words in the first homophonic sensitive word set to obtain the third sensitive word set.
[0160] In one embodiment, when the processor 502 implements the step of filtering the de-redundant text by the homophonic word indexer to obtain the fourth sensitive word set, the processor 502 specifically implements the following steps:
[0161] Converting Chinese characters in the de-redundant text into pinyin to obtain a de-redundant homophonic text;
[0162] Filtering the de-redundant homophonic text by the homophonic word indexer to obtain a second homophonic sensitive word set;
[0163] Acquire words in the de-redundant text that correspond to the homophonic sensitive words in the second homophonic sensitive word set to obtain the fourth sensitive word set.
[0164] In one embodiment, when the processor 502 implements the step of obtaining a sensitive word library from a preset sensitive word server, the processor 502 specifically implements the following steps:
[0165] If a sensitive word library update reminder message sent by the sensitive word server is received, a download address of an updated sensitive word library is obtained from the sensitive word library update reminder message, wherein the sensitive word library update reminder message includes the download address; and the updated sensitive word library is downloaded from the download address.
[0166] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0167] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0168] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program. When the computer program is executed by a processor, the processor executes the following steps:
[0169] Obtain the sensitive word library from the preset sensitive word server;
[0170] Constructing a homophonic word library corresponding to the sensitive word library;
[0171] Constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively;
[0172] If a text to be tested is received, the text to be tested is filtered by the sensitive word indexer to obtain a first sensitive word set;
[0173] Removing non-Chinese characters from the text to be tested to obtain a de-redundant text, and filtering the de-redundant text through the sensitive word indexer to obtain a second sensitive word set;
[0174] Filtering the text to be tested by the homophonic word indexer to obtain a third sensitive word set;
[0175] Filtering the de-redundant text by the homophonic word indexer to obtain a fourth sensitive word set;
[0176] The first sensitive word set, the second sensitive word set, the third sensitive word set and the fourth sensitive word set are deduplicated and merged to obtain a total sensitive word set.
[0177] In one embodiment, when the processor executes the computer program to implement the step of building a homophonic word library corresponding to the sensitive word library, the processor specifically implements the following steps:
[0178] Obtaining the pinyin of the sensitive words in the sensitive word library;
[0179] The pinyin of the sensitive words in the sensitive word library is used as a homophonic sensitive word, and the homophonic sensitive word is stored in a preset blank database to obtain the homophonic word library.
[0180] In one embodiment, when the processor executes the computer program to implement the steps of respectively constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library, the processor specifically implements the following steps:
[0181] Use a double array tire tree to construct a sensitive word indexer corresponding to the sensitive word library;
[0182] A homophonic word indexer corresponding to the homophonic word library is constructed using a double array tire tree.
[0183] In one embodiment, when the processor executes the computer program to implement the step of filtering the test text by the homophonic word indexer to obtain the third sensitive word set, the processor specifically implements the following steps:
[0184] Converting Chinese characters in the text to be tested into pinyin to obtain a homophonic text to be tested;
[0185] The homophonic text to be tested is filtered by the homophonic word indexer to obtain a first homophonic sensitive word set;
[0186] Acquire words in the test text corresponding to the homophonic sensitive words in the first homophonic sensitive word set to obtain the third sensitive word set.
[0187] In one embodiment, when the processor executes the computer program to implement the step of filtering the de-redundant text by the homophonic word indexer to obtain the fourth sensitive word set, the processor specifically implements the following steps:
[0188] Converting Chinese characters in the de-redundant text into pinyin to obtain a de-redundant homophonic text;
[0189] Filtering the de-redundant homophonic text by the homophonic word indexer to obtain a second homophonic sensitive word set;
[0190] Acquire words in the de-redundant text that correspond to the homophonic sensitive words in the second homophonic sensitive word set to obtain the fourth sensitive word set.
[0191] In one embodiment, when the processor executes the computer program to implement the step of obtaining a sensitive word library from a preset sensitive word server, the processor specifically implements the following steps:
[0192] If a sensitive word library update reminder message sent by the sensitive word server is received, a download address of an updated sensitive word library is obtained from the sensitive word library update reminder message, wherein the sensitive word library update reminder message includes the download address; and the updated sensitive word library is downloaded from the download address.
[0193] The storage medium is a physical, non-transient storage medium, for example, it can be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, etc., which can store program codes.
[0194] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0195] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0196] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention 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.
[0197] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0198] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0199] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0200] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A sensitive word detection method, characterized in that: include: Obtain the sensitive word library from the preset sensitive word server; Constructing a homophonic word library corresponding to the sensitive word library; Constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively; If a text to be tested is received, the text to be tested is filtered by the sensitive word indexer to obtain a first sensitive word set; Removing non-Chinese characters from the text to be tested to obtain a de-redundant text, and filtering the de-redundant text through the sensitive word indexer to obtain a second sensitive word set; Filtering the text to be tested by the homophonic word indexer to obtain a third sensitive word set; Filtering the de-redundant text by the homophonic word indexer to obtain a fourth sensitive word set; De-duplicate and merge the first sensitive word set, the second sensitive word set, the third sensitive word set, and the fourth sensitive word set to obtain a total sensitive word set; The step of constructing a homophonic word library corresponding to the sensitive word library includes: Obtaining the pinyin of the sensitive words in the sensitive word library; Using the pinyin of the sensitive words in the sensitive word library as homophonic sensitive words, and storing the homophonic sensitive words in a preset blank database to obtain the homophonic word library; The step of constructing a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively includes: Use a double array tire tree to construct a sensitive word indexer corresponding to the sensitive word library; Use a double array tire tree to construct a homophonic word indexer corresponding to the homophonic word library; The filtering the text to be tested by the homophonic word indexer to obtain a third sensitive word set includes: Converting Chinese characters in the text to be tested into pinyin to obtain a homophonic text to be tested; The homophonic text to be tested is filtered by the homophonic word indexer to obtain a first homophonic sensitive word set; Acquire words in the test text corresponding to the homophonic sensitive words in the first homophonic sensitive word set to obtain the third sensitive word set; The filtering the de-redundant text by the homophonic word indexer to obtain a fourth sensitive word set includes: Converting Chinese characters in the de-redundant text into pinyin to obtain a de-redundant homophonic text; Filtering the de-redundant homophonic text by the homophonic word indexer to obtain a second homophonic sensitive word set; Acquire words in the de-redundant text that correspond to the homophonic sensitive words in the second homophonic sensitive word set to obtain the fourth sensitive word set.
2. The sensitive word detection method according to claim 1, characterized in that: The step of obtaining a sensitive word library from a preset sensitive word server includes: If a sensitive word library update reminder message sent by the sensitive word server is received, obtaining a download address of an updated sensitive word library from the sensitive word library update reminder message, wherein the sensitive word library update reminder message includes the download address; Download the updated sensitive word library from the download address.
3. A sensitive word detection device, characterized in that: include: A first acquisition unit, used to acquire a sensitive word library from a preset sensitive word server; A first construction unit is used to construct a homophonic word library corresponding to the sensitive word library; A second construction unit is used to construct a sensitive word indexer and a homophonic word indexer according to the sensitive word library and the homophonic word library respectively; A first filtering unit, configured to filter the text to be tested by the sensitive word indexer to obtain a first sensitive word set upon receiving the text to be tested; A second filtering unit, configured to remove non-Chinese characters in the text to be tested to obtain a de-redundant text, and filter the de-redundant text through the sensitive word indexer to obtain a second sensitive word set; A third filtering unit, configured to filter the text to be tested by using the homophonic word indexer to obtain a third sensitive word set; a fourth filtering unit, configured to filter the de-redundant text through the homophonic word indexer to obtain a fourth sensitive word set; a merging unit, configured to remove duplicates from the first sensitive word set, the second sensitive word set, the third sensitive word set, and the fourth sensitive word set and merge them to obtain a total sensitive word set; Wherein, the first building block comprises: A second acquisition unit, used to acquire the pinyin of the sensitive words in the sensitive word library; A storage unit, used for taking the pinyin of the sensitive words in the sensitive word library as homophonic sensitive words, and storing the homophonic sensitive words in a preset blank database to obtain the homophonic word library; The second building block comprises: A third construction unit is used to construct a sensitive word indexer corresponding to the sensitive word library using a double array tire tree; A fourth construction unit is used to construct a homophonic word indexer corresponding to the homophonic word library using a double array tire tree; The third filtering unit comprises: A first conversion unit, used for converting Chinese characters in the text to be tested into pinyin to obtain a homophonic text to be tested; A fifth filtering unit, configured to filter the homophonic text to be tested through the homophonic word indexer to obtain a first homophonic sensitive word set; A third acquisition unit, configured to acquire words in the test text corresponding to the homophonic sensitive words in the first homophonic sensitive word set to obtain the third sensitive word set; The fourth filtering unit comprises: A second conversion unit, used for converting Chinese characters in the de-redundant text into pinyin to obtain a de-redundant homophonic text; a sixth filtering unit, configured to filter the de-redundant homophonic text through the homophonic word indexer to obtain a second homophonic sensitive word set; The fourth acquisition unit is used to acquire words in the de-redundant text corresponding to the homophonic sensitive words in the second homophonic sensitive word set to obtain the fourth sensitive word set.
4. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 2 when executing the computer program.
5. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 2 can be implemented.
