A string matching method, device, equipment and storage medium

By establishing a matching tree in string matching, the problems of poor intuitiveness and wrong matching position of existing tools are solved, and flexible and practical string matching is achieved, which is suitable for smart city construction and other fields.

CN112559818BActive Publication Date: 2025-03-21PINGAN INT SMART CITY TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011482497.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-15
Publication Date
2025-03-21
Estimated Expiration
2040-12-15

AI Technical Summary

Technical Problem

The existing string matching tools are not intuitive enough, have poor practicality, and are prone to errors in matching positions.

Method used

By finding the matching segment in the two strings as the root node of the matching tree, in the subsequent left substring match and right substring match, the child nodes of the matching tree are established by finding the matching segment to ensure the order of the original strings.

Benefits of technology

It realizes flexible string matching, ensures the order of the original strings, is of good practicality, and can flexibly operate nodes in the matching tree, reducing code coupling and facilitating expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112559818B_ABST
    Figure CN112559818B_ABST
Patent Text Reader

Abstract

The present invention discloses a string matching method, device, equipment and storage medium. The method comprises: matching the first matching segment of two strings and recording it in a root node; obtaining the left substring and the right substring of the first matching segment from the two strings as the left node and the right node of the root node respectively; taking the left node and the right node as the current node in turn, matching the second matching segment of the two substrings of the current node; if matched, recording the matched second matching segment in the current node, obtaining the left substring and the right substring of the second matching segment from the two substrings of the current node as the left node and the right node of the current node respectively, and continuing to match; if not matched, determining the mismatch type of the two substrings of the current node and recording it in the current node. By always searching for matching segments in the parent string and the substring to establish nodes of the matching tree, the order of the original string is guaranteed. Since each node records the intermediate matching result, each node can be flexibly operated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and is specifically applied to the field of intelligent decision-making, and relates to a string matching method, device, equipment and storage medium. Background Art

[0002] With the rise of artificial intelligence technology, string matching is involved in many technical fields (such as natural language processing, text analysis, etc.). Therefore, how to develop a practical matching solution has always been a concern of people.

[0003] At present, most of the string matching tools available in the industry are not intuitive enough. Some only show different positions, which are not friendly to end users; some can only find the similarities and differences, but disrupt the order, which is not practical; some will have incorrect matching positions. Summary of the invention

[0004] The purpose of the present invention is to provide a string matching method, device, equipment and storage medium in view of the above-mentioned deficiencies in the prior art, and the purpose is achieved through the following technical solutions.

[0005] A first aspect of the present invention provides a string matching method, the method comprising:

[0006] S1, match the first matching segment of the two strings and record it in the root node;

[0007] S2. Obtain the left substring and the right substring of the first matching segment from the two character strings as the left node and the right node of the root node respectively;

[0008] S3, taking the left node and the right node as the current node in turn, and matching the second matching segments of the two substrings of the current node;

[0009] S4. If a match is found, the matched second matching segment is recorded in the current node, the left substring and the right substring of the second matching segment are obtained from the two substrings of the current node as the left node and the right node of the current node respectively, and step S3 is continued;

[0010] S5. If no match is found, determine the mismatch type of the two substrings of the current node and record it in the current node.

[0011] A second aspect of the present invention provides a string matching device, the device comprising:

[0012] A root node module, used to match the first matching segments of two strings and record them in the root node;

[0013] A sub-node module, used for obtaining a left sub-string and a right sub-string of the first matching segment from the two character strings as a left node and a right node of the root node respectively;

[0014] A substring matching module, used to take the left node and the right node as the current node in sequence, and match the second matching segments of two substrings of the current node;

[0015] A first processing module is used to record the matched second matching segment into the current node when a match is found, obtain the left substring and the right substring of the second matching segment from the two substrings of the current node as the left node and the right node of the current node respectively, and continue to execute the process of the substring matching module;

[0016] The second processing module is used to determine the mismatch type of the two substrings of the current node and record it in the current node when no match is found.

[0017] The third aspect of the present invention proposes a string matching device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the string matching method described in the first aspect when executing the program.

[0018] A fourth aspect of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the string matching method described in the first aspect are implemented.

[0019] The string matching method described in the first aspect has the following beneficial effects:

[0020] By finding the matching segment in the two strings as the root node of the matching tree, the child nodes of the matching tree are always established by finding the matching segment in the subsequent left substring matching and right substring matching to ensure the order of the original string. Since each node in the matching tree records the intermediate matching result, each node can be flexibly operated, which is practical. In addition, when traversing the matching tree output, the output result can be changed by modifying the output mode of each node, which can achieve the purpose of separating the matching tree from the output matching result, has a smaller code coupling degree, and is easy to expand. This solution can be applied to the field of smart education, thereby promoting the construction of smart cities. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1This is a flow chart of an embodiment of a string matching method according to an exemplary embodiment of the present invention;

[0023] Figure 2 A schematic diagram of a matching tree establishment process shown in the present invention;

[0024] Figure 3 The present invention is based on Figure 2 A schematic diagram of a matching result output shown in the illustrated embodiment;

[0025] Figure 4 A hardware structure diagram of a string matching device according to an exemplary embodiment of the present invention;

[0026] Figure 5 The figure is a flow chart of an embodiment of a string matching device according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0027] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0028] The terms used in the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0029] It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0030] In order to solve the problem that most of the string matching tools in the industry are not flexible enough and have poor practicality, the present application proposes an improved string matching method, namely, by finding a matching segment in two strings as the root node of a matching tree, in subsequent left substring matching and right substring matching, child nodes of the matching tree are always established by finding the matching segment to ensure the order of the original string. Since each node in the matching tree records the intermediate matching results, each node can be flexibly operated, which has good practicality. Moreover, when traversing the matching tree output, the output result can be changed by modifying the output mode of each node, which can achieve the purpose of separating the matching tree from the output matching result, has a smaller code coupling degree, and is easy to expand.

[0031] The string matching method proposed in this application is described in detail below with specific embodiments.

[0032] Figure 1 FIG. 1 is a flow chart of an embodiment of a string matching method according to an exemplary embodiment of the present invention. The string matching method can be applied to a string matching device (such as a terminal, a server, etc.). Figure 1 As shown, the string matching method includes the following steps:

[0033] Step 101: Match the first matching segments of two strings and record them in the root node.

[0034] Among them, the two strings are the matched string and the matching string. In the construction of smart cities, taking the recording monitoring business scenario as an example, the matched string is the correct sentence string, and the matching string is the sentence string entered by the user, which needs to be matched with the correct sentence string.

[0035] In one embodiment, step 101 is the first matching of two strings. The longest matching segment can be found from the two strings to avoid the problem of incorrect matching position, and the found longest matching segment is used as the first matching segment.

[0036] When searching for the longest matching segment, the matching string is used to search for the longest matching segment in the matched string.

[0037] In an example, the specific search process can be: take the first character in the matching string as the current character, search for the character that is the same as the current character in the matched string, if found, match the next character of the current character with the next character of the character searched in the matched string, if the match is successful, take the next character of the current character as the current character, and then match the next character of the current character with the next character of the successfully matched character in the matched string, and continue the process of taking the next character of the current character as the current character, and then matching the next character of the current character with the next character of the successfully matched character in the matched string if the match is successful, until a match fails, and the character searched in the matched string and the successfully matched character are regarded as a matching segment.

[0038] Next, the second character in the matching string is used as the current character, and the above search process is performed until the last character in the matching string is used as the current character to end the search, thereby obtaining multiple matching segments, and finally selecting a matching segment with the longest character length from the multiple matching segments as the longest matching segment.

[0039] In the search process, the "space" between characters is used as the interval for searching. For example, if two strings are "abcd" and "albcedf", the longest "bc" substring will be used as the longest matching segment.

[0040] Those skilled in the art will appreciate that the above-described search process is merely an example, and the search method for the longest matching segment may also be implemented using other related technologies, which is not specifically limited in this application.

[0041] It should be noted that if the longest matching segment is not found during the first matching of two strings, it means that there is no matching between the two strings.

[0042] Step 102: Obtain the left substring and the right substring of the first matching segment from the two character strings as the left node and the right node of the root node respectively.

[0043] Among them, after obtaining the root node of the matching tree, the left substring is used as the left node of the root node, and the right substring is used as the right node of the root node, so that the order of the original string can be guaranteed.

[0044] Still taking the two strings "abcd" and "albcedf" as an example, the root node is "bc", and the "a" and "al" in the two strings will be used as the left nodes of the root node, and the "d" and "edf" will be used as the right nodes of the root node.

[0045] Step 103: The left node and the right node are taken as the current node in sequence, and the second matching segments of the two substrings of the current node are matched.

[0046] In one embodiment, in the process of matching the second matching segment of the two substrings of the current node, the longest matching segment can be found from the two substrings to avoid the problem of incorrect matching position, and the longest matching segment found is used as the second matching segment. The search principle of the second matching segment can refer to the search principle description of the first matching segment in the above step 101, which will not be repeated here.

[0047] Based on the matching process of the first matching segment and the second matching segment, since the longest matching segment is always searched in the parent string and the child string, the problem of incorrect matching positions of the two character strings can be avoided in the entire matching process.

[0048] Step 104: If a match is found, the matched second matching segment is recorded in the current node, the left substring and the right substring of the second matching segment are obtained from the two substrings of the current node as the left node and the right node of the current node respectively, and the process of step 103 is continued.

[0049] Step 105: If no match is found, the mismatch type of the two substrings of the current node is determined and recorded in the current node.

[0050] Still taking the two strings "abcd" and "albcedf" as examples, for "a" and "al" on the left node of the root node, the second matching segment matched is "a" and recorded in the left node, and "" and "l" are taken out from "a" and "al" as the right node of the node, and "" and "l" are continued to be matched. If the longest matching segment is not matched, the non-matching type is determined and recorded in the right node of the node; for "d" and "edf" on the right node of the root node, the second matching segment matched is "d" and recorded in the right node, and "" and "e" are taken out from "d" and "edf" as the left node of the node, and "" and "f" are taken out as the right node of the node, and "" and "e" are continued to be matched. If the longest matching segment is not matched, the non-matching type is determined to enter the left node of the node, and "" and "f" are continued to be matched. If the longest matching segment is not matched, the non-matching type is determined to enter the right node of the node, thereby completing the establishment of the matching tree, which consists of 6 nodes.

[0051] In one embodiment, the process of determining the mismatch type of two substrings of the current node can be divided into the following three cases:

[0052] First, if one of the two substrings of the current node belongs to the matching string and the other substring is empty, then the mismatch type of the two substrings is determined to be redundant;

[0053] The second type: if one of the two substrings of the current node belongs to the matched string and the other substring is empty, the mismatch type of the two substrings is determined to be missing;

[0054] The third type is that if both substrings of the current node are not empty, the mismatch type of the two substrings is determined to be an error.

[0055] Among them, "redundant" means that the substring belonging to the matching string is redundant in the matched string; "missing" means that the substring belonging to the matched string is missing in the matching string; "error" means that there is no longest matching segment between the substring belonging to the matching string and the substring belonging to the matched string.

[0056] Based on the above example, if "abcd" is the matched string and "albcedf" is the matching string, the non-matching types of the two substrings "" and "l" are redundant, the non-matching types of "" and "e" are redundant, and the non-matching types of "" and "f" are redundant.

[0057] It should be noted that, in order to distinguish different matching result types of each node, in step 101, while recording the first matching segment into the root node, the root node may be marked with a first mark corresponding to the matching success type; in step 104, while recording the matched second matching segment into the current node, the current node may be marked with a first mark corresponding to the matching success type; in step 105, while recording the mismatch type into the current node, the current node may be marked with a second mark corresponding to the mismatch type;

[0058] The second mark and the first mark are both used to represent the display color when outputting the two substring matching results of the current node, and different mismatch types correspond to different second marks.

[0059] Exemplarily, the first mark corresponding to the successful match type is green, the second mark corresponding to the mismatch type of missing is gray, the second mark corresponding to the mismatch type of redundant is yellow, and the second mark corresponding to the mismatch type of error is red.

[0060] Furthermore, for two non-empty substrings whose mismatch type is error, while recording the mismatch type as error in the current node, a third mark can be added to the substring belonging to the matching string, and a fourth mark can be added to the substring belonging to the matched string, so as to distinguish the belonging strings through different display methods indicated by different marks.

[0061] The third mark and the fourth mark are used to distinguish the different display modes of the two substrings. For example, the third mark is underlined and the fourth mark is not underlined, or the third mark is struck through and the fourth mark is not struck through.

[0062] Based on the above description, see Figure 2 The diagram of the matching tree establishment process shown in the figure takes the recording monitoring in the construction of smart cities as an example. Assume that the matched string is "hello I love you and this is what I need", which is a correct sentence string, and the matching string is "I hate you that is not what I need", which is a sentence string entered by the user and needs to be matched with the correct sentence string. First, the longest matching segment of the two strings is "what I need", so the root node 1 of the matching tree is "what I need" corresponding to the green mark;

[0063] The child node 2 (left node) of the root node is the longest matching segment "I" of the two substrings "hello I love you and this is" and "I hate you that is not", which corresponds to the green mark. There is no right node of the root node.

[0064] Subnode 3 (left node) of subnode 2 is two substrings "hello" and "", the corresponding mismatch type is missing, marked in gray, and subnode 4 (right node) of subnode 2 is the longest matching segment "you" of the two substrings "love you and this is" and "hate youthat is not", corresponding to the green mark;

[0065] The child node 5 (left node) of the child node 4 is two substrings "love" and "hate", and the corresponding mismatch type is error, marked in red. The fourth mark of "love" is not underlined, and the third mark of "hate" is underlined. The child node 6 (right node) of the child node 4 is the longest matching segment of the two substrings "and this is" and "that is not" is "is" corresponding to the green mark;

[0066] Child node 7 (left node) of child node 6 consists of two substrings "and this" and "that", and the corresponding mismatch type is error, marked in red. The fourth mark of "and this" is not underlined, and the third mark of "that" is underlined. Child node 8 (right node) of child node 6 consists of two substrings "" and "not", and the corresponding mismatch type is redundant, marked in yellow.

[0067] Furthermore, after the matching process of the two strings is completed, the matching result of the two strings can be output according to the mark recorded on each node.

[0068] Among them, since each node can be operated flexibly, the output method of each node can be easily modified when outputting the matching results.

[0069] Exemplarily, the matching results may be output in the form of HTML tags so that the browser can conveniently display the results and the user can view the results intuitively.

[0070] Based on the above Figure 2 The matching tree shown in the figure traverses each node on it and outputs the matching results of the two strings according to the mark recorded on each node. Figure 3 shown.

[0071] At this point, the above Figure 1 The matching process shown in the figure finds the matching segment in the two strings as the root node of the matching tree. In the subsequent left substring matching and right substring matching, the child nodes of the matching tree are always established by finding the matching segment to ensure the order of the original string. Since each node in the matching tree records the intermediate matching result, each node can be flexibly operated, which is practical. When traversing the matching tree output, the output result can be changed by modifying the output mode of each node, which can achieve the purpose of separating the matching tree from the output matching result, has a smaller code coupling, and is easy to expand.

[0072] Figure 4 FIG. 1 is a schematic diagram of the hardware structure of a string matching device according to an exemplary embodiment of the present invention. Figure 4 As shown, the string matching device includes a processor, a non-volatile storage medium, a memory and a network interface connected through a system bus. Among them, the non-volatile storage medium of the string matching device stores an operating system, a database and a computer-readable instruction, and the database may store a control information sequence. When the computer-readable instruction is executed by the processor, the processor can implement the string matching method described above. The processor of the string matching device is used to provide computing and control capabilities to support the operation of the entire string matching device. The memory of the string matching device may store computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor can execute a string matching method. The network interface of the string matching device is used to connect and communicate with a terminal.

[0073] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the string matching device to which the scheme of the present invention is applied. The specific string matching device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0074] Corresponding to the above-mentioned embodiment of the string matching method, the present invention also provides an embodiment of a string matching device.

[0075] Figure 5 FIG. 1 is a flow chart of an embodiment of a string matching apparatus according to an exemplary embodiment of the present invention, and the string matching apparatus can be applied to a string matching device. Figure 5 As shown, the string matching device comprises:

[0076] A root node module 510, used to match the first matching segments of two strings and record them in a root node;

[0077] A sub-node module 520 is used to obtain a left sub-string and a right sub-string of the first matching segment from the two character strings as a left node and a right node of the root node respectively;

[0078] A substring matching module 530 is used to take the left node and the right node as the current node in sequence, and match the second matching segments of two substrings of the current node;

[0079] The first processing module 540 is used to record the matched second matching segment into the current node when a match is found, obtain the left substring and the right substring of the second matching segment from the two substrings of the current node as the left node and the right node of the current node respectively, and continue to execute the process of the substring matching module;

[0080] The second processing module 550 is used to determine the mismatch type of the two substrings of the current node and record it in the current node when no match is found.

[0081] In an optional implementation, the first matching segment is the longest matching segment in the two character strings; the second matching segment is the longest matching segment in the two substrings of the current node.

[0082] In an optional implementation, the device further includes ( Figure 5 Not shown):

[0083] The first marking module is used to record the first matching segment into the root node and mark the root node with the first mark corresponding to the matching success type; record the matched second matching segment into the current node and mark the current node with the first mark corresponding to the matching success type; record the mismatch type into the current node and mark the current node with the second mark corresponding to the mismatch type; different mismatch types correspond to different second marks, and the second mark and the first mark are both used to represent the display color when outputting the two substring matching results of the current node.

[0084] In an optional implementation, the two strings are respectively a matched string and a matching string; the second processing module 550 is specifically used to, in the process of determining the mismatch type of two substrings of the current node, if one of the two substrings of the current node belongs to the matching string and the other substring is empty, then determine the mismatch type of the two substrings to be redundant; if one of the two substrings of the current node belongs to the matched string and the other substring is empty, then determine the mismatch type of the two substrings to be missing; if both substrings of the current node are not empty, then determine the mismatch type of the two substrings to be error.

[0085] In an optional implementation, the device further includes ( Figure 5 Not shown):

[0086] The second marking module is used to add a third mark to the substring belonging to the matching string and a fourth mark to the substring belonging to the matched string while determining that the mismatch type of the two substrings is an error and recording it in the current node; wherein the third mark and the fourth mark are used to represent different display modes.

[0087] In an optional implementation, the device further includes ( Figure 5 Not shown):

[0088] The output module is used to output the matching results of the two strings through HTML tags according to the color mark and / or display mark recorded on each node after completing the matching process of the two strings.

[0089] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0090] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.

[0091] The present invention also provides another embodiment, namely, providing a computer-readable storage medium having a computer program stored thereon, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of any one of the string matching methods described above.

[0092] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed by the present invention. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.

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

[0094] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A string matching method, characterized in that: The method comprises: S1, match the first matching segment of the two strings and record it in the root node, and mark the root node with a first mark corresponding to the successful match type; the first matching segment is the longest matching segment of the two strings; S2. Obtain the left substring and the right substring of the first matching segment from the two character strings as the left node and the right node of the root node respectively; S3, taking the left node and the right node as the current node in turn, and matching the second matching segment of the two substrings of the current node, where the second matching segment is the longest matching segment of the two substrings; S4. If a match is found, the matched second matching segment is recorded in the current node, the first tag corresponding to the match success type is marked for the current node, the left substring and the right substring of the second matching segment are obtained from the two substrings of the current node as the left node and the right node of the current node respectively, and step S3 is continued; S5. If no match is found, the mismatch type of the two substrings of the current node is determined and recorded in the current node, and a second mark corresponding to the mismatch type is marked for the current node; different mismatch types correspond to different second marks, and the second mark and the first mark are both used to represent the display color when the matching result of the two substrings of the current node is output; The method further includes: when determining that the mismatch type of the two substrings is an error, adding a third mark to the substring belonging to the matching string and adding a fourth mark to the substring belonging to the matched string; the third mark and the fourth mark are used to represent different display modes of the two substrings; Also includes: After completing the matching of the two strings, the matching results of the two strings are output according to the record mark on each node through the HTML tag method.

2. The method according to claim 1, characterized in that The first matching segment is the longest matching segment in the two character strings; The second matching segment is the longest matching segment in the two substrings.

3. The method according to claim 1, characterized in that The two strings are respectively a matched string and a matching string; and determining the mismatch type of the two substrings of the current node includes: If one of the two substrings of the current node belongs to the matching string and the other substring is empty, the mismatch type of the two substrings is determined to be redundant; If one of the two substrings of the current node belongs to the matched string and the other substring is empty, the mismatch type of the two substrings is determined to be missing; If both substrings of the current node are not empty, the mismatch type of the two substrings is determined to be an error.

4. A string matching device, characterized in that: The device comprises: A root node module, used to match the first matching segment of two strings and record it in a root node, wherein the first matching segment is the longest matching segment of the two strings; A sub-node module, used for obtaining a left sub-string and a right sub-string of the first matching segment from the two character strings as a left node and a right node of the root node respectively; A substring matching module, used to take the left node and the right node as the current node in sequence, and match the second matching segment of the two substrings of the current node, where the second matching segment is the longest matching segment of the two substrings; A first processing module is used to record the matched second matching segment into the current node when a match is found, obtain the left substring and the right substring of the second matching segment from the two substrings of the current node as the left node and the right node of the current node respectively, and continue to execute the process of the substring matching module; The second processing module is used to determine the mismatch type of the two substrings of the current node and record it in the current node when no match is found; The second processing module is further used to add a third mark to the substring belonging to the matching string and a fourth mark to the substring belonging to the matched string when determining that the mismatch type of the two substrings is an error; the third mark and the fourth mark are used to represent different display modes of the two substrings; The device also includes: A first marking module is used to record the first matching segment into the root node and mark the root node with a first mark corresponding to the matching success type; record the matched second matching segment into the current node and mark the current node with a first mark corresponding to the matching success type; record the mismatch type into the current node and mark the current node with a second mark corresponding to the mismatch type; wherein different mismatch types correspond to different second marks, and the second mark and the first mark are both used to represent the display color when outputting the two substring matching results of the current node; The device also includes: The output module is used to output the matching results of the two strings through HTML tags according to the color mark and / or display mark recorded on each node after completing the matching process of the two strings.

5. A string matching device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 3 when executing the program.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the string matching method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Parallelizable sequence alignment systems and methods

    CN111951894A