Information retrieval method and device, electronic equipment and storage medium
By performing non-repeating splitting and filtering on the string to be processed, the problem of low information retrieval efficiency in existing technologies is solved, and more efficient information retrieval is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-11-04
- Publication Date
- 2026-05-08
AI Technical Summary
In existing information retrieval methods, information redundancy caused by sliding window word segmentation with fixed character length leads to low retrieval efficiency.
The string to be processed is split without repetition, generating multiple split results. The preliminary search results are then filtered based on the distance between adjacent split results, avoiding the calculation of duplicate characters.
It improves the efficiency of information retrieval, reduces redundant calculations, and enhances the accuracy and speed of retrieval.
Smart Images

Figure CN121996687A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically to an information retrieval method, apparatus, electronic device, and storage medium. Background Technology
[0002] In existing technologies, when constructing an information retrieval database, each word in the text to be retrieved is often split into a fixed-length sliding window and stored in the database. When a user needs to retrieve text containing a certain word, they can input that word or a fixed-length portion of that word to perform the retrieval. For example, the word "apple" is split into three basic units: "app", "ppl", and "ple", and stored in the database. When a user needs to retrieve text containing the word "apple", they can input "apple" or any three consecutive characters from "apple" to perform a text retrieval containing the word "apple".
[0003] However, the word segmentation and matching process described above has information redundancy, resulting in low retrieval efficiency. Summary of the Invention
[0004] This application provides an information retrieval method, apparatus, electronic device, and storage medium, which can improve the problem of low retrieval efficiency in the prior art.
[0005] This application provides an information retrieval method, the method comprising:
[0006] Get the string to be processed;
[0007] If the length of the string to be processed exceeds the set length value, the string to be processed is split without repetition according to the set length value to obtain multiple split results. The length of the string to be processed is the number of characters contained in the string to be processed, and the set length value is a positive integer greater than 1.
[0008] Based on the multiple splitting results, a retrieval is performed to obtain multiple preliminary retrieval results, wherein each of the preliminary retrieval results includes the multiple splitting results;
[0009] For each of the preliminary search results, the filtering result of the preliminary search result is determined based on the distance between two adjacent split results in the preliminary search result.
[0010] This application provides an information retrieval device, the device comprising:
[0011] The string retrieval unit is used to retrieve the string to be processed.
[0012] A string splitting unit is used to split the string to be processed without repetition according to the set length value when the length of the string to be processed exceeds the set length value, so as to obtain multiple splitting results, wherein the length of the string to be processed is the number of characters contained in the string to be processed;
[0013] The retrieval unit is used to perform a retrieval based on the multiple splitting results to obtain multiple preliminary retrieval results, wherein each of the preliminary retrieval results includes the multiple splitting results;
[0014] A filtering unit is used to determine the filtering result of each preliminary search result based on the distance between two adjacent splitting results in the preliminary search result.
[0015] In one embodiment, the filtering unit is specifically used to determine the preliminary search result as the final search result when the distance between the last two split results in the plurality of split results is a first distance value, and the distance between any two adjacent split results other than the last two split results is a second distance value.
[0016] In one embodiment, the filtering unit is specifically used to remove the preliminary search results when the distance between the last two split results in the plurality of split results is not a first distance value, or the distance between any two adjacent split results other than the last two split results is not a second distance value.
[0017] In one embodiment, the device further includes:
[0018] The second retrieval unit is used to perform a retrieval based on the string to be processed when the length of the string to be processed does not exceed the set length value, and obtain the retrieval result, which is the final retrieval result.
[0019] In one embodiment, the device further includes:
[0020] The termination bit determination unit is used to determine the index termination bit for the target word of the text to be retrieved based on the word length of the target word, wherein the target word is any word of the text to be retrieved;
[0021] An initial position determination unit is used to determine the first and second digits of the target word as the initial index position;
[0022] An initial bit determination unit is used to determine whether the initial bit of the index exceeds the termination bit of the index;
[0023] An initial bit assignment unit is used to assign the value of the initial index bit to the character offset bit when the initial index bit does not exceed the terminating index bit.
[0024] A character reading unit is used to read the character corresponding to the character offset position, denoted as a keyword string, and store the keyword string as a search term in the database;
[0025] The new offset determination unit is used to determine the next bit of the character offset as the new character offset.
[0026] The offset bit determination unit is used to determine whether the character offset bit exceeds the index termination bit;
[0027] The concatenation result unit is used to read the character corresponding to the character offset position when the character offset position does not exceed the index termination position, concatenate the read character with the keyword string to obtain the concatenation result, and store the concatenation result as a search term in the database.
[0028] The step jump unit is used to assign the value of the character offset bit to the index initial bit, and jump to the step: determining whether the index initial bit exceeds the index termination bit.
[0029] In one implementation, the step jump unit is specifically used to assign the value of the character offset to the index initial position when the length of the keyword string reaches the set length value, and jump to the step: determining whether the index initial position exceeds the index termination position, wherein the set length value is a positive integer greater than 1;
[0030] Accordingly, the device also includes:
[0031] The new keyword unit is used to treat the concatenation result as a new keyword string;
[0032] The string length unit is used to determine whether the length of the keyword string reaches the set length value.
[0033] In one embodiment, the device further includes:
[0034] The offset jump unit is used to jump to the step of determining the next character offset as the new character offset when the length of the keyword string does not reach the set length value.
[0035] In one embodiment, the device further includes:
[0036] The first termination unit is used to terminate the process of storing the target word in the database when the initial index position exceeds the termination index position.
[0037] The second termination unit is used to terminate the process of storing the target word in the database when the character offset exceeds the index termination position.
[0038] In one embodiment, the device further includes:
[0039] The position allocation unit is used to allocate the positions of all search terms for the target word based on the time order in which the search terms were stored in the database.
[0040] In one implementation, the position allocation unit is specifically used to incrementally allocate the positions of all search terms for the target word based on the chronological order in which the search terms were stored in the database.
[0041] In the information retrieval method provided in this application embodiment, a string to be processed can be obtained. If the string to be processed exceeds a set length value, the string to be processed is split without repetition according to the set length value to obtain multiple splitting results. Multiple preliminary retrieval results are obtained through retrieval, and each preliminary retrieval result includes all the splitting results. Subsequently, the multiple preliminary retrieval results are filtered: for any preliminary retrieval result, based on the distance between two adjacent splitting results included in the preliminary retrieval result, it is determined whether the preliminary retrieval result carries the string to be processed.
[0042] In this embodiment, since the string to be processed is split without repetition, redundant calculation of repeated characters can be avoided, thereby improving the efficiency of information retrieval. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1a This is a schematic diagram illustrating the application scenario of the information retrieval method provided in this application;
[0045] Figure 1b This is a flowchart illustrating the information retrieval method provided in an embodiment of this application;
[0046] Figure 1c A schematic flowchart illustrating the index construction process with a set length value of 2 is shown.
[0047] Figure 1d This diagram illustrates the distance between search terms for the target word when the length value is set to 2.
[0048] Figure 1e A schematic flowchart illustrating the index construction process with a set length value greater than 2 is shown.
[0049] Figure 1f This diagram illustrates the distance between search terms for the target word when the length value is set to 3.
[0050] Figure 1g This diagram illustrates the distance between search terms for another target word when the set length value is 2.
[0051] Figure 1h This diagram illustrates the distance between search terms for a target word when the set length value is 2.
[0052] Figure 1i A diagram showing the time consumption of various technical solutions in processing keywords of different character lengths is presented.
[0053] Figure 2 This is a flowchart illustrating an information retrieval method provided in a specific embodiment of this application;
[0054] Figure 3 This is a schematic diagram of the structure of an information retrieval device provided in an embodiment of this application;
[0055] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0056] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0057] This application provides an information retrieval method, apparatus, electronic device, and storage medium.
[0058] Specifically, the information retrieval device can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet, smart Bluetooth device, laptop, or desktop computer. The server can be a single server, a server cluster consisting of multiple servers, or a cloud server.
[0059] In some embodiments, the information retrieval device may also be integrated into multiple electronic devices, such as multiple servers, with the information retrieval method of this application being implemented by multiple servers.
[0060] In some embodiments, the terminal can also be used as a server to implement some or all of the functions of a server.
[0061] Please see details Figure 1a The method provided in this application embodiment may include: obtaining a string to be processed; if the length of the string to be processed exceeds a set length value, splitting the string to be processed without repetition according to the set length value to obtain multiple splitting results. Wherein, the length of the string to be processed is the number of characters contained in the string to be processed, and the set length value is a positive integer greater than 1. Based on the multiple splitting results, a search is performed to obtain multiple preliminary search results, such as... Figure 1a The preliminary search results shown are 1, 2, ..., m. Each preliminary search result includes the plurality of split results. For each preliminary search result, the filtering result of the preliminary search result is determined based on the distance between two adjacent split results in the plurality of split results. For example, for preliminary search result i, it can be determined whether the preliminary search result is the final search result based on the distance between two adjacent split results in the plurality of split results of preliminary search result i.
[0062] In the above method, splitting the string to be processed without repetition can avoid redundant calculations of repeated characters and improve the efficiency of information retrieval.
[0063] The information retrieval method provided in this application embodiment can be applied to keyword retrieval in email, and the information retrieval method can be implemented based on the sqlite3 database. Specifically, when the email application (app) retrieves emails to local storage via a network request, it can pass the full text of the email to the full-text search module of the sqlite3 database for index building. At this time, the full-text search module will call the word segmenter in this application embodiment to split the text and insert it into the index structure. The specific process of splitting the text will be described in detail below.
[0064] When using the search function in an email app to search for email content such as the body, title, and contacts, the application passes the user-input keywords to the full-text search module of the sqlite3 database. The full-text search module then calls the word segmenter and word matching logic described in this embodiment to match all content containing the keywords and returns it to the application layer in list form. The application layer assembles the data to form the email list displayed in the user's UI. The specific process of the word segmentation matching logic matching all content containing the keywords will be described in detail below.
[0065] It is understood that in the embodiments of this application, data such as user information are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0066] The following sections provide detailed descriptions of each example. It should be noted that the sequence numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0067] This embodiment provides an information retrieval method. For example... Figure 1b As shown, this information retrieval method is applied to an electronic device. The specific process of this method may include the following steps 110 to 140:
[0068] 110. Obtain the string to be processed.
[0069] The string to be processed is the string to be used as a keyword for information retrieval. The string to be processed can consist of one or more characters. The string to be processed can be input by the user. The string to be processed can be a complete word or a series of letters from a word. For example, using the word "mail," the string to be processed could be "mail," or parts of "mail," such as "ma," "il," or "a."
[0070] Optionally, in one embodiment, after step 110, the present application embodiment may further include: if the length of the string to be processed does not exceed a set length value, performing a search based on the string to be processed to obtain a search result, wherein the search result is the final search result.
[0071] The length of the string to be processed is the number of characters it contains. Continuing with the example above, the length of the string "mail" is 4; the length of the string "il" is 2.
[0072] The length value is set to a predefined value. The length value can be a positive integer greater than 1, for example, 2; or 3. The specific value of the length value can be set by the developers based on their experience, and its specific value should not be construed as a limitation of this application.
[0073] In the above embodiments, for strings to be processed that do not exceed the set length value, the strings to be processed can be directly used as search terms for retrieval. The above process does not impose any limitation on the length of the strings to be processed input by the user, that is, the search results can be obtained based on the information retrieval method provided in this application embodiment for any length of string to be processed input by the user, thereby expanding the scope of application of this application embodiment.
[0074] Optionally, in one embodiment, prior to step 110, the present application embodiment may further include an index building process, namely, the process of storing text into a database.
[0075] Alternatively, let's take a length value of 2 as an example for explanation. For details, please refer to [link to relevant documentation]. Figure 1c The index building process may specifically include the following steps A1 to A9:
[0076] A1. For the target word in the text to be retrieved, determine the index termination position based on the word length of the target word.
[0077] The target word is any word in the text to be retrieved. The text to be retrieved may include multiple words, and the target word is any one of the multiple words in the text to be retrieved.
[0078] The index termination position indicates the end point of the indexing process for the target word. The index termination position can be determined based on the word length of the target word, and optionally, it can be represented by the symbol 'n'. Specifically, the index termination position can be the position corresponding to the last letter of the target word. Let's continue with the example of the target word "mail". The word length of "mail" is 4, so each letter in "mail" can be numbered: m, a, i, l correspond to 0, 1, 2, and 3 respectively. Accordingly, the index termination position is set to the position corresponding to the last letter "l" of "mail", which is 3.
[0079] A2. Determine the first and second characters of the target word as the initial index position.
[0080] The initial index position is used to represent the first letter of the search term. This initial index position changes as the steps progress, as will be described in detail below. Optionally, the initial index position can be represented by the symbol p. The first position of the target word is the position corresponding to the first letter of the target word. Continuing with the example above, the position corresponding to the first letter "m" of "mail" is 0, so in step A2, the initial index position can be set to 0.
[0081] Search terms are the basic units obtained after the target word has been segmented. Optionally, search terms can be represented by the symbol token.
[0082] A3. Determine whether the initial bit of the index exceeds the termination bit of the index.
[0083] The initial index position will be continuously updated in subsequent steps (such as step A9). Therefore, whether the initial index position exceeds the end index position can be used as a basis for determining whether to end the index building process of the target word (that is, the process of splitting the target word into multiple search terms and storing them in the database).
[0084] Continuing with the example above, we will check whether the initial index bit p exceeds the ending index bit n, that is, whether the value of p is greater than the value of n.
[0085] Optionally, in one embodiment, after step A3, the present application embodiment may further include the following step: if the initial index position exceeds the final index position, then the process of storing the target word in the database is terminated.
[0086] In the above implementation, if the initial index position exceeds the final index position, it is determined that the index building process for the target word has ended. Figure 1c As shown, the "Yes" branch in step A3 jumps to the end.
[0087] A4. If the initial index bit does not exceed the final index bit, assign the value of the initial index bit to the character offset bit.
[0088] The character offset is the position of all search terms for the target word traversed by offset. Optionally, the character offset can be represented by the symbol q. Before the index initial position exceeds the index termination position, the value of the current index initial position p is assigned to the character offset q. That is, the value of p is assigned to q.
[0089] A5. Read the character corresponding to the character offset position, record it as the keyword string, and store the keyword string as a search term in the database.
[0090] A keyword string is a string that represents a search term or a portion of a search term. Optionally, a keyword string can be represented by the symbol 's'. In step A5, the keyword string represents a search term; in step A8, the keyword string represents a portion of a search term.
[0091] A6. Determine the next bit after the character offset as the new character offset.
[0092] In this step, the character offset is updated; specifically, the next bit after the character offset is determined as the new character offset.
[0093] A7. Determine whether the character offset exceeds the index termination bit.
[0094] Whether the character offset exceeds the index termination position can be used as another criterion for determining whether to end the index building process of the target word (that is, the process of splitting the target word into multiple search terms and storing them in the database).
[0095] Continuing with the example above, we will check whether the character offset q exceeds the index termination bit n, that is, whether the value of q is greater than the value of n.
[0096] Optionally, in one embodiment, after step A7, the present application embodiment may further include the following step: if the character offset exceeds the index termination bit, then the process of storing the target word in the database is terminated.
[0097] In the above implementation, if the character offset exceeds the index termination position, it is determined that the index building process for the target word has ended. Figure 1c As shown, the "Yes" branch in step A7 jumps to the end.
[0098] A8. If the character offset does not exceed the index termination position, read the character corresponding to the character offset, concatenate the read character with the keyword string to obtain the concatenation result, and store the concatenation result as a search term in the database.
[0099] If the character offset does not exceed the index termination position, the character corresponding to the current character offset is read, and this read character is concatenated with the keyword string to obtain the concatenated result. This concatenated result is then stored in the database as the search term.
[0100] A9. Assign the value of the character offset to the index initial position, and jump to step: determine whether the index initial position exceeds the index termination position.
[0101] Then, the value of the character offset bit q is assigned to the initial index bit p, and the process jumps to step A3 to start a new round of looping. Steps A1 to A9 above can read UTF-8 characters during character reading.
[0102] Next, let's take the target word "mail" as an example. m, a, i, and l correspond to 0, 1, 2, and 3 respectively. For example... Figure 1c Steps A1 to A9 are illustrated by example:
[0103] For the target word "mail", the index termination bit n is set to 3, and the index initial bit p is set to 0.
[0104] First cycle:
[0105] The initial index bit p (i.e., 0) does not exceed the index termination bit n (i.e., 3);
[0106] Assign the value of the initial index p (i.e., 0) to the character offset q;
[0107] Read the character (m) corresponding to the character offset q (i.e. 0), denot it as the keyword string s, and store the keyword string s (i.e. m) as the search term token in the database;
[0108] The bit following the character offset q (i.e., 0) is determined as the new character offset q (i.e., 1);
[0109] The character offset q (i.e., 1) does not exceed the index termination bit (i.e., 3);
[0110] Read the character (a) corresponding to the character offset q (i.e. 1), concatenate the read character (i.e. a) with the keyword string s (i.e. m) to obtain the concatenation result (i.e. ma), and store the concatenation result (i.e. ma) as the search term token in the database;
[0111] Assign the character offset bit q (i.e., 1) to the initial index bit p, and jump to step A3 to start the second round of the loop.
[0112] In the first loop described above, the process of storing the search terms "m" and "ma" into the database is implemented.
[0113] Second round of cycles:
[0114] The initial index bit p (i.e., 1) does not exceed the index termination bit n (i.e., 3);
[0115] Assign the value of the initial index p (i.e., 1) to the character offset q;
[0116] Read the character (i.e., a) corresponding to the character offset q (i.e., 1), denot it as the keyword string s, and store the keyword string s (i.e., a) as the search term token in the database;
[0117] The next bit after character offset q (i.e., 1) (i.e., 2) is determined as the new character offset q (i.e., 2);
[0118] The character offset q (i.e., 2) does not exceed the index termination bit (i.e., 3);
[0119] Read the character (i) corresponding to the character offset q (i.e. 2), concatenate the read character (i.e. i) with the keyword string s (i.e. a) to get the concatenation result (i.e. ai), and store the concatenation result (i.e. ai) as the search term token in the database;
[0120] Assign the character offset q (i.e., 2) to the initial index p, and jump to step A3 to start the third round of the loop.
[0121] In the second loop described above, the process of storing the search terms "a" and "ai" into the database is implemented.
[0122] Third cycle:
[0123] The initial index bit p (i.e., 2) does not exceed the index termination bit n (i.e., 3);
[0124] Assign the value of the initial index p (i.e., 2) to the character offset q;
[0125] Read the character (i) corresponding to the character offset q (i.e. 2), denot it as the keyword string s, and store the keyword string s (i.e. i) as the search term token in the database;
[0126] The next bit after character offset q (i.e., 2) (i.e., 3) is determined as the new character offset q (i.e., 3);
[0127] The character offset q (i.e., 3) does not exceed the index termination bit (i.e., 3);
[0128] Read the character (i.e., l) corresponding to the character offset q (i.e., 3), concatenate the read character (i.e., l) with the keyword string s (i.e., i ... il), and store the concatenation result (i.e., il) as the search term token in the database;
[0129] Assign the character offset q (i.e., 3) to the initial index p, and jump to step A3 to start the fourth round of the loop.
[0130] In the third loop described above, the process of storing the search terms "i" and "il" into the database is implemented.
[0131] Fourth cycle:
[0132] The initial index bit p (i.e., 3) does not exceed the index termination bit n (i.e., 3);
[0133] Assign the value of the initial index p (i.e., 3) to the character offset q;
[0134] Read the character (i.e., l) corresponding to the character offset q (i.e., 3), denot it as the keyword string s, and store the keyword string s (i.e. l) as the search term token in the database;
[0135] The next bit after character offset q (i.e., 3) (i.e., 4) is determined as the new character offset q (i.e., 4);
[0136] If the character offset q (i.e., 4) exceeds the index termination position (i.e., 3), the process of storing the target word in the database ends.
[0137] In the fourth iteration of the above loop, the process of storing the search term "l" into the database is implemented.
[0138] In the above four rounds of iteration, the following search tokens for the target word "mail" were obtained in sequence: m, ma, a, ai, i, il, l.
[0139] In the above embodiments, for any word in the text to be searched, steps A1 to A9 can be executed to obtain all the search terms corresponding to that word. It should be understood that the above embodiments are illustrated using a set length value of 2 as an example, meaning the maximum length of the search term token is 2. Cases where the set length value is a positive integer greater than 2 will be described in detail below.
[0140] Optionally, in one embodiment, after step A9, the present application embodiment may further include the following step: assigning positions to all search terms of the target word based on the time order in which the search terms were stored in the database.
[0141] Accordingly, the above steps may specifically include: based on the chronological order in which the search terms were stored in the database, the positions of all search terms for the target word are incrementally allocated.
[0142] Continuing with the example above, for the target word "mail," the order in which it was stored in the database is: m, ma, a, ai, i, il, l. Therefore, let's assume the position corresponding to m is X. For more details, please refer to [link to relevant documentation]. Figure 1d :
[0143] The position corresponding to ma is X+1;
[0144] The position corresponding to 'a' is X+2;
[0145] The position corresponding to ai is X+3;
[0146] The position corresponding to i is X+4;
[0147] The position corresponding to il is X+5;
[0148] The position corresponding to l is X+6.
[0149] It should be understood that allocating the positions of all search terms for the target word in ascending order based on the chronological order in which they were stored in the database is one specific implementation. Other position allocation methods can also be used, such as allocating the positions of all search terms for the target word in descending order based on the chronological order in which they were stored in the database. The specific method of allocating the positions of all search terms for the target word based on the chronological order in which they were stored in the database should not be construed as a limitation of this application.
[0150] Optionally, in one embodiment, taking a positive integer with a length value greater than 2 as an example, step A9 can specifically be steps A91 to A92 as follows:
[0151] A91. If the length of the keyword string reaches the set length value, calculate the difference between the set length value and the value 2, and shift the character offset position forward by the difference position to obtain a new character offset position.
[0152] A92. Assign the value of the character offset to the index initial position, and jump to step: determine whether the index initial position exceeds the index termination position.
[0153] The length value is set to a positive integer greater than 1. It should be understood that when the length value is set to 2, Figure 1c The flowchart shown is consistent with Figure 1e Compared to the flowchart shown, the search term results obtained are the same, but... Figure 1c Compare Figure 1e Steps S1 to S3 are reduced. Therefore, for the case where the set length value is 2, to improve efficiency, the following can be adopted: Figure 1c The flowchart shown illustrates the process of obtaining search terms. It can be understood that, for the case where the length value is set to 2, this method can also be used. Figure 1e The flowchart shown obtains the search terms. The specific process used to calculate the length value of 2 should not be construed as a limitation of this application.
[0154] Accordingly, between step A8 and step A91, the embodiments of this application may further include the following steps: steps S1 to S2:
[0155] S1. Use the concatenated result as a new keyword string.
[0156] In this embodiment, the concatenation result can be used as a new keyword string s.
[0157] S2. Determine whether the length of the keyword string reaches the set length value.
[0158] The length of the keyword string (i.e., the concatenation result from step S1) is compared with the set length value to determine the generation method for the next search term. If the length of the keyword string s does not reach the set length value, it means that there are still character combinations within the set length value that have not yet generated search terms, so the process jumps to step A6 for further generation. If the length of the keyword string s reaches the set length value, it means that all character combinations within the set length value that can generate search terms have been traversed, and the process jumps to step A91 to proceed with the next step of generating search terms within the set length value range.
[0159] Optionally, in one embodiment, after step S2, the present application embodiment may further include the following step S3:
[0160] S3. If the length of the keyword string does not reach the set length value, then proceed to step: determine the next character offset as the new character offset.
[0161] The length of the keyword string s has not reached the set length value, indicating that there are still character combinations within the set length value that have not yet generated search terms. Therefore, we will proceed to step A6 to generate further terms.
[0162] Next, let's continue using the target word "mail" as an example. m, a, i, and l correspond to 0, 1, 2, and 3 respectively, and we set the length to 3. For example... Figure 1e Steps A1 to A9 are illustrated below:
[0163] For the target word "mail", the index termination bit n is set to 3, and the index initial bit p is set to 0.
[0164] First cycle:
[0165] The initial index bit p (i.e., 0) does not exceed the index termination bit n (i.e., 3);
[0166] Assign the value of the initial index p (i.e., 0) to the character offset q;
[0167] Read the character (m) corresponding to the character offset q (i.e. 0), denot it as the keyword string s, and store the keyword string s (i.e. m) as the search term token in the database;
[0168] The bit following the character offset q (i.e., 0) is determined as the new character offset q (i.e., 1);
[0169] The character offset q (i.e., 1) does not exceed the index termination bit (i.e., 3);
[0170] Read the character (a) corresponding to the character offset q (i.e. 1), concatenate the read character (i.e. a) with the keyword string s (i.e. m) to obtain the concatenation result (i.e. ma), and store the concatenation result (i.e. ma) as the search term token in the database;
[0171] Use the concatenated result (i.e., ma) as the new keyword string s (i.e., ma);
[0172] The length of the keyword string s (i.e., ma) is 2, which does not meet the set length value (i.e., 3);
[0173] The next bit after character offset q (i.e., 1) (i.e., 2) is determined as the new character offset q (i.e., 2);
[0174] Read the character (i) corresponding to the character offset q (i.e. 2), concatenate the read character (i.e. i) with the keyword string s (i.e. ma) to get the concatenation result (i.e. mai), and store the concatenation result (i.e. mai) as the search term token in the database;
[0175] Use the concatenated result (i.e., mai) as the new keyword string s (i.e., mai);
[0176] The length of the keyword string s (i.e., mai) is 3, reaching the set length value (i.e., 3);
[0177] Calculate the difference between the set length value (i.e., 3) and the value 2 (i.e., 3-2=1), and shift the character offset q (i.e., 2) forward by the difference bit, i.e., shift it forward by 1 bit, to obtain the new character offset (i.e., 1).
[0178] Assign the character offset bit q (i.e., 1) to the initial index bit p, and jump to step A3 to start the second round of the loop.
[0179] In the first loop described above, the process of storing the search terms m, ma, and mai into the database is implemented.
[0180] Second round of cycles:
[0181] The initial index bit p (i.e., 1) does not exceed the index termination bit n (i.e., 3);
[0182] Assign the value of the initial index p (i.e., 1) to the character offset q;
[0183] Read the character (i.e., a) corresponding to the character offset q (i.e., 1), denot it as the keyword string s, and store the keyword string s (i.e., a) as the search term token in the database;
[0184] The next bit after character offset q (i.e., 1) (i.e., 2) is determined as the new character offset q (i.e., 2);
[0185] The character offset q (i.e., 2) does not exceed the index termination bit (i.e., 3);
[0186] Read the character (i) corresponding to the character offset q (i.e. 2), concatenate the read character (i.e. i) with the keyword string s (i.e. a) to get the concatenation result (i.e. ai), and store the concatenation result (i.e. ai) as the search term token in the database;
[0187] Use the concatenated result (i.e., ai) as the new keyword string s (i.e., ai);
[0188] The length of the keyword string s (i.e., ai) is 2, which does not meet the set length value (i.e., 3);
[0189] The next bit after character offset q (i.e., 2) (i.e., 3) is determined as the new character offset q (i.e., 3);
[0190] Read the character (i.e., l) corresponding to the character offset q (i.e., 3), concatenate the read character (i.e., l) with the keyword string s (i.e., ai) to obtain the concatenation result (i.e., ail), and store the concatenation result (i.e., ail) as the search term token in the database;
[0191] Use the concatenated result (i.e., ail) as the new keyword string s (i.e., ail);
[0192] The length of the keyword string s (i.e., ail) is 3, which reaches the set length value (i.e., 3);
[0193] Calculate the difference between the set length value (i.e., 3) and the value 2 (i.e., 3-2=1), and shift the character offset q (i.e., 3) forward by the difference bit, i.e., shift it forward by 1 bit, to obtain the new character offset (i.e., 2).
[0194] Assign the character offset q (i.e., 2) to the initial index p, and jump to step A3 to start the second round of the loop.
[0195] In the second loop described above, the process of storing the search terms a, ai, and ail into the database is implemented.
[0196] Third cycle:
[0197] The initial index bit p (i.e., 2) does not exceed the index termination bit n (i.e., 3);
[0198] Assign the value of the initial index p (i.e., 2) to the character offset q;
[0199] Read the character (i) corresponding to the character offset q (i.e. 2), denot it as the keyword string s, and store the keyword string s (i.e. i) as the search term token in the database;
[0200] The next bit after character offset q (i.e., 2) (i.e., 3) is determined as the new character offset q (i.e., 3);
[0201] The character offset q (i.e., 3) does not exceed the index termination bit (i.e., 3);
[0202] Read the character (i.e., l) corresponding to the character offset q (i.e., 3), concatenate the read character (i.e., l) with the keyword string s (i.e., i ... il), and store the concatenation result (i.e., il) as the search term token in the database;
[0203] Use the concatenated result (i.e., il) as the new keyword string s (i.e., il);
[0204] The length of the keyword string s (i.e., il) is 2, which does not meet the set length value (i.e., 3);
[0205] The next bit after character offset q (i.e., 3) (i.e., 4) is determined as the new character offset q (i.e., 4);
[0206] If the character offset q (i.e., 4) exceeds the index termination position (i.e., 3), the process of storing the target word in the database ends.
[0207] In the third loop described above, the process of storing the search terms "i" and "il" into the database is implemented.
[0208] In the three rounds of iterations described above, the following search tokens for the target word "mail" were obtained in sequence: m, ma, mai, a, ai, ail, i, il.
[0209] Continuing with the example above, for the target word "mail," the order in which these search terms were stored in the database is as follows: m, ma, mai, a, ai, ail, i, il. Therefore, let's assume the position corresponding to m is Y. For more details, please refer to [link to relevant documentation]. Figure 1f :
[0210] The position corresponding to ma is Y+1;
[0211] The position corresponding to mai is Y+2;
[0212] The position corresponding to 'a' is Y+3;
[0213] The position corresponding to ai is Y+4;
[0214] The position corresponding to ail is Y+5;
[0215] The position corresponding to i is Y+6;
[0216] The position corresponding to il is Y+7.
[0217] It should be understood that allocating the positions of all search terms for the target word in ascending order based on the chronological order in which they were stored in the database is one specific implementation. Other position allocation methods can also be used, such as allocating the positions of all search terms for the target word in descending order based on the chronological order in which they were stored in the database. The specific method of allocating the positions of all search terms for the target word based on the chronological order in which they were stored in the database should not be construed as a limitation of this application.
[0218] 120. If the length of the string to be processed exceeds the set length value, the string to be processed is split without repetition according to the set length value to obtain multiple split results.
[0219] The length of the string to be processed is the number of characters contained in the string. For example, let the string to be processed be “mail”. The string to be processed contains 4 characters: m, a, i, l. Therefore, the length of the string “mail” is 4.
[0220] The length value is set to a positive integer greater than 1. For ease of description, we will use a length value of 2 as an example in the following text.
[0221] Non-repeating splitting means that multiple splitting results may not contain duplicate characters.
[0222] Taking the string to be processed as "mail" and the set length value as 2 as an example, since the length of "mail" is 4, which exceeds the set length value of 2, "mail" is split without repetition based on the length of 2. The resulting split is as follows: ma, il.
[0223] 130. Based on the multiple splitting results, perform a search to obtain multiple preliminary search results, wherein each of the preliminary search results includes the multiple splitting results.
[0224] After obtaining multiple splitting results, a search can be performed based on these results to obtain multiple preliminary search results. Each preliminary search result includes all splitting results.
[0225] Continuing with the example above, searching the database built in the previous steps based on the two split results of "mail": ma and il, will yield multiple preliminary search results. Each preliminary search result includes both the split results ma and il.
[0226] 140. For each of the preliminary search results, based on the distance between two adjacent splitting results in the preliminary search result, determine the filtering result of the preliminary search result.
[0227] After obtaining multiple preliminary search results, these results can be filtered based on the distance between two adjacent split results within the preliminary search results. While the preliminary search results include all split results, these split results may originate from multiple different words, not just the same word. Therefore, by determining the distance between two adjacent split results within the preliminary search results, it can be determined whether the split results originate from the same word, thus filtering out preliminary search results where the split results originate from multiple different words.
[0228] Continuing with the example above, for a given preliminary search result, if *ma* is located at position A and *il* is located at position B, then the difference between positions A and B can be calculated to obtain the distance between *ma* and *il* within that preliminary search result. For details, please refer to [link to relevant documentation]. Figure 1d The position corresponding to 'ma' is X+1, and the position corresponding to 'il' is X+5. The distance between them is (X+5) - (X+1) = 4. (Combined with...) Figure 1d It can be seen that if the distance between two non-repeating split results is 4, it means that the two split results come from the same word.
[0229] Therefore, in this example, we can determine whether the distance between "ma" and "il" in the initial search result is 4. If the distance is 4, it means that "ma" and "il" come from the same word in the initial search result, and this initial search result is selected as the final search result; if the distance is not 4, it means that "ma" and "il" do not come from the same word in the initial search result, and this initial search result is discarded.
[0230] Optionally, in one embodiment, step 140 may include the following steps 141 to 142:
[0231] 141. If the distance between the last two splitting results in the plurality of splitting results is a first distance value, and the distance between any two adjacent splitting results other than the last two splitting results is a second distance value, the preliminary search result is determined as the final search result.
[0232] The specific value of the first distance is related to the set length value and the setting method of the last split result. The specific value of the second distance is related to the set length value.
[0233] Whether the first and second distance values are the same depends on the length of the string to be processed. Since the length of the string to be processed is uncertain, when splitting the string into non-repeating segments according to a set length value, the length of the last segment may be less than or equal to the set length value. If the length of the last segment is less than the set length value, the first and second distance values are different; if the length of the last segment is equal to the set length value, the first and second distance values are the same. This will be explained in detail below with specific examples.
[0234] Since the example string "mail" above only has two splitting results, for ease of description, here are examples of strings with multiple splitting results: "email" and "strawberry".
[0235] The word "email" after Figure 1c When processing steps A1 to A9 as shown, the following search terms can be obtained: e, em, m, ma, a, ai, i, il, l. The distances between the above search terms are as follows: Figure 1g As shown.
[0236] The word "strawberry" after Figure 1c When processing steps A1 to A9 as shown, the following search terms can be obtained: s, st, t, tr, r, ra, a, aw, w, wb, b, be, e, er, r, rr, r, ry. The distances between the above search terms are as follows: Figure 1h As shown.
[0237] For the string "email", when splitting it into three unique segments with a set length of 2, we get three results: em, ai, and l. The length of the last segment (i.e., the length of l is 1) is less than the set length of 2. Therefore, if these three segments come from the same word, the first distance between l and ai is different from the second distance between em and ai. Figure 1g It can be seen that when the three splitting results come from the same word, the first distance value between l and ai should be (Z+8)-(Z+5)=3, and the second distance value between em and ai should be (Z+5)-(Z+1)=4.
[0238] In one implementation, when calculating the first distance value, 'l' can be padded forward to become 'il', and then the distance between 'il' and 'ai' can be calculated. At this point, combined with... Figure 1g It can be seen that the first distance between il and ai is (Z+7)-(Z+5)=2.
[0239] For the string "strawberry", when splitting it into five non-repeating segments with a set length of 2, we get: st, ra, wb, er, ry. The length of the last segment (i.e., the length of ry is 2) is equal to the set length of 2. Therefore, if all five segments come from the same word, the first distance between ry and er is the same as the second distance between st and ra. st and ra are examples of any two adjacent segments other than the last two; other adjacent segments are also possible. Figure 1h It can be seen that when the five splitting results come from the same word, the first distance value between ry and er should be (W+17)-(W+13)=4, and the second distance value between st and ra should be (W+5)-(W+1)=4.
[0240] Based on the examples above, when the length value is set to 2, for strings with odd-numbered character lengths (such as "email" in the example above), the first distance value is 3 if the last split result is not padded forward, and 2 if the last split result is padded forward. Whether the last split result is padded forward can be set by the developers according to their needs. The second distance value is 4. When the length value is set to 2, for strings with even-numbered character lengths (such as "strawberry" in the example above), the first and second distance values are equal, both being 4.
[0241] Therefore, if the distance between the last two splitting results in the plurality of splitting results is the first distance value, and the distance between any two adjacent splitting results other than the last two splitting results is the second distance value, it means that the plurality of splitting results in the preliminary search result come from the same word, and the preliminary search result is determined as the final search result.
[0242] 142. If the distance between the last two splitting results in the plurality of splitting results is not the first distance value, or the distance between any two adjacent splitting results other than the last two splitting results is not the second distance value, the preliminary search results shall be discarded.
[0243] If the distance between the last two splitting results in the multiple splitting results is not the first distance value, or the distance between any two adjacent splitting results other than the last two splitting results is not the second distance value, it means that the multiple splitting results in the preliminary search results do not come from the same word, and the preliminary search results are removed.
[0244] For existing technologies, the sqlite3 fts5 module itself does not have the concept of distance between search term tokens. For all word segmentation results, it is determined whether the word segmentation results come from the same keyword based on whether the positions of the word segmentation results in the text are adjacent. The above judgment process will result in a large amount of redundant matching.
[0245] In the information retrieval method provided in this application embodiment, a string to be processed can be obtained. If the string to be processed exceeds a set length value, the string to be processed is split without repetition according to the set length value to obtain multiple splitting results. Multiple preliminary retrieval results are obtained through retrieval, and each preliminary retrieval result includes all splitting results. Subsequently, the multiple preliminary retrieval results are filtered: for any preliminary retrieval result, based on the distance between two adjacent splitting results included in the preliminary retrieval result, it is determined whether the preliminary retrieval result carries the string to be processed. In this application embodiment, since the string to be processed is split without repetition, redundant calculation of duplicate characters can be avoided.
[0246] The embodiments of this application can improve the efficiency of information retrieval.
[0247] Please see details Figure 1i , combined Figure 1i It can be seen that, except for 4-character keywords, the processing time of this application is slightly slower than that of prior art 2, while the processing time of keywords of other character lengths is much lower than that of prior art 1 or prior art 2.
[0248] In this embodiment, the method of this application embodiment will be described in detail using a positive integer with a length value greater than 2 as an example. The information retrieval method provided in this application embodiment can be executed by an electronic device. In this embodiment, the electronic device is described as a server. Figure 2 As shown, the specific process of an information retrieval method is as follows:
[0249] 201. For the target word in the text to be retrieved, determine the index termination position based on the word length of the target word.
[0250] 202. Determine the first and second characters of the target word as the initial index position.
[0251] 203. Determine whether the initial index bit exceeds the terminating index bit. If yes, proceed to step 213; otherwise, proceed to step 204.
[0252] 204. Assign the value of the initial index bit to the character offset bit.
[0253] 205. Read the character corresponding to the character offset position, record it as the keyword string, and store the keyword string as the search term in the database.
[0254] 206. Determine the next bit after the character offset as the new character offset.
[0255] 207. Determine whether the character offset exceeds the index termination position. If yes, jump to step 213; if no, jump to step 208.
[0256] 208. Read the character corresponding to the character offset position, concatenate the read character with the keyword string to obtain the concatenation result, and store the concatenation result as the search term in the database.
[0257] 209. Use the concatenated result as a new keyword string.
[0258] 210. Determine whether the length of the keyword string has reached the set length value. If yes, proceed to step 211; otherwise, proceed to step 206.
[0259] 211. Calculate the difference between the set length value and the value 2, and shift the character offset position forward by the difference position to obtain the new character offset position.
[0260] 212. Assign the value of the character offset bit to the index initial bit.
[0261] 213. Based on the time order in which the search terms were stored in the database, position allocation is performed on all search terms for the target word.
[0262] Optionally, in one implementation, step 213 includes: incrementally allocating the positions of all search terms for the target word based on the chronological order in which the search terms were stored in the database.
[0263] 214. Obtain the string to be processed.
[0264] 215. If the length of the string to be processed exceeds the set length value, the string to be processed is split without repetition according to the set length value to obtain multiple split results.
[0265] 216. Based on multiple split results, a search is performed to obtain multiple preliminary search results.
[0266] 217. For each of the preliminary search results, based on the distance between two adjacent splitting results in the preliminary search result, determine the filtering result of the preliminary search result.
[0267] 218. If the length of the string to be processed does not exceed the set length value, a search is performed based on the string to be processed to obtain the search results, which are the final search results.
[0268] Optionally, in one implementation, step 218 includes:
[0269] If the distance between the last two splitting results in the plurality of splitting results is a first distance value, and the distance between any two adjacent splitting results other than the last two splitting results is a second distance value, the preliminary search result is determined as the final search result.
[0270] If the distance between the last two splitting results in the plurality of splitting results is not the first distance value, or the distance between any two adjacent splitting results other than the last two splitting results is not the second distance value, the preliminary search results are discarded.
[0271] The specific execution process of steps 201 to 218 has been explained in detail above, and will not be repeated here.
[0272] In the information retrieval method provided in this application embodiment, a string to be processed can be obtained. If the string to be processed exceeds a set length value, the string to be processed is split without repetition according to the set length value to obtain multiple splitting results. Multiple preliminary retrieval results are obtained through retrieval, and each preliminary retrieval result includes all splitting results. Subsequently, the multiple preliminary retrieval results are filtered: for any preliminary retrieval result, based on the distance between two adjacent splitting results included in the preliminary retrieval result, it is determined whether the preliminary retrieval result carries the string to be processed. In this application embodiment, since the string to be processed is split without repetition, redundant calculation of duplicate characters can be avoided.
[0273] The embodiments of this application can improve the efficiency of information retrieval.
[0274] The embodiments of this application significantly improve retrieval performance while supporting the retrieval of keywords with consecutive characters of arbitrary length, and the effect is even more significant in scenarios with dense English text.
[0275] To better implement the above methods, embodiments of this application also provide an information retrieval device, such as... Figure 3 As shown, the device includes:
[0276] String acquisition unit 301 is used to acquire the string to be processed;
[0277] The string splitting unit 302 is used to split the string to be processed without repetition according to the set length value when the length of the string to be processed exceeds the set length value, so as to obtain multiple splitting results, wherein the length of the string to be processed is the number of characters contained in the string to be processed;
[0278] The retrieval unit 303 is used to perform a retrieval based on the multiple splitting results to obtain multiple preliminary retrieval results, wherein each of the preliminary retrieval results includes the multiple splitting results;
[0279] The filtering unit 304 is used to determine the filtering result of each preliminary search result based on the distance between two adjacent splitting results in the preliminary search result.
[0280] In one embodiment, the filtering unit 304 is specifically used to determine the preliminary search result as the final search result when the distance between the last two split results in the plurality of split results is a first distance value, and the distance between any two adjacent split results other than the last two split results is a second distance value.
[0281] In one embodiment, the filtering unit 304 is specifically used to remove the preliminary search results when the distance between the last two split results in the plurality of split results is not a first distance value, or the distance between any two adjacent split results other than the last two split results is not a second distance value.
[0282] In one embodiment, the device further includes:
[0283] The second retrieval unit is used to perform a retrieval based on the string to be processed when the length of the string to be processed does not exceed the set length value, and obtain the retrieval result, which is the final retrieval result.
[0284] In one embodiment, the device further includes:
[0285] The termination bit determination unit is used to determine the index termination bit for the target word of the text to be retrieved based on the word length of the target word, wherein the target word is any word of the text to be retrieved;
[0286] An initial position determination unit is used to determine the first and second digits of the target word as the initial index position;
[0287] An initial bit determination unit is used to determine whether the initial bit of the index exceeds the termination bit of the index;
[0288] An initial bit assignment unit is used to assign the value of the initial index bit to the character offset bit when the initial index bit does not exceed the terminating index bit.
[0289] A character reading unit is used to read the character corresponding to the character offset position, denoted as a keyword string, and store the keyword string as a search term in the database;
[0290] The new offset determination unit is used to determine the next bit of the character offset as the new character offset.
[0291] The offset bit determination unit is used to determine whether the character offset bit exceeds the index termination bit;
[0292] The concatenation result unit is used to read the character corresponding to the character offset position when the character offset position does not exceed the index termination position, concatenate the read character with the keyword string to obtain the concatenation result, and store the concatenation result as a search term in the database.
[0293] The step jump unit is used to assign the value of the character offset bit to the index initial bit, and jump to the step: determining whether the index initial bit exceeds the index termination bit.
[0294] In one implementation, the step jump unit is specifically used to assign the value of the character offset to the index initial position when the length of the keyword string reaches the set length value, and jump to the step: determining whether the index initial position exceeds the index termination position, wherein the set length value is a positive integer greater than 1;
[0295] Accordingly, the device also includes:
[0296] The new keyword unit is used to treat the concatenation result as a new keyword string;
[0297] The string length unit is used to determine whether the length of the keyword string reaches the set length value.
[0298] In one embodiment, the device further includes:
[0299] The offset jump unit is used to jump to the step of determining the next character offset as the new character offset when the length of the keyword string does not reach the set length value.
[0300] In one embodiment, the device further includes:
[0301] The first termination unit is used to terminate the process of storing the target word in the database when the initial index position exceeds the termination index position.
[0302] The second termination unit is used to terminate the process of storing the target word in the database when the character offset exceeds the index termination position.
[0303] In one embodiment, the device further includes:
[0304] The position allocation unit is used to allocate the positions of all search terms for the target word based on the time order in which the search terms were stored in the database.
[0305] In one implementation, the position allocation unit is specifically used to incrementally allocate the positions of all search terms for the target word based on the chronological order in which the search terms were stored in the database.
[0306] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.
[0307] In the information retrieval method provided in this application embodiment, a string to be processed can be obtained. If the string to be processed exceeds a set length value, the string to be processed is split without repetition according to the set length value to obtain multiple splitting results. Multiple preliminary retrieval results are obtained through retrieval, and each preliminary retrieval result includes all splitting results. Subsequently, the multiple preliminary retrieval results are filtered: for any preliminary retrieval result, based on the distance between two adjacent splitting results included in the preliminary retrieval result, it is determined whether the preliminary retrieval result carries the string to be processed. In this application embodiment, since the string to be processed is split without repetition, redundant calculation of duplicate characters can be avoided.
[0308] The embodiments of this application can improve the efficiency of information retrieval.
[0309] This application also provides an electronic device. In this embodiment, a server will be used as an example for detailed description. For example, ... Figure 4 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically:
[0310] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, an input module 404, and a communication module 405. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0311] The processor 401 is the control center of the electronic device, connecting various parts of the device via various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402. In some embodiments, the processor 401 may include one or more processing cores; in some embodiments, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 401.
[0312] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and information retrieval model training by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0313] The electronic device also includes a power supply 403 that supplies power to the various components. In some embodiments, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0314] The electronic device may also include an input module 404, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0315] The electronic device may also include a communication module 405. In some embodiments, the communication module 405 may include a wireless module, through which the electronic device can perform short-range wireless transmission, thereby providing users with wireless broadband internet access. For example, the communication module 405 can be used to help users send and receive emails, browse web pages, and access streaming media.
[0316] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402, thereby realizing the various functions in the various method embodiments of this application.
[0317] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0318] To this end, embodiments of this application provide a computer-readable storage medium storing instructions that can be loaded by a processor to execute steps in any of the information retrieval methods provided in embodiments of this application. For example, the instructions can execute various steps in the various method embodiments of this application.
[0319] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0320] According to one aspect of this application, a computer program product or computer program is provided, comprising instructions stored in a computer-readable storage medium. A processor of a computer device reads the instructions from the computer-readable storage medium and executes the instructions, causing the computer device to perform the methods provided in the various optional implementations of the above embodiments.
[0321] Since the instructions stored in the storage medium can execute the steps of any of the information retrieval methods provided in the embodiments of this application, the beneficial effects that any of the information retrieval methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0322] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0323] The above provides a detailed description of an information retrieval method, apparatus, electronic device, and computer-readable storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An information retrieval method, characterized in that, The method includes: Get the string to be processed; If the length of the string to be processed exceeds the set length value, the string to be processed is split without repetition according to the set length value to obtain multiple split results. The length of the string to be processed is the number of characters contained in the string to be processed, and the set length value is a positive integer greater than 1. Based on the multiple splitting results, a retrieval is performed to obtain multiple preliminary retrieval results, wherein each of the preliminary retrieval results includes the multiple splitting results; For each of the preliminary search results, the filtering result of the preliminary search result is determined based on the distance between two adjacent split results in the preliminary search result.
2. The method as described in claim 1, characterized in that, The step of determining the filtering result of the preliminary search result based on the distance between two adjacent splitting results in the preliminary search result includes: If the distance between the last two splitting results in the plurality of splitting results is a first distance value, and the distance between any two adjacent splitting results other than the last two splitting results is a second distance value, the preliminary search result is determined as the final search result.
3. The method as described in claim 1, characterized in that, The step of determining the filtering result of the preliminary search result based on the distance between two adjacent splitting results in the preliminary search result includes: If the distance between the last two splitting results in the plurality of splitting results is not the first distance value, or the distance between any two adjacent splitting results other than the last two splitting results is not the second distance value, the preliminary search results are discarded.
4. The method as described in claim 1, characterized in that, After obtaining the string to be processed, the method further includes: If the length of the string to be processed does not exceed the set length value, a search is performed based on the string to be processed to obtain the search results, which are the final search results.
5. The method as described in claim 1, characterized in that, Before obtaining the string to be processed, the method further includes: For the target word in the text to be retrieved, the index termination position is determined based on the word length of the target word, wherein the target word is any word in the text to be retrieved; The first and second characters of the target word are determined as the initial index position; Determine whether the initial bit of the index exceeds the termination bit of the index; If the initial index bit does not exceed the terminating index bit, the value of the initial index bit is assigned to the character offset bit; Read the character corresponding to the character offset position, record it as the keyword string, and store the keyword string as a search term in the database; The next bit after the character offset is determined as the new character offset; Determine whether the character offset exceeds the index termination bit; If the character offset does not exceed the index termination position, read the character corresponding to the character offset, concatenate the read character with the keyword string to obtain the concatenation result, and store the concatenation result as a search term in the database; Assign the value of the character offset bit to the index initial bit, and jump to step: determine whether the index initial bit exceeds the index termination bit.
6. The method as described in claim 5, characterized in that, The step of assigning the value of the character offset to the initial index position and then jumping to the step of: determining whether the initial index position exceeds the terminating index position includes: If the length of the keyword string reaches the set length value, calculate the difference between the set length value and the value 2, and shift the character offset position forward by the difference position to obtain a new character offset position; Assign the value of the character offset to the index initial position, and jump to the step: determine whether the index initial position exceeds the index termination position, wherein the set length value is a positive integer greater than 1; If the character offset does not exceed the index termination position, the character corresponding to the character offset position is read, and the read character is concatenated with the keyword string to obtain the concatenation result. The concatenation result is then stored in the database as a search term. If the length of the keyword string reaches a set length value, the value of the character offset position is assigned to the index initial position, and the process jumps to the step before determining whether the index initial position exceeds the index termination position. The method further includes: Use the concatenated result as a new keyword string; Determine whether the length of the keyword string reaches the set length value.
7. The method as described in claim 6, characterized in that, After determining whether the length of the keyword string reaches the set length value, the method further includes: If the length of the keyword string does not reach the set length value, proceed to step: determine the next bit of the character offset as the new character offset.
8. The method as described in claim 5, characterized in that, After determining whether the initial bit of the index exceeds the terminating bit of the index, the method further includes: If the initial index position exceeds the final index position, the process of storing the target word in the database ends. After determining whether the character offset exceeds the index termination bit, the method further includes: If the character offset exceeds the index termination position, the process of storing the target word in the database ends.
9. The method as described in claim 5, characterized in that, The method further includes: Based on the time sequence in which the search terms were stored in the database, the positions of all search terms for the target word are assigned.
10. The method as described in claim 9, characterized in that, The step of allocating positions for all search terms related to the target word based on the time order in which the search terms were stored in the database includes: Based on the chronological order in which the search terms were stored in the database, the positions of all search terms for the target word are incrementally allocated.
11. An information retrieval device, characterized in that, The device includes: The string retrieval unit is used to retrieve the string to be processed. A string splitting unit is used to split the string to be processed without repetition according to the set length value when the length of the string to be processed exceeds the set length value, so as to obtain multiple splitting results, wherein the length of the string to be processed is the number of characters contained in the string to be processed; The retrieval unit is used to perform a retrieval based on the multiple splitting results to obtain multiple preliminary retrieval results, wherein each of the preliminary retrieval results includes the multiple splitting results; A filtering unit is used to determine the filtering result of each preliminary search result based on the distance between two adjacent splitting results in the preliminary search result.
12. An electronic device, characterized in that, It includes a processor and a memory, the memory storing instructions; the processor loads instructions from the memory to perform the steps in the information retrieval method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions adapted for loading by a processor to perform the steps of the information retrieval method according to any one of claims 1 to 10.
14. A computer program product, characterized in that, The method includes instructions that, when executed by a processor, implement the steps of the information retrieval method according to any one of claims 1 to 10.