A method of processing streaming text

The streaming text processing method designed using trie and state machine solves the performance bottleneck and high memory consumption problems in existing technologies, achieving efficient and real-time text processing, and is suitable for a variety of application scenarios.

CN122174789APending Publication Date: 2026-06-094399 NETWORK

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
4399 NETWORK
Filing Date
2026-02-27
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing text processing methods suffer from performance bottlenecks, high memory consumption, and the inability to perform streaming processing, thus failing to support character-by-character input and real-time operation.

Method used

It adopts a trie structure and state machine design. By constructing a trie of pattern strings, setting priority and fail pointers, it realizes character-by-character matching and replacement, and introduces a global position tracking and state preservation mechanism to support streaming text processing.

Benefits of technology

It achieves efficient processing with linear time complexity, supports streaming processing, reduces memory usage, ensures the accuracy of cross-block matching, and is suitable for scenarios such as real-time chat systems and large file processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122174789A_ABST
    Figure CN122174789A_ABST
Patent Text Reader

Abstract

The application provides a kind of stream text processing method, comprising the following steps: determining the pattern string needing to be matched;Set the priority of pattern string;Build the dictionary tree corresponding to all the pattern string;Based on the priority of pattern string and the dictionary tree built, multi-pattern string matching is carried out on the input stream text, and the matched pattern string is replaced with the corresponding replacement string.It has the following advantages: efficiency: the overall time complexity is linear time, better than regular expression.Real-time: support stream processing, text arrives immediately can be processed immediately, no need to wait for complete input.Accuracy: through global position tracking and state keeping mechanism, ensure the accuracy of cross-block matching.Memory optimization: through intelligent buffer management and state reset mechanism, significantly reduce memory occupation.Overlap processing: automatically process overlapping matching, avoid repeated replacement and conflict.Wide applicability: especially suitable for real-time chat system, large file processing, memory limited environment, etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of text processing technology, and more specifically to a streaming text processing method. Background Technology

[0002] Currently, text processing primarily uses regular expressions, which are widely used for string matching and replacement operations, such as the `String.replace()` method in JavaScript. However, this approach has the following drawbacks: Performance bottleneck: For matching multiple pattern strings, the regular expression needs to traverse the text multiple times, resulting in a worst-case time complexity of O(n²), which is inefficient. High memory consumption: The entire text must be loaded into memory at once for processing. Inability to stream: It does not support character-by-character input; matching and replacement operations can only be performed after the complete text has been input. Summary of the Invention

[0003] To address the shortcomings of existing technologies, this invention provides a streaming text processing method that can effectively solve the aforementioned problems.

[0004] The technical solution adopted in this invention is as follows:

[0005] This invention provides a streaming text processing method, comprising the following steps:

[0006] Step S1, determine the match to be made. A pattern string; each pattern string consists of several characters arranged in sequence; a replacement string is set for each of the pattern strings;

[0007] Step S2, set the priority of the pattern string:

[0008] exist In a pattern string, if a pattern string For another pattern string If the pattern string is a prefix or suffix, then the pattern string is set according to its length. and pattern string Priority, i.e., pattern string The priority is higher than the pattern string. Priority;

[0009] Step S3: Construct a trie corresponding to all the pattern strings; the trie has a root node and multiple nodes; the trie has the following characteristics:

[0010] The root node does not store characters; each node stores one character.

[0011] All child nodes of the root node store distinct characters; for each node, if it has child nodes, the characters stored by those child nodes are also distinct.

[0012] For the root node and each node with child nodes, a corresponding child node mapping table is established, and the child node mapping table stores the characters of each child node;

[0013] When each child node of the root node reaches a leaf node along the path of the parent-child relationship, a path is formed; the characters of each node on each path form a string in sequence, corresponding to a pattern string; a pattern string end marker and the corresponding pattern string content are added to the leaf node.

[0014] For a pattern string represented by a path from a child node of the root node to a leaf node, if the pattern string has a prefix pattern string, the prefix pattern string is still in the path. At the node corresponding to the end of the prefix pattern string, the prefix pattern string end flag and the corresponding prefix pattern string content are added.

[0015] For a pattern string represented by a path from a root node to a leaf node, if the pattern string has a suffix pattern string, then the suffix pattern string is located on another path; a critical jump link pointing to the starting character node of the suffix pattern string is added to the starting character node of the suffix pattern string; and an inheritance jump link pointing to the corresponding character node of the suffix pattern string is added to each other character node of the suffix pattern string.

[0016] Add a Fail pointer to each node. The Fail pointer represents the target node to which the node moves after a failed match. Except for the following cases, the Fail pointer of each node points to the root node: For the pattern string with a suffix pattern string, add a Fail pointer to each character node of the suffix pattern string to point to the corresponding character node of the suffix pattern string.

[0017] Step S4: Based on the priority of the pattern string and the constructed trie, perform multi-pattern string matching on the input streaming text, and replace the matched pattern string with the corresponding replacement string.

[0018] Furthermore, step S4 includes:

[0019] Step S41: Preset the text block division method, including dividing the text block by time interval or dividing the text block by the number of consecutive characters;

[0020] Step S42: When a new text character stream is detected, initialize the global position counter to 0 and initialize the current node currentNode to the root node of the trie.

[0021] Step S43: Receive the character stream in real time; the global position counter counts the position of each received character.

[0022] Step S44, character-by-character matching:

[0023] For each received character, character matching is performed based on the current node (currentNode) of the trie, in the following manner:

[0024] For the received current character to be matched, locate the current node currentNode in the trie, read the child node mapping table of the current node currentNode, and determine whether the current character is the same as a character in a child node of the current node currentNode's child node mapping table. If they are not the same, the match fails, and jump to the corresponding target node according to the Fail pointer of the current node currentNode. Then update the current node currentNode to the target node and continue to receive the next character for character matching. If the same character exists, the match succeeds, and update the current node currentNode in the trie to the child node with the same character match, and continue to receive the next character for character matching.

[0025] During the character-by-character matching process, for each current node located, if it also carries the prefix pattern string ending flag, the matched prefix pattern string is also recorded in the cache.

[0026] During the character-by-character matching process, for each current node located, if it also carries the end marker of the pattern string, the matched pattern string is also recorded in the cache.

[0027] During the character-by-character matching process, for each current node located, if it also has a key jump link, then according to the key jump link, the node with the same character in another path in the trie is located, which is called the secondary current node. The secondary current node does not need to perform character matching and directly obtains the conclusion that it matches the current character successfully.

[0028] During the character-by-character matching process, for each current node located, if it also has an inheritance jump link, then the node with the same character in another path in the trie is located according to the inheritance jump link. This node is called the inheritance node. The inheritance node does not need to perform character matching and directly inherits the matching result of the current node, including the matching result of successful matching and the matching result of unsuccessful matching.

[0029] Step S45, Overlap Matching:

[0030] During the character-by-character matching process, when the last character of the current text block is processed, all pattern strings matched by the current text block are recorded in the cache. Overlap matching is performed on each pattern string. If an overlap relationship (i.e., a priority relationship) is detected between two pattern strings, the higher priority pattern string is directly replaced with the corresponding replacement string and output.

[0031] Furthermore, during the character-by-character matching process, when the last character of the current text block is processed, a state preservation mechanism is adopted, that is, the state of the current node currentNode is preserved and not updated, and then the character matching of the next text block is continued.

[0032] Furthermore, after each text block completes character matching and pattern string replacement, the cache is cleared before processing the next text block.

[0033] The streaming text processing method provided by this invention has the following advantages: (1) High efficiency: The overall time complexity is O(n+m) linear time, which is better than O(n²) for regular expressions. (2) Real-time: It supports streaming processing, and the text can be processed immediately upon arrival without waiting for complete input. (3) Accuracy: It ensures the accuracy of cross-block matching through global position tracking and state maintenance mechanisms. (4) Scalability: It supports dynamically adding pattern strings to adapt to different application scenarios. (5) Compatibility: It is suitable for browsers and Node.js environments without external dependencies. (6) Memory optimization: It significantly reduces memory usage through intelligent buffer management and state reset mechanisms. (7) Overlapping handling: It automatically handles overlapping matching to avoid duplicate replacements and conflicts. (8) Wide applicability: It is particularly suitable for scenarios such as real-time chat systems, large file processing, and memory-constrained environments. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention 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 some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0035] Figure 1 A flowchart of the streaming text processing method provided by the present invention.

[0036] Figure 2 A flowchart of the state management mechanism provided by this invention.

[0037] Figure 3 A flowchart of the overlapping matching processing method provided by the present invention. Detailed Implementation

[0038] To make the technical problems solved, the technical solutions, and the beneficial effects of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the invention.

[0039] This invention provides a streaming text processing method involving streaming multi-pattern string matching and replacement. This method is particularly suitable for applications requiring real-time processing of dynamic text streams, such as chat systems, real-time editors, and content management systems. This technology is also applicable to server-side use; simply rewrite the provided JavaScript code into the corresponding server-side programming language.

[0040] The streaming text processing method provided by this invention has the following characteristics:

[0041] 1. Enables real-time processing of text streams without waiting for complete input;

[0042] 2. Supports continuous processing across text blocks, ensuring matching accuracy through state preservation;

[0043] 3. Provides an intelligent buffer management mechanism to reduce memory usage;

[0044] 4. Introduce global position tracking functionality to ensure the integrity of matching results;

[0045] 5. Supports overlapping matching parsing to avoid duplicate replacements and conflicts;

[0046] 6. Reduce memory pressure and latency when processing large files or long texts.

[0047] This invention provides a streaming text processing method, comprising the following steps:

[0048] Step S1, determine the match to be made. A pattern string; each pattern string consists of several characters arranged in sequence; a replacement string is set for each of the pattern strings;

[0049] Step S2, set the priority of the pattern string:

[0050] exist In a pattern string, if a pattern string For another pattern string If the pattern string is a prefix or suffix, then the pattern string is set according to its length. and pattern string Priority, i.e., pattern string The priority is higher than the pattern string. Priority;

[0051] Step S3: Construct a trie corresponding to all the pattern strings; the trie has a root node and multiple nodes; the trie has the following characteristics:

[0052] The root node does not store characters; each node stores one character.

[0053] All child nodes of the root node store distinct characters; for each node, if it has child nodes, the characters stored by those child nodes are also distinct.

[0054] For the root node and each node with child nodes, a corresponding child node mapping table is established, and the child node mapping table stores the characters of each child node;

[0055] When each child node of the root node reaches a leaf node along the path of the parent-child relationship, a path is formed; the characters of each node on each path form a string in sequence, corresponding to a pattern string; a pattern string end marker and the corresponding pattern string content are added to the leaf node.

[0056] For a pattern string represented by a path from a child node of the root node to a leaf node, if the pattern string has a prefix pattern string, the prefix pattern string is still in the path. At the node corresponding to the end of the prefix pattern string, the prefix pattern string end flag and the corresponding prefix pattern string content are added.

[0057] For a pattern string represented by a path from a root node to a leaf node, if the pattern string has a suffix pattern string, then the suffix pattern string is located on another path; a critical jump link pointing to the starting character node of the suffix pattern string is added to the starting character node of the suffix pattern string; and an inheritance jump link pointing to the corresponding character node of the suffix pattern string is added to each other character node of the suffix pattern string.

[0058] Add a Fail pointer to each node. The Fail pointer represents the target node to which the node moves after a failed match. Except for the following cases, the Fail pointer of each node points to the root node: For the pattern string with a suffix pattern string, add a Fail pointer to each character node of the suffix pattern string to point to the corresponding character node of the suffix pattern string.

[0059] Step S4: Based on the priority of the pattern string and the constructed trie, perform multi-pattern string matching on the input streaming text, and replace the matched pattern string with the corresponding replacement string.

[0060] Step S4 includes:

[0061] Step S41: Preset the text block division method, including dividing the text block by time interval or dividing the text block by the number of consecutive characters;

[0062] Step S42: When a new text character stream is detected, initialize the global position counter to 0 and initialize the current node currentNode to the root node of the trie.

[0063] Step S43: Receive the character stream in real time; the global position counter counts the position of each received character.

[0064] Step S44, character-by-character matching:

[0065] For each received character, character matching is performed based on the current node (currentNode) of the trie, in the following manner:

[0066] For the received current character to be matched, locate the current node currentNode in the trie, read the child node mapping table of the current node currentNode, and determine whether the current character is the same as a character in a child node of the current node currentNode's child node mapping table. If they are not the same, the match fails, and jump to the corresponding target node according to the Fail pointer of the current node currentNode. Then update the current node currentNode to the target node and continue to receive the next character for character matching. If the same character exists, the match succeeds, and update the current node currentNode in the trie to the child node with the same character match, and continue to receive the next character for character matching.

[0067] During the character-by-character matching process, for each current node located, if it also carries the prefix pattern string ending flag, the matched prefix pattern string is also recorded in the cache.

[0068] During the character-by-character matching process, for each current node located, if it also carries the end marker of the pattern string, the matched pattern string is also recorded in the cache.

[0069] During the character-by-character matching process, for each current node located, if it also has a key jump link, then according to the key jump link, the node with the same character in another path in the trie is located, which is called the secondary current node. The secondary current node does not need to perform character matching and directly obtains the conclusion that it matches the current character successfully.

[0070] During the character-by-character matching process, for each current node located, if it also has an inheritance jump link, then the node with the same character in another path in the trie is located according to the inheritance jump link. This node is called the inheritance node. The inheritance node does not need to perform character matching and directly inherits the matching result of the current node, including the matching result of successful matching and the matching result of unsuccessful matching.

[0071] Step S45, Overlap Matching:

[0072] During the character-by-character matching process, when the last character of the current text block is processed, all pattern strings matched by the current text block are recorded in the cache. Overlap matching is performed on each pattern string. If an overlap relationship (i.e., a priority relationship) is detected between two pattern strings, the higher priority pattern string is directly replaced with the corresponding replacement string and output.

[0073] In this invention, during the character-by-character matching process, when the last character of the current text block is processed, a state preservation mechanism is adopted, that is, the state of the current node currentNode is preserved and not updated, and then the character matching of each character of the next text block continues.

[0074] In this invention, after each text block completes character matching and pattern string replacement, the cache is cleared before processing the next text block.

[0075] The core innovation of the streaming text processing method provided by this invention is as follows:

[0076] 1. Streaming processing architecture design:

[0077] A four-layer architecture model is adopted, including:

[0078] Input layer: Receives text streams from external input and passes them to the streaming processor; it also supports dynamically adding pattern string configurations.

[0079] Core processing layer: Constructs a trie structure and generates a Fail pointer, forming a complete automaton state machine.

[0080] Streaming engine: Includes state management, real-time matching, buffer management, and overlapping matching parsing modules, supporting character-by-character processing.

[0081] Output layer: Generates replacement content based on the matching results and outputs the processing results in real time.

[0082] 2. Characteristics of a trie structure:

[0083] Child node mapping table: records the set of child nodes of the current node.

[0084] Fail pointer: Points to the target node for failover of the current node.

[0085] End-of-pattern flag: Indicates whether the current node is the end of a complete pattern string. Pattern string end-of-pattern flags are divided into two categories: prefix pattern string end-of-pattern flags and pattern string end-of-pattern flags;

[0086] Pattern string content: Stores the complete pattern string represented by this node.

[0087] Replacement content: The corresponding replacement string when this pattern string is matched.

[0088] Output list: Records all pattern strings that end with the current node.

[0089] This structure supports efficient multi-pattern string matching and replacement.

[0090] 3. Core algorithm for streaming processing:

[0091] The streaming processing of this invention mainly includes the following stages:

[0092] • State initialization: Set the root node as the current node during the first processing.

[0093] • Character-by-character processing: Proceeding the automaton state step by step according to the character sequence.

[0094] • State transition: Find the next state node based on the current character.

[0095] • Match detection: If the current node is the end of the pattern string, record the matching result.

[0096] • Output generation: Generate replacement content based on the matching results.

[0097] • State Update: Save the current node state and update the global position counter.

[0098] The entire processing flow supports real-time input and processing of text streams without waiting for the complete text.

[0099] 4. State Management Mechanism:

[0100] This invention introduces a state preservation mechanism, which allows the current node state to be retained after processing a text block, so that subsequent text blocks can continue to be processed. This mechanism ensures the consistency and correctness of cross-block matching.

[0101] In addition, the present invention provides a global position counter for tracking the position of the entire text stream, thereby providing accurate positioning information in the matching results.

[0102] 5. Overlapping Matching Mechanism

[0103] To handle overlapping matching between multiple pattern strings, this invention employs the following strategy:

[0104] Sort all matching results by their starting position.

[0105] • For matches with the same starting position, sort them in descending order of length.

[0106] • Traverse the sorted matching results and check whether each match overlaps with the previous one.

[0107] • If there is no overlap, keep it; otherwise, skip the current match.

[0108] • Update the position of the last match for subsequent judgments.

[0109] This mechanism effectively avoids duplicate replacements and conflicts, improving the accuracy of matching results.

[0110] 6. Memory optimization strategies

[0111] This invention introduces a variety of memory optimization techniques:

[0112] • Intelligent buffer management: Only retains the content that needs to be matched in the current text block, avoiding repeated processing of already matched parts.

[0113] • State reset mechanism: The state can be manually reset after processing to prevent memory leaks.

[0114] • Matching cleanup mechanism: Clean up completed matching results in a timely manner to release memory resources.

[0115] Compared with the prior art, the effects achieved by this invention are:

[0116] • Efficiency: The overall time complexity is O(n+m) linear time, which is better than O(n²) for regular expressions.

[0117] • Real-time performance: Supports streaming processing, text can be processed immediately upon arrival, without waiting for complete input.

[0118] • Accuracy: Ensures the accuracy of cross-block matching through global location tracking and state preservation mechanisms.

[0119] • Scalability: Supports dynamically adding pattern strings to adapt to different application scenarios.

[0120] • Compatibility: Works with browsers and Node.js environments, with no external dependencies.

[0121] • Memory optimization: Significantly reduces memory usage through intelligent buffer management and state reset mechanisms.

[0122] • Overlap handling: Automatically handles overlapping matches to avoid duplicate replacements and conflicts.

[0123] • Wide applicability: Especially suitable for scenarios such as real-time chat systems, large file processing, and memory-constrained environments.

[0124] The streaming text processing method provided by this invention can be used in the following scenarios:

[0125] Scenario 1: Basic Usage

[0126] Users can create AC automaton instances by calling the API interface and sequentially add pattern strings and their corresponding replacement content. Then, a failure pointer function is called to complete the state machine construction. Finally, the text stream to be processed is fed into the streaming processing interface, and the invention will gradually return the matched results.

[0127] Scenario 2: Batch Adding Pattern Strings

[0128] This invention supports batch importing of multiple pattern strings and their replacement rules, facilitating centralized configuration and management. After constructing the failure pointer, streaming text processing can be performed uniformly.

[0129] Scenario 3: Automatic Link Recognition

[0130] Users can bind keywords to URLs. This invention automatically replaces the pattern string with a hyperlink format during streaming processing, making it suitable for scenarios such as web page content generation and keyword recognition on social platforms.

[0131] Scenario 4: Performance Statistics Function

[0132] This invention has a built-in performance statistics module that can obtain key indicators such as the total number of characters processed, the number of matches, and the construction time at any time, which facilitates monitoring and optimization.

[0133] Scenario 5: Sensitive Word Filtering

[0134] In the chat system, this invention receives user input character by character, automatically identifies and replaces sensitive words, realizes real-time content review, and prevents the spread of inappropriate remarks.

[0135] Scenario 6: Large File Processing

[0136] When processing large log files or text files, this invention reads and processes the file content in blocks, eliminating the need to load the entire file into memory and effectively reducing resource consumption.

[0137] Scenario 7: Handling HTML Tag Nesting

[0138] This invention can distinguish between HTML tags and plain text content, and replace keywords in the text area without affecting the original tag structure. It is suitable for rich text editors and other scenarios.

[0139] Scenario 8: Asynchronous processing combined with Web Workers (Frontend)

[0140] On the browser side, this invention can use Web Workers to implement background thread processing, avoiding blocking the main thread and improving page response speed and user experience.

[0141] Scenario 9: Hot Update Mechanism (Server-side)

[0142] This invention supports dynamically loading new matching rules and rebuilding failure pointers at runtime, making it suitable for server-side applications that require frequent rule updates, and it takes effect without restarting the service.

[0143] Scenario 10: Optimized Compressed Transmission

[0144] This invention supports compressed encoding of processed text, which is suitable for remote call or API communication scenarios and saves bandwidth resources.

[0145] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A streaming text processing method, characterized in that, Includes the following steps: Step S1, determine the match to be made. A pattern string; each pattern string consists of several characters arranged in sequence; a replacement string is set for each of the pattern strings; Step S2, set the priority of the pattern string: exist In a pattern string, if a pattern string For another pattern string If the pattern string is a prefix or suffix, then the pattern string is set according to its length. and pattern string Priority, i.e., pattern string The priority is higher than the pattern string. Priority; Step S3: Construct a trie corresponding to all the pattern strings; the trie has a root node and multiple nodes; the trie has the following characteristics: The root node does not store characters; each node stores one character. All child nodes of the root node store distinct characters; for each node, if it has child nodes, the characters stored by those child nodes are also distinct. For the root node and each node with child nodes, a corresponding child node mapping table is established, and the child node mapping table stores the characters of each child node; When each child node of the root node reaches a leaf node along the path of the parent-child relationship, a path is formed; the characters of each node on each path form a string in sequence, corresponding to a pattern string; a pattern string end marker and the corresponding pattern string content are added to the leaf node. For a pattern string represented by a path from a child node of the root node to a leaf node, if the pattern string has a prefix pattern string, the prefix pattern string is still in the path. At the node corresponding to the end of the prefix pattern string, the prefix pattern string end flag and the corresponding prefix pattern string content are added. For a pattern string represented by a path from a root node to a leaf node, if the pattern string has a suffix pattern string, then the suffix pattern string is located on another path; a critical jump link pointing to the starting character node of the suffix pattern string is added to the starting character node of the suffix pattern string; and an inheritance jump link pointing to the corresponding character node of the suffix pattern string is added to each other character node of the suffix pattern string. Add a Fail pointer to each node. The Fail pointer represents the target node to which the node moves after a failed match. Except for the following cases, the Fail pointer of each node points to the root node: For the pattern string with a suffix pattern string, add a Fail pointer to each character node of the suffix pattern string to point to the corresponding character node of the suffix pattern string. Step S4: Based on the priority of the pattern string and the constructed trie, perform multi-pattern string matching on the input streaming text, and replace the matched pattern string with the corresponding replacement string.

2. The streaming text processing method according to claim 1, characterized in that, Step S4 includes: Step S41: Preset the text block division method, including dividing the text block by time interval or dividing the text block by the number of consecutive characters; Step S42: When a new text character stream is detected, initialize the global position counter to 0 and initialize the current node currentNode to the root node of the trie. Step S43: Receive the character stream in real time; the global position counter counts the position of each received character. Step S44, character-by-character matching: For each received character, character matching is performed based on the current node (currentNode) of the trie, in the following manner: For the received current character to be matched, locate the current node currentNode in the trie, read the child node mapping table of the current node currentNode, and determine whether the current character is the same as a character in a child node of the current node currentNode's child node mapping table. If they are not the same, the match fails, and jump to the corresponding target node according to the Fail pointer of the current node currentNode. Then update the current node currentNode to the target node and continue to receive the next character for character matching. If the same character exists, the match succeeds, and update the current node currentNode in the trie to the child node with the same character match, and continue to receive the next character for character matching. During the character-by-character matching process, for each current node located, if it also carries the prefix pattern string ending flag, the matched prefix pattern string is also recorded in the cache. During the character-by-character matching process, for each current node located, if it also carries the end marker of the pattern string, the matched pattern string is also recorded in the cache. During the character-by-character matching process, for each current node located, if it also has a key jump link, then according to the key jump link, the node with the same character in another path in the trie is located, which is called the secondary current node. The secondary current node does not need to perform character matching and directly obtains the conclusion that it matches the current character successfully. During the character-by-character matching process, for each current node located, if it also has an inheritance jump link, then the node with the same character in another path in the trie is located according to the inheritance jump link. This node is called the inheritance node. The inheritance node does not need to perform character matching and directly inherits the matching result of the current node, including the matching result of successful matching and the matching result of unsuccessful matching. Step S45, Overlap Matching: During the character-by-character matching process, when the last character of the current text block is processed, all pattern strings matched by the current text block are recorded in the cache. Overlap matching is performed on each pattern string. If an overlap relationship (i.e., a priority relationship) is detected between two pattern strings, the higher priority pattern string is directly replaced with the corresponding replacement string and output.

3. The streaming text processing method according to claim 2, characterized in that, During the character-by-character matching process, when the last character of the current text block is processed, a state preservation mechanism is adopted, that is, the state of the current node currentNode is preserved and not updated, and then the character matching of the next text block is continued.

4. The streaming text processing method according to claim 2, characterized in that, After each text block completes character matching and pattern string replacement, the cache is cleared before processing the next text block.