Object recommendation methods, apparatus and computer equipment

By introducing a single-child node tree structure and a prefix indexing algorithm into the double-array Trie tree, memory usage is optimized, the problem of high memory consumption in the double-array Trie tree is solved, and the efficiency of word segmentation and search is improved.

CN115730596BActive Publication Date: 2026-11-17CHINA SOUTHERN POWER GRID INTERNET SERVICE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211510311.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2026-11-17
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

Existing double-array Trie tree algorithms can generate huge tree trunks due to the different prefixes of words, resulting in excessive memory consumption and impacting server performance.

Method used

A portion of the data in the dual-array Trie tree is stored in an array, using a single-child node tree structure. Memory usage is optimized through prefix indexing and maximum matching algorithms, and text segmentation is performed in conjunction with the dual-array Trie tree.

Benefits of technology

It improved word segmentation efficiency, reduced server memory consumption, and enhanced search efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115730596B_ABST
    Figure CN115730596B_ABST
Patent Text Reader

Abstract

This application provides an object recommendation method, characterized by the following steps: obtaining search text for an object to be recommended; segmenting the search text to obtain text characters corresponding to the search text; performing prefix indexing on the text characters in a pre-constructed array to obtain a first matching result corresponding to the text characters; performing maximum matching on the text characters in a pre-constructed double-array Trie tree based on the first matching result to obtain text segmentation of the search text; and using the text segmentation, retrieving objects to be recommended from a recommendation object database that match the text segmentation. In this method provided by this application, a portion of the data in the original double-array Trie tree, such as a single-child node tree structure, is stored in an array, thereby avoiding the formation of a large tree trunk that consumes server memory and solving the problem of high memory consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information search, and in particular to an object recommendation method, apparatus, and computer device. Background Technology

[0002] When making purchases on shopping platforms, users typically "compare prices from multiple vendors," comparing similar products before ultimately choosing the most suitable item to place an order. Because shopping platforms possess massive amounts of product data, and manual filtering of similar products is inefficient, intelligent recommendation technology is currently commonly used to filter and recommend similar products. This allows the system to quickly help users select comparable items, making the purchasing reference data more comprehensive and further improving overall purchasing efficiency.

[0003] For intelligent recommendation technology, word segmentation has always been a crucial and fundamental step. Word segmentation breaks down long texts such as sentences, paragraphs, and articles into data structures based on words, facilitating subsequent processing and analysis. Current word segmentation technologies often employ the double-array Trie tree algorithm to segment search text. However, existing double-array Trie trees, because they expand a new tree to store words whose prefixes differ from other words, result in a large tree structure that consumes significant server memory. Therefore, they suffer from the problem of high memory consumption. Summary of the Invention

[0004] Therefore, it is necessary to provide an object recommendation method, apparatus, and computer device that optimizes memory usage to address the aforementioned technical problems.

[0005] Firstly, this application provides an object recommendation method. The method includes:

[0006] Get the search text for the object to be recommended;

[0007] The search text is segmented to obtain the text characters corresponding to the search text.

[0008] The text characters are prefix-indexed in a pre-constructed array to obtain the first matching result corresponding to the text characters; the array includes a single-child node tree structure;

[0009] Based on the first matching result, the text characters are subjected to maximum matching in a pre-constructed double-array Trie tree to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0010] Using the text segmentation, the recommended objects that match the text segmentation are obtained from the recommendation object database.

[0011] In one embodiment, prefix indexing of the text characters in a pre-constructed array to obtain a first matching result corresponding to the text characters includes: combining the first and second characters of the text characters to obtain a first term; matching the first term in the array; if the match is successful, determining that the first matching result is that the array includes the first term; if the match fails, determining that the first matching result is that the array does not include the first term.

[0012] In one embodiment, based on the first matching result, the text characters are subjected to maximum matching in a pre-constructed double-array Trie tree to obtain text segmentation of the search text, including: if the first matching result indicates that the array includes the first term, the last character of the first term is taken as the current character; the next character of the current character in the text characters is obtained, and the first term and the next character are combined to obtain a second term; the second term is taken as the current term; the current term is queried in the double-array Trie tree to obtain the current matching result corresponding to the current term; if the current matching result indicates that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, the current term is taken as a segment in the text segmentation.

[0013] In one embodiment, after querying the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term, the method further includes: if the current matching result is that the double-array Trie tree includes the current term, or the current term is a prefix of a word in the double-array Trie tree, taking the last character of the current term as the current character; obtaining the next character of the current character in the text characters, combining the current term and the next character to obtain a new current term, and returning to the step of querying the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term, until the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree.

[0014] In one embodiment, based on the first matching result, the text characters are subjected to maximum matching in a pre-constructed double-array Trie tree to obtain text segmentation of the search text, including: if the first matching result is that the array does not include the first term, the first character in the first term is taken as the current character; the next character of the current character in the text characters is obtained, and the current term is obtained by combining the current character and the next character; the current term is queried in the double-array Trie tree to obtain the current matching result corresponding to the current term; if the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, the current term is taken as a segment in the text segmentation.

[0015] In one embodiment, the method further includes: querying the search text in a data pool; the data pool includes historical segmented text; if the search text does not exist in the data pool, segmenting the search text to obtain the text characters corresponding to the search text.

[0016] In one embodiment, the text segmentation is used to obtain a recommended object that matches the text segmentation from a recommendation object database, including: obtaining the number of segments in the text segmentation; determining the product of a preset repetition rate threshold and the number of segments as the number of repeated segments between the search text and the matching text in the recommendation object database; and determining the object corresponding to the matching text as the recommended object if the number of repeated segments is greater than or equal to the preset matching threshold.

[0017] Secondly, this application also provides an object recommendation device, characterized in that the device comprises:

[0018] The first acquisition module is used to acquire the search text for the object to be recommended;

[0019] The segmentation module is used to segment the search text to obtain the text characters corresponding to the search text;

[0020] The first matching module is used to perform prefix indexing on the text characters in a pre-constructed array to obtain a first matching result; the array includes a single-child node tree structure.

[0021] The second matching module is used to perform maximum matching on the text characters in a pre-constructed double-array Trie tree based on the first matching result, so as to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0022] The second acquisition module is used to acquire, using the text segmentation, recommended objects that match the text segmentation from the recommendation object database.

[0023] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0024] Get the search text for the object to be recommended;

[0025] The search text is segmented to obtain the text characters corresponding to the search text.

[0026] The text characters are prefix-indexed in a pre-constructed array to obtain the first matching result corresponding to the text characters; the array includes a single-child node tree structure;

[0027] Based on the first matching result, the text characters are subjected to maximum matching in a pre-constructed double-array Trie tree to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0028] Using the text segmentation, the recommended objects that match the text segmentation are obtained from the recommendation object database.

[0029] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0030] Get the search text for the object to be recommended;

[0031] The search text is segmented to obtain the text characters corresponding to the search text.

[0032] The text characters are prefix-indexed in a pre-constructed array to obtain the first matching result corresponding to the text characters; the array includes a single-child node tree structure;

[0033] Based on the first matching result, the text characters are subjected to maximum matching in a pre-constructed double-array Trie tree to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0034] Using the text segmentation, the recommended objects that match the text segmentation are obtained from the recommendation object database.

[0035] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0036] Get the search text for the object to be recommended;

[0037] The search text is segmented to obtain the text characters corresponding to the search text.

[0038] The text characters are prefix-indexed in a pre-constructed array to obtain the first matching result corresponding to the text characters; the array includes a single-child node tree structure;

[0039] Based on the first matching result, the text characters are subjected to maximum matching in a pre-constructed double-array Trie tree to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0040] Using the text segmentation, the recommended objects that match the text segmentation are obtained from the recommendation object database.

[0041] In the aforementioned object recommendation method, apparatus, and computer device, the dictionary used for segmenting the search text can be pre-segmented and stored in an array and a double-array Trie tree, respectively. Then, the text characters can be prefix-indexed in the pre-constructed array to obtain a first matching result corresponding to the text characters. Next, based on the first matching result, the text characters are subjected to maximum matching in the pre-constructed double-array Trie tree to obtain the text segmentation of the search text. Finally, using the text segmentation, the recommended objects matching the text segmentation are retrieved from the recommendation object database. In the method provided in this application embodiment, a portion of the data in the original double-array Trie tree, such as a single-child node tree structure, is stored in an array, thereby avoiding the formation of a large tree trunk that consumes server memory and solving the problem of high memory consumption. Attached Figure Description

[0042] Figure 1 This is a diagram illustrating the application environment of an object recommendation method in one embodiment.

[0043] Figure 2 This is a flowchart illustrating an object recommendation method in one embodiment;

[0044] Figure 3 This is a flowchart illustrating the process of prefix indexing text characters in a pre-constructed array to obtain the first matching result corresponding to the text characters in one embodiment.

[0045] Figure 4This is a schematic diagram of the text segmentation process for obtaining the search text by performing maximum matching on text characters in a pre-constructed double-array Trie tree based on the first matching result in one embodiment.

[0046] Figure 5 This is a schematic diagram of the text segmentation process for obtaining the search text by performing maximum matching on text characters in a pre-constructed double-array Trie tree based on the first matching result in one embodiment.

[0047] Figure 6 This is a schematic diagram illustrating the process of using text segmentation to obtain recommended objects that match the text segmentation from a recommendation object database, as described in another embodiment.

[0048] Figure 7 This is a flowchart illustrating the object recommendation method in another embodiment;

[0049] Figure 8 This is a structural block diagram of an object recommendation device in one embodiment;

[0050] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0052] The collision avoidance and early warning method based on laser ranging and image ranging fusion provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 101 and server 102 can communicate via a network. Server 102 can be a backend server. A data storage system can store the data that server 102 needs to process. The data storage system can be integrated onto server 102, or it can be placed on a cloud server or other network server.

[0053] In this embodiment, terminal 101 can display search text and the corresponding object, i.e., the product. The user can click a button to search for similar products on the display screen of terminal 101.

[0054] Server 102 can pre-split the dictionary used for word segmentation of the search text and store the data in an array and a double-array Trie tree respectively. In response to the user's search command, server 102 can obtain the search text for the target object and segment it to obtain the corresponding text characters. Then, it can perform prefix indexing on the text characters in the pre-built array to obtain the first matching result. Based on the first matching result, it performs maximum matching on the text characters in the pre-built double-array Trie tree to obtain the text segmentation of the search text. Using the text segmentation, it retrieves the target objects that match the text segmentation from the target object database.

[0055] Terminal 101 can display the object to be recommended; the object to be recommended may include one or more objects. The user can click on one of the objects to be recommended on the display screen of terminal 101. In response to the user's click command, server 102 can obtain relevant descriptive information about the object to be recommended and display it on the display screen of terminal 101. In this embodiment, the object can be a product.

[0056] The terminal 101 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, cameras, sensors, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. The server 102 can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0057] In one embodiment, such as Figure 2 As shown, an object recommendation method is provided, which is applied to... Figure 1 Taking terminal 101 as an example, the following steps may be included:

[0058] Step S201: Obtain the search text for the object to be recommended.

[0059] Typically, when users browse products on a shopping platform, after identifying a target product, they can click the "Search Similar Products" button on the target product page. In response to the user's search command, the server first retrieves the search text for the target product, which can be the text information corresponding to the target product. Then, it displays recommended products on the terminal's screen. These recommended products can include one or more similar products from the same brand and category as the target product. The recommended products are those to be recommended.

[0060] Step S202: Segment the search text to obtain the text characters corresponding to the search text.

[0061] The search text can be text information such as sentences, paragraphs, and articles;

[0062] In this embodiment of the application, the search text can be segmented using a data segmentation algorithm, and can be segmented into a single character, which may include multiple characters.

[0063] Step S203: Prefix index the text characters in the pre-constructed array to obtain the first matching result corresponding to the text characters; the array includes a single-child node tree structure.

[0064] In the embodiments of this application, the pre-constructed array may include a single-child node tree structure. In one possible implementation, the array can be considered as a portion of the data in the original double-array Trie tree, i.e., a single-child node tree structure.

[0065] For detailed steps on prefix indexing and the first matching result, please refer to the following. Figure 3 The relevant descriptions in the text will not be repeated here.

[0066] For an introduction to double-array Trie trees, please refer to the following:

[0067] The Double-Array Trie structure is a compressed form of the Trie structure, using only two linear arrays to represent the Trie tree. This structure has the advantages of fast reading and high search efficiency. Essentially, a Double-Array Trie is a deterministic finite state automaton, where each node represents a state of the automaton. State transitions occur based on different variables, and a query operation is completed when the terminal state is reached or no transition is possible.

[0068] A Double-Array Trie is a Trie tree with low space complexity, consisting of two linear integer arrays: base[] and check[]. Each element in the base[] array is equivalent to a node in the Trie tree, and its value is used as the base value for transitioning to the next state. The value of check[] is the previous state of the current state.

[0069] Step S204: Based on the first matching result, perform maximum matching on the text characters in the pre-constructed double-array Trie tree to obtain the text segmentation of the search text.

[0070] Herein, the maximum matching algorithm includes a forward word-by-word maximum matching algorithm and a reverse word-by-word maximum matching algorithm. It should be understood that Chinese character segmentation is performed based on the principle of maximum matching and using bidirectional segmentation as the method. The maximum matching principle refers to finding the longest matching string in the double-array Trie tree dictionary as a word. For example, for "I love the People's Republic of China", word segmentation performed according to the maximum matching principle results in "I", "love", and "the People's Republic of China", rather than "I", "love", "Chinese", "people", and "republic".

[0071] For the introduction of the double-array Trie tree, reference may be made to the relevant description in step S203, which will not be repeated here.

[0072] Text word segmentation refers to the text after word segmentation. For example, "I love the People's Republic of China" can be regarded as a search text, and the array consisting of "I", "love", and "the People's Republic of China" is the text word segmentation.

[0073] In step S205, using the text word segmentation, to-be-recommended objects matching the text word segmentation are acquired from a recommended object database.

[0074] Herein, the recommended object database may be a massive product library of a shopping platform, configured to acquire recommended objects.

[0075] The to-be-recommended objects may include products of the same brand of one or more target products, and similar products under the same category. In some possible implementations, part of the acquired to-be-recommended objects may be displayed through the display screen of a terminal, which are the aforementioned recommended objects.

[0076] In the aforementioned object recommendation method, apparatus and computer device, a dictionary for segmenting search texts may be pre-segmented and stored in an array and a double-array Trie tree respectively. Further, prefix indexing may be performed on the text characters in the pre-constructed array to obtain a first matching result corresponding to the text characters; then, maximum matching is performed on the text characters in the pre-constructed double-array Trie tree according to the first matching result, to obtain the text word segmentation of the search text; finally, using the text word segmentation, to-be-recommended objects matching the text word segmentation are acquired from the recommended object database. In this method provided by the embodiments of the present application, part of the data originally in the double-array Trie tree, such as the single-child node tree structure, is stored in the array, thereby avoiding forming a huge trunk that consumes the memory of the server, and solving the problem of high memory consumption.

[0077] In some embodiments, performing prefix indexing on text characters in a pre-constructed array to obtain a first matching result corresponding to the text characters, where the array includes a single-child node tree structure, may include:

[0078] In step S301, the first character and the second character in the text characters are combined to obtain a first entry.

[0079] For example, after the text "I love the People's Republic of China" is segmented, it can become "I", "love", "the", "People", "Republic", "of", "China", and the resulting array is the text character. The first character "I" and the second character "love" are combined to obtain the first entry, which is "I love".

[0080] In the embodiments of the present application, each character in the text characters can be mapped to a numerical value, that is, a hash value, through a hash algorithm, which facilitates word segmentation. The hash value corresponding to the first character "I" may include the address information of the second character "love", so that in the process of prefix indexing in the array, the second character can be found according to the first character.

[0081] In step S302, the first entry is matched in the array.

[0082] This process is to query the second character in the array based on the first character in the text characters and the address information of the second character contained in the first character.

[0083] In step S303, if the matching is successful, it is determined that the first matching result is that the array includes the first entry.

[0084] If the second character in the text characters can be queried in the array, it indicates that the matching is successful, which means that the array includes the first entry.

[0085] In step S304, if the matching fails, it is determined that the first matching result is that the array does not include the first entry.

[0086] If the second character in the text characters cannot be queried in the array, it indicates that the matching fails, which means that the array does not include the first entry.

[0087] In some embodiments, as Figure 4 shown, performing maximum matching on the text characters in a pre-constructed double-array Trie tree according to the first matching result to obtain text word segmentation of the search text may include:

[0088] In step S401, when the first matching result indicates that the array includes the first entry, the last character of the first entry is taken as the current character.

[0089] Because the array contains only tree-structured data with a single child node, after obtaining the first matching result, prefix indexing needs to be performed in the double-array Trie tree. If the array includes the first term, the address information of the third character contained in the second term can be used to search for the third character in the double-array Trie tree.

[0090] Step S402: Obtain the next character of the current character in the text characters, combine the first term and the next character to obtain the second term; and use the second term as the current term.

[0091] The address information of the next character exists in the current character set. Therefore, when indexing the next character in the double-array Trie tree, it can be found through this address information.

[0092] Step S403: Query the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term.

[0093] Step S404: If the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, then the current term is used as a word in the text segmentation.

[0094] If the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, it means that the current term has reached the maximum match in the double-array Trie tree, so it can be segmented and used as a word in the text segmentation.

[0095] In some embodiments, after querying the current term in the double-array Trie tree and obtaining the current matching result corresponding to the current term, the process may further include:

[0096] If the current matching result is a double-array Trie tree that includes the current term, or if the current term is a prefix of a word in the double-array Trie tree, then the last character of the current term is taken as the current character.

[0097] Get the next character of the current character in the text, combine the current term and the next character to get a new current term; and return to the step of querying the current term in the double array Trie tree to get the current matching result corresponding to the current term, until the current matching result is that the double array Trie tree does not include the current term and the current term is not a prefix of a word in the double array Trie tree. At this time, the current term can be used as a word in the text segmentation.

[0098] In some embodiments, such as Figure 5As shown, based on the first matching result, the text characters are matched to the maximum value in the pre-constructed double-array Trie tree, and the resulting text segmentation of the search text can include:

[0099] Step S501: If the first matching result is that the array does not include the first term, then the first character in the first term is taken as the current character.

[0100] If the first term is not included in the array, the second character needs to be searched in the double-array Trie tree.

[0101] Step S502: Obtain the next character of the current character in the text characters, and combine the current character and the next character to obtain the current word.

[0102] Step S503: Query the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term.

[0103] Step S504: If the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, then the current term is used as a word in the text segmentation.

[0104] In some embodiments, after querying the current term in the double-array Trie tree and obtaining the current matching result corresponding to the current term, the process may further include:

[0105] If the current matching result is a double-array Trie tree that includes the current term, or if the current term is a prefix of a word in the double-array Trie tree, then the last character of the current term is taken as the current character.

[0106] Get the next character of the current character in the text, combine the current term and the next character to get a new current term; and return to the step of querying the current term in the double array Trie tree to get the current matching result corresponding to the current term, until the current matching result is that the double array Trie tree does not include the current term and the current term is not a prefix of a word in the double array Trie tree. At this time, the current term can be used as a word in the text segmentation.

[0107] In the above method, the embodiments of this application use a double-array Trie tree to perform word segmentation on the search text, which improves the word segmentation efficiency and thus improves the search efficiency. Moreover, the preceding character and the following character have pointers, which further improves the search efficiency.

[0108] In some embodiments, the object recommendation method provided in this application may further include:

[0109] Step 1: Query the search text in a data pool; the data pool includes historically segmented texts.

[0110] Herein, the data pool stores the historically segmented texts. If the search text can be found in the historically segmented texts, it is unnecessary to perform a segmentation operation on the search text, that is, the steps of segmenting the search text to obtain text characters corresponding to the search text; performing prefix indexing on the text characters in a pre-constructed array to obtain a first matching result corresponding to the text characters, where the array includes a single-child node tree structure; and performing maximum matching on the text characters in a pre-constructed double-array Trie tree according to the first matching result to obtain a text segmentation result of the search text, where the double-array Trie tree includes a multi-child node tree structure, can be omitted, and a to-be-recommended object matching the text segmentation result can be directly acquired from a recommended object database.

[0111] Step 2: In the case that the search text does not exist in the data pool, segment the search text to obtain text characters corresponding to the search text.

[0112] If the search text cannot be found in the historically segmented texts, it is necessary to perform a segmentation operation on the search text, that is, perform the steps of segmenting the search text to obtain text characters corresponding to the search text; performing prefix indexing on the text characters in a pre-constructed array to obtain a first matching result corresponding to the text characters, where the array includes a single-child node tree structure; and performing maximum matching on the text characters in a pre-constructed double-array Trie tree according to the first matching result to obtain a text segmentation result of the search text, where the double-array Trie tree includes a multi-child node tree structure, so that the to-be-recommended object matching the text segmentation result can be acquired from the recommended object database by using the text segmentation result.

[0113] In the above method, the search text is first queried in the historically segmented texts in the data pool. If the search text exists, no segmentation operation is required, which improves search efficiency.

[0114] In one embodiment, as Figure 6 shown, acquiring the to-be-recommended object matching the text segmentation result from the recommended object database by using the text segmentation result may include the following steps:

[0115] Step S601: Acquire the segmentation count of the text segmentation result.

[0116] For example, the segmentation count of the text segmentation result = {"I", "love", "the People's Republic of China"} is 3.

[0117] Step S602: Determine the product of a preset repetition rate threshold and the segmentation count as the repeated segmentation count of the search text and the matching text in the recommended object database.

[0118] For example, the preset repetition rate threshold may be 60%, then the number of repeated segmented words is 3 multiplied by 60%, which is 1.8, and the floor value is 1.

[0119] Step S603, in response to the number of repeated segmented words being greater than or equal to a preset matching threshold, the object corresponding to the matched text is determined as an object to be recommended.

[0120] For example, the preset matching threshold may be 3, and the number of repeated segmented words obtained in step S602 is 1, then the object corresponding to the matched text cannot be determined as the object to be recommended.

[0121] In some embodiments, as shown in Figure 7 , another object recommendation method is provided, which may include the following steps:

[0122] Step S701, splitting dictionary data and storing the split data in an array and a double-array Trie tree respectively.

[0123] Step S702, obtaining a search text for the object to be recommended.

[0124] Step S703, querying the search text in a data pool; the data pool includes historically segmented texts.

[0125] Step S704, in response to the search text not existing in the data pool, segmenting the search text to obtain text characters corresponding to the search text.

[0126] Step S705, performing prefix indexing on the text characters in a pre-constructed array to obtain a first matching result corresponding to the text characters.

[0127] In some embodiments, step S705 may include:

[0128] Step 1, combining the first character and the second character in the text characters to obtain a first entry.

[0129] For example, after segmenting the text "I love the People's Republic of China", it can be split into "I", "love", "Chi", "na", "peo", "ple", "rep", "ub", "lic", and the resulting array is the text characters. The first character "I" and the second character "love" are combined to obtain the first entry, which is "I love".

[0130] In the embodiments of the present application, each character in the text characters can be mapped to a numerical value, that is, a hash value, through a hash algorithm, which facilitates word segmentation. The hash value corresponding to the first character "I" may include address information of the second character "love", so that in the process of prefix indexing in the array, the second character can be found according to the first character.

[0131] Step 2: Match the first term in the array.

[0132] This process involves finding the address information of the first character in the text string and the second character contained within that first character, and then searching for the second character in the array.

[0133] Step 3: If a match is successful, determine the first matching result as an array including the first term.

[0134] If the second character of the text can be found in the array, it indicates a successful match, meaning the array includes the first term.

[0135] Step 4: If the match fails, determine that the first matching result is an array that does not include the first term.

[0136] If the second character in the text cannot be found in the array, it indicates a match failure, which means that the array does not include the first term.

[0137] Step S706: Based on the first matching result, perform maximum matching on the text characters in the pre-constructed double-array Trie tree to obtain the text segmentation of the search text.

[0138] In some embodiments, step S706 may include:

[0139] Step 1: If the first matching result is an array that includes the first term, then take the last character of the first term as the current character.

[0140] Because the array contains only tree-structured data with a single child node, after obtaining the first matching result, prefix indexing needs to be performed in the double-array Trie tree. If the array includes the first term, the address information of the third character contained in the second term can be used to search for the third character in the double-array Trie tree.

[0141] Step 2: Obtain the next character of the current character in the text, combine the first term and the next character to obtain the second term; and use the second term as the current term.

[0142] The address information of the next character exists in the current character set. Therefore, when indexing the next character in the double-array Trie tree, it can be found through this address information.

[0143] Step 3: Query the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term.

[0144] Step 4: If the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, then the current term is used as a word in the text segmentation.

[0145] If the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, it means that the current term has reached the maximum match in the double-array Trie tree, so it can be segmented and used as a word in the text segmentation.

[0146] In some embodiments, after querying the current term in the double-array Trie tree and obtaining the current matching result corresponding to the current term, the process may further include:

[0147] If the current matching result is a double-array Trie tree that includes the current term, or if the current term is a prefix of a word in the double-array Trie tree, then the last character of the current term is taken as the current character.

[0148] Get the next character of the current character in the text, combine the current term and the next character to get a new current term; and return to the step of querying the current term in the double array Trie tree to get the current matching result corresponding to the current term, until the current matching result is that the double array Trie tree does not include the current term and the current term is not a prefix of a word in the double array Trie tree. At this time, the current term can be used as a word in the text segmentation.

[0149] In some embodiments, step S706 may further include:

[0150] Step 1: If the first matching result is an array that does not include the first term, take the first character in the first term as the current character.

[0151] If the first term is not included in the array, the second character needs to be searched in the double-array Trie tree.

[0152] Step 2: Obtain the next character after the current character in the text, and combine the current character and the next character to obtain the current word.

[0153] Step 3: Query the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term.

[0154] Step 4: If the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, then the current term is used as a word in the text segmentation.

[0155] In some embodiments, after querying the current entry in the double-array Trie tree to obtain the current matching result corresponding to the current entry, the following steps may further be included:

[0156] In the case that the current matching result indicates that the double-array Trie tree includes the current entry, or the current entry is a prefix of a word in the double-array Trie tree, the last character of the current entry is taken as the current character;

[0157] The next character of the current character in the text characters is acquired, a new current entry is obtained by combining the current entry and the next character; and the step of querying the current entry in the double-array Trie tree to obtain the current matching result corresponding to the current entry is executed in return, until the current matching result indicates that the double-array Trie tree does not include the current entry and the current entry is not a prefix of any word in the double-array Trie tree, at this time, the current entry can be regarded as a word segmentation in the text segmentation result.

[0158] Step S707: Acquire the number of words in the text segmentation result.

[0159] For example, the number of words in the text segmentation result = {"I", "love", "the People's Republic of China"} is 3.

[0160] Step S708: The product of the preset repetition rate threshold and the number of words is determined as the number of repeated words between the search text and the matching text in the recommended object database.

[0161] For example, the preset repetition rate threshold may be 60%, then the number of repeated words is 3 multiplied by 60%, which is 1.8, and the result after rounding down is 1.

[0162] Step S709: In the case that the number of repeated words is greater than or equal to the preset matching threshold, the object corresponding to the matching text is determined as the object to be recommended.

[0163] For example, the preset matching threshold may be 3, while the number of repeated words obtained in step S602 is 1, then the object corresponding to the matching text cannot be determined as the object to be recommended.

[0164] In the aforementioned object recommendation method, apparatus, and computer device, the dictionary used for segmenting the search text can be pre-segmented and stored in an array and a double-array Trie tree, respectively. Then, the text characters can be prefix-indexed in the pre-constructed array to obtain a first matching result corresponding to the text characters. Next, based on the first matching result, the text characters are subjected to maximum matching in the pre-constructed double-array Trie tree to obtain the text segmentation of the search text. Finally, using the text segmentation, the recommended objects matching the text segmentation are retrieved from the recommendation object database. In the method provided in this application embodiment, a portion of the data in the original double-array Trie tree, such as a single-child node tree structure, is stored in an array, thereby avoiding the formation of a large tree trunk that consumes server memory and solving the problem of high memory consumption.

[0165] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0166] Based on the same inventive concept, this application also provides an object recommendation apparatus for implementing the object recommendation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more object recommendation apparatus embodiments provided below can be found in the limitations of the object recommendation method described above, and will not be repeated here.

[0167] In one embodiment, such as Figure 8 As shown, an object recommendation device is provided, including: a first acquisition module 810, a first matching module 820, a second matching module 830, and a second acquisition module 840, wherein:

[0168] The first acquisition module 810 is used to acquire the search text for the object to be recommended;

[0169] The segmentation module is used to segment the search text to obtain the text characters corresponding to the search text;

[0170] The first matching module 820 is used to perform prefix indexing on text characters in a pre-built array to obtain the first matching result; the array includes a single-child node tree structure;

[0171] The second matching module 830 is used to perform maximum matching of text characters in a pre-constructed double-array Trie tree based on the first matching result, and obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0172] The second acquisition module 840 is used to retrieve, from the recommendation object database, objects that match the text segmentation using text segmentation.

[0173] Each module in the aforementioned object recommendation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0174] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a radio-based intelligent monitoring and control method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0175] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0176] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0177] Get the search text for the object to be recommended;

[0178] The search text is segmented to obtain the text characters corresponding to the search text;

[0179] The text characters are prefixed in a pre-constructed array to obtain the first matching result corresponding to the text character; the array includes a single-child node tree structure;

[0180] Based on the first matching result, the text characters are matched to the maximum in the pre-constructed double-array Trie tree to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0181] By using text segmentation, we can obtain recommended objects that match the text segmentation from the recommendation object database.

[0182] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0183] Get the search text for the object to be recommended;

[0184] The search text is segmented to obtain the text characters corresponding to the search text;

[0185] The text characters are prefixed in a pre-constructed array to obtain the first matching result corresponding to the text character; the array includes a single-child node tree structure;

[0186] Based on the first matching result, the text characters are matched to the maximum in the pre-constructed double-array Trie tree to obtain the text segmentation of the search text; the double-array Trie tree includes a multi-child node tree structure;

[0187] By using text segmentation, we can obtain recommended objects that match the text segmentation from the recommendation object database.

[0188] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0189] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0190] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0191] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. An object recommendation method characterized by comprising: The method includes: Get the search text for the object to be recommended; The search text is segmented to obtain the text characters corresponding to the search text. The text characters are prefix-indexed in a pre-constructed array to obtain the first matching result corresponding to the text characters; the array includes a single-child node tree structure; The first and second characters of the text characters are combined to obtain a first term; the first term is matched in the array; if the first matching result indicates that the array includes the first term, the last character of the first term is taken as the current character; the next character of the current character in the text characters is obtained, and the first term and the next character are combined to obtain a second term; the second term is taken as the current term; the current term is queried in a pre-constructed double-array Trie tree to obtain the current matching result corresponding to the current term; if the current matching result indicates that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, the current term is... The term is used as a word in the text segmentation; if the first matching result is that the array does not include the first term, the first character in the first term is taken as the current character; the next character of the current character in the text characters is obtained, and the current term is obtained by combining the current character and the next character; the current term is queried in the double-array Trie tree to obtain the current matching result corresponding to the current term; if the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, the current term is used as a word in the text segmentation; the text segmentation is the segmented text; the double-array Trie tree includes a multi-child node tree structure; Using the text segmentation, the recommended objects that match the text segmentation are obtained from the recommendation object database.

2. The method according to claim 1, characterized in that, The step of performing prefix indexing on the text characters in a pre-constructed array to obtain the first matching result corresponding to the text characters includes: If the match is successful, the first matching result is determined to be that the array includes the first term; In the event of a failed match, the first matching result is determined to be that the array does not include the first term.

3. The method according to claim 2, characterized in that, After querying the current term in the double-array Trie tree to obtain the current matching result corresponding to the current term, the method further includes: If the current matching result is that the double-array Trie tree includes the current term, or the current term is a prefix of a word in the double-array Trie tree, then the last character of the current term is taken as the current character. Obtain the next character of the current character in the text characters, combine the current term and the next character to obtain a new current term, and return to the step of querying the current term in the double array Trie tree to obtain the current matching result corresponding to the current term, until the current matching result is that the double array Trie tree does not include the current term and the current term is not a prefix of a word in the double array Trie tree.

4. The method according to claim 1, characterized in that, The method further includes: The search text is queried from a data pool; the data pool includes historical segmented text. If the search text does not exist in the data pool, the search text is segmented to obtain the text characters corresponding to the search text.

5. The method according to claim 1, characterized in that, The step of using the text segmentation to obtain the recommended objects that match the text segmentation from the recommendation object database includes: Obtain the number of words segmented from the text; The product of the preset repetition rate threshold and the number of word segments is determined as the number of repeated word segments between the search text and the matching text in the recommendation object database; If the number of repeated word segments is greater than or equal to a preset matching threshold, the object corresponding to the matching text is determined as the object to be recommended.

6. An object recommendation device, characterized in that, The device includes: The first acquisition module is used to acquire the search text for the object to be recommended; The segmentation module is used to segment the search text to obtain the text characters corresponding to the search text; The first matching module is used to perform prefix indexing on the text characters in a pre-constructed array to obtain a first matching result; the array includes a single-child node tree structure. The second matching module is used to combine the first and second characters of the text characters to obtain a first term; match the first term in the array; if the first matching result indicates that the array includes the first term, take the last character of the first term as the current character; obtain the next character of the current character in the text characters, and combine the first term and the next character to obtain a second term; take the second term as the current term; query the current term in a pre-constructed double-array Trie tree to obtain the current matching result corresponding to the current term; if the current matching result indicates that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, then... The current term is used as a word in the text segmentation; if the first matching result is that the array does not include the first term, the first character in the first term is taken as the current character; the next character of the current character in the text characters is obtained, and the current term is obtained by combining the current character and the next character; the current term is queried in the double-array Trie tree to obtain the current matching result corresponding to the current term; if the current matching result is that the double-array Trie tree does not include the current term and the current term is not a prefix of a word in the double-array Trie tree, the current term is used as a word in the text segmentation; the text segmentation is the segmented text; the double-array Trie tree includes a multi-child node tree structure; The second acquisition module is used to acquire, using the text segmentation, recommended objects that match the text segmentation from the recommendation object database.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1-5.

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

Citation Information

Patent Citations

  • A Chinese word segmentation and big data information retrieval method and device

    CN109800412A