Matching method, number state detection method, device and electronic equipment
By employing a bidirectional pattern matching method and state machine optimization, the inefficiency of traditional algorithms in matching long and short pattern strings is resolved, achieving efficient pattern string matching that is suitable for number status detection and sensitive word matching in intelligent outbound calling scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI XULU INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2025-09-29
- Publication Date
- 2026-05-29
AI Technical Summary
Traditional single-pattern BM algorithm, KMP algorithm or AC automaton and other multi-pattern matching algorithms cannot match quickly when the pattern string lengths differ greatly, and there is a significant performance bottleneck.
A bidirectional pattern matching method is adopted. By determining the shortest and longest number of characters in the text to be matched, the bidirectional matching results include the pattern strings that are matched in the text to be matched. Combined with the reverse and forward state machines, the cuckoo filter is used to optimize the matching process.
While ensuring high matching accuracy, it significantly reduces unnecessary character comparisons, improves overall matching efficiency, and enhances the algorithm's adaptability to scenarios with large differences in pattern string length.
Smart Images

Figure CN120873252B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer matching algorithm technology, and more specifically, to a matching method, a number status detection method, a device, and an electronic device. Background Technology
[0002] In string matching scenarios, when the pattern strings differ significantly in length (e.g., the longest and shortest pattern strings differ by several characters), traditional single-pattern BM algorithm, KMP algorithm, or AC automaton and other multi-pattern matching algorithms all suffer from significant performance bottlenecks and cannot achieve fast matching. Summary of the Invention
[0003] The purpose of this invention is to provide a matching method, a number status detection method, a device, and an electronic device to improve the problems existing in the prior art.
[0004] The embodiments of the present invention can be implemented as follows:
[0005] In a first aspect, the present invention provides a matching method, comprising:
[0006] Obtain the text to be matched and a preset set of pattern strings; the set of pattern strings includes multiple pattern strings;
[0007] Determine the shortest and longest character counts from the character counts of each pattern string;
[0008] Determine a first stop position and a second stop position from the text to be matched, wherein the number of interval characters is equal to the number of the shortest characters.
[0009] Based on the set of pattern strings, the number of shortest characters, and the number of longest characters, bidirectional pattern matching is performed on the text to be matched to obtain a bidirectional matching result; the bidirectional matching result includes the pattern strings that are matched in the text to be matched.
[0010] Secondly, the present invention provides a number status detection method, comprising:
[0011] After each intelligent outbound call ends, retrieve the ringback tone for each outbound number from the outbound call data;
[0012] Convert the ringback tone of each outbound number into ringback tone text;
[0013] For each outbound number, the ringback tone text of the outbound number is used as the text to be matched, and a preset state set is used as the pattern string set, so as to obtain a two-way matching result through the matching method described in the first aspect above. The two-way matching result reflects the number status of the outbound number.
[0014] Thirdly, the present invention provides a matching device, including a data acquisition module for acquiring the text to be matched and a preset set of pattern strings; the set of pattern strings includes multiple pattern strings.
[0015] The positioning module is used to determine the shortest and longest character counts from the character counts of each pattern string;
[0016] The positioning module is further configured to determine a first stop position and a second stop position from the text to be matched, wherein the number of interval characters is equal to the number of the shortest characters;
[0017] A bidirectional matching module is used to perform bidirectional pattern matching on the text to be matched based on the set of pattern strings, the number of shortest characters, and the number of longest characters, to obtain a bidirectional matching result; the bidirectional matching result includes the pattern strings that are matched in the text to be matched.
[0018] Fourthly, the present invention provides a number status detection device, comprising:
[0019] The outbound call acquisition module is used to acquire the ringback tone of each outbound number in the outbound call data after each intelligent outbound call ends;
[0020] The conversion module is used to convert the ringback tone of each outbound number into the text to be matched;
[0021] The detection module is used to, for each outbound number, take the ringback tone text of the outbound number as the text to be matched and the preset state set as the pattern string set, so as to obtain a two-way matching result through the matching method described in the first aspect above, wherein the two-way matching result reflects the number status of the outbound number.
[0022] Fifthly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the matching method as described in the first aspect above, and / or the number status detection method as described in the second aspect above.
[0023] Compared with existing technologies, embodiments of the present invention provide a matching method, a number status detection method, an apparatus, and an electronic device. The method involves: first, acquiring the text to be matched and a preset set of pattern strings, which includes multiple pattern strings; then, determining the shortest and longest character counts from the character counts of each pattern string, and determining a first and a second stop position from the text to be matched where the interval character count is equal to the shortest character count; finally, based on the set of pattern strings, the shortest and longest character counts, performing bidirectional pattern matching on the text to be matched to obtain a bidirectional matching result; the bidirectional matching result includes the matched pattern strings in the text to be matched. The present invention employs a bidirectional matching method, which can significantly reduce unnecessary character comparisons while ensuring high matching accuracy, thereby improving overall matching efficiency. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is one of the flowcharts illustrating a matching method provided in an embodiment of the present invention.
[0026] Figure 2 This is a second flowchart illustrating a matching method provided in an embodiment of the present invention.
[0027] Figure 3 This is the third flowchart illustrating a matching method provided in an embodiment of the present invention.
[0028] Figure 4 This is a structural example diagram of a reverse state machine provided in an embodiment of the present invention.
[0029] Figure 5 This is one of the schematic diagrams of a bidirectional matching scenario according to an embodiment of the present invention.
[0030] Figure 6 This is the fourth flowchart illustrating a matching method provided in an embodiment of the present invention.
[0031] Figure 7 The fifth flowchart illustrates a matching method provided in an embodiment of the present invention.
[0032] Figure 8 This is a structural example diagram of a forward state machine provided in an embodiment of the present invention.
[0033] Figure 9This is a second schematic diagram of a bidirectional matching scenario according to an embodiment of the present invention.
[0034] Figure 10 This is a schematic diagram illustrating a process for obtaining ringback tone text according to an embodiment of the present invention.
[0035] Figure 11 This is a schematic diagram of a number matching device provided in an embodiment of the present invention.
[0036] Figure 12 This is a schematic diagram of a number status detection device provided in an embodiment of the present invention.
[0037] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0039] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0040] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0041] Furthermore, the terms "first" and "second" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0042] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0043] The matching method provided in this invention can be applied to electronic devices, including but not limited to smartphones, personal laptops, personal computers, servers, and other computing devices. Furthermore, the application areas of this matching method can include, but are not limited to: sensitive word matching, number status detection in intelligent outbound calling scenarios, deep packet inspection (DPI), virus scanning, and spam hardware filtering in the fields of network security and intrusion detection. The implementation process of the matching method provided in this invention will be described below in the context of a number status detection scenario.
[0044] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a matching method provided in an embodiment of the present invention, which includes the following steps S100~S400.
[0045] S100: Obtain the text to be matched and the preset pattern string set.
[0046] In this embodiment, the pattern string set includes multiple pattern strings.
[0047] For example, in a number status detection scenario, the text to be matched can be the text content of the ringback tone recorded after a smart outbound call to a number, while the pattern string set can include pattern strings such as "The number you dialed cannot be connected," "No answer," "Network busy," "Current user is not in the service area," "Number not in service," and "Please dial again later." The ringback tone is not an actual recording of the call between the caller and the called party, but rather an early media signal returned by the operator's network or terminal equipment before the call is connected. Its content includes non-call phase audio information such as ringing prompts and voice announcements.
[0048] For example, in a sensitive word matching scenario, the pattern string set includes a large number of preset sensitive words.
[0049] This example is merely illustrative and is not intended to be limiting.
[0050] S200. Determine the shortest and longest character counts from the character counts of each pattern string.
[0051] In this embodiment, it is assumed that the minimum number of characters in each pattern string in the set of pattern strings is the shortest character count, and the maximum number of characters is the longest character count. In the subsequent bidirectional pattern matching stage, this invention uses the shortest and longest character counts to set the window length, determine the movement distance, and identify the stopping position, thus forming a crucial basis for the time efficiency and space partitioning of the entire algorithm.
[0052] S300. Determine the first and second stop positions from the text to be matched, where the number of interval characters is equal to the number of shortest characters.
[0053] In this embodiment, the first stop position and the second stop position are both character positions in the text to be matched, and the number of characters between them is equal to the number of shortest characters.
[0054] Optionally, assuming the text to be matched contains N characters, we can first determine the center position of the text (the center position is 1 character when N is odd, and 2 characters when N is even), and then extend left and right from the center position to determine the first and second stop positions. The obtained first and second stop positions must satisfy the following: ,in This indicates the first stop. Indicates the second stop position. Indicates the minimum number of characters.
[0055] S400: Based on the pattern string set, the shortest character count, and the longest character count, perform bidirectional pattern matching on the text to be matched to obtain bidirectional matching results.
[0056] In this embodiment, the bidirectional matching result can include each target pattern string matched in the text to be matched. Bidirectional pattern matching refers to simultaneously starting from the beginning and end of the text to be matched and performing pattern searches in opposite directions: on the one hand, advancing from the beginning of the text towards the middle region until the first stopping position to perform multiple reverse matches; on the other hand, advancing from the end of the text towards the middle region until the second stopping position to perform multiple forward matches. The matching processes in the two directions run independently but share the same set of pattern strings, and finally, the matching results of each direction are summarized to determine the final bidirectional matching result.
[0057] Thus, the first stopping position indicates the end position of the reverse matching process in the forward scanning path, and the second stopping position indicates the end position of the forward matching process in the backward scanning path. Furthermore, the area between these two stopping positions constitutes a potential overlapping matching zone, allowing the matching processes in both directions to converge here, thereby avoiding the omission of pattern strings distributed across segments. This bidirectional parallelism shortens the unidirectional search path of the pattern string, significantly improving processing speed while ensuring recognition accuracy. Moreover, matching based on the shortest and longest character counts enhances the algorithm's adaptability to scenarios with large differences in pattern string length.
[0058] In optional implementations, step S400 may be implemented in ways that include S410 to S430.
[0059] S410. Based on the pattern string set, the shortest character count, and the longest character count, perform multiple reverse matching operations on the first text segment from left to right to obtain the first matching result.
[0060] In this embodiment, the first text segment is all the characters in the text to be matched, from the first character to the first stop position.
[0061] S420. Based on the pattern string set, the shortest character count, and the longest character count, perform multiple forward matching operations on the second text segment from right to left to obtain the second matching result.
[0062] In this embodiment, the second text segment is all the characters in the text to be matched, from the second stop position to the right and to the last character.
[0063] Both a single reverse match and a single forward match can be used to determine whether a character window contains any pattern string among the multiple characters in the text to be matched. However, during multiple reverse matches, the length of the character window gradually expands to the right from the shortest number of characters to the longest number of characters, and then slides to the right until it reaches the first stopping position. Conversely, during multiple forward matches, the length of the character window gradually expands to the left from the shortest number of characters to the longest number of characters, and then slides to the left until it reaches the second stopping position.
[0064] S430. Based on the first matching result and the second matching result, determine the bidirectional matching result.
[0065] In this embodiment, the first matching result and the second matching result are combined to obtain the bidirectional matching result. The first matching result and the second matching result may both be empty, or neither may be empty.
[0066] For example, in a number status detection scenario, suppose both the first and second matching results include the pattern string "empty number," meaning the bidirectional matching result includes "empty number," indicating that the outgoing number is empty. Alternatively, if the first matching result includes the pattern string "no answer," while the second matching result is empty, meaning the bidirectional matching result includes "no answer," it indicates that the outgoing number is currently unanswered.
[0067] The aforementioned reverse matching requires a reverse state machine in conjunction with the first auxiliary table, while the aforementioned forward matching requires a forward state machine in conjunction with the second auxiliary table. Here, we will first discuss the methods for obtaining the data upon which reverse and forward matching depend.
[0068] In one optional implementation, the first auxiliary table includes a first string skip table, a first final character table, and a first final string table. The data required for reverse matching can be obtained through the following steps a1 to a5.
[0069] Step a1: Based on the pattern string array, construct the inverse state machine and the inverse output table.
[0070] In this embodiment, each pattern string can be reversed first, that is, the original string is rearranged from the end to the beginning. For example, "unreachable" is converted to "able reach un". Then, all the reversed strings are used as inputs to construct a tree structure with shared prefixes, that is, a reverse state machine. The state machine starts from the root node, and each character corresponds to a state transition edge, finally forming a finite automaton model to support efficient state jumps in the subsequent reverse matching process.
[0071] Meanwhile, based on the termination positions of each pattern string during the reverse insertion process, a corresponding reverse output table is established. This table records the original pattern string content matched by the end state in each reverse state machine, so as to accurately output the corresponding pattern string content when a match is hit.
[0072] Step a2: Extract the last characters of each pattern string and reverse them to obtain the reversed characters. Take every two adjacent characters in the reversed characters as a double-character substring, and determine the jump distance between each double-character substring and the root node of the reverse state machine. Based on each double-character substring and its jump distance, construct a first string jump table.
[0073] In this embodiment, for each pattern string, extract its last characters and reverse them to obtain the reversed characters. Then, take every two adjacent characters in the reversed characters as a double-character substring. Then, take each double-character substring as a query key, trace its first occurrence position in the reverse state machine, and calculate the shortest path length from this position to the root node. This length is the jump distance corresponding to the double-character substring. Further, store each double-character substring and its corresponding jump distance in the form of a key-value pair to form a first string jump table. This table is used to quickly determine the number of characters that the pattern string should skip when the reverse matching fails.
[0074] For example, if =3, a pattern string is "no answer", and the reversed characters are "answer no", and the two double-character substrings "answer" and "no answer" can be split out. It should be noted that this example is only for illustration and is not limited here.
[0075] Step a3: Take the last character and the last character in each pattern string as the end substring to construct a first last-layer string table.
[0076] Step a4: Based on the last Use 100 characters to construct the first-level character table.
[0077] In this embodiment, the first end-level string table and the first end-level character table are used to assist in determining whether to expand the window to the right or shift the window distance to the right after each reverse matching is completed.
[0078] Step a5: Create the first cuckoo filter based on the hash value of each last substring in the first last-level string table and the hash value of each character in the first last-level character table.
[0079] In this embodiment, a hash operation is first performed on each last substring in the first final layer string table to generate a fixed-length hash value. Similarly, a hash operation is also performed on each character in the first final layer character table to obtain a corresponding hash value. These hash values are then input into the Cuckoo Hash Algorithm framework to assign fingerprints and select initial bucket positions, constructing a first Cuckoo filter with high query efficiency and low false positive rate. It should be noted that the Cuckoo filter is a space-efficient probabilistic data structure that supports deletion operations, offering better dynamic performance compared to traditional Bloom filters.
[0080] The first cuckoo filter acts as a fast pre-screening mechanism after each reverse match, which can determine whether a character or substring may exist in the key end feature set in constant time, thereby significantly reducing the access frequency of the first end string table and the first end character table, and achieving efficient switching in the pattern matching process.
[0081] In another optional implementation, the second auxiliary table includes a second string skip table, a second final string table, and a second final character table. The data required for forward matching can be obtained through the following steps b1 to b5.
[0082] Step b1: Based on the pattern string array, construct a forward state machine and a forward output table.
[0083] In this embodiment, each pattern string is first inserted character by character in its original order into a tree structure with a shared prefix, forming a forward state machine. This state machine starts with the root node as its initial state, and each edge represents a character transition relationship, thus forming a finite automaton model to support state transition operations in the subsequent forward matching process. Simultaneously, during the construction process, the termination state corresponding to the end of each pattern string is recorded, and an associated forward output table is established. This table is used to output the corresponding pattern string content when a match is successful.
[0084] Step b2: Extract the first part of each pattern string. Each pair of adjacent characters in the given characters is treated as a double substring, and the jump distance between each double substring and the root node of the forward state machine is determined. Based on each double substring and its jump distance, a second string jump table is constructed.
[0085] In this embodiment, for each pattern string, its i-th and i+1-th characters are extracted sequentially. The system constructs double-character substrings (adjacent character pairs) and uses these substrings as lookup keys to find their first occurrence position in the forward state machine. It then calculates the shortest path length from that position to the root node, which is the jump distance for that substring. Furthermore, each double-character substring and its corresponding jump distance are stored as key-value pairs, forming a second string jump table. This table is used to quickly determine the number of characters the current window should skip when forward matching fails, thereby improving overall matching efficiency.
[0086] For example, if For example, a pattern string like "no one answers" can be broken down into two substrings: "no one" and "someone answers". It should be noted that this example is for illustrative purposes only and is not intended to be limiting.
[0087] Step b3: Extract the first element from each pattern string. The character and the first Use 1 character as the last substring to construct the second final level string table.
[0088] Step b4, based on the first element in each pattern string Use 1 character to construct the second-level character table.
[0089] In this embodiment, the second-end string table and the second-end character table are used to assist in determining the distance to expand the window to the left or move the window to the left after each forward match.
[0090] Step b5: Create a second cuckoo filter based on the hash value of each last substring in the second final layer string table and the hash value of each character in the second final layer character table.
[0091] In this embodiment, a hash operation is first performed on each last substring in the second-end string table to generate a hash value of fixed length. Similarly, a hash operation is also performed on each character in the second-end character table to obtain a corresponding hash value. Subsequently, these hash values are input into the Cuckoo Hash Algorithm framework. Through steps such as fingerprint generation, bucket address mapping, and candidate position calculation, a second Cuckoo filter with high query performance and low false positive rate is constructed.
[0092] The second cuckoo filter acts as a fast pre-screening mechanism after each positive match, and can determine in constant time whether a character or substring may exist in the key feature set, thereby reducing the access frequency of the second final string table and the second final character table, and achieving efficient switching in the pattern matching process.
[0093] Next, combined Figure 2 and Figure 3 The process of performing multiple reverse matchings from left to right in step S410 is described.
[0094] Please see Figure 2 The implementation of step S410 above may include the following sub-steps S411 to S419.
[0095] S411. Initialize the window length to the shortest number of characters, and use the shortest number of characters preceding the first text segment as the current character window.
[0096] For example, assuming the shortest number of characters Therefore, the first to third characters of the first text segment constitute the current character window. It should be noted that this example is merely illustrative and is not intended to be limiting.
[0097] S412. Based on the set of pattern strings, perform pattern matching on each character in the current character window from right to left to determine whether any pattern string exists in each character corresponding to the current character window.
[0098] In this embodiment, the process of performing pattern matching on each character in the current character window from right to left requires the creation of the inverse state machine and inverse output table, and the implementation is based on the AC algorithm. Performing pattern matching on each character in the current character window from right to left constitutes a complete reverse matching.
[0099] One reverse match involves traversing from the rightmost character in the current character window to the left: starting from the root node of the reverse state machine, the state transition path is determined based on the currently traversed character; if a corresponding edge exists, the system enters the next state and checks whether the reverse output table is matched based on the next state. If matched, a target pattern string is output; otherwise, the system continues traversing the adjacent characters on the left. If no valid transition edge exists for the currently traversed character, the system continues traversing the adjacent characters on the left, and so on until the first character on the left of the current character window. If no pattern string is matched, the reverse match of the current character window is considered to have failed. If at least one target pattern string is matched, the reverse match of the current character window is considered to have succeeded.
[0100] S413. If any pattern string exists among the characters corresponding to the current character window, confirm that the reverse matching of the current character window is successful, and output the matched target pattern string.
[0101] S414. If no pattern string exists among the characters corresponding to the current character window, it is confirmed that the reverse matching of the current character window has failed.
[0102] S415. Determine whether the first stop position is located within the current character window.
[0103] In this embodiment, whether the reverse matching of the current character window is successful or fails, it is considered as completing a reverse matching of the current character window.
[0104] S416. If the first stop position is located in the current character window, the entire target pattern string matched from the first text segment will be used as the first matching result.
[0105] In this embodiment, as long as the first stop position is located in the current character window, it means that the multiple reverse matching of the first text segment is completed and the first matching result is obtained.
[0106] S417. If the first stop position is located in the current character window, determine the first distance based on the three characters on the right side of the current character window and the pre-created first auxiliary table.
[0107] In this embodiment, the first auxiliary table is used to help determine a first distance by which the window expands to the right or slides to the right. Based on this first distance, efficient window switching can be achieved to skip character regions that are obviously unrelated to the pattern string, thus speeding up the matching process of the first text segment.
[0108] S418. If the sum of the current window length and the first distance is less than the maximum number of characters, then expand the current character window to the right by the first distance to obtain a new current character window.
[0109] In this embodiment, if the sum of the current window length and the first distance is less than the longest number of characters, it means that the window length needs to be expanded to the right to improve the ability to capture longer pattern strings. Therefore, after executing S418, the execution returns to step S412 until the first stop position is located in the current character window, and the first matching result can be obtained.
[0110] S419. If the sum of the current window length and the first distance is not less than the longest number of characters, then expand the current character window to the right until the window length is equal to the longest number of characters, and then slide it to the right by the first distance.
[0111] In this embodiment, if the sum of the current window length and the first distance is not less than the longest character count, the current window length needs to be expanded to the right to the longest character count (if the current window length is less than the longest character count, expansion is not necessary). Afterward, a window sliding strategy is used instead of the expansion strategy, that is, the entire window is shifted to the right by the first distance (number of characters), maintaining the window length unchanged, ensuring that subsequent matching still occurs within a reasonable range. Therefore, after executing S419, the execution returns to step S412 until the first stopping position is within the current character window, at which point the first matching result is obtained.
[0112] In the optional implementation, assuming the three characters on the right side of the current character window are z, y, and x respectively, please combine... Figure 3 The implementation of step S417 above may include steps c1 to c10.
[0113] Step c0: Determine whether the first stop position is within three characters to the right of the current character window. If yes, determine that the first distance is the number of characters between the last character of the current character window and the first stop position, so that the current character window can slide directly to the right to the first stop position; if not, proceed to step c1.
[0114] Step c1: Determine whether the first character (i.e., z) on the right side of the current character window is located at the first node in the inverse state machine.
[0115] If the result of step c1 is "yes", it means that z is the last character of a pattern string. Starting from z to the left, a complete pattern string is likely to appear. Therefore, step c2 is executed to push the window to the right by one character. If the result of step c1 is "no", then step c3 is executed.
[0116] Step c2: Determine the first distance as 1.
[0117] Step c3: Determine whether the first reference string (i.e., yz) formed by the second and first characters on the right side of the current character window is in the first string skip list.
[0118] In step c3, if the result is "yes", it means that yz is already the last element of a certain pattern string. Two adjacent characters in the string are found, so step c4 is executed. The jump distance represents the character offset required to jump from the current mismatch position to the next possible matching starting point. The extra 2 is to compensate for the width of the two characters that make up the double substring itself, ensuring that the new window can cover the reasonable starting position of the potential pattern string. In this way, the existence of local high-frequency substrings is used to predict the feasibility of the global path, thereby achieving non-linear jumping.
[0119] If the result of step c3 is "no", then step c5 is executed.
[0120] Step c4: Obtain the jump distance corresponding to the first reference string (i.e., yz) in the first string jump table, and determine the first distance as the jump distance plus 2.
[0121] Step c5: Determine whether the hash value of the third character on the right side of the current character window (i.e., the hash value of x) and the hash value of the second reference string formed by the third and second characters (i.e., the hash value of xy) are both not in the first cuckoo filter. That is, determine whether the hash values of x and xy are both not in the first cuckoo filter.
[0122] The first cuckoo filter, as a probabilistic data structure, pre-loads the hash fingerprints of each end substring of the first final-level string table and the hash fingerprints of each character in the first final-level character table, used to quickly eliminate obviously irrelevant character combinations. Therefore: when the judgment result of step c5 is "yes", it indicates that the character z itself and the double-character substring formed by it and y do not belong to any pattern string, meaning that the current position is far from the starting point of all possible valid patterns. Therefore, step c6 is executed, taking the maximum conservative jump step size, considering expanding or moving the window to the right. +3 characters to skip the entire shortest pattern length and redundant interference area, and achieve rapid crossing of invalid areas through the first cuckoo filter.
[0123] If the result of step c5 is "no", it means that the first cuckoo filter has returned at least one hit result, that is, z or zy may be associated with a certain pattern string, and step c7 needs to be executed for further verification.
[0124] Step c6: Determine the first distance as .
[0125] Step c7: Determine whether the second reference string (i.e., xy) is in the first final level string table.
[0126] In step c7, if the result is "yes", it indicates that xy is a valid component of a pattern string. Although it cannot be matched immediately, it has a high semantic relevance, so step c8 needs to be executed. This only requires expanding or shifting to the right. A few characters are enough to realign potential matching intervals and avoid excessive jumping that could lead to missed detections.
[0127] If the result of step c7 is "no", then step c9 is executed.
[0128] Step c8: Determine the first distance as .
[0129] Step c9: Determine whether the third character (i.e., x) on the right side of the current character window is in the first bottom layer character table.
[0130] In step c9, if the result is "yes", it means that character x is the last character of a pattern string. The character is 1, so step c10 is executed, assigning the suboptimal first distance. +2.
[0131] If the result of step c9 is "no", it means that the three characters z, y, x on the right side of the current character window are not related to any pattern string. Therefore, step c6 is executed to skip the irrelevant character interval with a larger first distance.
[0132] Step c10: Determine the first distance as .
[0133] To facilitate understanding of the above combination Figure 2 , Figure 3 The matching process described below is illustrated with an example.
[0134] In an optional example, assuming the pattern string set P = {Unable to connect, No one answers, Network busy}, the structural diagram of the created inverse state machine is as follows. Figure 4 As shown, the reverse output table is shown in Table 1 below, and the first auxiliary table (first string skip table, first last-level string table, and first last-level character table) is shown in Table 2 below. In Table 2, Used to represent the first in set P The last one of the pattern strings One character.
[0135] Table 1. Reverse Output Table of the Reverse State Machine
[0136]
[0137] Table 2 First Auxiliary Table
[0138]
[0139] Assuming the text to be matched is "Current user is not on the server and cannot be connected. Please try again later," then please refer to [link / reference]. Figure 5 Please see 5. Figure 5 This is one of the schematic diagrams of a bidirectional matching scenario implemented in an embodiment of the present invention. Because the shortest number of characters in the pattern string set P... =3 and the longest character count is =4, then as Figure 5 :
[0140] (1) The first reverse match window 1 is "currently used". Search window 1 starting from "use". Figure 4 The reverse state machine. If the pattern string is not finally hit, it means that the reverse matching of window 1 fails. Then, based on the three characters on the right side of window 1 (where "z, y, x" are respectively "household, not, present"), the first distance is determined through the Figure 3 process shown. Since these three characters are not hit in both the second string skip list and the second cuckoo filter, the determined first distance should be .
[0141] However, since the current window length + 6 exceeds , therefore, window 1 needs to be expanded to the right by one character (so that the window length becomes = 4), and then the entire window is moved 6 characters to the right, thus determining window 2;
[0142] For example, Figure 5 , for the second reverse matching, window 2 is "no service area". Search for the Figure 4 reverse state machine starting from "no" in window 2. If the pattern string is not finally hit, it means that the reverse matching of window 2 fails. Then, based on the three characters on the right side of window 2 (where "z, y, x" are respectively "law, connect, pass"), the first distance is determined through the Figure 3 process shown. Since "law connect" is in the first string skip list in Table 2 and the skip distance is 1, then the first distance should be the skip distance + 2, that is, the first distance is 3.
[0143] Next, the entire window 2 needs to be moved 3 characters to the right, thus determining window 3;
[0144] For example, Figure 5 , for the third reverse matching, window 3 is "pass law connect no". Traverse and search for the Figure 4 reverse state machine starting from "pass" in window 3. It can finally reach state 4, and state 4 can hit "unable to connect" in the reverse output table (Table 1). Since the first stop position is within window 3, the matching ends, and the first matching result is "unable to connect".
[0145] It should be noted that this example is only for illustration and is not limited here.
[0146] Next, in combination with Figure 6 and Figure 7 , the implementation process of multiple forward matches of the second text segment from right to left in step S420 is introduced. The matching process of the second text segment is logically similar to that of the first text segment, except that the matching direction is opposite, so some logics will not be elaborated.
[0147] Please refer to Figure 6The implementation of step S420 above may include the following sub-steps S421 to S429.
[0148] S421. Initialize the window length to the shortest number of characters, and use the last shortest number of characters of the first text segment as the current character window.
[0149] S422. Based on the set of pattern strings, perform pattern matching on each character in the current character window from left to right to determine whether any pattern string exists in each character corresponding to the current character window.
[0150] In this embodiment, performing pattern matching on each character in the current character window from left to right constitutes a complete forward match. This pattern matching process requires the creation of the forward state machine and forward output table, and is implemented using the AC algorithm.
[0151] One of the forward matching processes is similar to the reverse matching process mentioned in the explanation of step S412 above, only in the opposite direction, and will not be elaborated here. After a forward matching is completed, if the pattern string is still not matched, it is determined that the forward matching of the current character window has failed. As long as at least one target pattern string is matched, it is determined that the forward matching of the current character window has succeeded.
[0152] S423. If any pattern string exists among the characters corresponding to the current character window, then the forward matching of the current character window is confirmed to be successful, and the matched target pattern string is output.
[0153] S424. If no pattern string exists among the characters corresponding to the current character window, then the forward matching of the current character window is confirmed to have failed.
[0154] S425. Determine whether the second stop position is located within the current character window.
[0155] S426. If the second stop position is located in the current character window, then all target pattern strings matched from the second text segment will be used as the second matching result.
[0156] In this embodiment, as long as the second stop position is located in the current character window, it indicates that multiple forward matches of the second text segment have been completed, and the second matching result is obtained.
[0157] S427. If the second stop position is not located in the current character window, determine the second distance based on the three characters on the left side of the current character window and the pre-created second auxiliary table.
[0158] In this embodiment, the second auxiliary table is used to help determine the second distance by which the window expands to the left or slides to the left. Based on this second distance, the window can be efficiently jumped to skip character areas that are obviously unrelated to the pattern string, thereby speeding up the matching process of the second text segment.
[0159] S428. If the sum of the current window length and the second distance is less than the maximum number of characters, then expand the current character window to the left by the second distance to obtain a new current character window.
[0160] In this embodiment, if the sum of the current window length and the second distance is less than the longest number of characters, it means that the window length needs to be expanded to the left to improve the ability to capture longer pattern strings. Therefore, after executing S428, the execution returns to step S422 until the second stop position is located in the current character window, and the second matching result can be obtained.
[0161] S429. If the sum of the current window length and the second distance is not less than the longest number of characters, then expand the current character window to the left until the window length is equal to the longest number of characters, and then slide the second distance to the left.
[0162] In this embodiment, if the sum of the current window length and the second distance is not less than the longest character count, the current window length needs to be expanded to the left to the longest character count (if the current window length is less than the longest character count, expansion is not necessary). Afterward, a window sliding strategy is used instead of the expansion strategy, that is, the entire window is shifted to the left by the second distance character while maintaining the window length, ensuring that subsequent matching still occurs within a reasonable range. Therefore, after executing S429, the execution returns to step S422 until the second stopping position is located within the current character window, at which point the second matching result is obtained.
[0163] In the optional implementation, assuming the three characters on the left side of the current character window are z, y, and x respectively, please combine... Figure 7 The implementation of step S427 above may include steps d1 to d10.
[0164] Step d0: Determine whether the second stop position is within three characters to the left of the current character window. If so, determine the second distance as the number of characters between the first character of the current character window and the second stop position. In this way, the current character window can be slid directly to the left to the first stop position. If not, execute step d1.
[0165] Step d1: Determine whether the second character (i.e., z) on the left side of the current character window is located at the first-level node in the forward state machine.
[0166] If the result of step d1 is "yes", it means that z is the first character of a pattern string. Starting from z to the right, it is very likely to be a complete pattern string. Therefore, step d2 is executed to push the window to the left by one character. If the result of step d1 is "no", then step d3 is executed.
[0167] Step d2: Determine the second distance as 1.
[0168] Step d3: Determine whether the first reference string (i.e., yz) formed by the second and first characters on the left side of the current character window is in the second string skip list.
[0169] In step d3, if the result is "yes", it means that yz is already the first character of a certain pattern string. Two adjacent characters in the string are found, so step d4 is executed. The jump distance represents the character offset required to jump from the current mismatch position to the next possible matching starting point. The extra 2 is to compensate for the width of the two characters that make up the double substring itself, ensuring that the new window can cover the reasonable starting position of the potential pattern string. In this way, the existence of local high-frequency substrings is used to predict the feasibility of the global path, thereby achieving non-linear jumping.
[0170] If the result of step d3 is "no", then step d5 is executed.
[0171] Step d4: Obtain the jump distance corresponding to the first reference string (i.e., yz) in the second string jump table, and determine the second distance as the jump distance plus 2.
[0172] Step d5: Determine whether the hash value of the third character on the left side of the current character window (i.e., the hash value of x) and the hash value of the second reference string formed by the third and second characters (i.e., the hash value of xy) are both not in the second cuckoo filter. That is, determine whether the hash values of x and xy are both not in the second cuckoo filter.
[0173] The second cuckoo filter, as a probabilistic data structure, pre-loads the hash fingerprints of each last substring in the second-level string table and each character in the second-level character table to quickly eliminate obviously irrelevant character combinations. Therefore, when the judgment result of step d5 is "yes," it indicates that the character z itself and the double-character substring formed by it and y do not belong to any pattern string, meaning the current position is far from the starting point of all possible valid patterns. Therefore, step d6 is executed, taking the maximum conservative jump step size, considering expanding or moving the window to the right. +3 characters to skip the entire shortest pattern length and redundant interference area, and achieve rapid crossing of invalid areas through the second cuckoo filter.
[0174] If the result of step d5 is "no", it means that the second cuckoo filter has returned at least one hit result, that is, z or zy may be associated with a certain pattern string, and step d7 needs to be executed for further verification.
[0175] Step d6: Determine the second distance as .
[0176] Step d7: Determine whether the second reference string (i.e., xy) is in the second final level string table.
[0177] In step d7, if the result is "yes", it indicates that xy is a valid component of a pattern string. Although it cannot be matched immediately, it has a high semantic relevance, so step d8 needs to be executed. This only requires expanding or shifting to the left. A few characters are enough to realign potential matching intervals and avoid excessive jumping that could lead to missed detections.
[0178] If the result of step d7 is "no", then step d9 is executed.
[0179] Step d8: Determine the second distance as .
[0180] Step d9: Determine whether the third character (i.e., x) on the left side of the current character window is in the second bottom layer character table.
[0181] In step d9, if the result is "yes", it means that character x is the last character of a pattern string. The character is 1, so step d10 is executed, assigning a suboptimal second distance. +2.
[0182] If the result of step d9 is "no", it means that the three characters z, y, x on the left side of the current character window are not related to any pattern string. Therefore, step d6 is executed to skip the irrelevant character interval with a larger second distance.
[0183] Step d10: Determine the second distance as .
[0184] Similarly, for ease of understanding the above combination Figure 6 , Figure 7 The matching process described below is illustrated with an example.
[0185] In an optional example, assuming the pattern string set P = {unreachable, no answer, network busy}, the structural diagram of the created forward state machine is as follows: Figure 8As shown, the forward output table is as shown in Table 3 below, and the second auxiliary table (the second string skip list, the second last-layer string table, and the second last-layer character table) is as shown in Table 4 below. Among them, in Table 4, is used to represent the positive th character of the
[0186] th pattern string in set P.
[0187]
[0188] Table 3 Forward Output Table of the Forward State Machine
[0189]
[0190] Assume that the text to be matched is "The current user is not available on the server. Please try again later." Then, please refer to Figure 9 , please refer to 9, Figure 9 which is the second scenario schematic diagram of the two-way matching adopted in the embodiment of the present invention. Since in the pattern string set P, the shortest number of characters = 3 and the longest number of characters is = 4, then as Figure 9 :
[0191] (1) The first forward matching window 1 is "try again later". Search for the forward state machine of window 1 starting from "again". Finally, no pattern string is hit, which means that the forward matching of window 1 fails. Then, based on the three characters on the left of window 1 ("z, y, x" are "slightly, please, connect" respectively), determine the second distance through the process shown in Figure 8 . Since these three characters are not hit in both the second string skip list and the second cuckoo filter, the determined second distance should be Figure 7 .
[0192] (2) However, since the current window length + 6 exceeds , therefore, it is necessary to expand window 1 to the left by one character (so that the window length becomes = 4), and then move the entire window 6 characters to the left, that is, determine window 2;
[0193] (3) As Figure 9 , the second forward matching window 2 is "area cannot connect". Search for the forward state machine of window 2 starting from "area" one by one. Finally, no pattern string is hit, which means that the forward matching of window 2 fails. Then, based on the three characters on the left of window 2 ("z, y, x" are "service, server, at" respectively), through Figure 8 Figure 7 The process shown determines the second distance. Since the position of the first character to the left of Window 2 is the second stop position, the second distance is directly determined to be 1.
[0194] (4) Next, it is necessary to move Window 2 as a whole 1 character to the left, that is, to determine Window 3;
[0195] (5) As Figure 9 , the third forward-matching Window 3 is "service area unavailable". Traverse and search Window 3 starting from "service" Figure 8 for the forward state machine, and finally the pattern string is not hit. And at this time, since the second stop position (that is, the character position of "service") is within Window 3, the matching ends and the second matching result is empty.
[0196] It should be noted that this example is only for illustration and is not limited here.
[0197] Taking the number status detection scenario as an example, an embodiment of the present invention further provides a number status detection method, which includes the following steps S500 to S700:
[0198] S500. After each intelligent outbound call ends, obtain the ringback tone of each outbound call number in the outbound call data.
[0199] It can be understood that an intelligent outbound call is a batch call for a large number of outbound call numbers in the outbound call data to achieve a specific task. The ringback tone refers to the early media signal returned by the operator network or the terminal device before the called party answers, and its content includes non-call stage audio information such as ringing prompts and voice announcements.
[0200] S600. Convert the ringback tone of each outbound call number into a ringback tone text.
[0201] Optionally, the ringback tone can be captured and stored as an independent audio file in real time by a softswitch platform such as FreeSwitch during the SIP signaling interaction process. Specifically, please refer to Figure 10 , the system ensures the complete recording of the ringback tone in the stage before the call is established by configuring the blocking script and interruption logic in the dialing plan, avoiding information loss caused by hanging up too early. The recorded ringback tone can be converted into a ringback tone text through ASR (Automatic Speech Recognition) technology.
[0202] S700. For each outbound call number, use the ringback tone text of the outbound call number as the text to be matched and the preset status set as the pattern string set, so as to obtain a bidirectional matching result through the matching method introduced above. This bidirectional matching result reflects the number status of the outbound call number.
[0203] It should be noted that the execution order of each step in the above method embodiments is not limited to that shown in the attached figures, and the execution order of each step shall be subject to the actual application situation.
[0204] In order to perform the corresponding steps in the above method embodiments and various possible implementations, an implementation of a matching device and a number status detection device is given below.
[0205] Please see Figure 11 , Figure 11 A schematic diagram of the matching device provided in an embodiment of the present invention is shown. The matching device 200 includes: a data acquisition module 210, a positioning module 220, and a bidirectional matching module 230.
[0206] The data acquisition module 210 is used to acquire the text to be matched and a preset set of pattern strings; the set of pattern strings includes multiple pattern strings.
[0207] The positioning module 220 is used to determine the shortest number of characters and the longest number of characters from the number of characters in each pattern string;
[0208] The positioning module 220 is also used to determine a first stop position and a second stop position from the text to be matched where the number of interval characters is equal to the number of shortest characters;
[0209] The bidirectional matching module 230 is used to perform bidirectional pattern matching on the text to be matched based on the set of pattern strings, the shortest number of characters and the longest number of characters, and to obtain the bidirectional matching result; the bidirectional matching result includes the pattern strings that are matched in the text to be matched.
[0210] Please see Figure 12 , Figure 12 A schematic diagram of the structure of a number status detection device provided in an embodiment of the present invention is shown. The number status detection device 400 includes: an outbound call acquisition module 410, a conversion module 420, and a detection module 430.
[0211] The outbound call acquisition module 410 is used to acquire the ringback tone of each outbound number in the outbound call data after each intelligent outbound call ends;
[0212] The conversion module 420 is used to convert the ringback tone of each outbound number into text to be matched;
[0213] The detection module 430 is used to, for each outbound number, take the ringback tone text of the outbound number as the text to be matched and the preset state set as the pattern string set, so as to obtain a two-way matching result through the matching method described above. The two-way matching result reflects the number status of the outbound number.
[0214] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the matching device 200 and the number status detection device 400 described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0215] Please see Figure 13 , Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 300 includes a processor 310, a memory 320, and a bus 330, with the processor 310 connected to the memory 320 via the bus 330.
[0216] The memory 320 can be used to store software programs or firmware, for example, software programs or firmware corresponding to the matching device 200 and / or the number status detection device 400 described above. The processor 310 executes various functional applications and data processing by running the software programs stored in the memory 320 to implement the matching method and / or number status detection method provided in the embodiments of the present invention.
[0217] The memory 320 may be, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), FLASH (Flash Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0218] The processor 310 can be an integrated circuit chip with signal processing capabilities, capable of executing software programs, such as the software programs corresponding to the matching device 200 and / or the number status detection device 400. The processor 310 can be a general-purpose processor, including: CPU (Central Processing Unit), NP (Network Processor), SoC (System on Chip), etc.; it can also be: DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0219] Understandable. Figure 13 The structure shown is for illustrative purposes only; the electronic device 300 may also include components that are more advanced than those shown. Figure 13 The more or fewer components shown, or having the same Figure 13 The different configurations shown. Figure 13 The components shown can be implemented using hardware, software, or a combination thereof.
[0220] In summary, this invention provides a matching method, a number status detection method, an apparatus, and an electronic device. The method involves: first, acquiring the text to be matched and a preset set of pattern strings, which includes multiple pattern strings; then, determining the shortest and longest character counts from the character counts of each pattern string, and determining a first and second stop position from the text to be matched where the interval character count is equal to the shortest character count; finally, performing bidirectional pattern matching on the text to be matched based on the pattern string set, the shortest character count, and the longest character count to obtain a bidirectional matching result; the bidirectional matching result includes the matched pattern strings in the text to be matched. This invention employs a bidirectional matching method, which can significantly reduce unnecessary character comparisons while ensuring high matching accuracy, thereby improving overall matching efficiency.
[0221] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A matching method, characterized in that, include: Obtain the text to be matched and a preset set of pattern strings; the set of pattern strings includes multiple pattern strings; Determine the shortest and longest character counts from the character counts of each pattern string; A first stop position and a second stop position are determined from the text to be matched; the first stop position and the second stop position are both character positions in the text to be matched, and the number of characters between them is equal to the number of the shortest characters. Based on the set of pattern strings, the number of shortest characters, and the number of longest characters, the first text segment is subjected to multiple reverse matchings from left to right to obtain a first matching result; wherein, the first text segment is all the characters in the text to be matched from the first character to the right to the first stop position; Based on the pattern string set, the number of shortest characters, and the number of longest characters, the second text segment is subjected to multiple forward matchings from right to left to obtain a second matching result; wherein, the second text segment is all the characters in the text to be matched from the second stop position to the right to the last character; Based on the first matching result and the second matching result, a bidirectional matching result is determined; the bidirectional matching result includes the pattern string matched in the text to be matched; The step of performing multiple reverse matching operations from left to right on the first text segment based on the pattern string set, the number of shortest characters, and the number of longest characters to obtain the first matching result includes: The window length is initialized to the shortest number of characters, and the number of characters preceding the first text segment are used as the current character window; Based on the set of pattern strings, pattern matching is performed on each character of the current character window from right to left to determine whether any pattern string exists in each character corresponding to the current character window. If so, the reverse matching of the current character window is confirmed to be successful, and the matched target pattern string is output. If not, the reverse matching of the current character window is confirmed to be unsuccessful. Determine whether the first stop position is located within the current character window; If so, then all target pattern strings matched from the first text segment will be used as the first matching result; If not, a first distance is determined based on the three characters on the right side of the current character window and a pre-created first auxiliary table; the first auxiliary table is used to help determine the first distance by which the window expands to the right or slides to the right. If the sum of the current window length and the first distance is less than the longest number of characters, then the current character window is expanded to the right by the first distance to obtain a new current character window, and then the step of performing pattern matching on each character of the current character window from right to left based on the pattern string set is returned to be executed until the first stopping position is located in the current character window, and the first matching result is obtained. If the sum of the current window length and the first distance is not less than the longest character count, then the current character window is expanded to the right until the window length is equal to the longest character count, and then slid to the right by the first distance. The process then returns to the step of performing pattern matching on each character of the current character window from right to left based on the pattern string set, until the first stop position is located in the current character window, and the first matching result is obtained. The first auxiliary table includes a first string skip table, a first final character table, and a first final string table; the step of determining the first distance based on the three characters on the right side of the current character window and the pre-created first auxiliary table includes: Determine whether the first stopping position is within three characters to the right of the current character window. If so, determine that the first distance is the number of characters between the last character of the current character window and the first stopping position. If not, determine whether the first character to the right of the current character window is located at the first-level node in the reverse state machine. The reverse state machine is a reverse tree storage structure where each pattern string is located. The reverse state machine and the reverse output table are used to implement reverse matching. If yes, then the first distance is determined to be 1; if no, then it is determined whether the first reference string formed by the second and first characters on the right side of the current character window is in the first string skip list. If the first reference string is located in the first string skip list, then obtain the skip distance corresponding to the first reference string in the first string skip list, and determine that the first distance is the skip distance plus 2; If the first reference string is not located in the first string skip list, then determine whether the hash value of the third character on the right side of the current character window and the hash value of the second reference string formed by the third character and the second character are both not in the first cuckoo filter; wherein, the first cuckoo filter includes the hash value of each last substring in the first last layer string table and the hash value of each character in the first last layer character table. If so, then the first distance is determined to be If not, then determine whether the second reference string is in the first last-level string table; Indicates the number of the shortest characters; If the second reference string is in the first last-level string table, then the first distance is determined to be... ; If the second reference string is not in the first last-level string table, then determine whether the third character on the right side of the current character window is in the first last-level character table. If so, then determine the first distance as... If not, then the first distance is determined to be ; The step of performing multiple forward matches from right to left on the second text segment based on the pattern string set, the number of shortest characters, and the number of longest characters to obtain the second matching result includes: The window length is initialized to the shortest number of characters, and the last shortest number of characters of the first text segment are used as the current character window; Based on the set of pattern strings, pattern matching is performed on each character of the current character window from left to right to determine whether any pattern string exists in each character corresponding to the current character window. If so, the forward matching of the current character window is confirmed to be successful, and the matched target pattern string is output. If not, the forward matching of the current character window is confirmed to be unsuccessful. Determine whether the second stop position is located within the current character window; If so, then all target pattern strings matched from the second text segment will be used as the second matching result; If not, a second distance is determined based on the three characters on the left side of the current character window and a pre-created second auxiliary table; the second auxiliary table is used to help determine the second distance when the window expands to the left or slides to the left. If the sum of the current window length and the second distance is less than the maximum number of characters, then the current character window is expanded to the left by the second distance to obtain a new current character window. Then, the step of performing pattern matching on each character of the current character window from left to right based on the pattern string set is returned to be executed until the second stop position is located in the current character window, and the second matching result is obtained. If the sum of the current window length and the second distance is not less than the longest character count, then the current character window is expanded to the left until the window length is equal to the longest character count, and then slid to the left by the second distance. The process of performing pattern matching on each character of the current character window from left to right based on the pattern string set is repeated until the second stop position is located in the current character window, and the second matching result is obtained. The second auxiliary table includes a second string skip table, a second final string table, and a second final character table. The step of determining the second distance based on the three characters on the left side of the current character window and a pre-created second auxiliary table includes: Determine whether the second stop position is within three characters to the left of the current character window. If so, determine that the second distance is the number of characters between the first character of the current character window and the second stop position. If not, determine whether the first character to the left of the current character window is located at the first-level node in the forward state machine. The forward state machine is an ascending tree storage structure where each pattern string is located. The forward state machine and the forward output table are used to implement forward matching. If yes, then the second distance is determined to be 1; otherwise, it is determined whether the first reference string formed by the second character and the first character on the left side of the current character window is in the second string skip list. If the first reference string is in the second string skip list, then obtain the skip distance corresponding to the first reference string in the second string skip list, and determine that the second distance is the skip distance plus 2; If the first reference string is not in the second string skip list, then determine whether the hash value of the third character on the left side of the current character window and the hash value of the second reference string formed by the third character and the second character are both not in the second cuckoo filter; wherein, the second cuckoo filter includes the hash value of each last substring in the second last layer string table and the hash value of each character in the second last layer character table; If so, then the second distance is determined to be If not, then determine whether the second reference string is in the second last-level string table; Indicates the number of the shortest characters; If the second reference string is in the second last-level string table, then the second distance is determined to be... ; If the second reference string is not in the second last-level string table, then determine whether the third character from the left of the current character window is in the second last-level character table; if so, then determine the second distance as... If not, then determine the second distance as ; The data required for reverse matching is obtained through the following steps: Based on the pattern string array, construct the reverse state machine and the reverse output table; Extract the last part of each pattern string The characters are processed and reversed to obtain the reversed order. The characters will be reversed. Each pair of adjacent characters in a string is treated as a double substring, and the jump distance between each double substring and the root node of the inverse state machine is determined. Based on each double substring and its jump distance, the first string jump table is constructed. Indicates the number of the shortest characters; The last element in each pattern string The first character and the last one 1 character is used as the last substring to construct the first final level string table; Based on the last digit of each pattern string Use 1 character to construct the first final-level character table; The first cuckoo filter is created based on the hash value of each end substring in the first end-level string table and the hash value of each character in the first end-level character table. The data required for positive matching is obtained through the following steps: Based on the pattern string array, construct the forward state machine and the forward output table; The first part of each pattern string Each pair of adjacent characters in the string is treated as a double substring, and the jump distance between each double substring and the root node of the forward state machine is determined. Based on each double substring and its jump distance, the second string jump table is constructed. The first element in each pattern string The character and the first 1 character is used as the last substring to construct the second final level string table; Based on the first in each pattern string Use 1 character to construct the second final-level character table; The second cuckoo filter is created based on the hash value of each last substring in the second last-level string table and the hash value of each character in the second last-level character table.
2. A method for detecting the status of a phone number, characterized in that, include: After each intelligent outbound call ends, obtain the ringback tone for each outbound number in the outbound call data; Convert the ringback tone of each outbound number into ringback tone text; For each outbound number, the ringback tone text of that outbound number is used as the text to be matched, and a preset state set is used as the pattern string set, so as to obtain a two-way matching result through the matching method described in claim 1, wherein the two-way matching result reflects the number status of the outbound number.
3. A matching device, characterized in that, include: The data acquisition module is used to acquire the text to be matched and a preset set of pattern strings; the set of pattern strings includes multiple pattern strings. The positioning module is used to determine the shortest and longest character counts from the character counts of the pattern string; The positioning module is further configured to determine a first stop position and a second stop position from the text to be matched; the first stop position and the second stop position are both character positions in the text to be matched, and the number of characters between them is equal to the number of the shortest characters; The bidirectional matching module is used to perform multiple reverse matchings on the first text segment from left to right based on the pattern string set, the number of shortest characters, and the number of longest characters to obtain a first matching result; wherein, the first text segment is all characters in the text to be matched from the first character to the right to the first stop position; The bidirectional matching module is further configured to perform multiple forward matching operations on the second text segment from right to left based on the pattern string set, the number of shortest characters, and the number of longest characters to obtain a second matching result; wherein, the second text segment is all characters in the text to be matched from the second stop position to the right to the last character; The bidirectional matching module is further configured to determine a bidirectional matching result based on the first matching result and the second matching result; the bidirectional matching result includes the pattern string matched in the text to be matched; Specifically, the bidirectional matching module can be used for: The window length is initialized to the shortest number of characters, and the number of characters preceding the first text segment are used as the current character window; Based on the set of pattern strings, pattern matching is performed on each character of the current character window from right to left to determine whether any pattern string exists in each character corresponding to the current character window. If so, the reverse matching of the current character window is confirmed to be successful, and the matched target pattern string is output. If not, the reverse matching of the current character window is confirmed to be unsuccessful. Determine whether the first stop position is located within the current character window; If so, then all target pattern strings matched from the first text segment will be used as the first matching result; If not, a first distance is determined based on the three characters on the right side of the current character window and a pre-created first auxiliary table; the first auxiliary table is used to help determine the first distance by which the window expands to the right or slides to the right. If the sum of the current window length and the first distance is less than the longest number of characters, then the current character window is expanded to the right by the first distance to obtain a new current character window, and then the step of performing pattern matching on each character of the current character window from right to left based on the pattern string set is returned to be executed until the first stopping position is located in the current character window, and the first matching result is obtained. If the sum of the current window length and the first distance is not less than the longest character count, then the current character window is expanded to the right until the window length is equal to the longest character count, and then slid to the right by the first distance. The process then returns to the step of performing pattern matching on each character of the current character window from right to left based on the pattern string set, until the first stop position is located in the current character window, and the first matching result is obtained. The first auxiliary table includes a first string skip table, a first final-level character table, and a first final-level string table; the bidirectional matching module can specifically be used for: Determine whether the first stopping position is within three characters to the right of the current character window. If so, determine that the first distance is the number of characters between the last character of the current character window and the first stopping position. If not, determine whether the first character to the right of the current character window is located at the first-level node in the reverse state machine. The reverse state machine is a reverse tree storage structure where each pattern string is located. The reverse state machine and the reverse output table are used to implement reverse matching. If yes, then the first distance is determined to be 1; if no, then it is determined whether the first reference string formed by the second and first characters on the right side of the current character window is in the first string skip list. If the first reference string is located in the first string skip list, then obtain the skip distance corresponding to the first reference string in the first string skip list, and determine that the first distance is the skip distance plus 2; If the first reference string is not located in the first string skip list, then determine whether the hash value of the third character on the right side of the current character window and the hash value of the second reference string formed by the third character and the second character are both not in the first cuckoo filter; wherein, the first cuckoo filter includes the hash value of each last substring in the first last layer string table and the hash value of each character in the first last layer character table. If so, then the first distance is determined to be If not, then determine whether the second reference string is in the first last-level string table; Indicates the number of the shortest characters; If the second reference string is in the first last-level string table, then the first distance is determined to be... ; If the second reference string is not in the first last-level string table, then determine whether the third character on the right side of the current character window is in the first last-level character table. If so, then determine the first distance as... If not, then the first distance is determined to be ; Specifically, the bidirectional matching module can be used for: The window length is initialized to the shortest number of characters, and the last shortest number of characters of the first text segment are used as the current character window; Based on the set of pattern strings, pattern matching is performed on each character of the current character window from left to right to determine whether any pattern string exists in each character corresponding to the current character window. If so, the forward matching of the current character window is confirmed to be successful, and the matched target pattern string is output. If not, the forward matching of the current character window is confirmed to be unsuccessful. Determine whether the second stop position is located within the current character window; If so, then all target pattern strings matched from the second text segment will be used as the second matching result; If not, a second distance is determined based on the three characters on the left side of the current character window and a pre-created second auxiliary table; the second auxiliary table is used to help determine the second distance when the window expands to the left or slides to the left. If the sum of the current window length and the second distance is less than the maximum number of characters, then the current character window is expanded to the left by the second distance to obtain a new current character window. Then, the step of performing pattern matching on each character of the current character window from left to right based on the pattern string set is returned to be executed until the second stop position is located in the current character window, and the second matching result is obtained. If the sum of the current window length and the second distance is not less than the longest character count, then the current character window is expanded to the left until the window length is equal to the longest character count, and then slid to the left by the second distance. The process of performing pattern matching on each character of the current character window from left to right based on the pattern string set is repeated until the second stop position is located in the current character window, and the second matching result is obtained. The second auxiliary table includes a second string skip table, a second final-level string table, and a second final-level character table; the bidirectional matching module can specifically be used for: Determine whether the second stop position is within three characters to the left of the current character window. If so, determine that the second distance is the number of characters between the first character of the current character window and the second stop position. If not, determine whether the first character to the left of the current character window is located at the first-level node in the forward state machine. The forward state machine is an ascending tree storage structure where each pattern string is located. The forward state machine and the forward output table are used to implement forward matching. If yes, then the second distance is determined to be 1; otherwise, it is determined whether the first reference string formed by the second character and the first character on the left side of the current character window is in the second string skip list. If the first reference string is in the second string skip list, then obtain the skip distance corresponding to the first reference string in the second string skip list, and determine that the second distance is the skip distance plus 2; If the first reference string is not in the second string skip list, then determine whether the hash value of the third character on the left side of the current character window and the hash value of the second reference string formed by the third character and the second character are both not in the second cuckoo filter; wherein, the second cuckoo filter includes the hash value of each last substring in the second last layer string table and the hash value of each character in the second last layer character table; If so, then the second distance is determined to be If not, then determine whether the second reference string is in the second last-level string table; Indicates the number of the shortest characters; If the second reference string is in the second last-level string table, then the second distance is determined to be... ; If the second reference string is not in the second last-level string table, then determine whether the third character from the left of the current character window is in the second last-level character table; if so, then determine the second distance as... If not, then determine the second distance as ; The data required for reverse matching is obtained through the following steps: Based on the pattern string array, construct the reverse state machine and the reverse output table; Extract the last part of each pattern string The characters are processed and reversed to obtain the reversed order. The characters will be reversed. Each pair of adjacent characters in a string is treated as a double substring, and the jump distance between each double substring and the root node of the inverse state machine is determined. Based on each double substring and its jump distance, the first string jump table is constructed. Indicates the number of the shortest characters; The last element in each pattern string The first character and the last one 1 character is used as the last substring to construct the first final level string table; Based on the last digit of each pattern string Use 1 character to construct the first final-level character table; The first cuckoo filter is created based on the hash value of each end substring in the first end-level string table and the hash value of each character in the first end-level character table. The data required for positive matching is obtained through the following steps: Based on the pattern string array, construct the forward state machine and the forward output table; The first part of each pattern string Each pair of adjacent characters in the string is treated as a double substring, and the jump distance between each double substring and the root node of the forward state machine is determined. Based on each double substring and its jump distance, the second string jump table is constructed. The first element in each pattern string The character and the first 1 character is used as the last substring to construct the second final level string table; Based on the first in each pattern string Use 1 character to construct the second final-level character table; The second cuckoo filter is created based on the hash value of each last substring in the second last-level string table and the hash value of each character in the second last-level character table.
4. A number status detection device, characterized in that, include: The outbound call acquisition module is used to acquire the ringback tone of each outbound number in the outbound call data after each intelligent outbound call ends; The conversion module is used to convert the ringback tone of each outbound number into the text to be matched; The detection module is used to, for each outbound number, take the ringback tone text of the outbound number as the text to be matched and the preset state set as the pattern string set, so as to obtain a two-way matching result by the matching method described in claim 1, wherein the two-way matching result reflects the number status of the outbound number.
5. An electronic device, characterized in that, include: The electronic device includes a memory and a processor, the memory storing a software program that, when the electronic device is running, the processor executes the software program to perform the matching method as described in claim 1, and / or the number status detection method as described in claim 2.