A method, apparatus, electronic device, and storage medium for filtering prompt words.

By extending the domain-level hierarchical tree structure of the deterministic finite automata, the problems of weak word transformation processing capability, low filtering efficiency and poor accuracy in the existing technology are solved, realizing efficient and accurate prompt word filtering and improving the prompt word filtering effect in multiple domain scenarios.

CN123068530APending Publication Date: 2026-11-10CHINA MOBILE (XIONGAN) ICT CO LTD +3
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611236949.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-14
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Existing technologies have weak word transformation processing capabilities, low filtering efficiency, and poor accuracy in various fields and scenarios, resulting in poor prompt word filtering effects, which affects the quality of solution creation and content security.

Method used

An extended deterministic finite automaton (DFA) is used. Through a domain hierarchical tree structure transformation, the state information is stored using an offset array, a check array, a domain array, a hierarchy array, and a termination identifier array to achieve accurate matching and processing of prompt words.

Benefits of technology

It improves the efficiency and accuracy of prompt word filtering, adapts to differentiated processing in various fields, and ensures content security and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123068530A_ABST
    Figure CN123068530A_ABST
Patent Text Reader

Abstract

This invention relates to the field of artificial intelligence technology, specifically disclosing a prompt word filtering method, apparatus, electronic device, and storage medium. The method includes: matching input prompt words with an extended deterministic finite automaton (EDF) to obtain target sensitive words; wherein the EDF is derived from a domain-layered tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words; and processing the prompt words according to the filtering strategy corresponding to the target sensitive words. This solution, by employing an EDF derived from a domain-layered tree structure, enables rapid and accurate identification of sensitive words in prompt words, effectively improving the efficiency, accuracy, and scene adaptability of prompt word filtering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a prompt word filtering method, apparatus, electronic device, and storage medium. Background Technology

[0002] In solution creation systems, prompts serve as crucial input for human-system interaction, and their compliance and validity are paramount. As the application scenarios of solution creation systems continue to expand, user-input prompts are becoming increasingly diverse and complex, potentially containing sensitive, invalid, or unsuitable words. These words can negatively impact the quality and efficiency of solution creation and may even pose content security risks. Existing prompt filtering methods, such as keyword matching, regular expression-based, and machine learning-based methods, lack sufficient ability to handle word variations and suffer from poor filtering efficiency and accuracy. Summary of the Invention

[0003] This invention provides a method, apparatus, electronic device, and storage medium for filtering prompt words, in order to solve the problems of weak word transformation processing capability, low filtering efficiency, and poor accuracy in existing technologies across multiple domain scenarios.

[0004] According to one aspect of the present invention, a cue word filtering method is provided, the method comprising: The extended deterministic finite automaton is used to match the input prompt words to obtain the target sensitive words. The extended deterministic finite automaton is transformed from a hierarchical tree structure and stores the state information through the following arrays: an offset array for determining the state transition, a validation array for verifying the validity of the state transition, a domain array for storing the domain identifier, a hierarchy array for storing the hierarchy weights, and a termination identifier array for marking the termination state of the sensitive words. The prompt words are processed according to the filtering strategy corresponding to the target sensitive words.

[0005] According to another aspect of the present invention, a prompt word filtering device is provided, the device comprising: The matching module is used to match the input prompt words based on the extended deterministic finite automaton to obtain the target sensitive words. The extended deterministic finite automaton is transformed from a domain-layered tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words. The processing module is used to process the prompt words according to the filtering strategy corresponding to the target sensitive words.

[0006] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the prompt word filtering method according to any embodiment of the present invention.

[0007] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the prompt word filtering method according to any embodiment of the present invention.

[0008] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the prompt word filtering method described in any embodiment of the present invention.

[0009] The technical solution of this invention matches input prompt words using an extended deterministic finite automaton to obtain target sensitive words. The extended deterministic finite automaton is derived from a domain-layered tree structure and stores state information using the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words. The prompt words are then processed according to the filtering strategy corresponding to the target sensitive words. This solution, by employing an extended deterministic finite automaton derived from a domain-layered tree structure, enables rapid and accurate identification of sensitive words in prompts, solving the problems of weak word transformation processing capabilities, low filtering efficiency, and poor accuracy in existing technologies across multiple domains. This effectively improves the efficiency, accuracy, and scenario adaptability of prompt word filtering.

[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a flowchart of a prompt word filtering method provided in Embodiment 1 of the present invention; Figure 2 This is a flowchart of a prompt word filtering method provided in Embodiment 2 of the present invention; Figure 3 This is a flowchart of a prompt word filtering method provided in Embodiment 3 of the present invention; Figure 4 This is a schematic diagram of a domain hierarchical tree structure provided in Embodiment 3 of the present invention; Figure 5 This is a schematic diagram of the structure of a prompt word filtering device according to Embodiment 4 of the present invention; Figure 6 This is a schematic diagram of the structure of an electronic device that implements the prompt word filtering method of this invention. Detailed Implementation

[0013] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0014] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0015] Example 1 Figure 1 This is a flowchart of a prompt word filtering method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations requiring efficient, accurate, and multi-domain differentiated processing of sensitive words for input prompt words. The method can be executed by a prompt word filtering device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1As shown in the figure, the prompt word filtering method provided in this embodiment includes the following steps: S110. The input prompt words are matched based on the extended deterministic finite automaton to obtain the target sensitive words; wherein, the extended deterministic finite automaton is transformed from a domain-layered tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words.

[0016] Among them, the extended deterministic finite automata (DFA) is a finite state machine used for pattern matching. This embodiment extends the functionality of the traditional double-array DFA data structure by adding an array to store and utilize semantic information such as domain and hierarchy, thereby supporting more intelligent matching logic.

[0017] A hierarchical tree structure for domain-specific data storage can be a data structure where the hierarchy can be flexibly configured according to business needs. For example, it can contain at least a root node, one or more levels of domain nodes, and terminology nodes for storing sensitive word character sequences. The number of domain node levels is not limited to two; it can be set to one, two, or more levels (e.g., root node → first-level domain node → second-level domain node → third-level domain node → ... → terminology node) to adapt to the varying requirements of domain granularity in different application scenarios. This scalable hierarchical design allows each sensitive word (terminology node) to belong to a specific domain path, binding domain identifiers and hierarchical information as node attributes.

[0018] An offset array can refer to an array used to store state node offset data, supporting state transition calculations in DFA (such as determining candidate state node indices).

[0019] A validation array can refer to an array used to store validation data for state nodes, verifying whether state transitions are valid (such as confirming whether a candidate node is a valid child node of the current node).

[0020] A domain array can refer to an array used to store the domain identifier of each state node, supporting domain compliance verification. The domain identifier is used to uniquely distinguish different business categories or application scenarios. It is bound to sensitive words and their nodes in the hierarchical structure, enabling the algorithm to identify and isolate the semantic differences of the same word in different domains (such as medical and financial), thereby achieving accurate multi-domain sensitive word matching and differentiated processing.

[0021] A hierarchical array can refer to an array used to store the hierarchical weights corresponding to each state node, supporting the hierarchical progressive rule verification and sensitive word matching priority judgment. The hierarchical weights are used to characterize the node depth or importance of sensitive words in the domain hierarchical tree structure. Their values ​​usually increase with the node depth. They are used to implement priority control during the matching process (such as matching longer words first) and as a basis for judging sensitivity or selecting processing strategies in filtering decisions.

[0022] The termination identifier array can be an array used to mark whether each state node is the end node of a sensitive word, which helps to determine whether the matched character sequence is a complete sensitive word.

[0023] Target sensitive words can refer to sensitive words that need to be filtered or processed and successfully matched and identified from the input prompt text through extended DFA.

[0024] In this embodiment of the invention, a pre-constructed extended DFA can be obtained, which is transformed from a tree structure that stores sensitive words, domain identifiers and hierarchical weights. Based on the extended DFA, the state transition of the prompt words is performed character by character, and the dual verification of domain and hierarchy is performed simultaneously, thereby accurately matching the target keywords.

[0025] S120. Process the prompt words according to the filtering strategy corresponding to the target sensitive words.

[0026] The filtering strategy can refer to the specific processing rules adopted for the identified target sensitive words. These can include, but are not limited to, deletion, replacement, prompting, and downgrading strategies. The strategy can be expanded according to business needs and dynamically selected based on the attributes of the sensitive words (such as domain identifier, hierarchical weight, sensitivity level, etc.).

[0027] In this embodiment of the invention, based on a pre-configured filtering strategy mapping relationship (such as a strategy mapping matrix), a corresponding filtering strategy can be selected for the target sensitive word according to information such as the domain identifier, hierarchical weight, and sensitivity level associated with it. The prompt word can then be processed accordingly according to the filtering strategy, such as directly deleting or replacing the target sensitive word, thereby generating a final prompt word that conforms to the preset output specifications.

[0028] The technical solution of this invention matches input prompt words using an extended deterministic finite automaton to obtain target sensitive words. The extended deterministic finite automaton is derived from a domain-layered tree structure and stores state information using the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words. The prompt words are then processed according to the filtering strategy corresponding to the target sensitive words. This solution, by employing an extended deterministic finite automaton derived from a domain-layered tree structure, enables rapid and accurate identification of sensitive words in prompts, solving the problems of weak word transformation processing capabilities, low filtering efficiency, and poor accuracy in existing technologies across multiple domains. This effectively improves the efficiency, accuracy, and scenario adaptability of prompt word filtering.

[0029] Example 2 Figure 2 This is a flowchart of a prompt word filtering method provided in Embodiment 2 of the present invention. It is further optimized and extended based on the above embodiments, and can be combined with various optional technical solutions in the above embodiments. For example... Figure 2 As shown, the prompt word filtering method provided in this embodiment is a further refinement of the process of matching input prompt words based on extended deterministic finite automata to obtain target sensitive words. The method specifically includes the following steps: S210. Determine the target domain range for this matching according to the preset scanning mode, set the initial state node of the extended finite automaton as the current state node, and initialize the preset matching buffer and the preset matching result storage area.

[0030] The preset scanning mode can refer to a predefined set of rules used to specify the scope of sensitive word matching, such as specified domain matching, multi-domain matching, and full-domain matching. The target domain scope refers to the set of domains that the current sensitive word matching needs to cover, defined based on the preset scanning mode; it is the domain boundary condition for sensitive word matching. The initial state node can refer to the starting state node of the extended DFA, usually the root node of a domain-level hierarchical tree structure, and is the starting point for sensitive word matching. The preset matching cache area can refer to a temporary storage area used to temporarily store character sequence fragments during the sensitive word matching process, used to assemble the sensitive word character sequences to be verified. The preset matching result storage area can refer to a storage area used to store candidate sensitive words identified during the matching process; it is a temporary carrier of candidate sensitive words.

[0031] In this embodiment of the invention, a preset scanning mode can be selected according to business needs, and the target domain range for this sensitive word matching can be defined based on the mode. This range can cover a single domain, multiple domains, or the entire domain to clearly define the domain boundaries for matching. In addition, the current state node of the extended DFA can be set as the initial state node (i.e., the root node) as the starting state for sensitive word matching; at the same time, a preset matching cache and a preset matching result storage area are initialized. The former is used to temporarily store character sequence fragments during the matching process, and the latter is used to store the identified candidate sensitive words.

[0032] S220. Traverse each character in the prompt words and perform the following operations: Based on the index of the current state node, the character identifier of the current character, and the offset array, determine the index of the candidate state node. According to the target domain range, the domain array, and the verification array, perform multi-level verification on the candidate state node. If the multi-level verification passes, update the current state node to a candidate state node and store the current character in the preset matching cache. Otherwise, reset the current state node to the initial state node and clear the preset matching cache, and continue processing the next character. If the termination identifier array corresponding to the updated current state node is a termination state, store the character sequence stored in the preset matching cache as a candidate sensitive word in the preset matching result storage area.

[0033] Here, the character identifier of the current character can refer to a unique numerical identifier assigned to each character in the prompt word, used to drive the state transition of the automaton. Multi-level validation can refer to a multi-dimensional validation mechanism performed sequentially during the DFA state transition process, such as domain compliance validation, hierarchical validity validation, and state transition legality validation. Candidate sensitive words can refer to a complete character sequence stored in a pre-defined matching cache and validated by the termination node; it is a candidate set of target sensitive words.

[0034] In this embodiment of the invention, each character can be processed sequentially, starting from the first character of the prompt word. For the current character, the index of the candidate state node is calculated by combining the index of the current state node, the unique character identifier corresponding to the character, and the offset array of the extended DFA. That is, the next state node that the current character may trigger, where the index of the candidate state node = offset array [index of the current state node] + character identifier.

[0035] Next, based on the target domain scope, domain array, and verification array, multi-level verification operations are performed on the calculated candidate state nodes. For example, the domain compliance, hierarchical validity, and state transition legality of the candidate state nodes are verified sequentially to filter out nodes that meet the matching rules.

[0036] If the multi-level verification passes, the current state node is updated to a candidate state node, and the current character is stored in the preset matching cache to continue the matching chain of the current sensitive word; if any verification fails, the current state node is immediately reset to the initial state node, the preset matching cache is cleared, the current invalid matching chain is interrupted, and the next character in the prompt word is processed.

[0037] After each status node update, query the marker corresponding to the current status node in the termination marker array; if the marker is a termination status, it means that the character sequence in the current matching cache is a complete sensitive word, and store the character sequence as a candidate sensitive word in the preset matching result storage area.

[0038] Furthermore, based on the above embodiments of the invention, multi-level verification is performed on candidate state nodes according to the target domain range, the domain array, and the verification array, specifically including: Read the domain identifier corresponding to the index of the candidate state node in the domain array, and determine whether the domain identifier belongs to the target domain range; If it does not belong to the category, the multi-level verification is deemed to have failed. If it belongs to the category, the stored value corresponding to the index of the candidate state node in the verification array is parsed, the hierarchical mask in the stored value is extracted, and the hierarchical mask is verified to conform to the preset hierarchical progression rule. If it does not meet the requirements, the multi-level verification is deemed to have failed. If it does meet the requirements, the parent node index is extracted from the stored value, and the parent node index is verified to be equal to the index of the current state node. If they are not equal, the multi-level validation is deemed to have failed; if they are equal, the multi-level validation is deemed to have passed.

[0039] Here, the hierarchy mask can refer to the feature information embedded in the verification array, used to characterize the level of the state node in the domain hierarchical tree structure. The preset hierarchical progression rule can refer to the predefined hierarchical order constraint rule for the legal transition of state nodes in the domain hierarchical tree structure. For example, this rule at least includes: it must follow a unidirectional progression relationship of "root node → domain node → child domain node → term node". The parent node index can refer to the unique index value stored in the verification array, used to characterize the parent node of the current state node in the extended DFA.

[0040] In this embodiment of the invention, the process of performing multi-level verification on candidate state nodes specifically includes: (1) Domain compliance verification: Based on the unique index of the candidate state node, index matching is performed in the pre-built domain array, and the domain identifier corresponding to the index is read; the read domain identifier is compared with the target domain range preset for this sensitive word matching; if the domain identifier is not within the target domain range, the multi-level verification is directly determined to fail, the subsequent verification process is terminated and the state reset logic is triggered; if the domain identifier belongs to the target domain range, the next level of verification is entered.

[0041] (2) Hierarchical validity verification: Based on the index of the candidate state node, the corresponding storage value is read from the verification array; the hierarchical mask encoded in a specific high bit (such as the high 8 bits) is extracted from the storage value, and the extracted hierarchical mask is verified against the preset hierarchical progression rule, that is, whether the hierarchical mask satisfies the unidirectional progression relationship of "root node → domain node → sub-domain node → term node" to verify whether the state transition conforms to the legal path from the higher level to the lower level; if the hierarchical mask does not conform to the preset hierarchical progression rule, the multi-level verification is determined to fail; if it does conform, the final level verification stage is entered.

[0042] (3) State transition legality verification: Extract the parent node index located in the low bit (such as the lower 24 bits) from the value stored in the verification array, and compare the extracted parent node index with the index of the current state node. If the two index values ​​are not equal, it means that there is no legal parent-child transition relationship between the candidate state node and the current state node, and the multi-level verification is determined to be unsuccessful. If the two index values ​​are completely equal, it is determined that the multi-level verification is completely successful, and the current state node is allowed to be updated to the candidate state node, and the sensitive word matching process continues.

[0043] The embodiments of the present invention employ a three-level progressive verification mechanism of "domain verification - hierarchical verification - state transition verification". This mechanism not only achieves precise isolation of sensitive words in different business domains and avoids cross-domain mismatches, but also ensures the rigor of the matching logic through dual verification of hierarchical and state transition. Meanwhile, the O(1) level array index query and short-circuit judgment mechanism significantly improves the verification efficiency, effectively enhancing the overall performance and accuracy of prompt word filtering.

[0044] S230. After traversing all characters of the prompt word, sort and deduplicate all candidate sensitive words stored in the preset matching result storage area to obtain the target sensitive word.

[0045] In this embodiment of the invention, after all characters in the prompt word have been traversed, all candidate sensitive words in the preset matching result storage area can be sorted and deduplicated. The deduplication operation can remove candidate sensitive words that are repeatedly identified, and the sorting operation can adjust the order of candidate sensitive words according to preset rules (such as sensitive word length, sensitivity level, etc.), and finally output one or more of the most accurate and critical target sensitive words.

[0046] S240. Process the prompt words according to the filtering strategy corresponding to the target sensitive words.

[0047] The technical solution of this invention, by introducing a preset scanning mode to determine the target domain range and performing multi-level verification on candidate state nodes during character-by-character matching, achieves accurate positioning and domain isolation of sensitive words, effectively avoiding cross-domain misjudgments. Simultaneously, by utilizing the collaborative mechanism of a preset matching cache and a preset matching result storage area, combined with sorting and deduplication after traversal, the most accurate and highest-priority target sensitive words can be selected from multiple candidate sensitive words. Then, differentiated filtering strategies are dynamically matched based on their domain and hierarchical attributes. This solution significantly improves the filtering accuracy and efficiency under multi-domain, large-scale sensitive word libraries, while reducing memory consumption, achieving efficient, intelligent, and scalable secure processing of prompt word content.

[0048] Example 3 Figure 3 This is a flowchart of a prompt word filtering method provided in Embodiment 3 of the present invention. It is further optimized and extended based on the above embodiments, and can be combined with various optional technical solutions in the above embodiments. For example... Figure 3 As shown, the prompt word filtering method provided in this embodiment three is a further refinement of the process of processing prompt words based on the filtering strategy corresponding to the target sensitive words. The method specifically includes the following steps: S310. The input prompt words are matched based on the extended deterministic finite automaton to obtain the target sensitive words; wherein, the extended deterministic finite automaton is transformed from a domain-layered tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words.

[0049] S320. Based on the domain identifier and hierarchical weight associated with the target sensitive words, query the preset filtering strategy mapping relationship to determine the corresponding filtering strategy; wherein, the filtering strategy includes at least one of the following: strict deletion strategy, character replacement strategy, prompt correction strategy and downgrade replacement strategy.

[0050] The preset filtering strategy mapping relationship can refer to a pre-configured correspondence between related domain identifiers, hierarchical weights, and filtering strategies, used to guide the filtering logic of target sensitive words; for example, the preset filtering strategy mapping relationship can be a strategy mapping matrix. A strict deletion strategy can refer to a filtering method that directly deletes the character sequence corresponding to the target sensitive word in the prompt and concatenates the remaining character sequence into a complete prompt. A character replacement strategy can refer to using preset compliant characters (such as "..."). "", The filtering process involves replacing each character of the target sensitive word in the prompt with a "etc." while maintaining the overall character length of the prompt. The prompt correction strategy could involve adding preset markers to the beginning and end of the target sensitive word in the prompt and simultaneously generating prompt content containing sensitive word information. The downgrade replacement strategy could involve replacing the target sensitive word in the prompt with a preset low-sensitivity compliant expression while maintaining the semantic coherence of the prompt.

[0051] In this embodiment of the invention, based on the matched target sensitive words, the domain identifier corresponding to the sensitive word can be read from the domain array of the extended DFA, and the hierarchical weight corresponding to the sensitive word can be read from the hierarchical array. Then, a preset "domain identifier-hierarchical weight-filtering strategy" mapping table is invoked, and the extracted target sensitive word's domain identifier and hierarchical weight are used as joint query conditions to match and obtain the corresponding filtering strategy. The matching strategy supports single-strategy matching or combined-strategy matching, and the selectable filtering strategies include at least one of the following: strict deletion strategy, character replacement strategy, prompt correction strategy, and downgrade replacement strategy.

[0052] S330. Process the prompt words according to the filtering strategy.

[0053] In this embodiment of the invention, the prompt words can be processed according to the filtering strategy determined for each target sensitive word, such as directly deleting or replacing the target sensitive word, so as to generate the final prompt words that conform to the preset output specifications.

[0054] The technical solution of this invention employs an extended deterministic finite automaton derived from a domain-level hierarchical tree structure for matching. It utilizes independent domain arrays, level arrays, and termination identifier arrays to store state information. This allows for simultaneous completion of domain compliance verification, level validity verification, and termination state determination during a single state transition, significantly improving the efficiency and accuracy of sensitive word identification across multiple domains. Furthermore, based on the mapping relationship between the domain identifier associated with the target sensitive word and the level weight query of the preset filtering strategy, differentiated processing methods such as strict deletion, character replacement, prompt correction, or downgrade replacement can be dynamically selected. This achieves flexible control over the same word across different domains and levels, ensuring content security while also considering text usability and business adaptability.

[0055] Furthermore, based on the above embodiments of the invention, the hierarchical tree structure of the domain is constructed in the following way: Initialize the tree structure; Based on a pre-defined sensitive word database, the domain path corresponding to each sensitive word is determined; the domain path includes at least a domain identifier and a subdomain identifier. Starting from the root node of the tree structure, create or locate the corresponding domain nodes and sub-domain nodes in sequence according to the domain path, and set the hierarchical weights for the created nodes. Under the subdomain node, a term node is created based on the character sequence of the sensitive words, and the term node is associated with the corresponding domain identifier and hierarchical weight; If there are sensitive words with the same character sequence but different domain identifiers in the preset sensitive word library, then mutually isolated term node branches are created for the character sequence under the corresponding different domain paths.

[0056] In this embodiment, the preset sensitive word library can refer to a vocabulary set that pre-stores a number of sensitive words, each of which is associated with domain attribute information. A domain path can refer to an identifier sequence describing which specific business domain and its subdomains a sensitive word belongs to; it indicates the complete address of the word from the root node to its terminology node in the hierarchical tree. A domain identifier can refer to an identifier that uniquely identifies the domain category to which a sensitive word belongs. A subdomain identifier can refer to an identifier that uniquely identifies the sub-category of a sensitive word within its domain. A domain node can refer to a hierarchical node corresponding to the domain to which a sensitive word belongs; it is an intermediate hierarchical node between the root node and the subdomain node. A subdomain node can refer to a hierarchical node corresponding to the subdomain to which a sensitive word belongs; it is an intermediate hierarchical node between the domain node and the terminology node. A terminology node can refer to a node corresponding to the character sequence of a sensitive word, created sequentially from the characters after the sensitive word is split; it is one of the terminal hierarchical nodes in the tree structure. Mutually isolated terminology node branches can refer to mutually independent, attribute-free terminology node sequences created under different domain paths for sensitive words with the same character sequence but different domain identifiers, to achieve logical and physical isolation.

[0057] In this embodiment of the invention, the node structure of the domain hierarchical tree structure (Trie) is as follows: Figure 4 As shown, it specifically includes the following four types of nodes: ① Root node (level weight level=0): It is the globally unique entry point and starting point of the entire domain's hierarchical tree structure. It does not carry specific business semantics and only serves as a logical anchor point for accessing the entire tree.

[0058] ② Domain Node (Level Weight=1): Represents a first-level business domain (such as healthcare, finance, education, etc.), and is the carrier of the first-level business semantics in the tree structure. It is directly attached to the root node and is the parent node of one or more child domain nodes. This node stores an empty string, but is associated with a unique domain identifier, domain_id (integer), used to precisely identify a specific first-level domain, such as 1=education, 2=finance, etc.

[0059] ③ Subdomain Node (Level Weight=2): Represents a second-level business domain, which is a further subdivision of the first-level domain (e.g., medical → surgery, finance → securities, etc.). It is attached to a specific domain node and is the parent node of one or more terminology nodes. This node also stores empty characters, but the associated domain identifier (domain_id) points to its specific second-level domain.

[0060] ④ Term Node (Level Weight ≥ 3): This is a leaf node in a tree structure that directly stores the sequence of sensitive words. Its level weight increases as the character moves deeper into the word, thus supporting priority matching of longer words. For example, "education and training violations" has a higher weight than "violation". This node also inherits and associates with the domain identifier of its parent node (child domain node).

[0061] Specifically, the process of creating a domain-level hierarchical tree structure (Trie) includes: (1) Create an empty tree structure and establish its preset hierarchical progression rules. These rules clearly define the tree organization as a four-level architecture of "root node → domain node → subdomain node → term node". At the same time, assign a unique identifier to all business domains involved in the system (such as healthcare, finance, and education).

[0062] (2) Obtain all sensitive words in the preset sensitive word library, and label each sensitive word with its domain identifier and subdomain identifier. Based on this labeling information, determine the domain path corresponding to each sensitive word. The domain path is a hierarchical path from the root node to the target subdomain node, and includes at least the domain identifier and subdomain identifier, which is used to clarify the hierarchical level of the sensitive word in the tree structure.

[0063] (3) Starting from the root node of the tree structure, traverse the domain identifiers and subdomain identifiers in the determined domain path in sequence: if the corresponding domain node / subdomain node already exists, directly locate the node; if it does not exist, create a new domain node / subdomain node. At the same time, assign the corresponding level weight to the newly created node according to the preset level progression rules to clarify the level position of the node in the tree structure.

[0064] (4) Under the subdomain node located or created in step 3, the sensitive words are split into continuous character sequences, and term nodes are created sequentially according to the character order to form the character branches corresponding to the sensitive words. Each term node is associated with its domain identifier and subdomain identifier, and a corresponding hierarchical weight is set for the term node according to the preset hierarchical progression rule, such as assigning a higher hierarchical weight according to the depth of its character sequence (e.g., increasing from 3).

[0065] (5) When traversing the preset sensitive word library, if sensitive words with the same character sequence but different domain identifiers are detected, these sensitive words will not share the same set of term nodes. Instead, independent term node branches will be created for the same character sequence under their respective corresponding domain paths. Although these branch nodes store the same characters, they are physically isolated in the tree structure because of their different domain identifiers and paths, thus ensuring the independence and accuracy of words under different domain semantics.

[0066] The domain-level hierarchical tree structure proposed in this invention achieves domain-based classification and storage of sensitive words through hierarchical node design and domain path division. It also solves the problem of confusion between sensitive words in different domains with the same character sequence by processing cross-domain isolated branches. At the same time, the binding of nodes with domain identifiers and hierarchical weights provides core structural support for subsequent domain-specific accurate matching, hierarchical validity verification, and sensitive word priority filtering in the extended DFA, which greatly improves the accuracy and efficiency of sensitive word matching.

[0067] Furthermore, based on the above embodiments of the invention, the process of converting the domain-layered tree structure into an extended deterministic finite automaton includes: Based on the domain identifier of the nodes in the tree structure, pre-allocate non-overlapping index ranges in the array for nodes in different domains; Traverse the tree structure, map the nodes in the tree structure to the state nodes of the extended deterministic finite automaton, and assign corresponding indices to the state nodes; For each state node assigned an index, perform the following assignment operation: The offset array stores the composite offset calculated from the base offset and the neighborhood offset of the state node; The verification array stores the parent node index and hierarchical verification information of the status node; The domain array, hierarchy array, and termination identifier array store the domain identifier, hierarchy weight, and termination status flag corresponding to the state node, respectively.

[0068] The composite offset refers to a value stored in the offset array, consisting of a base offset used to calculate the child node position and a domain offset used to achieve domain spatial isolation. The base offset is the smallest positive integer that ensures no conflict between the indices of any child node of the current state node and any occupied index, guaranteeing the uniqueness of the child node indices. The domain offset is a fixed value calculated based on the node's domain identifier and a preset offset base, used to identify the node's domain affiliation and divide the index range. The domain offset is a fixed numerical offset calculated based on the unique identifier (domain_id) of the state node's domain. Its core function is to ensure that nodes from different domains are physically mapped to completely separate, non-overlapping index ranges in the array, thus achieving physical spatial isolation between domains. This lays the underlying data foundation for efficient and accurate domain-specific matching. Its specific value can be flexibly set according to actual needs, such as 1000 or 10000, but this embodiment does not limit this.

[0069] Hierarchical verification information can refer to a portion of data encoded into the verification array storage value, used to quickly verify whether the transition conforms to the preset hierarchical progression rules during state transitions. Termination state markers can refer to marker information used to identify whether a state node is a sensitive word termination node, used to determine whether a complete sensitive word has been identified during sensitive word matching.

[0070] In this embodiment of the invention, the process of converting a domain hierarchical tree structure into an extended DFA specifically includes: (1) Based on the domain identifier bound to each node in the domain hierarchical tree structure, divide the nodes of different domains into independent and non-overlapping array index ranges. The division rules can be determined based on a preset offset base. For example, if the offset base is set to 10000, then the index range corresponding to the node with domain identifier 1 is [10000, 20000), the index range corresponding to the node with domain identifier 2 is [20000, 30000), and so on.

[0071] (2) According to the preset hierarchical progression rule of “root node → domain node → subdomain node → term node”, and using breadth-first traversal or depth-first traversal, the tree structure is traversed one-to-one, and each tree node is mapped to a state node of the extended DFA; an index is assigned to each mapped state node. When assigning, it is necessary to ensure that the index of the state node falls within the corresponding domain index range pre-allocated in step 1, and that the index of each state node is unique.

[0072] (3) For each state node with an allocated index, write the corresponding information to the offset array, check array, neighborhood array, hierarchy array, and termination identifier array, as follows: ① Assigning values ​​to the offset array (base array): Calculate the composite offset of the current state node, composite offset = base offset + domain offset (where domain offset = domain_id × preset offset base); write the calculated composite offset to the position corresponding to the current state node index (current_idx) in the offset array; at the same time, determine the index of the child node based on the composite offset: child node DFA index = base[current_idx] + child node character ID.

[0073] ② Assigning values ​​to the check array: The parent node index of the current state node and the hierarchical mask (i.e., hierarchical verification information) are concatenated and integrated through bitwise operations (for example, the parent node index is stored in the lower 24 bits and the hierarchical mask is stored in the higher 8 bits) to form a complete check value; this check value is written to the position corresponding to the current state node index in the check array.

[0074] ③ Assigning values ​​to the domain array (domain_id array): Synchronously write the domain identifier corresponding to the state node to the corresponding index position of the domain array.

[0075] ④ Assigning values ​​to the level array: Synchronously write the level weights of the state nodes to the corresponding index positions in the level array.

[0076] ⑤ Assigning values ​​to the term_flag array: Determine whether the state node is a sensitive word termination node in the Trie tree. If so, mark it as a termination state (e.g., true) at the corresponding index position in the term_flag array; otherwise, mark it as a non-termination state (e.g., false).

[0077] This invention achieves physical isolation of nodes in different domains through pre-allocation of domain index intervals, avoiding cross-domain index conflicts while improving domain filtering efficiency; it ensures the complete migration of tree structure hierarchical features to DFA through hierarchical node mapping, maintaining the association logic between nodes; it realizes the structured storage of state node attributes through the collaborative assignment of five arrays, writing composite offsets and integrated verification information into the corresponding arrays respectively, reducing the number of array accesses in the subsequent sensitive word matching process, supporting attribute query and multi-level verification with O(1) time complexity, and greatly improving the sensitive word matching efficiency and accuracy of extended DFA.

[0078] Furthermore, based on the above embodiments of the invention, the determination of the finite automaton is extended to store state information using the following five parallel arrays: The offset array is used to store the composite offsets for state transitions. The composite offsets include the base offset and the neighborhood offset. The neighborhood offset is determined based on the neighborhood identifier and offset base of the state node. The verification array is used to store the parent node index and hierarchical verification information of the status node; The domain array is used to store the domain identifiers corresponding to the state nodes; A hierarchy array is used to store the hierarchy weights corresponding to the state nodes; The termination identifier array is used to identify whether a status node is a termination node containing sensitive words.

[0079] In this embodiment of the invention, the extended DFA can adopt a five-tuple structure. It is based on the traditional two-array DFA (which only contains base[] and check[]), and is an extended DFA state information storage system formed by extending the core array function and adding three auxiliary arrays. The five arrays share the same index space (that is, each state node corresponds to a unique index value, which can be used in all five arrays). It is corely adapted to multi-domain and hierarchical sensitive word matching scenarios, as detailed below: (1) Offset array (base[]): Its core function is to store the offset of the state node. Unlike the traditional double array DFA design that only stores the basic offset, it is extended to store the composite offset. The specific logic is base[i] = basic offset + domain offset. Among them, the basic offset is the core parameter to ensure the uniqueness of the index of the child node of the state node (the smallest positive integer that makes the index of all child nodes of the current node not conflict with the index of the occupied node); the domain offset is calculated by domain_id × 10000 (preset offset base). Its core function is to define independent index ranges for state nodes in different domains, to ensure that the indexes of cross-domain nodes do not overlap, to realize the index isolation of state nodes in different domains from the bottom layer, and to avoid state interference when matching sensitive words in multiple domains.

[0080] (2) Validation Array (check[]): The core function retains the basic logic of "storing the parent node index for validating the validity of state transitions" in the traditional double-array DFA. At the same time, a new hierarchical validation extension design is added. The specific logic is check[i] = parent node index | (hierarchical validation bits << 24). This design splits the array storage value bit by bit: the lower 24 bits retain the parent node index, which is used to verify the legality of the association between the current node and the parent node (i.e., whether the state transition is valid); the higher 8 bits store the hierarchical mask (hierarchical validation bits), which can quickly verify whether the node hierarchy conforms to the preset hierarchical progression rule of "root node → domain node → subdomain node → term node", realizing "one-time reading, double verification", and completing the dual verification of state transition and hierarchical validity without having to read other arrays.

[0081] (3) Domain ID Array (domain_id[]): Its core function is to store the domain ID to which the status node belongs. This array shares the index space with base[] and check[], and the corresponding domain ID can be directly read through the node index, supporting O(1) level domain matching operations. During sensitive word matching, it can quickly determine whether the current node belongs to the target matching domain without traversal or additional calculation, which greatly improves the efficiency of accurate multi-domain matching.

[0082] (4) Hierarchical array (level[]): Its core function is to store the hierarchical weights corresponding to the state nodes. The hierarchical weights correspond one-to-one with the levels of the nodes in the hierarchical tree structure of the domain (e.g., root node 0, domain node 1, subdomain node 2, term node ≥ 3). The core function of this array is to provide a priority judgment basis for sensitive word matching results. After the matching is completed, the candidate sensitive words can be sorted based on the hierarchical weights in level[] to realize the hierarchical processing logic of prioritizing the filtering of high-weight sensitive words.

[0083] (5) Termination Flag Array (term_flag[]): Its core function is to mark whether a status node is a sensitive word termination node (i.e., whether it corresponds to the last character of a sensitive word). This array replaces the design of marking termination nodes with negative numbers such as -1 and -2 in the base array in the traditional double array DFA, avoiding the conflict between the termination flag and the offset value. At the same time, by using independent Boolean flags (yes / no), it can directly and quickly determine whether a node is a termination node, improving the determination efficiency in the final stage of sensitive word matching.

[0084] The extended DFA five-tuple structure in this embodiment of the invention, through the design of "core array expansion + auxiliary array supplementation," retains the efficient state transition and verification capabilities of the traditional two-array DFA, while adapting to multi-domain, hierarchical sensitive word matching scenarios through the independent storage and expansion design of domain, level, and termination identifiers. The design of the five arrays sharing the index space ensures the consistency of association of all attributes of the state node, realizing fast reading of "one index, all attributes," and comprehensively improving the stability, accuracy, and execution efficiency of the extended deterministic finite automaton in multi-domain sensitive word matching scenarios.

[0085] Example 4 Figure 5 This is a schematic diagram of a prompt word filtering device provided in Embodiment 4 of the present invention. Figure 5 As shown, the device includes: The matching module 41 is used to match the input prompt words based on the extended deterministic finite automaton to obtain the target sensitive words; wherein, the extended deterministic finite automaton is transformed from a domain-layered tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words; The processing module 42 is used to process the prompt words according to the filtering strategy corresponding to the target sensitive words.

[0086] Furthermore, based on the above embodiments of the invention, the matching module 41 is specifically used for: The target domain range for this matching is determined according to the preset scanning mode, and the initial state node of the extended finite automaton is set as the current state node, and the preset matching buffer and preset matching result storage area are initialized. Iterate through each character in the prompt words and perform the following operations: Based on the index of the current state node, the character identifier of the current character, and the offset array, determine the index of the candidate state node. According to the target domain range, the domain array, and the verification array, perform multi-level verification on the candidate state node. If the multi-level verification passes, update the current state node to a candidate state node and store the current character in the preset matching cache. Otherwise, reset the current state node to the initial state node and clear the preset matching cache, and continue processing the next character. If the termination identifier array corresponding to the updated current state node indicates a termination state, store the character sequence stored in the preset matching cache as a candidate sensitive word in the preset matching result storage area. After traversing all characters of the prompt word, all candidate sensitive words stored in the preset matching result storage area are sorted and deduplicated to obtain the target sensitive word.

[0087] Furthermore, based on the above embodiments of the invention, the matching module 41 performs multi-level verification on the candidate state nodes according to the target domain range, the domain array, and the verification array, including: Read the domain identifier corresponding to the index of the candidate state node in the domain array, and determine whether the domain identifier belongs to the target domain range; If it does not belong to the category, the multi-level verification is deemed to have failed. If it belongs to the category, the stored value corresponding to the index of the candidate state node in the verification array is parsed, the hierarchical mask in the stored value is extracted, and the hierarchical mask is verified to conform to the preset hierarchical progression rule. If it does not meet the requirements, the multi-level verification is deemed to have failed. If it does meet the requirements, the parent node index is extracted from the stored value, and the parent node index is verified to be equal to the index of the current state node. If they are not equal, the multi-level validation is deemed to have failed; if they are equal, the multi-level validation is deemed to have passed.

[0088] Furthermore, based on the above embodiments of the invention, the processing module 42 is specifically used for: Based on the domain identifier and hierarchical weight associated with the target sensitive words, the mapping relationship of the preset filtering strategy is queried to determine the corresponding filtering strategy; wherein, the filtering strategy includes at least one of the following: strict deletion strategy, character replacement strategy, prompt correction strategy and downgrade replacement strategy; The prompts are processed according to the filtering strategy.

[0089] Furthermore, based on the above embodiments of the invention, the hierarchical tree structure of the domain is constructed in the following way: Initialize the tree structure; Based on a pre-defined sensitive word database, the domain path corresponding to each sensitive word is determined; the domain path includes at least a domain identifier and a subdomain identifier. Starting from the root node of the tree structure, create or locate the corresponding domain nodes and sub-domain nodes in sequence according to the domain path, and set the hierarchical weights for the created nodes. Under the subdomain node, a term node is created based on the character sequence of the sensitive words, and the term node is associated with the corresponding domain identifier and hierarchical weight; If there are sensitive words with the same character sequence but different domain identifiers in the preset sensitive word library, then mutually isolated term node branches are created for the character sequence under the corresponding different domain paths.

[0090] Furthermore, based on the above embodiments of the invention, the process of converting the domain-layered tree structure into an extended deterministic finite automaton includes: Based on the domain identifier of the nodes in the tree structure, pre-allocate non-overlapping index ranges in the array for nodes in different domains; Traverse the tree structure, map the nodes in the tree structure to the state nodes of the extended deterministic finite automaton, and assign corresponding indices to the state nodes; For each state node assigned an index, perform the following assignment operation: The offset array stores the composite offset calculated from the base offset and the neighborhood offset of the state node; The verification array stores the parent node index and hierarchical verification information of the status node; The domain array, hierarchy array, and termination identifier array store the domain identifier, hierarchy weight, and termination status flag corresponding to the state node, respectively.

[0091] Furthermore, based on the above embodiments of the invention, the determination of the finite automaton is extended to store state information using the following five parallel arrays: The offset array is used to store the composite offsets for state transitions. The composite offsets include the base offset and the neighborhood offset. The neighborhood offset is determined based on the neighborhood identifier and offset base of the state node. The verification array is used to store the parent node index and hierarchical verification information of the status node; The domain array is used to store the domain identifiers corresponding to the state nodes; A hierarchy array is used to store the hierarchy weights corresponding to the state nodes; The termination identifier array is used to identify whether a status node is a termination node containing sensitive words.

[0092] The prompt word filtering device provided in the embodiments of the present invention can execute the prompt word filtering method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.

[0093] Example 5 Figure 6A schematic diagram of an electronic device 50 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0094] like Figure 6 As shown, the electronic device 50 includes at least one processor 51 and a memory, such as a read-only memory (ROM) 52 and a random access memory (RAM) 53, communicatively connected to the at least one processor 51. The memory stores computer programs executable by the at least one processor. The processor 51 can perform various appropriate actions and processes based on the computer program stored in the ROM 52 or loaded from storage unit 58 into the RAM 53. The RAM 53 can also store various programs and data required for the operation of the electronic device 50. The processor 51, ROM 52, and RAM 53 are interconnected via a bus 54. An input / output (I / O) interface 55 is also connected to the bus 54.

[0095] Multiple components in electronic device 50 are connected to I / O interface 55, including: input unit 56, such as keyboard, mouse, etc.; output unit 57, such as various types of monitors, speakers, etc.; storage unit 58, such as disk, optical disk, etc.; and communication unit 59, such as network card, modem, wireless transceiver, etc. Communication unit 59 allows electronic device 50 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0096] Processor 51 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 51 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 51 performs the various methods and processes described above, such as prompt word filtering methods.

[0097] In some embodiments, the prompt word filtering method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 58. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 50 via ROM 52 and / or communication unit 59. When the computer program is loaded into RAM 53 and executed by processor 51, one or more steps of the prompt word filtering method described above may be performed. Alternatively, in other embodiments, processor 51 may be configured to perform the prompt word filtering method by any other suitable means (e.g., by means of firmware).

[0098] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0099] In some embodiments, the prompt word filtering method may be implemented as a computer program, which is implicitly included in a computer program product. When executed by a processor, the computer program implements the prompt word filtering method of the present invention. The computer program product can be understood as a software product that primarily implements its solution through a computer program. The computer program used to implement the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer program causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer program may be executed entirely on a machine, partially on a machine, partially on a remote machine as a standalone software package, or entirely on a remote machine or server.

[0100] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0101] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0102] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0103] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0104] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0105] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for filtering prompt words, characterized in that, The method includes: The extended deterministic finite automaton is used to match the input prompt words to obtain the target sensitive words; wherein the extended deterministic finite automaton is transformed from a domain-layered tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words. The prompt words are processed according to the filtering strategy corresponding to the target sensitive words.

2. The method according to claim 1, characterized in that, The process of matching input prompt words using an extended deterministic finite automaton to obtain target sensitive words includes: The target domain range for this matching is determined according to the preset scanning mode, and the initial state node of the extended finite automaton is set as the current state node, and the preset matching buffer and preset matching result storage area are initialized. Traverse each character in the prompt words and perform the following operations: Based on the index of the current state node, the character identifier of the current character, and the offset array, determine the index of the candidate state node; perform multi-level verification on the candidate state node according to the target domain range, the domain array, and the verification array; if the multi-level verification passes, update the current state node to the candidate state node and store the current character in the preset matching cache; otherwise, reset the current state node to the initial state node and clear the preset matching cache, and continue processing the next character; if the termination identifier array corresponding to the updated current state node indicates a termination state, store the character sequence stored in the preset matching cache as a candidate sensitive word in the preset matching result storage area. After traversing all characters of the prompt word, all candidate sensitive words stored in the preset matching result storage area are sorted and deduplicated to obtain the target sensitive word.

3. The method according to claim 2, characterized in that, The step of performing multi-level verification on the candidate state nodes based on the target domain range, the domain array, and the verification array includes: Read the domain identifier corresponding to the index of the candidate state node in the domain array, and determine whether the domain identifier belongs to the target domain range; If it does not belong to the category, the multi-level verification is deemed to have failed. If it belongs to the category, the stored value corresponding to the index of the candidate state node in the verification array is parsed, the hierarchical mask in the stored value is extracted, and the hierarchical mask is verified to conform to the preset hierarchical progression rule. If it does not meet the requirements, the multi-level verification is deemed to have failed. If it does meet the requirements, the parent node index in the stored value is extracted, and the parent node index is verified to be equal to the index of the current state node. If they are not equal, the multi-level verification is deemed to have failed; if they are equal, the multi-level verification is deemed to have passed.

4. The method according to claim 1, characterized in that, The step of processing the prompt words according to the filtering strategy corresponding to the target sensitive words includes: Based on the domain identifier and hierarchical weight associated with the target sensitive words, a preset filtering strategy mapping relationship is queried to determine the corresponding filtering strategy; wherein, the filtering strategy includes at least one of the following: strict deletion strategy, character replacement strategy, prompt correction strategy, and downgrade replacement strategy; The prompt words are processed according to the filtering strategy described above.

5. The method according to claim 1, characterized in that, The hierarchical tree structure of the domain is constructed in the following way: Initialize the tree structure; Based on a pre-defined sensitive word database, the domain path corresponding to each sensitive word is determined; the domain path includes at least a domain identifier and a sub-domain identifier. Starting from the root node of the tree structure, corresponding domain nodes and sub-domain nodes are created or located sequentially according to the domain path, and hierarchical weights are set for the created nodes. Under the sub-domain node, a term node is created based on the character sequence of the sensitive word, and the term node is associated with a corresponding domain identifier and hierarchical weight; If there are sensitive words with the same character sequence but different domain identifiers in the preset sensitive word library, then mutually isolated term node branches are created for the character sequence under the corresponding different domain paths.

6. The method according to claim 1, characterized in that, The process of converting the hierarchical tree structure of the domain into the extended deterministic finite automaton includes: Based on the domain identifier of the nodes in the tree structure, non-overlapping index ranges in the array are pre-assigned to nodes in different domains; Traverse the tree structure, map the nodes in the tree structure to the state nodes of the extended deterministic finite automaton, and assign corresponding indices to the state nodes; For each state node assigned an index, perform the following assignment operation: The offset array stores the composite offset calculated based on the base offset and the neighborhood offset of the state node; The verification array stores the parent node index and hierarchical verification information of the status node; The domain array, the hierarchy array, and the termination identifier array respectively store the domain identifier, hierarchy weight, and termination status marker corresponding to the state node.

7. The method according to claim 1, characterized in that, The extended deterministic finite automaton stores state information using the following five parallel arrays: The offset array is used to store the composite offset of state transitions. The composite offset includes a base offset and a neighborhood offset. The neighborhood offset is determined based on the neighborhood identifier and offset base of the state node. The verification array is used to store the parent node index and hierarchical verification information of the status node; The domain array is used to store the domain identifiers corresponding to the state nodes; The hierarchical array is used to store the hierarchical weights corresponding to the state nodes; The termination identifier array is used to identify whether a status node is a termination node for a sensitive word.

8. A prompt word filtering device, characterized in that, The device includes: The matching module is used to match the input prompt words based on the extended deterministic finite automaton to obtain the target sensitive words; wherein the extended deterministic finite automaton is obtained by transforming the domain hierarchical tree structure and stores state information through the following arrays: an offset array for determining state transitions, a validation array for verifying the validity of state transitions, a domain array for storing domain identifiers, a hierarchy array for storing hierarchy weights, and a termination identifier array for marking the termination state of sensitive words; The processing module is used to process the prompt words according to the filtering strategy corresponding to the target sensitive words.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the prompt word filtering method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the prompt word filtering method according to any one of claims 1-7.