Fuzzy matching method and system based on AC tree, electronic equipment and storage medium

By setting the maximum number of skips and a two-branch matching strategy on the AC tree, combined with the reverse position correction algorithm, the matching problems of non-continuous matching and multilingual environments in the existing technology are solved, realizing efficient fuzzy matching and accurate position positioning, and improving the accuracy of keyword filtering and content analysis.

CN121579671APending Publication Date: 2026-02-27湖南四方天箭信息科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511677392.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing AC tree-based multi-pattern matching methods suffer from insufficient non-continuous matching capabilities, rigid matching rules, and insufficient accuracy in fuzzy matching when dealing with complex text environments. This results in low recall and high false negative rates, making it difficult to effectively identify non-continuous keywords and support multilingual environments.

Method used

A fuzzy matching method based on AC trees is adopted. By setting the maximum number of characters to skip, and combining a two-branch matching strategy and a reverse position correction algorithm, an AC tree is constructed and fuzzy matching is performed. This method supports the recognition of non-continuous keywords and accurate location positioning in multilingual environments.

Benefits of technology

It achieves effective identification and precise location of non-continuous keywords, improves recall rate by 30-50%, enhances the accuracy of keyword filtering and content analysis, and supports matching tasks in multilingual and complex modes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579671A_ABST
    Figure CN121579671A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of text processing and information retrieval, and discloses a fuzzy matching method and system based on an AC tree, electronic equipment and a storage medium. According to the fuzzy matching method based on the AC tree, a flexible matching strategy is achieved by setting the maximum skipping number, and in the process of matching a to-be-matched text based on the AC tree, the maximum skipping number is set, so that the matching efficiency is improved. If the current character is not matched, the current character is allowed to be skipped to continue matching until the set maximum skipping number is reached, accurate matching and fuzzy matching can be achieved at the same time, keywords in a discontinuous form can be effectively recognized, an accurate matching position can be returned, the accuracy of keyword filtering and content analysis is improved, and the user experience is improved. And matching tasks in multiple languages and complex modes can be supported.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of text processing and information retrieval, in particular, to an AC tree-based fuzzy matching method and system, an electronic device, and a computer-readable storage medium. BACKGROUND

[0002] Multi-pattern matching technology based on Aho-Corasick (AC automaton) algorithm is one of the core technologies in the field of text processing and information retrieval. Traditional AC automaton can achieve efficient state transition by constructing a finite state machine containing all pattern strings and using a failure pointer mechanism, and can complete the matching task within O(n+m+z) time complexity, where n is the length of the text, m is the sum of the lengths of all pattern strings, and z is the number of matching results. The AC automaton algorithm is widely used in sensitive word filtering, virus signature detection, biological information sequence analysis, log analysis, etc.

[0003] However, the existing AC tree-based multi-pattern matching method has the following technical defects when dealing with complex text environment:

[0004] 1. Lack of non-continuous matching capability: The existing technology requires strict continuous matching of pattern string characters, and cannot identify keywords separated by one or more irrelevant characters, such as "dangerous goods" and "illegal goods", etc., resulting in low recall rate in colloquial and unstructured text. For example, the Chinese invention patent application with publication number CN105373601A discloses a multi-pattern matching method based on keyword frequency features, which realizes pattern matching by constructing a binary tree containing word frequency information, and adopts a strict character continuous matching strategy.

[0005] 2. Matching rule rigidity: The existing technology usually does not support case-insensitive or automatic conversion between traditional and simplified Chinese matching, resulting in high false negative rate in multi-language or non-standard format text, and requiring tedious preprocessing of input text and keyword library.

[0006] 3. Insufficient precision of fuzzy matching: Some existing technologies introduce fuzzy concepts, but often at the expense of performance, or after identifying fuzzy matching, cannot accurately report the precise start and end positions of the keyword in the original text, limiting its value in application scenarios that require high-precision positioning (such as text highlighting and information extraction), and thus affecting the effectiveness of subsequent processing. For example, the Chinese invention patent application with publication number CN115238132A discloses a pattern string matching method, which mentions the concept of fuzzy matching, but fails to solve the problem of accurate position positioning of non-continuous character matching. SUMMARY

[0007] The application provides an AC tree-based fuzzy matching method and system, an electronic device and a computer-readable storage medium, which can effectively identify keywords in a discontinuous form, thereby realizing fuzzy matching, processing an incomplete matching condition, enhancing the accuracy of keyword filtering and content analysis, and supporting more languages and complex pattern matching.

[0008] According to an aspect of the application, an AC tree-based fuzzy matching method is provided, including the following steps:

[0009] Input a keyword set, a text to be matched and a maximum skip number, wherein the maximum skip number is used to limit the maximum number of characters allowed to be skipped in the matching process;

[0010] Construct an AC tree based on the keyword set;

[0011] Perform fuzzy matching on the text to be matched based on the AC tree and the maximum skip number, and output a matching result.

[0012] Further, the process of performing fuzzy matching on the text to be matched based on the AC tree and the maximum skip number includes the following steps:

[0013] Initialize a state metadata list of the AC tree, wherein each state metadata in the state metadata list includes a current state, a first skip character position and a skip character count;

[0014] Iterate through each character of the text to be matched, match each character using a double-branch matching strategy and update the state, and obtain a matching result of each character;

[0015] Perform deduplication processing on the matching result obtained after the iteration, and output a deduplicated matching result; wherein a matching result with a skip character count greater than 0 is regarded as a fuzzy matching result, and a matching result with a skip character count equal to 0 is regarded as an accurate matching result.

[0016] Further, the process of matching each character using a double-branch matching strategy and updating the state is specifically as follows:

[0017] For each character, parallel processing of the normal matching branch and the skip character branch is performed. For the normal matching branch, character matching is performed according to the standard transition rules of the AC state machine. When the match is successful, the current state is updated and it is checked whether the keyword is hit. If the keyword is hit, the start position, end position and keyword content of the matching result are recorded. For the skip character branch, under the premise of satisfying the preset skip constraint, the current state remains unchanged and the character is skipped. At the same time, the skipped character count and the first skipped character position are updated, and new state metadata is generated. The preset skip constraint must simultaneously satisfy the following conditions: the current state is not the root state, the skipped character count does not exceed the set upper limit, the current character is not the last character of the text and there is a change in the state before and after.

[0018] Furthermore, after the step of outputting the deduplicated matching results, the following is also included:

[0019] Determine whether the length of the matched fragment in the fuzzy matching result is equal to the length of the corresponding keyword. If it is equal, add the fuzzy matching result directly to the final output matching result set. If it is not equal, correct the fuzzy matching result by reversing its position.

[0020] Furthermore, the process of reversing the position of the fuzzy matching results includes the following:

[0021] Starting from the last character of the matching segment, iterate backwards in reverse order. At the same time, starting from the last character of the corresponding keyword, perform reverse matching with the matching segment in reverse order. During the reverse matching process, irrelevant characters in the matching segment are allowed to be skipped, but the characters of the keyword are required to appear in order. If the reverse matching is successful, record the offset of the reverse matching and correct the starting position in the fuzzy matching result according to the offset.

[0022] Furthermore, after the steps of inputting the keyword set and the text to be matched, the following is also included:

[0023] The keyword set and the text to be matched are preprocessed based on preset rules, wherein the preset rules include at least one of the following rules:

[0024] Case-sensitive configuration rule: Convert the keyword set and the text to be matched to lowercase or uppercase.

[0025] Simplified / Traditional Chinese sensitivity configuration rules: Convert or compare the keyword set and the text to be matched between simplified and traditional Chinese characters;

[0026] Keyword exclusion rules: Filter the keyword set and remove predefined exclusions.

[0027] Furthermore, the following content is included after outputting the matching results:

[0028] Visualize the matching results in the text to be matched.

[0029] In addition, the present invention also provides a fuzzy matching system based on an AC tree, comprising:

[0030] The data input module is used to input the keyword set, the text to be matched, and the maximum number of skips; the maximum number of skips is used to limit the maximum number of characters allowed to be skipped during the matching process.

[0031] An AC tree construction module is used to construct an AC tree based on the keyword set;

[0032] The fuzzy matching module is used to perform fuzzy matching on the text to be matched based on the AC tree and the maximum number of skips, and output the matching result.

[0033] In addition, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor executes the steps of the method described above by calling the computer program stored in the memory.

[0034] In addition, the present invention provides a computer-readable storage medium for storing a computer program for fuzzy matching based on an AC tree, wherein the computer program executes the steps of the method described above when running on a computer.

[0035] The present invention has the following beneficial effects:

[0036] The AC tree-based fuzzy matching method of this invention achieves a flexible matching strategy by setting a maximum number of skips. During the matching process of the text to be matched based on the AC tree, if the current character does not match, the current character is allowed to be skipped and the matching continues until the set maximum number of skips is reached. It can achieve both precise matching and fuzzy matching at the same time, and can effectively identify keywords in non-contiguous forms such as "dangerous goods" and "contraband". It can also return the precise matching position, improving the accuracy of keyword filtering and content analysis, and can support matching tasks in multiple languages ​​and complex modes.

[0037] In addition, the AC tree-based fuzzy matching system of the present invention also has the above-mentioned advantages.

[0038] In addition to the objectives, features, and advantages described above, the present invention has other objectives, features, and advantages. The invention will now be described in further detail with reference to the figures. Attached Figure Description

[0039] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:

[0040] Figure 1 This is a flowchart illustrating the fuzzy matching method based on the AC tree according to a preferred embodiment of this application;

[0041] Figure 2 This is a schematic diagram of the AC tree structure constructed based on h->s in a preferred embodiment of this application;

[0042] Figure 3 yes Figure 1 A schematic diagram of the sub-process of step S3;

[0043] Figure 4 yes Figure 1 Another sub-process diagram of step S3;

[0044] Figure 5 This is another flowchart illustrating the fuzzy matching method based on the AC tree according to a preferred embodiment of this application;

[0045] Figure 6 This is another flowchart illustrating the fuzzy matching method based on the AC tree according to a preferred embodiment of this application;

[0046] Figure 7 This is a schematic diagram of the module structure of a fuzzy matching system based on an AC tree according to another embodiment of this application. Detailed Implementation

[0047] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0048] This application is applicable to scenarios requiring non-continuous, case-insensitive, and simplified / traditional Chinese compatible keyword retrieval and analysis in complex text environments.

[0049] Reference Figure 1 As shown, a preferred embodiment of this application provides a fuzzy matching method based on an AC tree, including the following:

[0050] Step S1: Input the keyword set, the text to be matched, and the maximum number of skips, where the maximum number of skips is used to limit the maximum number of characters allowed to be skipped during the matching process.

[0051] Specifically, users can input a set of keywords to be matched and the text to be searched for, based on their actual needs. The keyword set includes the strings to be matched, which can be words or phrases, such as "dangerous goods" or "contraband." The text to be matched is the target text to be searched for, such as logs, document content, or web page content. Furthermore, users can flexibly set the maximum number of skips based on their matching accuracy requirements. The maximum number of skips limits the maximum number of characters allowed to be skipped during the matching process, enabling the matching of non-contiguous characters and thus achieving fuzzy matching.

[0052] Step S2: Construct an AC tree based on the keyword set.

[0053] Specifically, this step is used to construct an efficient AC double-array trie based on the keyword set. The AhoCorasick DoubleArrayTrie algorithm is used to construct the double-array trie, storing all pattern strings and establishing failure pointers between nodes during construction to facilitate transitions during matching. The double-array trie is a double-array data structure, storing state transition information in a state transition array (base array) and failure pointer information in a failure pointer array (fail array).

[0054] Based on this, this application makes the following improvements: The construction process adopts a ReentrantReadWriteLock read-write lock mechanism, supporting multi-threaded concurrent reading and ensuring thread safety in high-concurrency environments; a built-in caching mechanism avoids duplicate construction through hashCode comparison, improving dynamic update efficiency. When the keyword set changes, the AC tree structure is only reconstructed when the hashCode is different, significantly improving construction efficiency. For example, the AC tree structure based on h->s is as follows: Figure 2 As shown.

[0055] Step S3: Perform fuzzy matching on the text to be matched based on the AC tree and the maximum skip count, and output the matching results.

[0056] Specifically, this step is used to implement skip character matching. Using the maximum skip count and the constructed AC tree, it performs character matching on the input text to be matched, returning all matching results that meet the conditions. The matching results include the matched keyword content, start position, end position, and number of skipped characters. The algorithm's time complexity is O(n×k×s), where n is the text length, k is the maximum skip count, and s is the average number of states.

[0057] Among them, such as Figure 3 As shown, the process of performing fuzzy matching on the text to be matched based on the AC tree and the maximum skip count includes the following:

[0058] Step S31: Initialize the state metadata list of the AC tree; wherein each state metadata in the state metadata list includes the current state, the position of the first skipped character, and the skipped character count;

[0059] Step S32: Traverse each character of the text to be matched, use a two-branch matching strategy to match each character and update the state to obtain the matching result for each character;

[0060] Step S33: Perform deduplication on the matching results obtained after traversal and output the deduplicated matching results; among them, the matching results with a skipped character count greater than 0 are regarded as fuzzy matching results, and the matching results with a skipped character count equal to 0 are regarded as exact matching results.

[0061] Specifically, first, initialize the state metadata list of the AC tree. Each state metadata in the state metadata list includes the current state, the position of the first skipped character, and the skipped character count. The current state refers to the current state position in the AC automaton, the position of the first skipped character refers to the position index of the first skipped character, and the skipped character count refers to the cumulative number of skipped characters.

[0062] Then, each character of the text to be matched is traversed, and a two-branch matching strategy is used to match each character and update its state, resulting in the matching result for each character. Specifically, the process of using a two-branch matching strategy to match each character and update its state is as follows:

[0063] For each character, perform parallel processing of the normal matching branch and the character skipping branch. For the normal matching branch, perform character matching according to the standard transition rules of the AC state machine. When the match is successful, update the current state and check whether the keyword is hit. If it is hit, record the start position, end position and keyword content of the matching result.

[0064] For skipped character branches, provided that the preset skipping constraints are met, the current state remains unchanged and the character is skipped. Simultaneously, the skipped character count and the position of the first skipped character are updated, and new state metadata is generated. The preset skipping constraints must simultaneously meet the following four conditions: (1) the current state is not the root state; (2) the skipped character count has not exceeded the set upper limit; (3) the current character is not the last character of the text; and (4) there is a change in the preceding and following states. For skipped character branches, the position calculation formula is: starting position = current position - keyword length - number of skipped characters + 1; ending position = current position.

[0065] Understandably, this invention, through its parallel processing mechanism employing a dual-branch matching strategy, can simultaneously complete precise matching and fuzzy matching within a single text traversal. This represents a fundamental breakthrough from traditional "continuous matching" to "skipping character matching," overcoming the technical limitation of existing AC algorithms in handling non-continuous strings and significantly improving matching efficiency and coverage. Furthermore, it supports multi-threaded operations, greatly enhancing the performance of large-scale text analysis.

[0066] Finally, a LinkedHashSet collection is used to deduplicate the matching results obtained after traversal. This prevents duplicate matching results, maintains the insertion order of the matching results, and outputs the deduplicated matching results, reducing the computational burden of subsequent processing and avoiding performance waste caused by duplicate matching. The specific deduplication process is existing technology and will not be elaborated here. In the deduplicated output matching results, matches with a character count greater than 0 are considered fuzzy matches, while matches with a character count of 0 are considered exact matches.

[0067] Understandably, the AC tree-based fuzzy matching method of this invention achieves a flexible matching strategy by setting a maximum number of skips. During the matching process of the text to be matched based on the AC tree, if the current character does not match, it is allowed to skip the current character and continue matching until the set maximum number of skips is reached. It can achieve both precise matching and fuzzy matching at the same time, and can effectively identify keywords in non-continuous forms such as "dangerous goods" and "contraband". It can also return the precise matching position. The recall rate is 30-50% higher than that of the traditional AC algorithm, which effectively improves the accuracy of keyword filtering and content analysis. It can support matching tasks in multiple languages ​​and complex modes.

[0068] Optional, such as Figure 4 As shown, the process of performing fuzzy matching on the text to be matched based on the AC tree and the maximum skip count includes the following after the step of outputting the deduplicated matching result:

[0069] Step S34: Determine whether the length of the matched fragment in the fuzzy matching result is equal to the length of the corresponding keyword. If it is equal, directly add the fuzzy matching result to the final output matching result set. If it is not equal, correct the reverse order of the fuzzy matching result.

[0070] Specifically, for fuzzy matching results, the system first checks if the length of the matched segment is equal to the length of the corresponding keyword. If they are equal, the fuzzy matching result is directly added to the final output matching result set. If they are not equal, the fuzzy matching result is reversed to correct its position. This process checks for substring matches within the fuzzy matching result and corrects inaccurate starting positions. The final output matching result set includes the starting index position, the ending index position, and the matched keyword characters.

[0071] The process of reversing the order of the fuzzy matching results includes the following:

[0072] Starting from the last character of the matching segment, iterate backwards in reverse order. Simultaneously, starting from the last character of the corresponding keyword, perform reverse matching with the matching segment in reverse order. During the reverse matching process, irrelevant characters in the matching segment are allowed to be skipped, but the characters of the keyword must appear in order. If all characters of the keyword are found in the matching segment in order, the reverse matching is considered successful. The offset of the reverse matching is recorded, and the starting position in the fuzzy matching result is corrected according to the offset. That is, the new starting position = the original starting position + the offset returned by the reverse matching. The ending position remains unchanged to ensure the integrity of the matching segment.

[0073] Understandably, if the length of the matched segment is not equal to the length of the corresponding keyword, this invention corrects the starting position in the fuzzy matching result through an original reverse position correction algorithm. This can accurately locate the true starting position of the skip character matching, completely solving the problem of inaccurate position positioning caused by skip character matching. This is the first fuzzy matching technology to achieve accurate position return based on the AC automaton, effectively ensuring the accuracy of the fuzzy matching result.

[0074] Understandably, the fuzzy matching process and the reverse position correction process in this application are both indispensable. The former is responsible for discovering potential matches, while the latter is responsible for precise positioning. Only by using them together can a complete and practical non-continuous character matching solution be formed.

[0075] Optional, such as Figure 5 As shown, the AC tree-based fuzzy matching method further includes the following after inputting the keyword set and the text to be matched:

[0076] Step S12: Preprocess the keyword set and the text to be matched based on preset rules.

[0077] Specifically, the keyword set and the text to be matched can be preprocessed according to user-configured preset rules. These preset rules include at least one of case-sensitive rules, simplified / traditional Chinese character sensitivity rules, and keyword exclusion rules. Case-sensitive rules convert both the keyword set and the text to be matched to lowercase or uppercase, avoiding missed matches due to format differences. Simplified / traditional Chinese character sensitivity rules convert or compare the keyword set and the text to be matched between simplified and traditional Chinese characters, improving compatibility in multilingual environments. Keyword exclusion rules filter the keyword set, removing predefined exclusions and supporting dynamic filtering rules. Preprocessing the keyword set and the text to be matched according to preset rules significantly lowers the user barrier and improves system usability. The preprocessed keyword set and the text to be matched are then output for further processing.

[0078] Understandably, in this invention, users can set preset rules according to actual needs, thus making it applicable to multi-language scenarios such as case sensitivity and simplified / traditional character conversion. It supports intelligent recognition and matching of mixed Chinese and English text, and can also flexibly set exclusion word options in complex scenarios, thereby improving the applicability and compatibility of the algorithm.

[0079] Optional, such as Figure 6 As shown, the AC tree-based fuzzy matching method further includes the following after the step of outputting the matching result:

[0080] Step S4: Visualize the matching results in the text to be matched.

[0081] Specifically, the matching results are highlighted in the text to be matched, allowing users to quickly, accurately, and intuitively view the results, and facilitating development, debugging, and algorithm verification. Furthermore, clicking on the highlighted area allows users to view detailed matching information, including the matched content, the start and end positions of the match.

[0082] Understandably, this invention visualizes the matching results within the text to be matched, facilitating quick querying of results for users. Furthermore, the preceding reverse order correction algorithm provides accurate positional information for text highlighting, ensuring the accuracy of the visualization. In addition, the matching results support multiple output formats and can be directly used for scenarios such as text highlighting, content replacement, and information extraction.

[0083] In addition, such as Figure 7 As shown, another embodiment of the present invention also provides a fuzzy matching system based on an AC tree, preferably employing the fuzzy matching method based on an AC tree as described above, including:

[0084] The data input module is used to input the keyword set, the text to be matched, and the maximum number of skips; the maximum number of skips is used to limit the maximum number of characters allowed to be skipped during the matching process.

[0085] An AC tree construction module is used to construct an AC tree based on the keyword set;

[0086] The fuzzy matching module is used to perform fuzzy matching on the text to be matched based on the AC tree and the maximum number of skips, and output the matching result.

[0087] Understandably, the AC tree-based fuzzy matching system in this embodiment achieves a flexible matching strategy by setting a maximum number of skips. During the matching process of the text to be matched based on the AC tree, if the current character does not match, it is allowed to skip the current character and continue matching until the set maximum number of skips is reached. It can achieve both precise matching and fuzzy matching at the same time, and can effectively identify keywords in non-continuous forms such as "dangerous goods" and "contraband". It can also return the precise matching position. The recall rate is 30-50% higher than that of the traditional AC algorithm, which effectively improves the accuracy of keyword filtering and content analysis. It can support matching tasks in multiple languages ​​and complex modes.

[0088] In addition, the AC tree-based fuzzy matching system also includes:

[0089] The data preprocessing module is used to preprocess the keyword set and the text to be matched based on preset rules.

[0090] In addition, the AC tree-based fuzzy matching system also includes:

[0091] The visualization module is used to visualize the matching results in the text to be matched.

[0092] It is understood that each module of this system embodiment corresponds to each step of the above method embodiment. The specific working principle of each module will not be repeated here, but can be referred to the steps of the above method embodiment.

[0093] In addition, another embodiment of the present invention provides an electronic device including a processor and a memory, wherein the memory stores a computer program, and the processor executes the steps of the method described above by calling the computer program stored in the memory.

[0094] In addition, another embodiment of the present invention provides a computer-readable storage medium for storing a computer program for fuzzy matching based on an AC tree, wherein the computer program performs the steps of the method described above when run on a computer.

[0095] Common computer-readable storage media include: floppy disks, flexible disks, hard disks, magnetic tapes, any other magnetic media, CD-ROMs, any other optical media, punch cards, paper tape, any other physical media with perforated patterns, random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), flash erasable programmable read-only memory (FLASH-EPROM), any other memory chips or cartridges, or any other media readable by a computer. Instructions may further be transmitted or received by a transmission medium. The term transmission medium can include any tangible or intangible medium used to store, encode, or carry instructions for execution by a machine, and includes digital or analog communication signals or intangible media that facilitate communication of such instructions. Transmission media include coaxial cables, copper wires, and optical fibers, which contain conductors for transmitting a bus of computer data signals.

[0096] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0097] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0098] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0099] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0100] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0101] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

[0102] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A fuzzy matching method based on AC trees, characterized in that, Includes the following: Input the keyword set, the text to be matched, and the maximum number of skips; where the maximum number of skips is used to limit the maximum number of characters allowed to be skipped during the matching process; Construct an AC tree based on the keyword set; Based on the AC tree and the maximum skip count, perform fuzzy matching on the text to be matched and output the matching result.

2. The fuzzy matching method based on AC tree as described in claim 1, characterized in that, The process of performing fuzzy matching on the text to be matched based on the AC tree and the maximum skip count includes the following: Initialize the state metadata list of the AC tree; wherein each state metadata in the state metadata list includes the current state, the position of the first skipped character, and the skipped character count; Iterate through each character of the text to be matched, use a two-branch matching strategy to match each character and update the state to obtain the matching result for each character; The matching results obtained after traversal are deduplicated, and the deduplicated matching results are output. Among them, the matching results with a skipped character count greater than 0 are considered as fuzzy matching results, and the matching results with a skipped character count equal to 0 are considered as exact matching results.

3. The fuzzy matching method based on AC tree as described in claim 2, characterized in that, The process of matching each character and updating its state using a two-branch matching strategy is as follows: Perform parallel processing of the normal matching branch and the skip character branch for each character; For normal matching branches, character matching is performed according to the standard transition rules of the AC state machine. When a match is successful, the current state is updated and it is checked whether a keyword is hit. If a keyword is hit, the start position, end position, and keyword content of the matching result are recorded. For skip character branches, under the premise of satisfying the preset skip constraint, the current state remains unchanged and the character is skipped. At the same time, the skipped character count and the first skipped character position are updated, and new state metadata is generated. The preset skip constraint must simultaneously satisfy the following conditions: the current state is not the root state, the skipped character count does not exceed the set upper limit, the current character is not the last character of the text, and there is a change in the state before and after.

4. The fuzzy matching method based on AC tree as described in claim 2, characterized in that, The following is included after the step of outputting the deduplicated matching results: Determine whether the length of the matched fragment in the fuzzy matching result is equal to the length of the corresponding keyword. If it is equal, add the fuzzy matching result directly to the final output matching result set. If it is not equal, correct the fuzzy matching result by reversing its position.

5. The fuzzy matching method based on AC tree as described in claim 4, characterized in that, The process of reversing the order of the fuzzy matching results includes the following: Starting from the last character of the matching segment, iterate backwards in reverse order. At the same time, starting from the last character of the corresponding keyword, perform reverse matching with the matching segment in reverse order. During the reverse matching process, irrelevant characters in the matching segment are allowed to be skipped, but the characters of the keyword are required to appear in order. If the reverse matching is successful, record the offset of the reverse matching and correct the starting position in the fuzzy matching result according to the offset.

6. The fuzzy matching method based on AC tree as described in claim 1, characterized in that, After the steps of entering the keyword set and the text to be matched, the following is also included: The keyword set and the text to be matched are preprocessed based on preset rules, wherein the preset rules include at least one of the following rules: Case-sensitive configuration rule: Convert the keyword set and the text to be matched to lowercase or uppercase. Simplified / Traditional Chinese sensitivity configuration rules: Convert or compare the keyword set and the text to be matched between simplified and traditional Chinese characters; Keyword exclusion rules: Filter the keyword set and remove predefined exclusions.

7. The fuzzy matching method based on AC tree as described in claim 1, characterized in that, The following content is included after the output of the matching results: Visualize the matching results in the text to be matched.

8. A fuzzy matching system based on an AC tree, characterized in that, include: The data input module is used to input the keyword set, the text to be matched, and the maximum number of skips; the maximum number of skips is used to limit the maximum number of characters allowed to be skipped during the matching process. An AC tree construction module is used to construct an AC tree based on the keyword set; The fuzzy matching module is used to perform fuzzy matching on the text to be matched based on the AC tree and the maximum number of skips, and output the matching result.

9. An electronic device, characterized in that, The method includes a processor and a memory, wherein the memory stores a computer program, and the processor performs the steps of the method as described in any one of claims 1 to 7 by invoking the computer program stored in the memory.

10. A computer-readable storage medium for storing a computer program for fuzzy matching based on an AC tree, characterized in that, The computer program, when run on a computer, performs the steps of the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Keyword word frequency characteristic-based multimode matching method

    CN105373601A

  • Matching method and device of pattern string

    CN115238132A