Keyword search method, device, equipment and computer-readable storage medium
By matching and merging common substrings of keyword lexicons and building an index library, the high space and time overhead problems of traditional methods are solved, and more efficient keyword search is achieved.
Patent Information
- Application Number
- CN202311092855.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-28
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-08-28
AI Technical Summary
Traditional keyword search methods require building large-scale index libraries in massive data, resulting in excessive space and time overhead, affecting operating costs and customer satisfaction.
By matching common substrings between any two phrases in the keyword database, an index database is constructed to reduce the space consumption of the index database. When a search keyword is received, matching and merging are performed to find the original phrase.
The space overhead and retrieval time overhead of the indexing process in keyword search are reduced, and the search efficiency is improved.
Smart Images

Figure CN117150128B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a keyword search method, device, electronic device, and readable storage medium. Background Art
[0002] Traditional keyword search methods primarily involve crawling, parsing, indexing, retrieval, and sorting, with indexing and retrieval being the most crucial. Faced with massive amounts of data, indexing is an essential core module for quickly finding the content users are looking for. Traditional search engines employ an inverted index, extracting document keywords through a single scan and establishing an index relationship between document keywords and documents. In financial applications, this approach often requires building a large-scale index library, which incurs significant space overhead. Furthermore, searching against this large-scale index also incurs a time overhead proportional to the index size. This significant time and space overhead leads to high operating costs and compromises customer satisfaction. Summary of the Invention
[0003] The present invention provides a keyword search method, device, electronic device and readable storage medium, which aim to reduce the space overhead of the indexing process in keyword search and improve the efficiency of keyword search.
[0004] To achieve the above object, the present invention provides a keyword search method, which includes:
[0005] Perform common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set;
[0006] Selecting common substrings that meet preset conditions from the common substring set, and building an index library based on the selected common substrings;
[0007] When receiving a search keyword input by a user, matching the search keyword with a common substring in the index library to obtain a search affix set;
[0008] Merging the phrases in the search affix set to obtain a merged affix, and searching for the original phrase from the keyword thesaurus based on the merged affix;
[0009] A search is performed based on the original phrase to obtain search results corresponding to the search keyword.
[0010] Optionally, performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set includes:
[0011] Select any two phrases in the keyword vocabulary through traversal operation, and form the two selected phrases into a phrase pair;
[0012] When the words in any identical position in the phrase pair are identical, the identical words are added to the pre-built common substring set.
[0013] When all words in the same position in the phrase pair are different, it is determined that there is no common substring in the phrase pair, and the process returns to the above step of selecting any two phrases in the keyword vocabulary through traversal operation and forming the selected two phrases into a phrase pair, and continues to traverse the words in the next phrase pair until all phrase pairs are traversed to obtain a common substring set.
[0014] Optionally, constructing an index library based on the selected common substrings includes:
[0015] Extracting data features of the common substrings, and setting an index library structure according to the data features and preset index requirements;
[0016] Constructing an initial index library according to the index library structure;
[0017] The common substring is imported into the initial index library to obtain an index library.
[0018] Optionally, merging the phrases in the search affix set to obtain a merged affix includes:
[0019] Comparing each phrase in the search affix set with the search keyword to determine the position and interval of each phrase in the search affix set;
[0020] According to the positions and the intervals, each phrase in the search affix set is spliced to obtain a merged affix.
[0021] Optionally, searching for an original phrase from the keyword thesaurus according to the combined affix includes:
[0022] The merged affix is compared with the keyword phrases in the keyword thesaurus, and the keyword phrases that match the affix phrase position and the number of merged affix characters in the merged affix are output as comparison results to obtain the original phrases.
[0023] Optionally, before performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set, the method further includes:
[0024] Remove useless characters from the keyword set to be processed to obtain a preliminary keyword set;
[0025] According to preset phrase format rules, the initially processed keyword set is phrase-normalized to obtain a keyword thesaurus.
[0026] Optionally, after constructing the index library according to the selected common substrings, the method further includes:
[0027] The keyword thesaurus is monitored in real time, and when a new phrase is introduced into the keyword thesaurus, the new phrase is matched with the original phrases in the keyword thesaurus one by one for common substrings to obtain a new common substring set;
[0028] Newly added common substrings that meet preset conditions are screened out from the newly added common substring set and imported into the index library.
[0029] In order to solve the above problem, the present invention further provides a keyword search device, which includes:
[0030] An index library construction module is used to perform common substring matching on any two phrases in the keyword library to obtain a common substring set, select common substrings that meet preset conditions from the common substring set, and construct an index library based on the selected common substrings;
[0031] an original phrase search module for, upon receiving a search keyword input by a user, matching the search keyword with a common substring in the index library to obtain a search affix set, merging the phrases in the search affix set to obtain a merged affix, and searching the keyword library for an original phrase based on the merged affix;
[0032] The keyword search module is used to search according to the original phrase to obtain search results corresponding to the search keyword.
[0033] In order to solve the above problem, the present invention further provides an electronic device, comprising:
[0034] a memory storing at least one computer program; and
[0035] The processor executes the computer program stored in the memory to implement the keyword search method described above.
[0036] In order to solve the above problem, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one computer program, and the at least one computer program is executed by a processor in an electronic device to implement the above-mentioned keyword search method.
[0037] The embodiment of the present invention performs common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set, and takes the common substrings in the common substring set that meet preset conditions as indexes to obtain an index library, thereby reducing the space overhead of the indexing process in the keyword search. Furthermore, when a search keyword input by a user is received, the search keyword is matched with the common substring in the index library to obtain a search affix, the search affix is merged to obtain a merged affix, and the original phrase in the keyword vocabulary is searched based on the merged affix, thereby reducing the time overhead of the retrieval process in the keyword search and improving the efficiency of the keyword search. Therefore, the keyword search method, device, equipment and storage medium provided by the present invention can reduce the space overhead of the indexing process in the keyword search and improve the efficiency of the keyword search. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flowchart of a keyword search method provided by one embodiment of the present invention;
[0039] Figure 2 and Figure 3 A detailed implementation flow chart of one step in a keyword search method provided by one embodiment of the present invention;
[0040] Figure 4 A schematic diagram of a module of a keyword search device provided by an embodiment of the present invention;
[0041] Figure 5 A schematic diagram of the internal structure of an electronic device for implementing a keyword search method provided by an embodiment of the present invention;
[0042] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0043] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0044] An embodiment of the present invention provides a keyword search method. The execution subject of the keyword search method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the keyword search method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server can include an independent server, or it can include a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0045] Reference Figure 1 FIG. 1 is a flow chart of a keyword search method provided by an embodiment of the present invention. In the embodiment of the present invention, the keyword search method includes:
[0046] S1. Perform common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set.
[0047] In an embodiment of the present invention, the keyword lexicon may be a set of phrases containing all keywords in a certain field. For example, a keyword lexicon in the financial field may contain words such as insurance contract descriptions, bond usage instructions, and fund contract rules.
[0048] In order to ensure the standardization of the keyword thesaurus, before performing common substring matching on any two phrases in the keyword thesaurus, an optional embodiment of the present invention also needs to standardize the phrases in the keyword thesaurus, so as to ensure that the matching success rate can be improved when performing common substring matching on any two phrases in the keyword thesaurus.
[0049] In detail, as an optional embodiment of the present invention, refer to Figure 2 As shown, before performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set, the method further includes:
[0050] S11, removing useless characters from the keyword set to be processed to obtain a preliminary processing keyword set;
[0051] S12. Perform phrase normalization processing on the initially processed keyword set according to preset phrase format rules to obtain a keyword vocabulary.
[0052] In an embodiment of the present invention, the preset phrase format rule may be converting Arabic numerals in the preliminary processed keyword vocabulary into characters and unifying English letters into lowercase.
[0053] In an optional embodiment of the present invention, useless characters are removed and normalized on the keyword set to be processed, thereby ensuring the standardization of each phrase in the keyword vocabulary, so that the matching success rate of each phrase in the keyword vocabulary is higher when performing common substring matching.
[0054] In detail, as an optional embodiment of the present invention, performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set includes:
[0055] Select any two phrases in the keyword vocabulary through traversal operation, and form the two selected phrases into a phrase pair;
[0056] When the words in any identical position in the phrase pair are identical, the identical words are added to the pre-built common substring set.
[0057] When all words in the same position in the phrase pair are different, it is determined that there is no common substring in the phrase pair, and the process returns to the above step of selecting any two phrases in the keyword vocabulary through traversal operation and forming the selected two phrases into a phrase pair, and continues to traverse the words in the next phrase pair until all phrase pairs are traversed to obtain a common substring set.
[0058] In an optional embodiment of the present invention, when there are keyword words such as "insurance contract description", "bond usage instructions" and "fund contract rules" in the financial keyword vocabulary, by arbitrarily combining the keyword words, phrase pairs such as (insurance contract description, bond usage instructions), (bond usage instructions, fund contract rules) and (insurance contract description, fund contract rules) are obtained, and the words in the same position of the two keyword words in any phrase pair are compared one by one, and it is obtained that the positions of the fifth and sixth words in the phrase pair (insurance contract description, bond usage instructions) exist the same words, and the positions of the third and fourth words in the phrase pair (insurance contract description, fund contract rules) exist the same words. Therefore, the same words "description" and "contract" are added to the pre-constructed common substring set. All words in the same position in the phrase pair (bond usage instructions, fund contract rules) are different. Therefore, it is determined that the phrase pair (bond usage instructions, fund contract rules) does not have a common substring.
[0059] In an optional embodiment of the present invention, by performing phrase pair comparison on any two phrases in the keyword vocabulary, the same words in the same position in the phrase pairs are added to a pre-constructed common substring set to obtain a common substring set, thereby ensuring that no common substrings are missing or omitted, thereby improving the integrity of the common substring set.
[0060] The embodiment of the present invention reduces the number of phrases in the index library and reduces the space consumption of the index library by performing common substring matching on any two phrases in the keyword library.
[0061] S2. Selecting common substrings that meet preset conditions from the common substring set, and building an index library based on the selected common substrings.
[0062] In an embodiment of the present invention, the preset condition may be a common substring screening condition set by a technician to reduce storage space consumption, wherein the common substring screening condition may be that if a phrase pair contains multiple common substrings, only the common substring with the longest length is taken, and among all the common strings in the common substring set, only the common substrings with a length greater than or equal to 2 word lengths are taken.
[0063] In an optional embodiment of the present invention, by selecting common substrings that meet preset conditions from the common substring set, the number of common substrings in the common string set is reduced, thereby reducing the space consumption of the index library during the keyword search process. Furthermore, by constructing the index library based on the selected common substrings, the embodiment of the present invention can significantly reduce the data storage capacity of the index library, thereby reducing space consumption during the indexing process.
[0064] In detail, as an optional embodiment of the present invention, refer to Figure 3 As shown, the index library is constructed based on the selected common substrings, including:
[0065] S21, extracting data features of the common substring, and setting an index library structure according to the data features and preset index requirements;
[0066] S22. Construct an initial index library according to the index library structure;
[0067] S23. Import the common substring into the initial index library to obtain an index library.
[0068] In the embodiment of the present invention, the data feature may be a feature such as a field type, etc. The preset index requirement refers to the purpose of building an index library, which may be a search engine or data analysis purpose.
[0069] Furthermore, the embodiment of the present invention utilizes preset tools, such as open source search engine libraries, for example, Elasticsearch, Apache Lucene, Apache Solr, etc., to construct an initial index library.
[0070] In an optional embodiment of the present invention, based on the data characteristics of the common substring and the index requirements for the search engine, the index library to be constructed is subjected to index field confirmation, field type confirmation and field analyzer confirmation, thereby determining the index library structure and ensuring that the constructed index library can store the common substring and meet the preset index requirements.
[0071] In order to improve the effectiveness of the index library and the accuracy of keyword search, when a new phrase appears in the keyword library, the embodiment of the present invention also needs to synchronize the new phrase in the keyword library to the index library.
[0072] In detail, as an optional embodiment of the present invention, after constructing the index library based on the selected common substrings, the method further includes:
[0073] The keyword thesaurus is monitored in real time, and when a new phrase is introduced into the keyword thesaurus, the new phrase is matched with the original phrases in the keyword thesaurus one by one for common substrings to obtain a new common substring set;
[0074] Newly added common substrings that meet preset conditions are screened out from the newly added common substring set and imported into the index library.
[0075] In an optional embodiment of the present invention, by real-time monitoring of the keyword thesaurus, synchronization of newly added data of the keyword thesaurus and the index library is achieved, thereby improving the effectiveness of the index library and the accuracy of keyword searches.
[0076] S3. When a search keyword input by a user is received, the search keyword is matched with a common substring in the index library to obtain a search affix set.
[0077] In the embodiment of the present invention, the search keyword may be any phrase input by the user. The search affix set includes one or more phrases.
[0078] Since the index library only contains common substrings, after receiving the search keyword input by the user, the embodiment of the present invention needs to accurately match the search keyword with the common substrings in the index library, and then perform a keyword search based on the user input.
[0079] It should be understood that if the keyword thesaurus is directly used as an index library, when a user enters a search keyword containing a typo, a search error prompt is likely to appear, reducing the user's search efficiency and the efficiency of keyword searches. In an embodiment of the present invention, when the index fields stored in the index library are all common substrings, when a user enters a search keyword containing a typo, the matching success rate between the search keyword and the common substring can be improved, and then a keyword search can be performed based on the matching results, thereby improving the user's search efficiency and the efficiency of keyword searches.
[0080] In the embodiment of the present invention, by determining whether some fields in the search keyword are identical to the common substring in the index library, the search keyword is matched with the common substring in the index library, thereby obtaining a search affix set.
[0081] S4. Merge the phrases in the search affix set to obtain a merged affix, and search the keyword thesaurus for the original phrase based on the merged affix.
[0082] In the embodiment of the present invention, the original phrase may be one or more.
[0083] The embodiment of the present invention merges the phrases in the search affix set to obtain a merged affix, and searches the original phrase from the keyword thesaurus based on the merged affix, thereby ensuring that even if the search keyword entered by the user contains typos, the original phrase corresponding to the search keyword can be found based on the merged affix, thereby reducing the time consumption of keyword search and improving the speed and efficiency of keyword search.
[0084] Furthermore, as an optional embodiment of the present invention, merging the phrases in the search affix set to obtain a merged affix includes:
[0085] Comparing each phrase in the search affix set with the search keyword to determine the position and interval of each phrase in the search affix set;
[0086] According to the positions and the intervals, each phrase in the search affix set is spliced to obtain a merged affix.
[0087] In an optional embodiment of the present invention, when the user enters the search keyword "insurance contract description", the search affix set {contract, description} is obtained based on the matching results of the search keyword and the common string in the index library. Furthermore, the search affix set is compared with the search keyword to determine the position and interval of "contract" and "description" in the search affix set, and based on the position and interval, the merged affix "xx contract description" is generated.
[0088] Furthermore, after obtaining the merged affix, the embodiment of the present invention searches for the original phrase from the keyword database according to the merged affix to determine the phrase to be searched, thereby implementing keyword search.
[0089] In detail, as an optional embodiment of the present invention, searching for the original phrase from the keyword thesaurus according to the combined affix includes:
[0090] The merged affix is compared with the keyword phrases in the keyword thesaurus, and the keyword phrases that match the affix phrase position and the number of merged affix characters in the merged affix are output as comparison results to obtain the original phrases.
[0091] In an optional embodiment of the present invention, when the merged affix is "xx contract description", by traversing each keyword phrase in the keyword vocabulary and comparing the keyword phrase with the merged affix, the original phrases such as "insurance contract description" and "fund contract description" are obtained.
[0092] S5. Search according to the original phrase to obtain search results corresponding to the search keyword.
[0093] In an optional embodiment of the present invention, after the original phrase is determined, the original phrase is returned as a search to obtain search results corresponding to the search keyword.
[0094] Furthermore, in order to obtain the accurate search results required by the user, the embodiment of the present invention needs to sort, filter and handle conflicts of the search results after the search results are obtained, so as to improve the accuracy of the keyword search.
[0095] The embodiment of the present invention performs common substring matching on any two phrases in the keyword thesaurus to obtain a common substring set, and takes the common substrings in the common substring set that meet preset conditions as indexes to obtain an index library, thereby reducing the space overhead of the indexing process in the keyword search. Furthermore, when a search keyword input by a user is received, the search keyword is matched with the common substring in the index library to obtain a search affix, the search affix is merged to obtain a merged affix, and the original phrase in the keyword thesaurus is searched based on the merged affix, thereby reducing the time overhead of the retrieval process in the keyword search and improving the efficiency of the keyword search. Therefore, the keyword search method provided by the present invention can reduce the space overhead of the indexing process in the keyword search and improve the efficiency of the keyword search.
[0096] like Figure 4 FIG. 1 is a functional module diagram of the keyword search device of the present invention.
[0097] The keyword search device 100 of the present invention can be installed in an electronic device. Depending on the functions to be implemented, the keyword search device 100 can include an index library construction module 101, an original phrase search module 102, and a keyword search module 103. The modules of the present invention, also referred to as units, refer to a series of computer program segments that can be executed by an electronic device processor and can perform fixed functions, and are stored in the memory of the electronic device.
[0098] In this embodiment, the functions of each module / unit are as follows:
[0099] The index library construction module 101 is used to perform common substring matching on any two phrases in the keyword library to obtain a common substring set, select common substrings that meet preset conditions from the common substring set, and construct an index library based on the selected common substrings.
[0100] In an embodiment of the present invention, the keyword lexicon may be a set of phrases containing all keywords in a certain field. For example, a keyword lexicon in the financial field may contain words such as insurance contract descriptions, bond usage instructions, and fund contract rules.
[0101] In order to ensure the standardization of the keyword thesaurus, before performing common substring matching on any two phrases in the keyword thesaurus, an optional embodiment of the present invention also needs to standardize the phrases in the keyword thesaurus, so as to ensure that the matching success rate can be improved when performing common substring matching on any two phrases in the keyword thesaurus.
[0102] In detail, as an optional embodiment of the present invention, refer to Figure 2 As shown, before performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set, the method further includes:
[0103] Remove useless characters from the keyword set to be processed to obtain a preliminary keyword set;
[0104] According to preset phrase format rules, the initially processed keyword set is phrase-normalized to obtain a keyword thesaurus.
[0105] In an embodiment of the present invention, the preset phrase format rule may be converting Arabic numerals in the preliminary processed keyword vocabulary into characters and unifying English letters into lowercase.
[0106] In an optional embodiment of the present invention, useless characters are removed and normalized on the keyword set to be processed, thereby ensuring the standardization of each phrase in the keyword vocabulary, so that the matching success rate of each phrase in the keyword vocabulary is higher when performing common substring matching.
[0107] In detail, as an optional embodiment of the present invention, performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set includes:
[0108] Select any two phrases in the keyword vocabulary through traversal operation, and form the two selected phrases into a phrase pair;
[0109] When the words in any identical position in the phrase pair are identical, the identical words are added to the pre-built common substring set.
[0110] When all words in the same position in the phrase pair are different, it is determined that there is no common substring in the phrase pair, and the process returns to the above step of selecting any two phrases in the keyword vocabulary through traversal operation and forming the selected two phrases into a phrase pair, and continues to traverse the words in the next phrase pair until all phrase pairs are traversed to obtain a common substring set.
[0111] In an optional embodiment of the present invention, when there are keyword words such as "insurance contract description", "bond usage instructions" and "fund contract rules" in the financial keyword vocabulary, by arbitrarily combining the keyword words, phrase pairs such as (insurance contract description, bond usage instructions), (bond usage instructions, fund contract rules) and (insurance contract description, fund contract rules) are obtained, and the words in the same position of the two keyword words in any phrase pair are compared one by one, and it is obtained that the positions of the fifth and sixth words in the phrase pair (insurance contract description, bond usage instructions) exist the same words, and the positions of the third and fourth words in the phrase pair (insurance contract description, fund contract rules) exist the same words. Therefore, the same words "description" and "contract" are added to the pre-constructed common substring set. All words in the same position in the phrase pair (bond usage instructions, fund contract rules) are different. Therefore, it is determined that the phrase pair (bond usage instructions, fund contract rules) does not have a common substring.
[0112] In an optional embodiment of the present invention, by performing phrase pair comparison on any two phrases in the keyword vocabulary, the same words in the same position in the phrase pairs are added to a pre-constructed common substring set to obtain a common substring set, thereby ensuring that no common substrings are missing or omitted, thereby improving the integrity of the common substring set.
[0113] The embodiment of the present invention reduces the number of phrases in the index library and reduces the space consumption of the index library by performing common substring matching on any two phrases in the keyword library.
[0114] In an embodiment of the present invention, the preset condition may be a common substring screening condition set by a technician to reduce storage space consumption, wherein the common substring screening condition may be that if a phrase pair contains multiple common substrings, only the common substring with the longest length is taken, and among all the common strings in the common substring set, only the common substrings with a length greater than or equal to 2 word lengths are taken.
[0115] In an optional embodiment of the present invention, by selecting common substrings that meet preset conditions from the common substring set, the number of common substrings in the common string set is reduced, thereby reducing the space consumption of the index library during the keyword search process. Furthermore, by constructing the index library based on the selected common substrings, the embodiment of the present invention can significantly reduce the data storage capacity of the index library, thereby reducing space consumption during the indexing process.
[0116] In detail, as an optional embodiment of the present invention, refer to Figure 3 As shown, the index library is constructed based on the selected common substrings, including:
[0117] Extracting data features of the common substrings, and setting an index library structure according to the data features and preset index requirements;
[0118] Constructing an initial index library according to the index library structure;
[0119] The common substring is imported into the initial index library to obtain an index library.
[0120] In the embodiment of the present invention, the data feature may be a feature such as a field type, etc. The preset index requirement refers to the purpose of building an index library, which may be a search engine or data analysis purpose.
[0121] Furthermore, the embodiment of the present invention utilizes preset tools, such as open source search engine libraries, for example, Elasticsearch, Apache Lucene, Apache Solr, etc., to construct an initial index library.
[0122] In an optional embodiment of the present invention, based on the data characteristics of the common substring and the index requirements for the search engine, the index library to be constructed is subjected to index field confirmation, field type confirmation and field analyzer confirmation, thereby determining the index library structure and ensuring that the constructed index library can store the common substring and meet the preset index requirements.
[0123] In order to improve the effectiveness of the index library and the accuracy of keyword search, when a new phrase appears in the keyword library, the embodiment of the present invention also needs to synchronize the new phrase in the keyword library to the index library.
[0124] In detail, as an optional embodiment of the present invention, after constructing the index library based on the selected common substrings, the method further includes:
[0125] The keyword thesaurus is monitored in real time, and when a new phrase is introduced into the keyword thesaurus, the new phrase is matched with the original phrases in the keyword thesaurus one by one for common substrings to obtain a new common substring set;
[0126] Newly added common substrings that meet preset conditions are screened out from the newly added common substring set and imported into the index library.
[0127] In an optional embodiment of the present invention, by real-time monitoring of the keyword thesaurus, synchronization of newly added data of the keyword thesaurus and the index library is achieved, thereby improving the effectiveness of the index library and the accuracy of keyword searches.
[0128] The original phrase search module 102 is used to match the search keyword with a common substring in the index library when receiving a search keyword input by the user, obtain a search affix set, merge the phrases in the search affix set to obtain a merged affix, and search the original phrase from the keyword library based on the merged affix.
[0129] In the embodiment of the present invention, the search keyword may be any phrase input by the user. The search affix set includes one or more phrases.
[0130] Since the index library only contains common substrings, after receiving the search keyword input by the user, the embodiment of the present invention needs to accurately match the search keyword with the common substrings in the index library, and then perform a keyword search based on the user input.
[0131] It should be understood that if the keyword thesaurus is directly used as an index library, when a user enters a search keyword containing a typo, a search error prompt is likely to appear, reducing the user's search efficiency and the efficiency of keyword searches. In an embodiment of the present invention, when the index fields stored in the index library are all common substrings, when a user enters a search keyword containing a typo, the matching success rate between the search keyword and the common substring can be improved, and then a keyword search can be performed based on the matching results, thereby improving the user's search efficiency and the efficiency of keyword searches.
[0132] In the embodiment of the present invention, by determining whether some fields in the search keyword are identical to the common substring in the index library, the search keyword is matched with the common substring in the index library, thereby obtaining a search affix set.
[0133] In the embodiment of the present invention, the original phrase may be one or more.
[0134] The embodiment of the present invention merges the phrases in the search affix set to obtain a merged affix, and searches the original phrase from the keyword thesaurus based on the merged affix, thereby ensuring that even if the search keyword entered by the user contains typos, the original phrase corresponding to the search keyword can be found based on the merged affix, thereby reducing the time consumption of keyword search and improving the speed and efficiency of keyword search.
[0135] Furthermore, as an optional embodiment of the present invention, merging the phrases in the search affix set to obtain a merged affix includes:
[0136] Comparing each phrase in the search affix set with the search keyword to determine the position and interval of each phrase in the search affix set;
[0137] According to the positions and the intervals, each phrase in the search affix set is spliced to obtain a merged affix.
[0138] In an optional embodiment of the present invention, when the user enters the search keyword "insurance contract description", the search affix set {contract, description} is obtained based on the matching results of the search keyword and the common string in the index library. Furthermore, the search affix set is compared with the search keyword to determine the position and interval of "contract" and "description" in the search affix set, and based on the position and interval, the merged affix "xx contract description" is generated.
[0139] Furthermore, after obtaining the merged affix, the embodiment of the present invention searches for the original phrase from the keyword database according to the merged affix to determine the phrase to be searched, thereby implementing keyword search.
[0140] In detail, as an optional embodiment of the present invention, searching for the original phrase from the keyword thesaurus according to the combined affix includes:
[0141] The merged affix is compared with the keyword phrases in the keyword thesaurus, and the keyword phrases that match the affix phrase position and the number of merged affix characters in the merged affix are output as comparison results to obtain the original phrases.
[0142] In an optional embodiment of the present invention, when the merged affix is "xx contract description", by traversing each keyword phrase in the keyword vocabulary and comparing the keyword phrase with the merged affix, the original phrases such as "insurance contract description" and "fund contract description" are obtained.
[0143] The keyword search module 103 is used to search according to the original phrase to obtain search results corresponding to the search keyword.
[0144] In an optional embodiment of the present invention, after the original phrase is determined, the original phrase is returned as a search to obtain search results corresponding to the search keyword.
[0145] Furthermore, in order to obtain the accurate search results required by the user, the embodiment of the present invention needs to sort, filter and handle conflicts of the search results after the search results are obtained, so as to improve the accuracy of the keyword search.
[0146] The embodiment of the present invention performs common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set, and takes the common substrings in the common substring set that meet preset conditions as indexes to obtain an index library, thereby reducing the space overhead of the indexing process in the keyword search. Furthermore, when a search keyword input by a user is received, the search keyword is matched with the common substring in the index library to obtain a search affix, the search affix is merged to obtain a merged affix, and the original phrase in the keyword vocabulary is searched based on the merged affix, thereby reducing the time overhead of the retrieval process in the keyword search and improving the efficiency of the keyword search. Therefore, the keyword search device provided by the present invention can reduce the space overhead of the indexing process in the keyword search and improve the efficiency of the keyword search.
[0147] like Figure 5 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the keyword search method of the present invention.
[0148] The electronic device may include a processor 10 , a memory 11 , a communication bus 12 , and a communication interface 13 , and may further include a computer program stored in the memory 11 and executable on the processor 10 , such as a keyword search program.
[0149] Wherein, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 can also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the memory 11 can also include both an internal storage unit of the electronic device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device, such as the code of a keyword search program, etc., but can also be used to temporarily store data that has been output or is to be output.
[0150] In some embodiments, the processor 10 may be composed of an integrated circuit, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The processor 10 is the control core (Control Unit) of the electronic device, connecting the various components of the entire electronic device using various interfaces and circuits. It executes or runs programs or modules (such as keyword search programs) stored in the memory 11 and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0151] The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Such a bus may be classified as an address bus, a data bus, a control bus, etc. The communication bus 12 is configured to enable communication between the memory 11 and at least one processor 10. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0152] Figure 5 Only the electronic device with components is shown, and it can be understood by those skilled in the art that Figure 5 The structure shown does not limit the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0153] For example, although not shown, the electronic device may further include a power source (such as a battery) for powering various components. Preferably, the power source may be logically connected to the at least one processor 10 via a power management device, thereby implementing functions such as charge management, discharge management, and power consumption management through the power management device. The power source may further include any components such as one or more DC or AC power sources, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, etc. The electronic device may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0154] Optionally, the communication interface 13 may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices.
[0155] Optionally, the communication interface 13 may further include a user interface, which may be a display or an input unit (such as a keyboard). Optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0156] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0157] The keyword search program stored in the memory 11 of the electronic device is a combination of multiple computer programs. When running in the processor 10, it can achieve the following:
[0158] Perform common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set;
[0159] Selecting common substrings that meet preset conditions from the common substring set, and building an index library based on the selected common substrings;
[0160] When receiving a search keyword input by a user, matching the search keyword with a common substring in the index library to obtain a search affix set;
[0161] Merging the phrases in the search affix set to obtain a merged affix, and searching for the original phrase from the keyword thesaurus based on the merged affix;
[0162] A search is performed based on the original phrase to obtain search results corresponding to the search keyword.
[0163] Specifically, the specific implementation method of the processor 10 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0164] Furthermore, if the module / unit integrated into the electronic device is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, or read-only memory (ROM).
[0165] An embodiment of the present invention may further provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor of an electronic device, the computer program may implement:
[0166] Perform common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set;
[0167] Selecting common substrings that meet preset conditions from the common substring set, and building an index library based on the selected common substrings;
[0168] When receiving a search keyword input by a user, matching the search keyword with a common substring in the index library to obtain a search affix set;
[0169] Merging the phrases in the search affix set to obtain a merged affix, and searching for the original phrase from the keyword thesaurus based on the merged affix;
[0170] A search is performed based on the original phrase to obtain search results corresponding to the search keyword.
[0171] Furthermore, the computer-usable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0172] In the several embodiments provided herein, it should be understood that the disclosed electronic devices, apparatuses, and methods may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the module division is merely a logical functional division, and actual implementation may employ other division methods.
[0173] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0174] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional modules.
[0175] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0176] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0177] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0178] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. Second-order terms are used to indicate names and do not imply any particular order.
[0179] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A keyword search method, characterized in that: The method comprises: Perform common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set; Selecting common substrings that meet preset conditions from the common substring set, and building an index library based on the selected common substrings; When receiving a search keyword input by a user, matching the search keyword with a common substring in the index library to obtain a search affix set; Comparing each phrase in the search affix set with the search keyword, determining the position and interval of each phrase in the search affix set, concatenating each phrase in the search affix set according to the position and interval to obtain a merged affix, and searching the keyword thesaurus for the original phrase based on the merged affix; Returning the original phrase as the search result corresponding to the search keyword to the user; The common substring matching is performed on any two phrases in the keyword vocabulary to obtain a common substring set, including: Select any two phrases in the keyword vocabulary through traversal operation to form a phrase pair; When the words in any identical position in the phrase pair are identical, the identical words are added to the pre-constructed common substring set; When all words in the same position in the phrase pair are different, it is determined that there is no common substring in the phrase pair, and the process returns to the above step of selecting any two phrases in the keyword vocabulary through traversal operation and forming the selected two phrases into a phrase pair, and continues to traverse the words in the next phrase pair until all phrase pairs are traversed to obtain a common substring set.
2. The keyword search method according to claim 1, wherein: The step of constructing an index library based on the selected common substrings includes: Extracting data features of the common substrings, and setting an index library structure according to the data features and preset index requirements; Constructing an initial index library according to the index library structure; The common substring is imported into the initial index library to obtain an index library.
3. The keyword search method according to claim 1, wherein: The searching for the original phrase from the keyword thesaurus according to the combined affix includes: The merged affix is compared with the keyword phrases in the keyword thesaurus, and the keyword phrases that match the affix phrase position and the number of merged affix characters in the merged affix are output as comparison results to obtain the original phrases.
4. The keyword search method according to claim 1, wherein: Before performing common substring matching on any two phrases in the keyword vocabulary to obtain a common substring set, the method further includes: Remove useless characters from the keyword set to be processed to obtain a preliminary keyword set; According to preset phrase format rules, the initially processed keyword set is phrase-normalized to obtain a keyword thesaurus.
5. The keyword search method according to claim 1, wherein: After the index library is constructed according to the selected common substrings, the method further includes: The keyword thesaurus is monitored in real time, and when a new phrase is introduced into the keyword thesaurus, the new phrase is matched with the original phrases in the keyword thesaurus one by one for common substrings to obtain a new common substring set; Newly added common substrings that meet preset conditions are screened out from the newly added common substring set and imported into the index library.
6. A keyword search device for executing the keyword search method according to any one of claims 1 to 5, characterized in that: The device comprises: An index library construction module is used to perform common substring matching on any two phrases in the keyword library to obtain a common substring set, select common substrings that meet preset conditions from the common substring set, and construct an index library based on the selected common substrings; an original phrase search module for, upon receiving a search keyword input by a user, matching the search keyword with a common substring in the index library to obtain a search affix set, merging the phrases in the search affix set to obtain a merged affix, and searching the keyword library for an original phrase based on the merged affix; The keyword search module is used to return the original phrase as the search result corresponding to the search keyword to the user.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor. The computer program instructions are executed by the at least one processor to enable the at least one processor to perform the keyword search method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the keyword search method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Search processing method and device, equipment and storage medium
CN112860840A
Method and system for providing keyword ranking using common affix
WO2008143407A1