Method, device, setting and storage medium for detecting sensitive strings
By utilizing the first character of sensitive words and target identifiers in the prefix tree, combined with various extension methods and whitelist verification, the problem of low efficiency in sensitive string detection is solved, achieving efficient and accurate identification of sensitive information and improving the security of business processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-06-29
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, the detection efficiency of sensitive information is low, especially in long texts where it is difficult to efficiently identify sensitive strings, which affects the efficiency and security of business processing.
By employing a prefix tree structure, the first character of a sensitive word is used as a child node of the root node, and the end of the sensitive string is marked by a target identifier. This enables the rapid location of the beginning and end characters of the sensitive string. Multiple extension forms are combined to cover possible sensitive strings, and whitelists and word segmentation models are used for verification to improve detection accuracy.
It improves the efficiency and accuracy of sensitive string detection, reduces the false detection rate, and enhances the processing efficiency and security of sensitive information.
Smart Images

Figure CN116756382B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text processing, and provides a method, apparatus, setup, and storage medium for detecting sensitive strings. Background Technology
[0002] With the deepening of informatization and digitalization on the internet, while providing convenience to people's lives, an increasing amount of sensitive information, including unhealthy or personal information-related content, frequently appears unrestricted in various corners of cyberspace. Especially in specific fields, when this sensitive information is mixed with business information and enters the relevant systems for processing along with it through the network, it actually increases the difficulty of processing business information. For example, the processing and protection of personal information in the financial sector.
[0003] However, due to the large volume of sensitive information, searching for sensitive words in the text to be detected based on a pre-set sensitive word database is inefficient, especially with long texts. Currently, sensitive information detection is a prerequisite for business operations in the industry, enabling the effective protection or filtering of sensitive information in specific business scenarios. Therefore, there is an urgent need for a method that can efficiently detect sensitive strings in text. Summary of the Invention
[0004] This invention provides a method, apparatus, setup, and storage medium for detecting sensitive strings, thereby improving the efficiency of detecting sensitive words in text.
[0005] Firstly, embodiments of this application provide a method for detecting sensitive strings, including:
[0006] Obtain the text to be detected and its prefix tree; wherein the prefix tree includes a target path, the starting point of the target path is a child node of the root node of the prefix tree, and the ending point of the target path is a node containing a target identifier;
[0007] In response to a match between a target string in the text to be detected and a node string in the target path, the target string is determined to be the sensitive string; wherein, the node characters in the node string correspond one-to-one with the nodes on the target path.
[0008] One possible implementation, in response to a match between a target string in the text to be detected and a node string of the target path, determining the target string as the sensitive string includes:
[0009] In response to a match between a first character in the text to be detected and a first node character in the prefix tree, a second node character corresponding to a second character in the text to be detected is determined among the child nodes of the first node; wherein, the first node corresponding to the first node character is a child node of the root node in the prefix tree; and the second character is a character read sequentially after the first character.
[0010] In response to the second node corresponding to the second node character containing the target identifier, the first target string composed of the first character and the second character is determined to be the sensitive string.
[0011] One possible implementation, wherein the step of determining the first target string composed of the first character and the second character as the sensitive string in response to the second node corresponding to the second node character containing the target identifier, includes:
[0012] In response to the first node not containing the target identifier and the second node containing the target identifier, the first target string is determined to be the sensitive string.
[0013] In one possible implementation, after determining that the first target string composed of the first character and the second character is the sensitive string in response to the second node corresponding to the second node character containing the target identifier, the method further includes:
[0014] In response to the second node containing the target identifier and the second node being a non-leaf node, a third node character matching the third character in the text to be detected is determined among the child nodes of the second node; wherein, the third character is a character read sequentially after the second character;
[0015] In response to the fact that the third node corresponding to the third node character contains the target identifier, and the third node is a leaf node, the second target string composed of the first character, the second character, and the third character is determined to be the sensitive string.
[0016] In one possible implementation, after determining that the first target string composed of the first character and the second character is the sensitive string in response to the second node corresponding to the second node character containing the target identifier, the method further includes:
[0017] In response to the second node containing the target identifier and the second node being a leaf node, a fourth node character matching the second character is determined among the child nodes of the root node; wherein the fourth node character corresponds to the fourth node;
[0018] In the text to be detected, the fourth character following the second character is read sequentially, and in the prefix tree, the fifth node character matching the fourth character is determined, as well as whether the fifth node corresponding to the fifth node character contains the target identifier; wherein, the fifth node is a child node of the fourth node;
[0019] If so, the third target string formed by the second character and the fourth character is determined to be the sensitive string.
[0020] In one possible implementation, after determining that the first target string composed of the first character and the second character is the sensitive string in response to the second node corresponding to the second node character containing the target identifier, the method further includes:
[0021] In response to the second node containing the target identifier and the second node being a leaf node, a sixth node character matching the fifth character in the text to be detected is determined among the child nodes of the root node; wherein the fifth character is a character read sequentially after the second character; the sixth node character corresponds to the sixth node;
[0022] Determine whether the sixth node contains the target identifier; if so, determine that the fourth target string composed of the fifth character is the sensitive string.
[0023] One possible implementation, wherein reading a second character adjacent to and following the first character, further includes:
[0024] In response to the fact that the second character does not match any of the child nodes of the first node, the first target character is determined to be a non-sensitive character.
[0025] In one possible implementation, the node characters in the prefix tree are sensitive characters in the sensitive string; the type of the node characters includes: Chinese characters corresponding to the sensitive characters, the first letter sequence corresponding to the sensitive characters, or the second letter sequence corresponding to the sensitive string;
[0026] The second letter sequence is composed of sub-sequences corresponding to the sensitive character, and the first letter sequence and the sub-sequences indicate: the full pinyin spelling of the sensitive character, the first letter of the pinyin spelling of the sensitive character, or the English word of the sensitive character.
[0027] In one possible implementation, the text to be detected is the text obtained by filtering the text to be processed based on phrases in a preset whitelist; the text to be detected does not contain the phrases in the preset whitelist.
[0028] After determining that the target string is the sensitive string, the method further includes:
[0029] Determine whether the text to be processed contains the sensitive string; if not, determine that the sensitive string is a non-sensitive string marked as an error.
[0030] One possible implementation, after determining that the target string is the sensitive string, further includes:
[0031] The text to be processed is segmented using a preset word segmentation model to obtain a word segmentation set; wherein, the text to be processed is the original text of the text to be detected;
[0032] In response to a segment of a keyword group in the word segmentation set being identified as a sensitive string, the sensitive string is determined to be a non-sensitive string that has been incorrectly flagged.
[0033] Secondly, embodiments of this application provide an apparatus for detecting sensitive strings, comprising:
[0034] An acquisition unit is used to acquire the text to be detected and a prefix tree; wherein the prefix tree includes a target path, the starting point of the target path is a child node of the root node of the prefix tree, and the ending point of the target path is a node containing a target identifier;
[0035] A matching unit is configured to determine the target string as the sensitive string in response to a match between the target string in the text to be detected and the node string of the target path; wherein the node characters in the node string correspond one-to-one with the nodes on the target path.
[0036] In one possible implementation, the matching unit is specifically configured to, in response to a first character in the text to be detected matching a first node character in the prefix tree, determine a second node character in the child nodes of the first node that corresponds to a second character in the text to be detected; wherein, the first node corresponding to the first node character is a child node of the root node in the prefix tree; the second character is a character read sequentially after the first character; and in response to the second node corresponding to the second node character containing the target identifier, determine the first target string composed of the first character and the second character as the sensitive string.
[0037] In one possible implementation, the matching unit is specifically configured to, in response to the second node containing the target identifier and the second node being a non-leaf node, determine a third node character among the child nodes of the second node that matches the third character in the text to be detected; wherein the third character is a character read sequentially after the second character; and in response to the third node corresponding to the third node character containing the target identifier and the third node being a leaf node, determine the second target string composed of the first character, the second character, and the third character as the sensitive string.
[0038] In one possible implementation, the matching unit is further configured to, in response to the second node containing the target identifier and the second node being a leaf node, determine a fourth node character matching the second character among the child nodes of the root node; wherein the fourth node character corresponds to the fourth node; in the text to be detected, sequentially read the fourth character located after the second character, and in the prefix tree, determine a fifth node character matching the fourth character, and whether the fifth node corresponding to the fifth node character contains the target identifier; wherein the fifth node is a child node of the fourth node; if so, determine the third target string composed of the second character and the fourth character as the sensitive string.
[0039] In one possible implementation, the matching unit is specifically configured to, in response to the second node containing the target identifier and the second node being a leaf node, determine a sixth node character among the child nodes of the root node that matches the fifth character in the text to be detected; wherein the fifth character is a character read sequentially after the second character; the sixth node character corresponds to the sixth node; determine whether the sixth node contains the target identifier; if so, determine the fourth target string composed of the fifth character as the sensitive string.
[0040] In one possible implementation, the node characters in the prefix tree are sensitive characters in the sensitive string; the type of the node characters includes: Chinese characters corresponding to the sensitive characters, a first letter sequence corresponding to the sensitive characters, or a second letter sequence corresponding to the sensitive string; wherein, the second letter sequence is composed of a subsequence corresponding to the sensitive characters, and the first letter sequence and the subsequence indicate: the full pinyin spelling of the sensitive characters, the first letter of the pinyin spelling of the sensitive characters, or the English word of the sensitive characters.
[0041] In one possible implementation, the text to be detected is the text obtained by filtering the text to be processed based on phrases in a preset whitelist; if the text to be detected does not contain the phrases in the preset whitelist, then the device further includes a first unit, the first unit being used to determine whether the text to be processed includes the sensitive string; if not, the sensitive string is determined to be a non-sensitive string marked with an error.
[0042] In one possible implementation, the device further includes a second unit, which is used to segment the text to be processed using a preset word segmentation model to obtain a word segmentation set; wherein the text to be processed is the original text of the text to be detected; and in response to the fact that a fragment of a keyword group in the word segmentation set is the sensitive string, the sensitive string is determined to be a non-sensitive string marked with an error.
[0043] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor.
[0044] When the processor executes the computer program, it implements the steps of the method described in the first aspect and any possible implementation.
[0045] Fourthly, embodiments of this application provide a computer storage medium on which a computer program is stored.
[0046] When the computer program is executed by a processor, it implements the steps of the method described in the first aspect and any possible implementation.
[0047] Fifthly, embodiments of this application provide a computer program product, including a computer program.
[0048] When the computer program is executed by a processor, it implements the steps of the method described in the first aspect and any possible implementation.
[0049] The one or more technical solutions provided in the embodiments of this application have at least the following technical effects:
[0050] First, by setting the child nodes of the root node in the prefix tree to the first character of each sensitive word, when detecting sensitive strings in the text to be detected, the first character only needs to traverse the child nodes of the root node, thereby reducing the number of characters that need to be traversed for each character, instead of traversing all characters in the sensitive word database one by one, thus improving detection efficiency. Furthermore, by using the target identifier contained in the nodes of the prefix tree as the marker for the end of the sensitive string, and through the child nodes of the root node in the prefix tree, the target identifier, and the tree structure of the prefix tree, using the target path in the prefix tree as the matching unit, the starting and ending characters of the sensitive string can be quickly located, and the sensitive string can be efficiently identified.
[0051] Secondly, by setting node characters instead of phrases or chunks in each node of the prefix tree, the granularity of the characters on each node is reduced to a single Chinese character, making the settings in the prefix tree more flexible and reducing the number of nodes at each level. Therefore, this enables efficient detection of sensitive strings.
[0052] Furthermore, in this embodiment of the application, different extended words are set for each sensitive word according to various extended forms to achieve comprehensive coverage of sensitive strings that may be contained in the text to be detected, thereby improving the accuracy of the detection results.
[0053] Finally, the whitelist filtering and scene restoration methods and word segmentation methods set in the embodiments of this application not only solve the problem of decreased detection accuracy caused by the use of whitelists or word segmentation models to process the text to be tested in the prior art, but also further improve the detection results of sensitive strings.
[0054] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the application. The purposes and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not intended to limit this disclosure. Attached Figure Description
[0055] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0056] Figure 1 A flowchart illustrating a method for detecting sensitive strings provided in an embodiment of this application;
[0057] Figure 2 A schematic diagram of a prefix tree provided for an embodiment of this application;
[0058] Figure 3 A schematic diagram illustrating a method for detecting sensitive strings provided in an embodiment of this application;
[0059] Figure 4 This application provides a schematic diagram of a structure for obtaining a subscription thesaurus based on a sensitive word database, as shown in the embodiments of this application.
[0060] Figure 5 A schematic diagram of the structure of a device for detecting sensitive strings provided in an embodiment of this application;
[0061] Figure 6 This is a schematic diagram of the structure of an electronic device for detecting sensitive strings, provided in an embodiment of this application. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0063] The terms "first" and "second" in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more, and the embodiments of this application do not impose limitations.
[0064] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.
[0065] Please refer to Figure 1 This application provides a method for detecting sensitive strings to improve the efficiency of sensitive word detection. The specific steps of this method are as follows:
[0066] Step 101: Obtain the text to be detected and its prefix tree.
[0067] The prefix tree includes the target path, where the starting point of the target path is the child node of the root node in the prefix tree, and the ending point of the target path is the node containing the target identifier.
[0068] The characters in the text to be detected, as well as the characters in the aforementioned sensitive strings, include letters and / or Chinese characters. The text to be detected may also include special characters, such as numbers, or other symbols; for example, &*, etc.
[0069] None of the characters in the embodiments of this application include the aforementioned special characters. When such special characters appear in the text to be detected, they can be directly skipped without processing, and the reading and processing of the next character can continue. The above prefix tree corresponds to the usage scenario of the text to be detected (for example, it can be a business scenario).
[0070] The prefix tree is a multi-fork tree structure composed of multiple paths and nodes. The last node of each path is a leaf node. The nodes of each path are sequentially connected to form one or more sensitive words. Figure 2 This is a schematic structural diagram of a prefix tree provided by the embodiments of this application. The following provides a detailed description of the prefix tree and its settings:
[0071] As Figure 2 shown, the prefix tree includes a unique and common root node: the root node. The child nodes of this root node are the starting points of each path. Each path contains multiple sensitive words, and each node stores or indicates a single Chinese character in the sensitive word separately. The first character in the sensitive word corresponds to the character on the child node of the root node in the prefix tree.
[0072] Assume that "Chongqing Hot Pot" and "Chongqing" are two sensitive words. Please continue to refer to Figure 2 , it can be seen that the target paths can partially overlap, presenting a relationship where one target path is included in another target path. Moreover, the last character in the sensitive word corresponds to the node with the target identifier in the prefix tree. This target identifier can be "F".
[0073] Furthermore, in order to achieve comprehensive detection of sensitive words, the sensitive words in the prefix tree include basic sensitive words and extended words of the basic sensitive words. The extended methods include but are not limited to the following several provided by the embodiments of this application. The following takes "Chongqing" as the basic word for example:
[0074] First, perform deformation extension on the basic word and add a deformation extension mark to the word extended based on this method.
[0075] In some embodiments, traditional Chinese, full pinyin, or simple pinyin, or a combination of full pinyin and simple pinyin, or a combination of full pinyin and / or simple pinyin and Chinese characters can be used. For example, "Chongqing", "CQ", "C Qing", etc.
[0076] Second, perform homophone extension on the basic word and add a homophone extension mark to the word extended based on this method.
[0077] In some embodiments, the single character can be converted into pinyin, and the pinyin obtained by conversion can be used to determine homophone characters, and homophone extended words can be constructed with other single characters. For example, "重磬".
[0078] Third, perform synonymous expansion on the basic word and add a marker for synonymous expansion to the words expanded based on this method.
[0079] In some embodiments, a thesaurus can be combined to first construct synonyms of the basic word; then, perform deformation expansion and homophonic expansion on the synonyms. For example, "Mountain City", "SC", "Fog City", "wudu".
[0080] Fourth, perform homomorphic expansion on the basic word and add a marker for homomorphic expansion to the words expanded based on this method.
[0081] In some embodiments, the single characters in the basic word can be first divided into two categories: single-component characters and compound characters.
[0082] Among them, single-component characters are characters composed of strokes, such as "month", "concave", etc.; compound characters contain radical structures. According to the upper-lower structure, left-right, inside-outside, framework or single-component structure of each single character in the sensitive word, split the single character to obtain homomorphic expansion words of the basic word. For example, "Chongqing" is expanded to "Chong Guang Da". Another example is to expand "kick" to "foot easy".
[0083] Therefore, the construction of sensitive words includes the basic word and one or more expanded words obtained through homophonic expansion, synonymous expansion, homomorphic expansion or deformation expansion.
[0084] The node characters on each node in the prefix tree are the sensitive characters in the sensitive string, but the manifestation forms of each node character are not limited to English, Chinese single characters or pinyin combinations, and the types of each node character can include: Chinese characters corresponding to the sensitive characters (that is, single characters in the sensitive word), the first letter sequence corresponding to the sensitive characters, or the second letter sequence corresponding to the sensitive string.
[0085] Among them, the second letter sequence is composed of subsequences corresponding to the sensitive characters (that is, the aforementioned Chinese single characters), and the first letter sequence and the subsequence respectively indicate the full pinyin, the first letter of the pinyin, or the English word of the sensitive character corresponding to them. The second letter sequence can also be the English word or phrase corresponding to the sensitive string as a whole.
[0086] That is to say, the node characters on each node in the prefix tree can be divided into two categories, one is simplified or traditional Chinese, and the other is English and pinyin. When the node character is a Chinese character, the character is divided with a single Chinese character as the smallest granularity, and there is only 1 Chinese character on each node; when the node character is a letter, it is no longer divided with a single Chinese character as the smallest granularity, but from the appearance of the first letter to the end of the last letter. The special characters that do not need to be processed can be included between the first letter and the last letter, but Chinese characters are not included. The letter sequence obtained by splicing the first letter to the last letter does not necessarily correspond to a certain Chinese character; continue to refer to Figure 2 In a prefix tree, consecutive letters are treated as a single node, for example, the abbreviation of "Chongqing" is "CQ". The abbreviation mentioned above refers to the initial letter abbreviation of the pinyin.
[0087] Step 102: In response to the matching of the target string in the text to be detected with the node string of the target path, determine that the target string is a sensitive string.
[0088] In this context, each node character in the node string corresponds one-to-one with a node on the target path.
[0089] Specifically, the target path mentioned above is the target path in the prefix tree. Matching the target string with the node string actually means that the characters in the target string are matched one by one with the node characters on the target path. Therefore, it is necessary to first read the characters to be detected sequentially in the text to be detected and match them with the node characters in the prefix tree. Each time a match is successful, it is determined whether the node contains a target identifier to determine whether the end of a target path has been reached, so as to identify the sensitive string in the text to be detected in time. If there is no target identifier, or if there is a target identifier but it is not a leaf node, the next character in the text to be detected is read sequentially, and the next character is matched in the child nodes of the matched node. If the match fails in the child nodes of the aforementioned node, it is determined that the current character to be detected is not a character in the target string, and the next character is read, and the multiple child nodes of the root node are traversed again to perform the next match: to determine the node character that uniquely matches the next character.
[0090] Because the prefix tree sets multiple possible forms corresponding to sensitive words (i.e., sensitive strings) at each node, the above matching actually involves traversing the child nodes of the corresponding node to determine whether it contains a node character that matches the character to be detected. If yes, the match is successful; otherwise, the match fails. The starting point of each match is the node character that matches the root node's child nodes in the prefix tree; the ending point of each match is the node character that contains the target identifier.
[0091] Therefore, characters in the text to be detected can be read sequentially. When a special character is encountered, it is skipped, and reading continues. Otherwise, the read characters are matched in the prefix tree: in response to the first character in the text to be detected matching the first node character in the prefix tree, the first character is recorded. Simultaneously, it is determined whether the first node corresponding to the first node character contains the target identifier. If so, the first character is determined to form a sensitive string; otherwise, the next character is read sequentially in the text to be detected and treated as the second character. In the child nodes of the first node in the prefix tree, the second node character corresponding to the second character is determined.
[0092] Wherein, the first node corresponding to the first node character is the child node of the root node in the prefix tree, and the second character is the character read sequentially after the first character.
[0093] If no matching second character is found in the child nodes of the first node, then the second character is used as a new starting character and the matching is performed again with the child nodes of the root node in the prefix tree.
[0094] If a second node character corresponding to the second character is matched in a child node of the first node, thus identifying the second node character corresponding to the second character, it is necessary to determine whether the first node corresponding to the second node containing the second node character contains a target identifier indicating the end of the sensitive word. In other words, in response to the second node containing a target identifier, the first target string composed of the first and second characters is determined to be a sensitive string.
[0095] Subsequently, the position of the second node in the prefix tree can be further determined to determine whether it is a leaf node, in order to avoid missing sensitive strings with inclusion relationships, such as "Chongqing" or "Chongqing hotpot". Specifically, in response to the second node in the prefix tree containing the target identifier and the second node not being a leaf node, the third character following the second character in the text to be detected, which is read sequentially, will continue to be matched in the child nodes of the second node.
[0096] If the match fails, the third character is matched against the child nodes of the root node in the prefix tree.
[0097] If a match is successful, it is determined whether the corresponding node contains the target identifier and its position in the prefix tree. That is, in the child nodes of the second node, the third node character that matches the third character in the text to be detected is determined; in response to the third node corresponding to the third node character containing the target identifier and the third node being a leaf node, the second target string composed of the first character, the second character, and the third character is determined to be the sensitive string.
[0098] At this point, the first and second characters form a set of sensitive strings, and the first, second, and third characters form another set of sensitive strings in the text to be detected. The nodes of the first and second node characters in the prefix tree constitute the first target path, and the nodes of the second, third, and fourth node characters constitute the second target path of the prefix tree.
[0099] In other words, when a node containing a target identifier is found by matching a path in the prefix tree for a character in the text to be detected, the path is first determined to be the target path. The characters on the target path correspond one-to-one with the characters in the target string in the text to be detected, and are therefore sensitive strings. Then, by determining whether the node is a leaf node, it is determined whether to return to the child nodes of the root node to match the next character read in the text to be detected, or to continue matching in the child nodes of the non-leaf node.
[0100] Furthermore, determining whether a matched node is a leaf node also serves to reposition the starting character of the target string. If it is not a leaf node, it means that if the next character matches successfully, the starting character of the new target string is the same as the starting character of the previous target string, and the target path corresponding to the previous target string is part of the new target path. If it is a leaf node, it means that if the next character matches successfully, that next character becomes the new starting character of the new target string.
[0101] It is worth noting that in the process of matching the characters in the text to be detected with the characters in the prefix tree in this embodiment of the application, when encountering letters during reading or traversal, case is not distinguished.
[0102] Furthermore, to avoid missed detections, each time the matching of a target string ends and the next target string is processed, the detection begins from the second character of the newly determined target string; that is, the character after the first character of the previous target string is used as the second character for detection. The starting characters in the text to be detected, i.e., the first and second characters, may or may not contain special characters; they may be consecutive or non-consecutive. However, there are no characters between the starting characters. Therefore, the starting characters of consecutive target strings obtained through sequential detection should be adjacent characters in the text to be detected.
[0103] Therefore, when determining to match newly read characters within the child nodes of the root node of the prefix tree, the matching should begin with the second character in the latest detected target string, i.e., the first character after the first character of the most recently determined sensitive string in the text to be detected. In some embodiments, in response to the second node containing the target identifier and being a leaf node, a fourth node character matching the second character is determined among the child nodes of the root node in the prefix tree. This fourth node character corresponds to the fourth node, which is a child node of the root node of the prefix tree. This fourth node is then recorded as the starting character. Similarly, the fourth character following the second character is sequentially read in the text to be detected and matched in the prefix tree: a fifth node character matching the fourth character is determined, and whether the fifth node corresponding to the fifth node character contains the target identifier is determined. This fifth node is a child node of the fourth node.
[0104] If yes, determine the third target string formed by the second and fourth characters as a sensitive string. If not, match the fourth character with the child nodes of the root node in the prefix tree to start a new round of target string detection.
[0105] In addition, all detected sensitive strings are blurred in the text (e.g., masking). To further improve detection efficiency, when matching the next target string after the previous one ends, the first character after the target string can be directly matched. This ensures that after the target string is blurred, no character or string fragment in the target string can form a sensitive string with subsequent characters, and avoids matching and detecting each character in the target string except for the first character, thus further improving detection efficiency. Specifically, in response to the second node containing the target identifier, after determining that the first character and the second character form the first target string, and that the first target string is the aforementioned sensitive string, in response to the second node containing the target identifier and the second node being a leaf node, the sixth node character matching the fifth character in the text to be detected is determined from the child nodes of the root node in the prefix tree. The fifth character is the character read sequentially after the second character; the sixth node character corresponds to the sixth node. Then, it is determined whether the sixth node contains the target identifier; if so, the fourth target string formed by the fifth character is determined to be a sensitive string. If not, continue with the detection target as described above, that is, sequentially read the characters in the text to be detected after the fifth character and match them with the child nodes of the sixth node until a node containing the target identifier is matched.
[0106] A situation contrary to directly matching the first character after the target string after detecting the target string above is: the target string fails to match; then still backtrack to the second character of the string where the match fails, and use this second character as the first character to match at the root node of the prefix tree. For example, if the target string is "The weather is very cool" and the text to be detected is "The weather is hot", when the character "hot" fails to match, then use "weather" as the first character to match at the root node of the prefix tree again.
[0107] In the embodiments of the present application, the fourth character and the fifth character are named because they are the characters to be matched in the new target string. Actually, the fourth character and the fifth character should be the same character as the third character in the text to be detected, and both are the first characters after the second character. Correspondingly, for the nodes matching the same character, the third node, the fifth node, and the sixth node in the prefix tree are also the same node.
[0108] It is worth proving that, as mentioned above, when reading letters, consecutive letters can be used as a whole character to match in the prefix tree. When ending the matching of the target string and starting to match the next string, the next character determined at this time should be the remaining letters after removing the first letter from the consecutive letters, and the remaining consecutive characters are used as a whole character to match again in the children nodes of the root node in the prefix tree.
[0109] For example; "chongqing", after completing the detection of the target string "chongqing", "hong" should be used as a character to match in the children nodes of the root node of the prefix tree.
[0110] Furthermore, in order to avoid the occurrence of misdetection cases, the embodiments of the present application also provide the following two implementation methods for rechecking whether the aforementioned sensitive strings are sensitive. These two implementation methods can be used independently or in combination, and there is no limit to the order of their use when used in combination.
[0111] Implementation method 1 [[ID=I7]]
[0112] Due to different scenarios, the sensitive characteristics of vocabulary will change. A sensitive word in one scenario may no longer be a sensitive word when used in another scenario. Therefore, the embodiments of the present application set a whitelist for each scenario, and this whitelist is the non-sensitive vocabulary that is easily misjudged in the corresponding scenario.
[0113] In some embodiments, the setting of the whitelist is as follows: first obtain information sample data, and use a word segmentation tool (for example,jieba) to process the sensitive and non-sensitive segments in the information sample data, and incorporate the processed word chunks / phrases into the whitelist; or incorporate the nouns and gerunds in the processed word chunks / phrases into the whitelist.
[0114] In some embodiments, the whitelist is configured as follows: in the corresponding scenario, falsely detected word chunks / phrases are identified and analyzed for inclusion, and word chunks / phrases with a false detection count exceeding the false detection threshold are included in the whitelist.
[0115] In some embodiments, the whitelist is configured to: predict word chunks / phrases that are likely to be misdetected and include them in the whitelist based on the changing patterns / trends of the corresponding scenario.
[0116] Therefore, to improve the accuracy of sensitive word detection results, the text to be detected in step 101 should be preprocessed using the aforementioned preset whitelist. Specifically, the scenario corresponding to the text to be processed and the preset whitelist corresponding to that scenario can be determined first.
[0117] Then, based on the phrases in the preset whitelist, the strings in the text to be processed are filtered to remove non-sensitive strings that are easily misdetected, resulting in the text to be detected that does not contain the phrases in the preset whitelist.
[0118] Furthermore, filtering the text to be processed means directly removing whitelisted phrases from the text. A potential issue is that two characters that were originally whitelisted phrases may become two adjacent characters in the text after filtering. If the string formed by these two adjacent characters, or a string containing these two characters, happens to correspond to a node character on a target path in the prefix tree, it will be incorrectly identified as a sensitive string. Therefore, after step 102, the sensitive word detection result (sensitive string) is reconstructed. Specifically, the sensitive string can be treated as a whole to be detected and searched in the unprocessed original text (the text to be processed) to determine whether the text to be processed contains the sensitive string obtained in step 102.
[0119] If a sensitive string is detected in the text to be processed, meaning the characters in the sensitive string are arranged consecutively in the text to be processed, then the detection of the sensitive string is confirmed to be correct.
[0120] If no sensitive string is detected in the text to be processed, it is determined that the characters in the sensitive string are distributed in a scattered manner rather than arranged continuously. Therefore, the sensitive string is a false detection caused by whitelist filtering, and it is determined that the sensitive string is an incorrectly marked non-sensitive string.
[0121] Implementation Method 2
[0122] First, the text to be processed is segmented using a pre-defined word segmentation model to obtain a set of segmented words.
[0123] Then, the sensitive strings obtained from the foregoing detection are retrieved one by one in the word segmentation set, and the retrieval results include: not retrieved, the sensitive string is a fragment of a phrase in the word segmentation set, the fragment of the sensitive string is a phrase in the word segmentation set, or the sensitive string corresponds to a phrase.
[0124] For the detection result where the sensitive string completely corresponds to a phrase, it is determined that the detection of the sensitive string is correct.
[0125] For those not retrieved, or the fragment of the sensitive string is a phrase in the word segmentation set, these two cases are very likely due to the corpus of the word segmentation model not being updated in time, so no processing is done. For example, when the sensitive character is "Chongqing hot pot", the word segmentation model only detects "Chongqing" and "hot pot".
[0126] For the case where the retrieved sensitive string is a fragment of a phrase in the word segmentation set, for example, when the detected sensitive string is "hot pot" and the corresponding phrase in the word segmentation set is "Chongqing hot pot" and "Chongqing hot pot" is not a sensitive word, it can be determined that the sensitive string is a false detection.
[0127] It can be seen that in order to avoid the influence of low word segmentation accuracy of the word segmentation model based on semantics due to the corpus not being updated in time, after word segmentation, in response to the fragment of the keyword phrase in the word segmentation set being a sensitive string, it is determined that the sensitive string is a non-sensitive string with an incorrect label; in other cases, the detection of the sensitive string is regarded as correct.
[0128] Based on the above two implementation manners, or in combination, the detection results obtained in steps 101 - 102 can be further verified, so as to achieve the purpose of improving the accuracy of the detection results of sensitive strings.
[0129] Further, based on steps 101 - 102, the following takes the preprocessed text to be detected as an example for illustration. Please refer to Figure 3 .
[0130] After starting the detection of sensitive strings, the text to be detected and the corresponding detection parameters are first set. The matched consecutive strings are marked as cmparTxt. Each time a target string or string fragment is matched, the index of the first character of the target string or string fragment in the text to be detected is marked as startcomparIndex. This startcomparIndex is used to mark the starting position of the target string or string fragment in the text to be detected. The word index is used to read characters sequentially in the text to be detected. After each target string match and each string fragment is completed, the index is reset to null. Based on the startcomparIndex and the word index, the character to be matched is named tempChar. The detected sensitive strings are summarized into a sensitive word result set: RET. The nodes that are compared in the prefix tree each time are formed into a node set C, and a matching index cmparIndex is set for each of the detected sensitive strings.
[0131] Subscribe to a prefix tree of a thesaurus that corresponds to the usage scenario of the text to be detected. Please refer to [reference needed]. Figure 4 The sensitive word library contains multiple sensitive words, each corresponding to a base word and extended words with extension tags obtained through corresponding extension methods. After determining the use case, a sensitive word library can be subscribed to. Thus, the subscribed library contains all base words from the sensitive word library, as well as extended words corresponding to the extension strategy for that use case. The prefix tree is configured according to the subscribed library; each node contains a single Chinese character (simplified or traditional), or consecutive letters.
[0132] Simultaneously, the aforementioned parameters are initialized: cmparTxt is set to null; the word extraction index is set to 0; the comparison node set C is set to S, which consists of the child nodes of the root node in the prefix tree; the character to be matched, tempChar, read according to the word extraction index is set to null; and the matching index cmparIndex of the sensitive string is set to 0. In this way, matching and detection can begin from the first character in the text to be detected. The following details the case when index is m:
[0133] Read character 'm' from the text to be tested based on the index, then tempChar = m. Determine if 'm' is a special character; if so, increment the index by 1 and read the characters following 'm' sequentially.
[0134] If it is not a special character, check if it contains `temChar` in node set C. If not, increment the index by 1 and read the characters after `m` sequentially. If it is, first check if the node containing `temChar` contains the reuse identifier `F`.
[0135] If not, first update the matched continuous string cmparTxt with temChar: cmparTxt = cmparTxt + temChar. Then update C with the node set K composed of the child nodes of the node where temChar is located, so that C = K; and index + 1. Read the characters after the text to be detected in sequence and match them with the characters of the nodes in C until startcomparIndex + index is greater than the length of the text to be detected, which determines that the current segment string has not matched a sensitive string; then you can continue to update startcomparIndex: startcomparIndex = startcomparIndex + 1, so that the second character in the segment string becomes the first character and repeats the above matching with the node set C = S, and the subsequent steps, until startcomparIndex is greater than the length of the text to be detected.
[0136] If so, the matched consecutive string cmparTxt is still updated with temChar: cmparTxt = cmparTxt + temChar, and the updated cmparTxt is added to the RET result set as a sensitive string. In addition, the detection strategy is further determined.
[0137] If the detection strategy is fast detection, meaning that sensitive strings are detected and output immediately, then the result set RET is directly output. Conversely, if the detection strategy is full-text detection, then it is further determined whether the temChar node is a leaf node in the prefix tree.
[0138] If not, the word index is incremented by 1, and the characters read based on the index are matched with the node characters of the previously updated node set C (C=K). After a successful match, the aforementioned matching / judgment steps are continued until the index is greater than the text length.
[0139] If so, update startcomparIndex with the length (i.e., Index) of the latest updated cmparTxt: startcomparIndex = startcomparIndex + Index. Then, reset index to 0 and begin a new round of sensitive string matching. Read the first character after the sensitive string from the text to be detected, and perform the aforementioned steps: match sequentially in the C=S node set, and update C using the node set of successfully matched nodes, continuing the matching of the next character until startcomparIndex exceeds the text length. Output the result set RET consisting of sensitive strings detected using the above method.
[0140] Based on the same inventive concept, this application provides a device for detecting sensitive strings, which is similar to the aforementioned device. Figure 1 The method for detecting sensitive strings shown corresponds to the specific implementation of this device, which can be found in the description of the aforementioned method embodiments. Repeated descriptions will not be repeated here. Figure 5 The device includes:
[0141] The acquisition unit 501 is used to acquire the text to be detected and the prefix tree.
[0142] The prefix tree includes a target path, the starting point of which is a child node of the root node of the prefix tree, and the ending point of the target path is a node containing a target identifier.
[0143] The node characters in the prefix tree are the sensitive characters in the sensitive string.
[0144] The types of node characters include: Chinese characters corresponding to the sensitive character, the first letter sequence corresponding to the sensitive character, or the second letter sequence corresponding to the sensitive string.
[0145] The second letter sequence is composed of sub-sequences corresponding to the sensitive character, and the first letter sequence and the sub-sequences indicate: the full pinyin spelling of the sensitive character, the first letter of the pinyin spelling of the sensitive character, or the English word of the sensitive character.
[0146] The matching unit 502 is configured to determine the target string as the sensitive string in response to a match between the target string in the text to be detected and the node string of the target path.
[0147] The node characters in the node string correspond one-to-one with the nodes on the target path.
[0148] The matching unit 502 is specifically used to respond to the first character in the text to be detected being matched with the first node character in the prefix tree, and to determine the second node character corresponding to the second character in the text to be detected in the child nodes of the first node.
[0149] Wherein, the first node corresponding to the first node character is a child node of the root node in the prefix tree.
[0150] The second character is the character read sequentially after the first character; in response to the second node corresponding to the second node character containing the target identifier, the first target string composed of the first character and the second character is determined to be the sensitive string.
[0151] The matching unit 502 is specifically used to, in response to the second node containing the target identifier and the second node being a non-leaf node, determine a third node character that matches the third character in the text to be detected among the child nodes of the second node.
[0152] The third character is the character read sequentially after the second character.
[0153] In response to the fact that the third node corresponding to the third node character contains the target identifier, and the third node is a leaf node, the second target string composed of the first character, the second character, and the third character is determined to be the sensitive string.
[0154] The matching unit 502 is further configured to, in response to the second node containing the target identifier and the second node being a leaf node, determine a fourth node character that matches the second character among the child nodes of the root node. The fourth node character corresponds to a fourth node.
[0155] In the text to be detected, the fourth character following the second character is read sequentially, and in the prefix tree, the fifth node character that matches the fourth character is determined, and whether the fifth node corresponding to the fifth node character contains the target identifier is determined.
[0156] Wherein, the fifth node is a child node of the fourth node; if so, the third target string composed of the second character and the fourth character is determined to be the sensitive string.
[0157] The matching unit 502 is further configured to, in response to the second node containing the target identifier and the second node being a leaf node, determine a sixth node character that matches the fifth character in the text to be detected among the child nodes of the root node.
[0158] Wherein, the fifth character is the character read sequentially after the second character; the sixth node character corresponds to the sixth node; it is determined whether the sixth node contains the target identifier; if so, the fourth target string composed of the fifth characters is determined to be the sensitive string.
[0159] The text to be detected is the text obtained by filtering the text to be processed based on phrases in a preset whitelist; if the text to be detected does not contain the phrases in the preset whitelist, then the device for detecting sensitive strings further includes a first unit, which is used to determine whether the text to be processed includes the sensitive string; if not, the sensitive string is determined to be a non-sensitive string marked with an error.
[0160] The device for detecting sensitive strings further includes a second unit, which is used to segment the text to be processed using a preset word segmentation model to obtain a word segmentation set; wherein the text to be processed is the original text of the text to be detected; in response to the fact that the fragment of the keyword group in the word segmentation set is the sensitive string, the sensitive string is determined to be a non-sensitive string marked with an error.
[0161] Based on the same inventive concept, embodiments of this application also provide a readable storage medium, including:
[0162] memory,
[0163] The memory is used to store instructions that, when executed by a processor, cause the apparatus including the readable storage medium to perform the method for detecting sensitive strings as described above.
[0164] Based on the same inventive concept as the data management method described above, this application also provides an electronic device that can perform the aforementioned function of detecting sensitive strings. (Refer to...) Figure 6 The electronic device includes:
[0165] At least one processor 601 and a memory 602 connected to at least one processor 601. In this embodiment, the specific connection medium between the processor 601 and the memory 602 is not limited. Figure 6 The example shown is the connection between processor 601 and memory 602 via bus 600. Bus 600 is... Figure 6 The connections between other components are indicated by thick lines and are for illustrative purposes only, not as limiting information. The 600 bus can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 6 The term is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, the processor 601 can also be called a controller; there is no restriction on the name.
[0166] In this embodiment, memory 602 stores instructions executable by at least one processor 601. By executing the instructions stored in memory 602, at least one processor 601 can perform the data management method described above. Processor 601 can implement... Figure 5 The functions of each module in the device shown.
[0167] The processor 601 is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory 602 and calling data stored in memory 602, the processor can perform various functions and process data, thereby monitoring the device as a whole.
[0168] In one possible design, processor 601 may include one or more processing units. Processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 601. In some embodiments, processor 601 and memory 602 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.
[0169] Processor 601 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps for detecting sensitive strings disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0170] Memory 602, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 602 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 602 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 602 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0171] By designing and programming the processor 601, the code corresponding to the data management method described in the foregoing embodiments can be embedded into the chip, enabling the chip to execute it during operation. Figure 1The steps for detecting sensitive strings in the illustrated embodiment are as follows. How to design and program the processor 601 is a technique well-known to those skilled in the art and will not be described further here.
[0172] Based on the same inventive concept, embodiments of this application also provide a storage medium storing computer instructions that, when executed on a computer, cause the computer to perform the data management method described above.
[0173] In some possible implementations, the various aspects of the detection of sensitive strings provided in this application can also be implemented in the form of a program product, which includes program code that, when the program product is run on a device, causes the control device to perform the steps in the data management method according to the various exemplary embodiments of this application described above.
[0174] The program product may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be—but is not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0175] The program product for detecting sensitive strings provided in the embodiments of the present invention can be a portable compact disc read-only memory (CD-ROM) and include program code, and can run on a computing device. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0176] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take many forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0177] The program code contained on the readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wired, optical fiber, RF, or any suitable combination thereof.
[0178] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0179] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.
[0180] Furthermore, although the operations of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0181] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0182] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0183] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0184] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0185] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for detecting sensitive strings, characterized in that, include: Obtain the text to be detected and its prefix tree; wherein, the prefix tree includes a target path, the starting point of the target path is a child node of the root node of the prefix tree, and the ending point of the target path is a node containing a target identifier; the prefix tree is obtained by subscribing to a sensitive word library based on the usage scenario of the text to be detected, and the sensitive words in the sensitive word library include basic sensitive words and extended words obtained by one or more of the following: homophonic extension, synonymous extension, homomorphic extension, or variant extension; In response to a match between a target string in the text to be detected and a node string in the target path, the target string is determined to be the sensitive string; wherein, the node characters in the node string correspond one-to-one with the nodes on the target path; Determine whether the text to be processed contains the sensitive string; if not, determine that the sensitive string is a non-sensitive string marked with an error; wherein, the text to be detected is the text obtained by filtering the text to be processed based on phrases in a preset whitelist; the text to be detected does not contain the phrases in the preset whitelist.
2. The method as described in claim 1, characterized in that, The step of determining the target string as the sensitive string in response to a match between the target string in the text to be detected and the node string of the target path includes: In response to a match between a first character in the text to be detected and a first node character in the prefix tree, a second node character corresponding to a second character in the text to be detected is determined among the child nodes of the first node; wherein, the first node corresponding to the first node character is a child node of the root node in the prefix tree; and the second character is a character read sequentially after the first character. In response to the second node corresponding to the second node character containing the target identifier, the first target string composed of the first character and the second character is determined to be the sensitive string.
3. The method as described in claim 2, characterized in that, After determining that the first target string composed of the first character and the second character is the sensitive string in response to the second node corresponding to the second node character containing the target identifier, the method further includes: In response to the second node containing the target identifier and the second node being a non-leaf node, a third node character matching the third character in the text to be detected is determined among the child nodes of the second node; wherein, the third character is a character read sequentially after the second character; In response to the fact that the third node corresponding to the third node character contains the target identifier, and the third node is a leaf node, the second target string composed of the first character, the second character, and the third character is determined to be the sensitive string.
4. The method as described in claim 2, characterized in that, After determining that the first target string composed of the first character and the second character is the sensitive string, in response to the second node corresponding to the second node character containing the target identifier, the method further includes: In response to the second node containing the target identifier and the second node being a leaf node, a fourth node character matching the second character is determined among the child nodes of the root node; wherein the fourth node character corresponds to the fourth node; In the text to be detected, the fourth character following the second character is read sequentially, and in the prefix tree, the fifth node character matching the fourth character is determined, as well as whether the fifth node corresponding to the fifth node character contains the target identifier; wherein, the fifth node is a child node of the fourth node; If so, the third target string formed by the second character and the fourth character is determined to be the sensitive string.
5. The method as described in claim 2, characterized in that, After determining that the first target string composed of the first character and the second character is the sensitive string, in response to the second node corresponding to the second node character containing the target identifier, the method further includes: In response to the second node containing the target identifier and the second node being a leaf node, a sixth node character matching the fifth character in the text to be detected is determined among the child nodes of the root node; wherein the fifth character is a character read sequentially after the second character; the sixth node character corresponds to the sixth node; Determine whether the sixth node contains the target identifier; if so, determine that the fourth target string composed of the fifth character is the sensitive string.
6. The method according to any one of claims 1-5, characterized in that, After determining that the target string is the sensitive string, the method further includes: The text to be processed is segmented using a preset word segmentation model to obtain a word segmentation set; wherein, the text to be processed is the original text of the text to be detected; In response to a segment of a keyword group in the word segmentation set being identified as a sensitive string, the sensitive string is determined to be a non-sensitive string that has been incorrectly flagged.
7. A device for detecting sensitive strings, characterized in that, include: An acquisition unit is used to acquire the text to be detected and a prefix tree; wherein, the prefix tree includes a target path, the starting point of the target path is a child node of the root node of the prefix tree, and the ending point of the target path is a node containing a target identifier; the prefix tree is obtained by subscribing to a sensitive word library based on the usage scenario of the text to be detected, and the sensitive words in the sensitive word library include basic sensitive words and extended words obtained by performing one or more of the following: homophonic extension, synonymous extension, homomorphic extension, or variant extension on the basic sensitive words; A matching unit is configured to determine the target string as the sensitive string in response to a match between the target string in the text to be detected and the node string of the target path; wherein, the node characters in the node string correspond one-to-one with the nodes on the target path; The first unit is used to determine whether the text to be processed contains the sensitive string; if not, it determines that the sensitive string is a non-sensitive string marked with an error; wherein, the text to be detected is the text obtained by filtering the text to be processed based on the phrases in the preset whitelist; the text to be detected does not contain the phrases in the preset whitelist.
8. The apparatus as claimed in claim 7, characterized in that, The matching unit is specifically configured to, in response to a first character in the text to be detected matching a first node character in the prefix tree, determine a second node character corresponding to a second character in the text to be detected among the child nodes of the first node; wherein, the first node corresponding to the first node character is a child node of the root node in the prefix tree; the second character is a character read sequentially after the first character; and in response to the second node corresponding to the second node character containing the target identifier, determine the first target string composed of the first character and the second character as the sensitive string.
9. The apparatus as claimed in claim 8, characterized in that, The matching unit is specifically configured to, in response to the second node containing the target identifier and the second node being a non-leaf node, determine a third node character that matches the third character in the text to be detected among the child nodes of the second node; wherein the third character is a character read sequentially after the second character; in response to the third node corresponding to the third node character containing the target identifier and the third node being a leaf node, determine the second target string composed of the first character, the second character, and the third character as the sensitive string.
10. The apparatus as claimed in claim 8, characterized in that, The matching unit is further configured to, in response to the second node containing the target identifier and the second node being a leaf node, determine a fourth node character that matches the second character among the child nodes of the root node; wherein the fourth node character corresponds to the fourth node; in the text to be detected, sequentially read the fourth character located after the second character, and in the prefix tree, determine a fifth node character that matches the fourth character, and whether the fifth node corresponding to the fifth node character contains the target identifier; wherein the fifth node is a child node of the fourth node; if so, determine the third target string composed of the second character and the fourth character as the sensitive string.
11. The apparatus as claimed in claim 8, characterized in that, The matching unit is further configured to, in response to the second node containing the target identifier and the second node being a leaf node, determine a sixth node character that matches the fifth character in the text to be detected among the child nodes of the root node; wherein the fifth character is a character read sequentially after the second character; the sixth node character corresponds to the sixth node; determine whether the sixth node contains the target identifier; if so, determine the fourth target string composed of the fifth character as the sensitive string.
12. The apparatus according to any one of claims 7-11, characterized in that, The device further includes a second unit, which is used to segment the text to be processed using a preset word segmentation model to obtain a word segmentation set; wherein the text to be processed is the original text of the text to be detected; in response to the fact that the fragment of the keyword group in the word segmentation set is the sensitive string, the sensitive string is determined to be a non-sensitive string marked with an error.
13. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1-6.
14. A computer storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-6.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Sensitive word matching method and system
CN103617251A
Sensitive word searching method and device
CN103678651A
Sensitive information detection method and device and storage medium
CN111831803A
Text auditing method and device, electronic equipment, storage medium and product
CN115952792A