Sensitive word desensitization method and device and medium

By constructing a sensitive word dictionary tree and a state transition table, the problem of limited sensitive word recognition capabilities in the existing technology is solved, the rapid and accurate detection of sensitive words in complex texts is achieved, and the recognition efficiency and flexibility are improved.

CN118734356AInactive Publication Date: 2024-10-01INSPUR ZHUOSHU BIG DATA IND DEV CO LTD

Patent Information

Application Number
CN202410819257.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-10-01
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technology has limited recognition capabilities when identifying sensitive words in complex texts, especially the detection efficiency of new types of sensitive words is low, and rule-based matching methods rely on preset lexicon and rule templates, making it difficult to adapt to large-scale data processing .

Method used

Using the method of sensitive word dictionary tree and state transfer table, by constructing the sensitive word dictionary tree and the state transfer table of the finite state machine, the rapid matching and identification of the text to be detected can be achieved, ensuring the accurate detection of all preset sensitive words and reducing missed detections. and false detections.

Benefits of technology

It improves the efficiency and accuracy of sensitive word detection, is more flexible, can quickly identify and extract sensitive words, adapts to identification tasks with large amounts of data, and reduces invalid comparison operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734356A_ABST
    Figure CN118734356A_ABST
Patent Text Reader

Abstract

The invention discloses a sensitive word desensitization method and device and a medium, and the method comprises the steps: constructing a sensitive word dictionary tree for sensitive words in a sensitive word library according to a character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to one character; according to a tree structure of the sensitive word dictionary tree, constructing a state transition table corresponding to the sensitive words; wherein the state transition table comprises states of the finite-state machine and transition rules between the states; obtaining a to-be-detected text, detecting the to-be-detected text according to the state transition table, performing state transition according to the transition rule when a state matched with the state transition table exists in the to-be-detected text, and extracting a corresponding target sensitive word from the to-be-detected text until the state is transferred to a termination state; and performing desensitization processing on the target sensitive word according to a preset desensitization rule to obtain a processed target sensitive word.
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 desensitization method, device and medium. Background Art

[0002] With the rapid development of information technology, data, as an important asset, plays an increasingly important role in all walks of life. However, sensitive information contained in the data, such as personal identity information, credit card numbers, phone numbers, etc., once leaked, may cause serious losses to individuals and enterprises. Therefore, desensitizing sensitive information has become one of the important measures for data protection. At present, common sensitive word detection methods include keyword matching, regular expression matching, etc. However, this rule-based matching method relies on preset sensitive word libraries and rule templates, and its recognition ability is limited for complex text data and new sensitive word types. Summary of the invention

[0003] In order to solve the above problems, this application proposes a sensitive word desensitization method, including:

[0004] For the sensitive words in the sensitive word library, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character;

[0005] According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed; wherein the state transition table includes the state of a finite state machine and the transition rules between the states;

[0006] Acquire a text to be detected, and detect the text to be detected according to the state transition table, so that when there is a state matching the state transition table in the text to be detected, perform state transition according to the transition rule until the state is transferred to the terminal state, and extract the corresponding target sensitive word from the text to be detected;

[0007] According to the preset desensitization rules, the target sensitive words are desensitized to obtain the processed target sensitive words.

[0008] In one implementation of the present application, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words, specifically including:

[0009] Generate a root node, and generate a corresponding child node for each character in the sensitive word;

[0010] For each sensitive word, a path formed by connecting corresponding sub-nodes is determined according to the character order of each character in the sensitive word, and the path is sequentially connected to the root node to obtain a sensitive word dictionary tree.

[0011] In one implementation of the present application, a state transition table corresponding to the sensitive word is constructed according to the tree structure of the sensitive word dictionary tree, specifically including:

[0012] According to the tree structure of the sensitive word dictionary tree, the sensitive word dictionary tree is traversed, and a corresponding state is generated according to the characters matched by the path from the root node to each child node; wherein the state is used to represent the currently matched character information;

[0013] An identifier corresponding to the state is generated, and a state transition table corresponding to the sensitive word is constructed according to the identifier and characters in the sensitive word.

[0014] In one implementation of the present application, a state transition table corresponding to the sensitive word is constructed according to the identifier and the characters in the sensitive word, specifically including:

[0015] Determining a transition rule between the states according to the character sequence of each character in the sensitive word;

[0016] The identifier is used as a row, and the characters in the sensitive word are used as a column. The identifier and the characters are combined according to the transition rule to construct a state transition table corresponding to the sensitive word.

[0017] In one implementation of the present application, detecting the text to be detected according to the state transition table specifically includes:

[0018] According to the state transition table, a state transition is performed in the process of traversing the characters in the to-be-detected text, so as to determine whether the characters match the child nodes in the sensitive word dictionary tree according to the state reached after the transition;

[0019] If so, the preset matching identification number is updated, and for the current child node where the currently matched character is located, it is determined whether the current child node is a leaf node to determine whether the state has reached the terminal state.

[0020] In one implementation of the present application, for a current child node where a currently matched character is located, determining whether the current child node is a leaf node to determine whether the state has reached a terminal state specifically includes:

[0021] For the current child node where the currently matched character is located, determine whether the current child node is a leaf node;

[0022] If so, the string corresponding to the path from the root node to the current child node is used as the filtered sensitive word, and the preset sensitive word end flag is assigned a value of true;

[0023] A preset matching rule is obtained, and according to the matching rule, it is determined whether the state corresponding to the sensitive word is a termination state.

[0024] In one implementation of the present application, determining whether the state corresponding to the sensitive word is a termination state according to the matching rule specifically includes:

[0025] In the case where the matching rule is a minimum matching rule, determining that the state corresponding to the sensitive word is a termination state, and returning the corresponding matching identification number;

[0026] When the matching rule is a maximum matching rule, the characters in the text to be detected are continuously traversed until a target sensitive word is obtained.

[0027] In one implementation of the present application, the state includes an initial state, an intermediate state corresponding to a child node in the sensitive word dictionary tree, and a terminal state.

[0028] The present application provides a sensitive word desensitization device, the device comprising:

[0029] at least one processor;

[0030] and, a memory communicatively coupled to the at least one processor;

[0031] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:

[0032] For the sensitive words in the sensitive word library, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character;

[0033] According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed; wherein the state transition table includes the state of the finite state machine and the transition rules between the states;

[0034] Obtain the text to be detected, and detect the text to be detected according to the state transition table, so that when there is a state matching the state transition table in the text to be detected, the state transition is performed according to the transition rule until the state is transferred to the terminal state, and the corresponding target sensitive word is extracted from the text to be detected;

[0035] According to the preset desensitization rules, the target sensitive words are desensitized to obtain the processed target sensitive words.

[0036] The embodiment of the present application provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as follows:

[0037] For the sensitive words in the sensitive word library, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character;

[0038] According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed; wherein the state transition table includes the state of the finite state machine and the transition rules between the states;

[0039] Obtain the text to be detected, and detect the text to be detected according to the state transition table, so that when there is a state matching the state transition table in the text to be detected, the state transition is performed according to the transition rule until the state is transferred to the terminal state, and the corresponding target sensitive word is extracted from the text to be detected;

[0040] According to the preset desensitization rules, the target sensitive words are desensitized to obtain the processed target sensitive words.

[0041] The sensitive word desensitization method proposed in this application can bring the following beneficial effects:

[0042] By constructing a sensitive word dictionary tree and a state transition table, it is possible to locate and extract characters in the text to be detected, quickly determine the transfer status of the characters, avoid invalid comparison operations between characters, and effectively improve the detection efficiency of sensitive words. The sensitive word dictionary tree ensures that all preset sensitive words can be accurately detected, reducing the possibility of missed detection and false detection, and improving the accuracy of detection. By updating the sensitive word dictionary tree and the state transition table, sensitive words can be added or deleted more conveniently without making a lot of modifications to the entire detection logic, which is more flexible. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0044] Figure 1 A schematic diagram of a sensitive word desensitization method provided in an embodiment of the present application;

[0045] Figure 2 A schematic diagram of the structure of a sensitive word desensitization device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0047] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0048] like Figure 1 As shown, a sensitive word desensitization method provided in an embodiment of the present application includes:

[0049] S101: for sensitive words in the sensitive word library, construct a sensitive word dictionary tree according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character.

[0050] In the data processing process, the identification and desensitization of sensitive words are key steps to protect user privacy and data security. Although traditional sensitive word identification methods, such as rule-based matching, are simple and easy to implement, they are inefficient and prone to omissions when processing large-scale data or complex texts. In order to improve the efficiency and accuracy of sensitive word identification, an embodiment of the present application proposes a sensitive word fast identification method based on a sensitive word dictionary tree. A sensitive word dictionary tree is a data structure for storing sensitive words, and each node corresponds to a character in a sensitive word. Therefore, when constructing a sensitive word dictionary tree, it is necessary to construct nodes corresponding to characters layer by layer based on the order of characters in the sensitive words.

[0051] Specifically, an empty sensitive word dictionary tree is created, which consists only of a root node, and the root node does not correspond to any character. Then, for each character in the sensitive word, a corresponding child node is generated, and the order between characters determines the connection order between child nodes. Therefore, after obtaining the child nodes corresponding to each character, it is necessary to determine the path connected by the corresponding child nodes for the sensitive words in the sensitive word library according to the character order of each character in the sensitive word. This path passes through the child nodes corresponding to each character until the last character of the sensitive word. The paths corresponding to each sensitive word are connected to the root node in turn, and the sensitive words in the sensitive word library can be completely represented as a sensitive word dictionary tree. In order to quickly identify the complete sensitive words in the dictionary tree, a mark will be set on the child node corresponding to the last character of the sensitive word, indicating that the node is the end node of the sensitive word. In this way, in the subsequent text matching process, once such a node is traversed, it can be determined that a complete sensitive word has been obtained. By constructing a sensitive word dictionary tree, fast matching and recognition of sensitive words are achieved, and when facing sensitive word recognition tasks with large amounts of data, the processing efficiency can also be significantly improved.

[0052] S102: constructing a state transition table corresponding to the sensitive words according to the tree structure of the sensitive word dictionary tree; wherein the state transition table includes states of a finite state machine and transition rules between states.

[0053] Based on the tree structure of the sensitive word dictionary tree, a state transition table corresponding to sensitive words can be constructed. The state transition table is an implementation of a finite state machine, which includes a finite number of states and transition rules between states, usually represented as a two-dimensional table. The states include initial state, intermediate state and terminal state, where the initial state indicates that no character has been matched yet, corresponding to the root node in the sensitive word dictionary tree, the intermediate state corresponds to the non-root node in the sensitive word dictionary tree, each intermediate state corresponds to a child node in the sensitive word dictionary tree, and the terminal state indicates that a complete sensitive word has been found, corresponding to the leaf node marked as the end node of the sensitive word dictionary tree.

[0054] In one embodiment, according to the tree structure of the sensitive word dictionary tree, the sensitive word dictionary tree is traversed, and the corresponding state is generated according to the characters matched by the path from the root node to each child node. The state is used to represent the character information currently matched. If no character information is matched, the current state remains the initial state. Assuming that the sensitive word is "name", each time a character is traversed, a state will be generated accordingly, such as the initial state, "the state of reaching n", "the state of reaching na", "the state of reaching nam", and the terminal state. Each state needs to be assigned a unique identifier, such as a digital number, a hash value, etc., so as to be referenced in the state transition table. After the identifier is generated, the corresponding state transition table can be constructed according to the identifier and the characters in the sensitive word. The state transition table can efficiently guide the state transition in the text matching process by storing the transition rules between states.

[0055] Specifically, the transition rules between states are determined based on the character order of each character in the sensitive word. For each state, determine whether there is a successor node with a certain character as a child node. If it exists, it means that when the current state matches a certain character, it can be transferred to the state represented by the successor node corresponding to the character. At this time, the transition between the two nodes is a transition rule. The identifier is used as the row of the state transition table and the characters in the sensitive word are used as the column. For each state, all possible characters are traversed, and the identifier and character corresponding to the state are combined according to the transition rule between the two, so as to construct a state transition table based on the combined state transition result. If it is possible to transfer from the current state to another state through a certain character, fill in the identifier corresponding to the target state in the corresponding position of the state transition table; otherwise, it is set to a special value, such as null, -1, etc., indicating that it cannot be transferred or transferred to a default state.

[0056] S103: Obtain the text to be detected, and detect the text to be detected according to the state transition table. When there is a state in the text to be detected that matches the state transition table, the state transition is performed according to the transition rule until the state is transferred to the terminal state, and the corresponding target sensitive word is extracted from the text to be detected.

[0057] After the state transition table is constructed, the text to be detected can be detected according to this table to identify sensitive words in the text to be detected. The text to be detected can be text entered by the user, or text read from a file or database, etc. The state transition table indicates the transfer direction corresponding to each character in the text to be detected. When there is a state matching the text to be detected in the state transition table, the state can be transferred until the terminal state where the complete sensitive word is identified is reached, and the corresponding target sensitive word can be extracted.

[0058] Specifically, when the detection starts, the state is initialized to the initial state in the state transition table. The characters in the text to be detected are read in sequence, and the corresponding transfer results are searched in the state transition table according to the current state and the read characters. According to the state transition table, the current state is updated to the state indicated by the transfer result. According to the state reached after the transfer, it is judged whether the current character matches the child node in the sensitive word dictionary tree. This process can be completed by checking whether there is a valid state identifier in the corresponding position in the state transition table. If the current character matches the child node in the sensitive word dictionary tree, the matching identification number is updated, and the matching identification number is added by 1, so as to count the currently filtered sensitive words. For the current child node where the currently matched character is located, check whether it is a leaf node, that is, the end node of the sensitive word. If the current child node is a leaf node, it means that the terminal state of a sensitive word has been reached. At this time, the string corresponding to the path between the root node and the current child node is used as the filtered sensitive word, and the preset sensitive word end identification bit is assigned to true.

[0059] Although the complete sensitive word is obtained at this time, there may be continuous fragment-type sensitive words in the text to be detected. It is impossible to directly determine whether the state corresponding to the sensitive word is the terminal state. It is necessary to further determine the state at this time according to the preset matching rules. Under the minimum matching rule, once a matching sensitive word fragment is found, it will stop immediately and return the fragment. Therefore, the state at this time becomes the terminal state, and the matching identifier number corresponding to the sensitive word matched at this time needs to be returned, and the corresponding sensitive word is extracted from the text to be detected. Under the maximum matching rule, it will try to match the longest sensitive word fragment as possible. When a leaf node is reached, the characters in the text to be detected will continue to be traversed to try to obtain a longer sensitive word fragment. Until the entire text is traversed or no longer sensitive word fragment can be found, the longest target sensitive word and the corresponding matching identifier number are returned. For example, when the text to be detected contains the word "sexual", when the sensitive word "sex" is matched, it is necessary to decide whether the sensitive word finally extracted is "sex" or "sexual" according to the matching rules. When the matching rule is the minimum rule, the target sensitive word is "sex", and when the matching rule is the maximum rule, it is necessary to extract the longest possible sensitive word fragment "sexual" as the target sensitive word.

[0060] S104: Desensitizing the target sensitive word according to a preset desensitization rule to obtain a processed target sensitive word.

[0061] When the target sensitive words are identified in the text to be detected, they need to be desensitized according to the desensitization rules based on the actual desensitization requirements. Common desensitization rules involve replacing sensitive words with some placeholders, asterisks (*) or other marks to ensure that sensitive information is not directly exposed. By desensitizing the target sensitive words, important information can be effectively protected from being leaked and data security can be improved.

[0062] The above are embodiments of the method proposed in this application. Based on the same idea, some embodiments of this application also provide devices and non-volatile computer storage media corresponding to the above methods.

[0063] Figure 2 This is a schematic diagram of the structure of a sensitive word desensitization device provided in an embodiment of the present application. Figure 2 As shown, including:

[0064] at least one processor; and,

[0065] at least one processor is communicatively connected to a memory; wherein,

[0066] The memory stores instructions executable by at least one processor, the instructions being executed by at least one processor to enable the at least one processor to:

[0067] For the sensitive words in the sensitive word library, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character;

[0068] According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed; wherein the state transition table includes the state of the finite state machine and the transition rules between the states;

[0069] Obtain the text to be detected, and detect the text to be detected according to the state transition table, so that when there is a state matching the state transition table in the text to be detected, the state transition is performed according to the transition rule until the state is transferred to the terminal state, and the corresponding target sensitive word is extracted from the text to be detected;

[0070] According to the preset desensitization rules, the target sensitive words are desensitized to obtain the processed target sensitive words.

[0071] The embodiment of the present application provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as follows:

[0072] For the sensitive words in the sensitive word library, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character;

[0073] According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed; wherein the state transition table includes the state of the finite state machine and the transition rules between the states;

[0074] Obtain the text to be detected, and detect the text to be detected according to the state transition table, so that when there is a state matching the state transition table in the text to be detected, the state transition is performed according to the transition rule until the state is transferred to the terminal state, and the corresponding target sensitive word is extracted from the text to be detected;

[0075] According to the preset desensitization rules, the target sensitive words are desensitized to obtain the processed target sensitive words.

[0076] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0077] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.

[0078] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0079] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0080] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0081] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0082] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0083] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0084] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0085] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0086] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A sensitive word desensitization method, characterized in that: The method comprises: For sensitive words in the sensitive word library, a sensitive word dictionary tree is constructed according to the character sequence corresponding to the sensitive words; wherein each node in the sensitive word dictionary tree corresponds to a character; According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed; wherein the state transition table includes the state of a finite state machine and the transition rules between the states; Acquire a text to be detected, and detect the text to be detected according to the state transition table, so that when there is a state matching the state transition table in the text to be detected, perform state transition according to the transition rule until the state is transferred to the terminal state, and extract the corresponding target sensitive word from the text to be detected; According to the preset desensitization rules, the target sensitive words are desensitized to obtain the processed target sensitive words.

2. A sensitive word desensitization method according to claim 1, characterized in that: According to the character sequence corresponding to the sensitive words, a sensitive word dictionary tree is constructed, which specifically includes: Generate a root node, and generate a corresponding child node for each character in the sensitive word; For each sensitive word, a path formed by connecting corresponding sub-nodes is determined according to the character order of each character in the sensitive word, and the path is sequentially connected to the root node to obtain a sensitive word dictionary tree.

3. A sensitive word desensitization method according to claim 1, characterized in that: According to the tree structure of the sensitive word dictionary tree, a state transition table corresponding to the sensitive word is constructed, specifically including: According to the tree structure of the sensitive word dictionary tree, the sensitive word dictionary tree is traversed, and a corresponding state is generated according to the characters matched by the path from the root node to each child node; wherein the state is used to represent the currently matched character information; An identifier corresponding to the state is generated, and a state transition table corresponding to the sensitive word is constructed according to the identifier and characters in the sensitive word.

4. A sensitive word desensitization method according to claim 1, characterized in that: According to the identifier and the characters in the sensitive word, a state transition table corresponding to the sensitive word is constructed, specifically including: Determining a transition rule between the states according to the character sequence of each character in the sensitive word; The identifier is used as a row, and the characters in the sensitive word are used as a column. The identifier and the characters are combined according to the transition rule to construct a state transition table corresponding to the sensitive word.

5. A sensitive word desensitization method according to claim 1, characterized in that: Detecting the text to be detected according to the state transition table specifically includes: According to the state transition table, a state transition is performed in the process of traversing the characters in the to-be-detected text, so as to determine whether the characters match the child nodes in the sensitive word dictionary tree according to the state reached after the transition; If so, the preset matching identification number is updated, and for the current child node where the currently matched character is located, it is determined whether the current child node is a leaf node to determine whether the state has reached the terminal state.

6. A sensitive word desensitization method according to claim 5, characterized in that: For the current child node where the currently matched character is located, determining whether the current child node is a leaf node to determine whether the state has reached the terminal state specifically includes: For the current child node where the currently matched character is located, determine whether the current child node is a leaf node; If yes, the string corresponding to the path from the root node to the current child node is used as the filtered sensitive word, and the preset sensitive word end flag is assigned a value of true; A preset matching rule is obtained, and according to the matching rule, it is determined whether the state corresponding to the sensitive word is a termination state.

7. A sensitive word desensitization method according to claim 6, characterized in that: According to the matching rule, determining whether the state corresponding to the sensitive word is a termination state specifically includes: In the case where the matching rule is a minimum matching rule, determining that the state corresponding to the sensitive word is a termination state, and returning the corresponding matching identification number; When the matching rule is a maximum matching rule, the characters in the text to be detected are continuously traversed until a target sensitive word is obtained.

8. A sensitive word desensitization method according to claim 1, characterized in that: The states include an initial state, an intermediate state corresponding to a child node in the sensitive word dictionary tree, and a terminal state.

9. A sensitive word desensitization device, characterized in that: The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a sensitive word desensitization method as described in any one of claims 1-8.

10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured to: A sensitive word desensitization method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Sensitive word filtering method based on text content

    CN107463666A

Cited By

  • Sensitive ship determination method and device and readable storage medium

    CN122364695A

  • Method, device and readable storage medium for determining sensitive ship

    CN122364695B