Fuzzy search method and device, electronic equipment and readable storage medium

By transforming fuzzy search into the problem of 'longest intersecting subset sequence', and using dynamic programming to determine the intersection of the longest query term fragments as the recall result, the problem of insufficient accuracy and versatility in existing fuzzy search technologies is solved, achieving low-cost and efficient fuzzy search results.

CN115292442BActive Publication Date: 2026-02-06SHANGHAI ZHENGDA XIMALAYA NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210401748.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-18
Publication Date
2026-02-06
Estimated Expiration
2042-04-18

AI Technical Summary

Technical Problem

Existing fuzzy search techniques suffer from insufficient accuracy and limited versatility in recalling relevant content, especially when dealing with long-tail queries. Furthermore, supervised learning-based methods are costly, and modifying the retrieval logic can easily lead to the recall of a large amount of irrelevant content.

Method used

The fuzzy search problem is transformed into the problem of 'longest intersecting subsequence'. By obtaining the query term sequence from the target query text, the intersection of the longest consecutive query term segments is determined as the recall result. Dynamic programming is used to ensure the accuracy and efficiency of the recall result.

Benefits of technology

It achieves low-cost, high-accuracy, and widely applicable fuzzy search, effectively recalling relevant content for long-tail queries and improving the accuracy and versatility of the recall results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115292442B_ABST
    Figure CN115292442B_ABST
Patent Text Reader

Abstract

The application provides a fuzzy search method and device, electronic equipment and a readable storage medium, and relates to the technical field of computers. The method comprises the following steps: obtaining a query word sequence from a target query text, the plurality of query words included in the query word sequence being sorted according to the order of the query words in the target query text; obtaining a target query result set corresponding to a target query word segment based on the query word sequence, the target query result set being non-empty, the target query result set being the intersection of the query result sets corresponding to the query words included in the target query word segment, the target query word segment being the longest continuous query word segment with non-empty intersection of the query result sets corresponding to the query words included in the query word sequence; and obtaining a fuzzy search result according to the target query result set. In this way, the intersection of the recall result corresponding to the longest content segment with the intersection can be taken as the recall result, thereby ensuring the accuracy of the recall result, and the method has low cost and strong versatility.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, in particular to a fuzzy search method and device, electronic equipment and readable storage medium. BACKGROUND

[0002] Fuzzy search has always been a difficulty based on inverted index retrieval and other technologies, and there are many practical solutions, including methods based on supervised learning and methods for modifying retrieval logic operations (such as strict retrieval logic operations being "and" operations, which can be partially adjusted to "or" operations). However, the former requires the support of deep learning models, has high training costs and is not very versatile; the latter can easily recall a large amount of irrelevant content if not careful, and bad cases are difficult to fix. SUMMARY

[0003] The embodiments of the present application provide a fuzzy search method, device, electronic equipment and readable storage medium, which can ensure the accuracy of the recall results while being low in cost and strong in versatility.

[0004] Embodiments of the present application can be implemented as follows:

[0005] In a first aspect, the embodiments of the present application provide a fuzzy search method, which comprises:

[0006] obtaining a query word sequence from a target query text, wherein the plurality of query words included in the query word sequence are sorted according to the order of each query word in the target query text;

[0007] obtaining a target query result set corresponding to a target query word segment based on the query word sequence, wherein the target query result set is not empty, the target query result set is the intersection of the query result sets corresponding to each query word included in the target query word segment, and the target query word segment is the longest continuous query word segment for which the intersection of the query result sets corresponding to each query word included in the query word sequence is not empty;

[0008] obtaining a fuzzy search result according to the target query result set.

[0009] In a second aspect, the embodiments of the present application provide a fuzzy search device, which comprises:

[0010] a query word obtaining module configured to obtain a query word sequence from a target query text, wherein the plurality of query words included in the query word sequence are sorted according to the order of each query word in the target query text;

[0011] The processing module is configured to obtain a target query result set corresponding to a target query word segment based on the query word sequence, wherein the target query result set is not empty, the target query result set is an intersection of query result sets corresponding to each query word included in the target query word segment, and the target query word segment is a longest continuous query word segment in the query word sequence for which an intersection of query result sets corresponding to each query word included in the query word sequence is not empty.

[0012] The result determination module is configured to obtain a fuzzy search result based on the target query result set.

[0013] In a third aspect, an electronic device is provided, which includes a processor and a memory. The memory stores machine executable instructions which can be executed by the processor. The processor can execute the machine executable instructions to implement the fuzzy search method described in the foregoing embodiments.

[0014] In a fourth aspect, a readable storage medium is provided, which stores a computer program. The computer program is executed by a processor to implement the fuzzy search method described in the foregoing embodiments.

[0015] The fuzzy search method, device, electronic device and readable storage medium provided by the embodiments of the present application first obtain a plurality of query words from a target query text, and sort the plurality of query words according to the order in the target query text to obtain a query word sequence. Then, based on the query word sequence, a target query result set corresponding to a target query word segment is obtained. The target query result set is not empty, and the target query result set is an intersection of query result sets corresponding to each query word included in the target query word segment. The target query word segment is a longest continuous query word segment in the query word sequence for which an intersection of query result sets corresponding to each query word included in the query word sequence is not empty. Finally, a fuzzy search result is obtained based on the obtained target query result set. In this way, the intersection of the recall set corresponding to the longest content segment with the recall intersection can be taken as the recall result, thereby ensuring the accuracy of the recall result, and the cost is low and the versatility is strong. BRIEF DESCRIPTION OF DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be considered as limiting the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0017] Figure 1 The block diagram of the electronic device provided by the embodiments of the present application is shown;

[0018] Figure 2 A flowchart of the fuzzy search method provided by the embodiment of the present application is shown in the figure.

[0019] Figure 3 For Figure 2 One of the flowcharts of the sub-steps included in step S120 in the embodiment of the present application is shown in the figure.

[0020] Figure 4 For Figure 2 The second flowchart of the sub-steps included in step S120 in the embodiment of the present application is shown in the figure.

[0021] Figure 5 For Figure 2 The third flowchart of the sub-steps included in step S120 in the embodiment of the present application is shown in the figure.

[0022] Figure 6 A block diagram of the fuzzy search device provided by the embodiment of the present application is shown in the figure.

[0023] Figure: 100-electronic device; 110-memory; 120-processor; 130-communication unit; 200-fuzzy search device; 210-query word obtaining module; 220-processing module; 230-result determining module. DETAILED DESCRIPTION

[0024] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. The components of the embodiments of the present application described and shown in the accompanying drawings herein can be arranged and designed in various different configurations.

[0025] Therefore, the detailed description of the embodiments of the present application provided below in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative labor are within the scope of protection of the present application.

[0026] It should be noted that the terms "first", "second", and so on are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

[0027] Fuzzy search aims to solve the problem of long-tail queries, but through analysis, long-tail queries actually also have a clear search intent, except that there are some additional components such as verbs, modifiers, qualifiers or noise in the query. For example, "where did the money go" is a head query (i.e., a query that is used more often), and usually head queries can always recall results with high enough matching degree, but queries such as "where did all the money go", "where did all the money go", "where did all the money go" and the like may be long-tail queries, and sometimes such queries cannot recall matching content due to index logical operations and the like. If a supervised learning-based method is used to process, the training cost is high, and the versatility is not strong.

[0028] To solve the above problems, the embodiments of the present application provide a low-cost and widely applicable fuzzy search method, device, electronic equipment and readable storage medium, which converts the fuzzy search problem into a "longest intersection subsequence" problem, and takes the recall intersection corresponding to the longest content fragment with a recall intersection as the recall result, so as to ensure the accuracy of the recall result, and the cost is low and the versatility is strong.

[0029] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. In the case of no conflict, the following embodiments and features in the embodiments can be combined with each other.

[0030] Please refer to Figure 1 , Figure 1This is a block diagram of an electronic device 100 provided in an embodiment of this application. The electronic device 100 may be, but is not limited to, a computer, a server, etc. The electronic device 100 may include a memory 110, a processor 120, and a communication unit 130. The memory 110, processor 120, and communication unit 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0031] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0032] The processor 120 is used to read / write data or programs stored in the memory 110 and perform corresponding functions. For example, the memory 110 stores a fuzzy search device 200, which includes at least one software function module that can be stored in the memory 110 in the form of software or firmware. The processor 120 executes various functional applications and data processing by running the software programs and modules stored in the memory 110, such as the fuzzy search device 200 in this embodiment, thereby implementing the fuzzy search method in this embodiment.

[0033] The communication unit 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through the network, and to send and receive data through the network. For example, the communication unit 130 can send the obtained fuzzy search results to other devices.

[0034] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0035] Please refer to Figure 2 , Figure 2 A flowchart of a fuzzy search method provided in an embodiment of the present application is shown. The method can be applied to the electronic device 100 described above. The specific flow of the fuzzy search method is described in detail below. The method can be applied to scenarios such as index supplementary recall and recommended search recall. In this embodiment, the method can include steps S110-S130.

[0036] Step S110: Obtain a query word sequence from a target query text.

[0037] In this embodiment, the target query text can be input by a user during a search, can be sent to the electronic device 100 by another device having a search requirement, or can be obtained in another way, which is not limited here. After the target query text is obtained, the target query text can be preprocessed, such as error correction and noise removal, and then the preprocessed result can be processed for word segmentation to obtain a plurality of query words. Then, the query words in the target query word sequence can be sorted according to their order in the target query text. For example, the target query text is “A certain B certain selected stand-up comedy”, and the result after word segmentation is “A certain B certain selected stand-up comedy” (the space represents a division mark). The query words in the target query word sequence can be A certain, B certain, and selected stand-up comedy in order from front to back.

[0038] Step S120: Obtain a target query result set corresponding to a target query word segment based on the query word sequence.

[0039] In this embodiment, the query word sequence can be used for query processing to obtain a target query word segment and a target query result set corresponding to the target query word segment. The target query result set is not empty, that is, the target query result set includes at least one query result. The target query result set is the intersection of query result sets corresponding to each query word included in the target query word segment. A query result set corresponding to a query word is a set of results obtained by querying only the query word. The target query word segment is the longest continuous query word segment in which the intersection of query result sets corresponding to each query word included in the query word sequence is not empty; that is, the target query word segment is the longest query word segment with an intersection, in other words, the target query word segment is the longest query word segment that can be obtained from the query word sequence and in which the intersection of query result sets corresponding to each query word included in the query word segment is not empty.

[0040] Optionally, as one possible implementation, the query result set corresponding to each query word in the query word sequence can be obtained first, and then a plurality of query word segments of arbitrary length can be obtained by combining according to the query word sequence. Each query word segment includes at least one query word, and when a query word segment includes a plurality of query words, the plurality of query words are continuous in the query word sequence. Then, for each query word segment, the intersection of the query result sets corresponding to the query words included in the query word segment can be obtained according to the query words included in the query word segment and the query result sets corresponding to the query words in the query word sequence. Finally, the intersection corresponding to the longest query word segment can be selected as the target query result set according to the length of each query word segment and the corresponding intersection.

[0041] Optionally, as another possible implementation, the query word sequence can be traversed according to a preset traversal order, the query word segment corresponding to each query word and the first intersection corresponding to the query word segment can be obtained, and the target query result set can be obtained according to each query word segment and the first intersection corresponding to the query word segment. The target query result set is the query word segment with the longest length and a non-empty first intersection. When the query words in the query word segment corresponding to any query word are sorted according to the order of the query words in the query word sequence, the last query word is the query word. When a query word segment includes a plurality of query words, the plurality of query words are continuous in the query word sequence. The first intersection corresponding to any query word segment is the intersection of the query result sets corresponding to the query words in the query word segment. In this way, by traversing, the accuracy of the target query result set obtained can be avoided due to the omission of query word segments.

[0042] Optionally, the preset traversal order can include a forward traversal order or a reverse traversal order. When the traversal is based on the forward traversal order, each query word in the query word sequence is traversed from front to back, and the target query result set obtained when the traversal is based on the forward traversal order is obtained. When the traversal is based on the reverse traversal order, each query word in the query word sequence is traversed from back to front, and the target query result set obtained when the traversal is based on the reverse traversal order is obtained.

[0043] Optionally, in the traversing, the query word piece corresponding to the current traversed query word and the first intersection corresponding to the query word piece can be determined based on the current traversed query word and the traversed query words, and then the target query result set can be obtained based on the query word pieces corresponding to the query words in the query word sequence and the first intersections corresponding to the query word pieces.

[0044] As a possible implementation, the query word piece and the first intersection can be obtained in the manner as shown in Figure 3 Please refer to Figure 3 , Figure 3 As a possible implementation, the query word piece and the first intersection can be obtained in the manner as shown in Figure 2 The step S120 in the embodiment includes the sub-steps. FIG. 1 shows a flowchart of one of the sub-steps of the step S120. In the embodiment, the step S120 can include the sub-step S1211 to the sub-step S1214.

[0045] In the sub-step S1211, the current query result set corresponding to the current query word in the traversing is obtained.

[0046] The current query word is the query word currently traversed in the traversing. The current query result set includes the set of results obtained by querying based on the current query word.

[0047] In the sub-step S1212, it is determined whether the intersection of the current query result set and the previous first intersection corresponding to the previous query word piece is empty.

[0048] In the case where the current query result set is obtained, the intersection of the current query result set and the previous first intersection corresponding to the previous query word piece can be calculated, and it is determined whether the calculated intersection is empty. The previous query word piece is the query word piece corresponding to the previous query word of the current query word, and the previous first intersection is the intersection of the query result sets corresponding to the query words in the previous query word piece. The previous first intersection and the previous query word piece are determined based on the already obtained first intersection and query word piece. Here, “previous” is determined based on the preset traversing order.

[0049] In the case where the intersection of the current query result set and the previous first intersection is empty, the sub-step S1213 can be executed.

[0050] In the sub-step S1213, the current query word is taken as the current query word piece, and the current query result set is taken as the current first intersection.

[0051] In the case that the intersection of the current query result set and the previous first intersection is not empty, sub-step S1214 can be performed.

[0052] In the case that the intersection of the current query result set and the previous first intersection is not empty, sub-step S1214 can be performed.

[0053] In the case that the intersection of the current query result set and the previous first intersection is not empty, sub-step S1214 can be performed.

[0054] It can be understood that, in the case that the current query word is the first query word in the traversal process, the first query word can be directly taken as the current query word segment, and the query result set corresponding to the first query word can be taken as the current first intersection. When the second query word is reached, the current query word segment and the current first intersection obtained when the first query word is traversed can be taken as the previous query word segment and the previous first intersection. By analogy, the query word segment corresponding to each query word and the first intersection corresponding to the query word segment can be obtained.

[0055] For the current query word in the traversal process, in the case that the current query word segment and the current first intersection corresponding to the current query word are obtained, the second intersection for determining the target query result set can be obtained in the manner shown in FIG. 6. That is, before the next query word of the current query word is reached, step S120 can be performed. Figure 4 The second intersection for determining the target query result set can be obtained in the manner shown in FIG. 6. That is, before the next query word of the current query word is reached, step S120 can be performed. Figure 4 The second intersection for determining the target query result set can be obtained in the manner shown in FIG. 6. That is, before the next query word of the current query word is reached, step S120 can be performed.

[0056] In the case that the intersection of the current query result set and the previous first intersection is not empty, sub-step S1214 can be performed.

[0057] The current longest query word segment is the longest query word segment in the query word segments obtained without considering the current query word and corresponding to a non-empty first intersection.

[0058] In the sub-step S1222, it is judged whether the first string length is greater than the second string length.

[0059] In the case that the first string length is greater than the second string length, the sub-step S1223 can be executed.

[0060] In the sub-step S1223, the current longest query word segment is updated to the current query word segment, and the current second intersection corresponding to the current longest query word segment is updated to the current first intersection.

[0061] Since the purpose is to find the query word segment corresponding to a non-empty first intersection and being the longest, when the first string length of the current query word segment is greater than the second string length of the current longest query word segment, the current longest query word segment needs to be updated to the current query word segment, and the current second intersection corresponding to the current longest query word segment needs to be updated to the current first intersection. In this way, the accuracy of the current longest query word segment and the corresponding current second intersection can be ensured. It can be understood that the current second intersection is the intersection of the query result sets corresponding to each query word included in the current longest query word segment.

[0062] The "previous" in the previous query word segment and the previous first intersection described above is determined based on the position of the query word in the query word sequence and the preset traversal order used. For example, assuming that a query word sequence is: "A certain", "B certain", "Selected comedy", when the preset traversal order is a forward traversal order, the previous query word segment can be "A certain B certain", and the current query word segment can be "A certain B certain selected comedy"; when the preset traversal order is a reverse traversal order, the previous query word segment can be "B certain selected comedy", and the current query word segment can be "A certain B certain selected comedy".

[0063] Please refer to Figure 5 , Figure 5 For Figure 2 The flowchart of the sub-steps included in the step S120 of the third embodiment is shown in FIG. 12C. In the embodiment, the step S120 can further include the sub-step S1224 to the sub-step S1227.

[0064] In the case that the first string length is not greater than the second string length, the sub-step S1224 can be executed.

[0065] In the sub-step S1224, it is judged whether the first string length is equal to the second string length.

[0066] In the case that the first string length is equal to the second string length, the obtained current longest query word segment and the current second intersection set can not be updated, and the current query word segment and the corresponding current first intersection set are also taken as the current longest query word segment and the current second intersection set. Sub-step S1225 and sub-step S1226 can also be executed.

[0067] In sub-step S1225, the number of query results in the current first intersection set is taken as a first number, and the number of query results in the current second intersection set is taken as a second number.

[0068] In sub-step S1226, it is judged whether the first number is greater than the second number.

[0069] In the case that the first number is greater than the second number, sub-step S1223 is executed.

[0070] In sub-step S1223, the current longest query word segment is updated to the current query word segment, and the current second intersection set corresponding to the current longest query word segment is updated to the current first intersection set.

[0071] In the case that the first string length is less than the second string length, or in the case that the first string length is equal to the second string length and the first number is not greater than the second number, sub-step S1227 can be executed.

[0072] In sub-step S1227, the current longest query word segment and the current second intersection set are not updated.

[0073] In the embodiment, the above sub-steps S1211-S1214 and S1221-S1227 can be executed every time a query word is traversed, so as to obtain a current query word segment and a current first intersection set, and further obtain a current longest query word segment and a current second intersection set. When all the query words are traversed, the finally obtained current longest query word segment can be taken as the target query word segment, and the finally obtained current second intersection set can be taken as the target query result set. In this way, the efficiency of obtaining the target query result set can be improved.

[0074] The above sub-steps S1211-S1214 can also be performed each time a query word is traversed, so as to obtain a current query word segment corresponding to each query word as a current query word, and a current first intersection. Then, the obtained query word segments are traversed according to the order in which the query word segments are obtained, each time a query word segment corresponding to a query word is traversed, the query word segment is taken as a current query word segment, and the above sub-steps S1221-S1127 are performed. When all the query word segments are traversed, the last obtained current longest query word segment is taken as the target query word segment, and the last obtained current second intersection is taken as the target query result set.

[0075] In step S130, a fuzzy search result is obtained according to the target query result set.

[0076] Optionally, in the case of traversing the query word sequence only through the forward traversal order or the reverse traversal order, the target query result set obtained through the traversal can be taken as a fuzzy search result corresponding to the target query text.

[0077] In this way, the longest content segment with a recall intersection can be obtained by using dynamic programming, and the intersection thereof is the recall result. This method is efficient and low in cost, and in principle, the longer the query, the more advantages of this algorithm can be exerted, and in a real situation, the effect is indeed better than other methods tried.

[0078] The above method will be described below by taking an application of the method to an index recall technique as an example. In the following example, index content corresponding to a query word can be obtained based on an inverted index technique.

[0079] An index recall technique strictly according to the "and" logic is certainly reliable, because the recalls are results of taking intersections of index content corresponding to each token (i.e., each segmented word) after segmentation of a query (i.e., the target query text in the above description), and of course, this method often cannot recall relevant content. The inventors of the present application think that a longest segment of a query satisfying the recall result of the "and" logic is usually reliable, and the longer the segment, the higher the reliability. Therefore, a longest segment with a result after taking an intersection according to the "and" logic can be found, and the result corresponding to the segment is taken as the recall result of the query. The longest segment can be determined by using dynamic programming, i.e., the "longest sub-sequence with an intersection" mentioned above.

[0080] Assume that the index is built with the same tokenizer as the one used in recall, to avoid the possibility that the recall has no result due to the inconsistency between the tokenization of query in index and recall. Assume that the current string fragment is named localGram, and its corresponding intersection set is localBestSet; the current longest intersection fragment (i.e. the current longest query fragment) is bestGram, and its corresponding intersection set is bestRecallSet (i.e. the current second intersection). The processing procedure is shown as follows.

[0081] STEP1: Tokenize the query after pre-processing (such as error correction, noise removal, etc.), to obtain the tokenization result.

[0082] The tokenization result in the analysis result is sorted according to the order in the query.

[0083] STEP2: Traverse each token (i.e. query word) in the tokenization result from front to back, to calculate the local optimal fragment localGram and the recall result localBestSet based on the current token.

[0084] Specifically, take the intersection interSet of the index content of the current token (i.e. the current query set) and the localBestSet of the previous state (the localBestSet of the previous state is the previous first intersection). If interSet is not empty, update localBestSet to interSet, and localGram absorbs the current token to extend backward. Otherwise, localBestSet becomes the index content of the current token, and localGram also becomes the current token. The localBestSet obtained after the current update is the current query fragment, and the localGram obtained after the current update is the current first intersection.

[0085] IF interSet is not empty, THEN localGram.append(token) localBestSet = interSet

[0086] ELSE localGram = token localBestSet = indexDict(token)

[0087] STEP3: compare localGram with bestGram, if length of localGram is greater than length of bestGram, then update; if length of localGram is equal to length of bestGram and localBestSet has more elements than bestRecallSet, then also update; otherwise, do not update.

[0088] The update is to assign bestGram to localGram, and to assign bestRecallSet to localBestSet.

[0089] IF length(localGram) > length(bestGram) OR

[0090] (length(localGram) == length(bestGram) AND localBestSet.size() > bestRecallSet.size())

[0091] THEN bestGram = localGram bestRecallSet = localBestSet

[0092] STEP4: repeat STEP2 and STEP3 until the loop ends, and get the optimal recall result.

[0093] The bestRecallSet at the end of the loop can be taken as the optimal recall result, i.e. the fuzzy search result for the query.

[0094] For example, assume there is an album named "A certain B certain xiangsheng selection", and the result of the index segmentation is "A certain B certain xiangsheng selection" (the space represents the segmentation mark), so the index content of "A certain", "B certain" and "xiangsheng selection" all contain this album.

[0095] When there is a query "B certain partner A certain cross talk selected", the result after segmentation is "B certain partner A certain cross talk selected". Assuming that the index content of "partner" never includes any A certain B certain cross talk, the query cannot find relevant results if strictly according to the "and" logic, but the method provided in the embodiment can solve the problem. From front to back, the first token "B certain" has results; the intersection of the index content of the next token "partner" and the index content of the previous token "B certain" is empty, and localGram and localBestSet become "partner" and the corresponding results (i.e. the index content of "partner"). Next, the index content of "A certain" has no intersection with the previous local optimal solution, and localGram and localBestSet become "A certain" and the corresponding results; the index content of the last token "cross talk selected" has an intersection with the previous local optimal solution, and localGram is extended to "A certain cross talk selected", and localBestSet is updated to still have relevant albums. Finally, the album "A certain B certain cross talk selected" can be recalled.

[0096] To perform the corresponding steps in the above embodiments and various possible manners, an implementation of a fuzzy search device 200 is given below, which can optionally employ the device structure of the electronic device 100 shown in Figure 1 . Further, please refer to Figure 6 , Figure 6 for the block schematic diagram of the fuzzy search device 200 provided in the embodiment of the present application. It should be noted that the fuzzy search device 200 provided in the embodiment has the same basic principles and technical effects as the above embodiments, and for brief description, the part not mentioned in the embodiment can refer to the corresponding content in the above embodiments. The fuzzy search device 200 can include a query word obtaining module 210, a processing module 220 and a result determining module 230.

[0097] The query word obtaining module 210 is configured to obtain a query word sequence from a target query text. The plurality of query words included in the query word sequence are sorted according to the order of each query word in the target query text.

[0098] The processing module 220 is configured to obtain a target query result set corresponding to a target query word segment based on the query word sequence. The target query result set is not empty, and the target query result set is the intersection of the query result sets corresponding to each query word included in the target query word segment. The target query word segment is the longest continuous query word segment whose intersection of the query result sets corresponding to each query word included in the query word sequence is not empty.

[0099] The result determination module 230 is configured to obtain the fuzzy search result according to the target query result set.

[0100] In this embodiment, the processing module 220 is specifically configured to: traverse the query word sequence according to a preset traversal order, obtain a query word segment corresponding to each query word and a first intersection corresponding to the query word segment, and obtain the target query result set according to each query word segment and the first intersection corresponding to the query word segment; wherein a query word in the query word segment corresponding to any query word is the last query word in the query word when the query words in the query word sequence are sorted in order of the query words in the query word sequence; when a plurality of query words are included in a query word segment, the plurality of query words are continuous in position in the query word sequence; and the first intersection corresponding to any query word segment is the intersection of the query result sets corresponding to the query words in the query word segment.

[0101] Optionally, the above modules can be stored in the memory 110 in the form of software or firmware (Firmware) or solidified in the operating system (Operating System, OS) of the electronic device 100, and can be executed by the processor 120 in the electronic device 100. At the same time, the data, program code, etc. required for executing the above modules can be stored in the memory 110. Figure 1 Figure 1 The above modules can be executed by the processor 120 in the electronic device 100. At the same time, the data, program code, etc. required for executing the above modules can be stored in the memory 110.

[0102] The embodiments of the present application also provide a readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the fuzzy search method.

[0103] In summary, the embodiments of the present application provide a fuzzy search method, device, electronic device and readable storage medium. First, a plurality of query words are obtained from a target query text, and the plurality of query words are sorted in order in the target query text to obtain a query word sequence. Then, based on the query word sequence, a target query result set corresponding to a target query word segment is obtained, the target query result set is not empty, the target query result set is the intersection of the query result sets corresponding to each query word included in the target query word segment, and the target query word segment is the longest continuous query word segment whose intersection of the query result sets corresponding to each query word included in the query word sequence is not empty. Finally, a fuzzy search result is obtained according to the obtained target query result set. In this way, the recall intersection corresponding to the longest content segment with a recall intersection can be taken as a recall result, so as to ensure the accuracy of the recall result, and the cost is low and the versatility is strong.

[0104] ​In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiments described above are merely illustrative, for example, the flowcharts and block diagrams in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders from those noted in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and the combination of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system for executing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0105] In addition, the functional modules in the embodiments of the present application can be integrated together to form a separate part, or each module can exist independently, or two or more modules can be integrated to form a separate part.

[0106] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0107] The above only describes optional embodiments of the present application and is not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A fuzzy search method, characterized in that, The method includes: Obtain a query term sequence from the target query text, wherein the multiple query terms included in the query term sequence are ordered according to the order of the query terms in the target query text; Based on the query term sequence, a target query result set corresponding to the target query term fragment is obtained, wherein the target query result set is not empty, the target query result set is the intersection of the query result sets corresponding to each query term included in the target query term fragment, and the target query term fragment is the longest continuous query term fragment whose intersection of the query result sets corresponding to each query term included in the query term sequence is not empty; The step of obtaining the target query result set corresponding to the target query term fragment based on the query term sequence includes: The query term sequence is traversed according to a preset traversal order to obtain the query term fragments corresponding to each query term and the first intersection of the query term fragments. The target query result set is then obtained based on each query term fragment and the first intersection of the query term fragments. Wherein, when the query terms in a query term fragment corresponding to any query term are sorted according to the order of the query terms in the query term sequence, the last query term is that query term. When a query term fragment includes multiple query terms, the multiple query terms are in consecutive positions in the query term sequence. The first intersection of any query term fragment is the intersection of the query result sets corresponding to each query term in that query term fragment. Based on the target query result set, fuzzy search results are obtained.

2. The method according to claim 1, characterized in that, The step of traversing the query term sequence according to a preset traversal order to obtain the query term fragments corresponding to each query term and the first intersection corresponding to the query term fragments includes: For each query term encountered during iteration, obtain the current query result set corresponding to that query term; Determine whether the intersection of the current query result set and the previous first intersection corresponding to the obtained previous query term fragment is empty, wherein the previous query term fragment is the query term fragment corresponding to the previous query term of the current query term, and the previous first intersection is the intersection of the query result sets corresponding to each query term in the previous query term fragment; If the intersection of the current query result set and the previous first intersection is not empty, the current query term is added to the previous query term fragment to obtain the current query term fragment, and the intersection of the current query result set and the previous first intersection is taken as the current first intersection; If the intersection of the current query result set and the previous first intersection is empty, the current query term is taken as the current query term fragment, and the current query result set is taken as the current first intersection.

3. The method according to claim 2, characterized in that, The target query result set is obtained through dynamic programming, and the current second intersection obtained after traversing all the query terms is the target query result set; for the current query term, obtaining the target query result set based on each query term fragment and the first intersection corresponding to that query term fragment includes: Obtain the first string length of the current query term fragment, and the second string length of the currently longest query term fragment; Determine whether the length of the first string is greater than the length of the second string; If the length of the first string is greater than the length of the second string, the current longest query term fragment is updated to the current query term fragment, and the current second intersection corresponding to the current longest query term fragment is updated to the current first intersection.

4. The method according to claim 3, characterized in that, The step of obtaining the target query result set based on each query term fragment and the first intersection corresponding to that query term fragment further includes: If the length of the first string is equal to the length of the second string, the number of query results in the current first intersection is obtained as the first number, and the number of query results in the current second intersection is obtained as the second number. If the first quantity is greater than the second quantity, the current longest query term fragment is updated to the current query term fragment, and the current second intersection corresponding to the current longest query term fragment is updated to the current first intersection; If the length of the first string is equal to the length of the second string and the first quantity is not greater than the second quantity, or if the length of the first string is less than the length of the second string, the current longest query term fragment and the current second intersection will not be updated.

5. The method according to any one of claims 2-4, characterized in that, The preset traversal order includes a forward traversal order or a reverse traversal order, and the target query result set is the fuzzy search results.

6. A fuzzy search device, characterized in that, The device includes: A query term acquisition module is used to obtain a query term sequence from a target query text, wherein the multiple query terms included in the query term sequence are ordered according to the order of the query terms in the target query text; The processing module is configured to obtain a target query result set corresponding to the target query term fragment based on the query term sequence, wherein the target query result set is not empty, the target query result set is the intersection of the query result sets corresponding to each query term included in the target query term fragment, and the target query term fragment is the longest consecutive query term fragment whose intersection of the query result sets corresponding to each query term included in the query term sequence is not empty; the processing module is specifically configured to: The query term sequence is traversed according to a preset traversal order to obtain the query term fragments corresponding to each query term and the first intersection of the query term fragments. The target query result set is then obtained based on each query term fragment and the first intersection of the query term fragments. Wherein, when the query terms in a query term fragment corresponding to any query term are sorted according to the order of the query terms in the query term sequence, the last query term is that query term. When a query term fragment includes multiple query terms, the multiple query terms are in consecutive positions in the query term sequence. The first intersection of any query term fragment is the intersection of the query result sets corresponding to each query term in that query term fragment. The result determination module is used to obtain fuzzy search results based on the target query result set.

7. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the fuzzy search method according to any one of claims 1-5.

8. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the fuzzy search method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Text query error correction method and device, computer equipment and storage medium

    CN108595437A

  • Search text processing method, device, electronic equipment and medium

    CN113535895A