Statement recommendation method, related device and medium
By setting an ancestor node identifier for each node in the reference sentence library tree, the problems of long recommendation time and large memory consumption in input methods are solved, achieving efficient and low-memory sentence recommendation.
Patent Information
- Application Number
- CN202410650176.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-23
- Publication Date
- 2025-11-25
AI Technical Summary
Existing input methods suffer from problems such as excessive recommendation time and excessive memory consumption when recommending sentences, especially when traversing the reference sentence library tree, where the accuracy is poor or memory consumption is excessive.
An ancestor node identifier is set for each node in the reference sentence tree. The recommended sub-path is determined by the node identifier, which reduces memory usage. After receiving the input string, the target node is traversed to determine the recommended sub-path.
While maintaining low recommendation time and high accuracy, memory usage was reduced and the efficiency of statement recommendation was improved.
Smart Images

Figure CN121008698A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of input methods, and in particular to a sentence recommendation method, related apparatus and medium. Background Technology
[0002] Input methods typically predict the second half of a target sentence based on the first half of the input, thus recommending sentences. This prediction usually involves searching a reference sentence library tree. Each node in the reference sentence library tree corresponds to a character. A path from the root node to a leaf node corresponds to a reference sentence. When the input is the first half, matching sub-paths are found in the upper levels of the reference sentence library tree for each character, and the possible sub-paths for the second half in the reference sentence library tree are predicted. During prediction, the probability is determined for each sub-path. Therefore, the traversal time is too long, impacting prediction performance.
[0003] In existing technologies, methods to shorten recommendation time mainly fall into two categories. One is to limit the number of sub-paths traversed in the reference sentence library tree. For example, among multiple possible sub-paths, only the first two are traversed. However, the optimal sub-path may exist in later sub-paths. This method is obviously inaccurate. The other method is to pre-determine the multiple preferred sub-paths below each node by comparison and store them under that node. Its disadvantage is that it consumes a large amount of memory. Summary of the Invention
[0004] This disclosure provides a statement recommendation method, related apparatus, and medium that can reduce memory usage while keeping the statement recommendation time short and the recommendation accuracy high.
[0005] According to one aspect of this disclosure, a statement recommendation method is provided, comprising:
[0006] Obtain a reference sentence library tree, which includes multiple levels of nodes, wherein, except for the root node at the top level, each node of the reference sentence library tree is connected upward to a node at a higher level, each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree;
[0007] For each node in the reference sentence library tree, a downward recommendation sub-path is determined in the reference sentence library tree, and the ancestor node identifier of each node in the downward recommendation sub-path is set using the node identifier of the node;
[0008] Receive input string;
[0009] Based on the order of the characters in the input string, the reference sentence library tree is traversed starting from the root node until the target node corresponding to the last character in the input string is found;
[0010] Based on the ancestor node identifiers of each lower-level node of the target node, the target downward recommendation sub-path of the target node is determined, and based on the input string and the target downward recommendation sub-path, the recommendation statement is determined.
[0011] According to one aspect of this disclosure, a sentence recommendation apparatus is provided, comprising:
[0012] An acquisition unit is used to acquire a reference sentence library tree, the reference sentence library tree including multiple layers of nodes, wherein, except for the root node of the top layer, each node of the reference sentence library tree is connected upward to a node of a higher layer, each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree;
[0013] The first determining unit is configured to determine a downward recommendation sub-path in the reference sentence library tree for each node in the reference sentence library tree, and to set the ancestor node identifier of each node in the downward recommendation sub-path using the node identifier of the node.
[0014] The receiving unit is used to receive the input string;
[0015] The traversal unit is used to traverse the reference sentence library tree from the root node based on the order of the characters in the input string until the target node corresponding to the last character in the input string is found.
[0016] The second determining unit is used to determine the target downward recommendation sub-path of the target node based on the ancestor node identifiers of each lower-level node of the target node, and to determine the recommendation statement based on the input string and the target downward recommendation sub-path.
[0017] Optionally, the first determining unit is specifically used for:
[0018] Assign ascending node identifiers to each node in the reference sentence library tree;
[0019] According to the ascending order, the nodes in the reference sentence library tree are sequentially extracted, and for the extracted nodes, the downward recommendation sub-path is determined in the reference sentence library tree;
[0020] For the sub-path nodes in the downward recommendation sub-path, if the sub-path node has not set the ancestor node identifier, set the ancestor node identifier to the node identifier of the node; if the sub-path node has already set the ancestor node identifier, keep the set ancestor node identifier.
[0021] Optionally, the first determining unit is further configured to:
[0022] Assign a node identifier to each node in the reference sentence tree, such that the higher the layer in which the node is located, the smaller the node identifier;
[0023] Within the same layer, the node identifiers are assigned in a manner that increases from left to right.
[0024] Optionally, the first determining unit is further configured to:
[0025] For the extracted node, multiple candidate downward sub-paths for the node are determined in the reference sentence library tree;
[0026] Obtain the candidate substring corresponding to each of the candidate downward sub-paths;
[0027] Based on the first frequency of each candidate string after the target object inputs the input string, the score corresponding to each candidate downward sub-path is determined;
[0028] Based on the scores corresponding to each of the candidate downward sub-paths, the downward recommendation sub-path is determined among each of the candidate downward sub-paths.
[0029] Optionally, the first determining unit is further configured to:
[0030] The extracted node is used as the first anchor node;
[0031] Perform a first process, which includes: determining each lower-level node connected to the first anchor node in the reference sentence tree, updating the first anchor node with each lower-level node, repeating the first process until a leaf node is reached, wherein the leaf node is a node that is not connected to a lower-level node.
[0032] The ordered set of all nodes traversed from the extracted node to a leaf node in the first process is taken as a candidate downward sub-path.
[0033] Optionally, the first determining unit is further configured to:
[0034] For each candidate downward sub-path, obtain the word corresponding to each node in the candidate downward sub-path;
[0035] The words are concatenated into the candidate word string according to the order of the nodes in the candidate downward sub-path.
[0036] Optionally, the first determining unit is further configured to:
[0037] Obtain the first count of each candidate string after the input string is entered in the target object within a predetermined time period before the current time;
[0038] Based on each of the first counts and the duration of the predetermined time period, the first frequency of each of the input candidate strings is determined;
[0039] Based on the first frequency of each of the input candidate strings, the score corresponding to each candidate downward sub-path is determined.
[0040] Optionally, the first determining unit is further configured to:
[0041] The second frequency of each candidate string is obtained after the input string is input to the target platform. The target platform is the platform to which the statement recommendation method is applied. The target platform includes multiple platform objects, and the multiple platform objects include the target object.
[0042] Based on the first frequency and the second frequency, determine the total frequency;
[0043] Based on the total frequency, the score corresponding to each of the candidate downward sub-paths is determined.
[0044] Optionally, the first determining unit is further configured to:
[0045] Obtain the second count of each candidate string after the input string is entered into the target platform within a predetermined time period before the current time;
[0046] The second frequency of each of the candidate strings is determined based on the second frequency and the duration of the predetermined time period.
[0047] Optionally, the first determining unit is further configured to:
[0048] Obtain the first weight of the first frequency and the second weight of the second frequency;
[0049] Based on the first weight and the second weight, the first frequency and the second frequency are weighted and summed to obtain the total frequency.
[0050] Optionally, the second determining unit is specifically used for:
[0051] The target node is used as the second anchor node;
[0052] Perform a second process, which includes: determining in the reference sentence tree a node whose ancestor node identifier is less than or equal to the node identifier of the target node among the next-lower-level nodes connected to the second anchor node; if the determined node is not a leaf node, updating the second anchor node with the determined node; repeating the second process until the leaf node is reached, which is a node that is not connected to the next-lower-level node.
[0053] The ordered set of each lower-level node determined in the second process is used as the target to recommend sub-paths downwards.
[0054] Optionally, the statement recommendation device further includes:
[0055] The first identification unit is used to identify that the ancestor node corresponding to the ancestor node identifier of the determined node is not the upstream node of the target node, wherein the upstream node is a node in the reference sentence library tree that has a downward path to the target node;
[0056] A discard unit is used to discard the identified nodes.
[0057] Optionally, the second determining unit is further configured to:
[0058] Connect the characters corresponding to each node in the downward recommendation sub-path of the target to obtain the predicted character string;
[0059] The input string and the predicted string are concatenated to obtain the recommended statement.
[0060] Optionally, the traversal unit is specifically used for:
[0061] The first character in the input string is taken as the first anchor character, and the root node is taken as the third anchor node;
[0062] Perform a third process, which includes: searching for a node corresponding to the first anchor word in the next lower level node of the third anchor node; updating the third anchor node with the found node; updating the first anchor word with the next word of the first anchor word; repeating the third process if the first anchor word is not the last word until the first anchor word is the last word; and determining the node corresponding to the first anchor word as the target node.
[0063] Optionally, the statement recommendation device further includes:
[0064] The third determining unit is used to determine the semantic similarity between the characters corresponding to each of the next lower level nodes and the first anchor character if no node corresponding to the first anchor character is found in the next lower level nodes.
[0065] The fourth determining unit is used to determine the distance between the word corresponding to each of the next lower-level nodes and the first anchor word in the knowledge graph;
[0066] The fifth determining unit is used to determine the target's next-lower-level node among the various next-lower-level nodes based on the semantic similarity and the distance;
[0067] An update unit is used to update the third anchor node using the target node at the next lower level.
[0068] Optionally, the acquisition unit is specifically used for:
[0069] Obtain a set of reference sentences, which includes multiple reference sentences;
[0070] For each of the reference sentences, the first character of the reference sentence is taken as the second anchor character, and the root node is taken as the first anchor layer;
[0071] The fourth process includes: when it is determined that the second anchor word does not exist in the layer below the first anchor layer, writing the second anchor word into the layer below the first anchor layer as a node of the layer below the first anchor layer; when it is determined that the second anchor word exists in the layer below the first anchor layer, not writing the second anchor word; updating the second anchor word with the next word in the reference sentence, updating the first anchor layer with the layer below the first anchor layer, and repeating the fourth process until multiple reference sentences have been traversed.
[0072] According to one aspect of this disclosure, an electronic device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the statement recommendation method as described above.
[0073] According to one aspect of this disclosure, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements the statement recommendation method as described above.
[0074] According to one aspect of this disclosure, a computer program product is provided, comprising a computer program that is read and executed by a processor of a computer device, causing the computer device to perform the statement recommendation method as described above.
[0075] This embodiment of the disclosure determines downward recommendation sub-paths for each node in the reference sentence library tree. Unlike existing technologies that directly write these downward recommendation sub-paths into the node's memory, this method maintains only an ancestor node identifier for each node in the downward recommendation sub-path. This ancestor node identifier is set using the node's node identifier, for example, by setting it to be consistent with the node's node identifier. When an input string is actually received, the target node corresponding to the last character of the input string is found in the reference sentence library tree. Then, the downward recommendation sub-path is searched for below the target node. When searching for the target downward recommendation sub-path, since the ancestor node identifiers of lower-level nodes are all set using the node identifiers of upper-level nodes, it is possible to determine whether these lower-level nodes belong to the target downward recommendation sub-path based on the ancestor node identifiers of each lower-level node of the target node. In this way, since only the ancestor node identifiers of lower-level nodes need to be determined, the sentence recommendation time is shorter and the recommendation accuracy is higher. Because this method only requires storing the ancestor node identifiers of nodes and does not require storing all downward recommendation sub-paths, memory usage is reduced.
[0076] Other features and advantages of this disclosure will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the disclosure. The objectives and other advantages of this disclosure may be realized and obtained by means of the structures particularly pointed out in the description, claims and drawings. Attached Figure Description
[0077] The accompanying drawings are provided to further understand the technical solutions of this disclosure and constitute a part of the specification. They are used together with the embodiments of this disclosure to explain the technical solutions of this disclosure and do not constitute a limitation on the technical solutions of this disclosure.
[0078] Figure 1 This is a system architecture diagram of the statement recommendation method according to an embodiment of this disclosure;
[0079] Figure 2 This is a schematic diagram of the statement recommendation method provided by the embodiments of this disclosure applied to the interface of an input method;
[0080] Figure 3 This is a main flowchart of a statement recommendation method according to an embodiment of the present disclosure;
[0081] Figure 4A and Figure 4B This is a schematic diagram of a reference sentence library tree for a sentence recommendation method according to an embodiment of the present disclosure;
[0082] Figure 5 This is a schematic diagram illustrating an overall implementation of a statement recommendation method according to an embodiment of the present disclosure;
[0083] Figure 6 yes Figure 3A flowchart for step 310, obtaining the reference sentence library tree;
[0084] Figure 7A This is a schematic diagram of the reference sentence library tree according to an embodiment of the present disclosure before the execution of the fourth process;
[0085] Figure 7B This is a schematic diagram of the reference sentence library tree after the fourth process is performed, according to an embodiment of the present disclosure;
[0086] Figure 8 yes Figure 3 A flowchart of step 320, which determines the downward recommended sub-path and sets the ancestor node identifier;
[0087] Figure 9A This is a schematic diagram of a reference sentence library tree after assigning node identifiers according to an embodiment of the present disclosure;
[0088] Figure 9B This is a schematic diagram of a reference sentence library tree after setting the ancestor node identifier according to an embodiment of the present disclosure;
[0089] Figure 10 yes Figure 8 A flowchart of step 810, which assigns the ascending node identifier;
[0090] Figure 11 yes Figure 8 A flowchart for step 820, which determines the downward recommended sub-path;
[0091] Figure 12 yes Figure 11 A schematic diagram illustrating the determination of the downward recommendation sub-path;
[0092] Figure 13 yes Figure 11 A flowchart for step 1110, which determines candidate downward paths;
[0093] Figure 14 yes Figure 11 A flowchart for step 1120 of the process to obtain candidate strings;
[0094] Figure 15 yes Figure 11 A flowchart for step 1130 of the middle section, which determines the score corresponding to each candidate downward sub-path;
[0095] Figure 16 yes Figure 15 A schematic diagram for determining the scores corresponding to each candidate downward sub-path;
[0096] Figure 17 yes Figure 11Another flowchart for step 1130 of the middle section, which determines the scores corresponding to each candidate downward sub-path;
[0097] Figure 18 yes Figure 17 A schematic diagram for determining the scores corresponding to each candidate downward sub-path;
[0098] Figure 19 yes Figure 17 A flowchart for obtaining the second frequency in step 1710;
[0099] Figure 20 yes Figure 19 A schematic diagram for obtaining the second frequency;
[0100] Figure 21 yes Figure 17 A flowchart for step 1720, which determines the total frequency;
[0101] Figure 22 yes Figure 21 A schematic diagram for determining the total frequency;
[0102] Figure 23 This is a flowchart illustrating how to update a third anchor point when no node corresponding to the first anchor word is found in a lower-level node, according to an embodiment of this disclosure.
[0103] Figure 24A This is a flowchart of a reference sentence library tree provided according to embodiments of the present disclosure;
[0104] Figure 24B Provided according to embodiments of this disclosure Figure 24A A schematic diagram of updating the third anchor point when no node corresponding to the first anchor word is found in the reference sentence library tree at the next lower level;
[0105] Figure 25 yes Figure 3 A flowchart for step 350, which determines the target and recommends sub-paths downwards;
[0106] Figure 26 This is a flowchart of an embodiment of the present disclosure providing a second process performed when the ancestor node corresponding to the ancestor node identifier of the determined node is not the upstream node of the target node;
[0107] Figure 27 This is a schematic diagram of a reference sentence library tree where the ancestor node corresponding to the ancestor node identifier of the determined node provided in the embodiments of this disclosure is not the upstream node of the target node.
[0108] Figure 28 yes Figure 3 A flowchart for step 350, which determines the recommended statement;
[0109] Figure 29 This is a detailed implementation diagram of the statement recommendation method according to an embodiment of this disclosure.
[0110] Figure 30 This is a block diagram of a statement recommendation device according to embodiments of the present disclosure;
[0111] Figure 31 Based on embodiments of this disclosure Figure 3 The diagram shows the terminal structure of the statement recommendation method.
[0112] Figure 32 Based on embodiments of this disclosure Figure 3 The diagram shows the server architecture for the statement recommendation method. Detailed Implementation
[0113] To make the objectives, technical solutions, and advantages of this disclosure 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 are not intended to limit the scope of this disclosure.
[0114] Before providing a further detailed description of the embodiments of this disclosure, the terms and concepts used in these embodiments are explained, and they are subject to the following interpretations:
[0115] A tree is a data structure consisting of a finite set of n (n≥0) nodes arranged in a hierarchical relationship. It's called a "tree" because it resembles an inverted tree, with the root at the top and the leaves at the bottom. Trees come in various forms, including unordered trees, ordered trees, binary trees, full binary trees, complete binary trees, and Huffman trees.
[0116] A Trie (or Trie Tree) is a tree-like data structure, a variant of a hash tree. It is used for counting, sorting, and storing large amounts of text, and is therefore frequently used in search engine systems for text word frequency statistics. Tries utilize common prefixes of strings and statements to reduce query time and minimize unnecessary string comparisons, resulting in higher query efficiency than hash trees.
[0117] A knowledge graph is a structured semantic knowledge base used to quickly describe concepts and their relationships in the physical world. By effectively processing, handling, and integrating complex document data, a knowledge graph transforms it into simple, clear "entity-relationship-entity" triples, ultimately aggregating vast amounts of knowledge to achieve rapid knowledge response and reasoning.
[0118] Input methods typically predict the second half of a target sentence based on the first half of the input, thus recommending sentences. This prediction usually involves searching a reference sentence library tree. Each node in the reference sentence library tree corresponds to a character. A path from the root node to a leaf node corresponds to a reference sentence. When the input is the first half, matching sub-paths are found in the upper levels of the reference sentence library tree for each character, and the possible sub-paths for the second half in the reference sentence library tree are predicted. During prediction, the probability is determined for each sub-path. Therefore, the traversal time is too long, impacting prediction performance.
[0119] In related technologies, methods to shorten recommendation time mainly fall into two categories. One is to limit the number of sub-paths traversed in the reference sentence library tree. For example, among multiple possible sub-paths, only the first two are traversed. However, the optimal sub-path may exist in later sub-paths. This method is obviously inaccurate. The other method is to pre-determine the multiple preferred sub-paths below each node by comparison and store them under that node. Its disadvantage is that it consumes a large amount of memory.
[0120] Based on this, embodiments of this disclosure provide a sentence recommendation method, related apparatus, and medium. The sentence recommendation method provided by embodiments of this disclosure can reduce memory usage while keeping the sentence recommendation time short and the recommendation accuracy high.
[0121] System architecture and scenario description of the embodiments disclosed herein
[0122] Figure 1 This is a system architecture diagram of the statement recommendation method applied according to embodiments of the present disclosure. It includes an object terminal 110, an Internet 120, a gateway 130, and a server 140, etc.
[0123] The object terminal 110 is a device used to display recommended statements, and the object can perform operations such as inputting strings through the object terminal 110. The object terminal 110 includes various forms such as desktop computers, laptops, PDAs (personal digital assistants), mobile phones, in-vehicle terminals, home theater terminals, dedicated terminals, and graphics tablets. Furthermore, it can be a single device or a collection of multiple devices. For example, multiple devices can be connected via a local area network, sharing a single display device to work collaboratively, forming a single terminal. The terminal can also communicate with the Internet 120 via wired or wireless means to exchange data.
[0124] Gateway 130, also known as an internetwork connector or protocol converter, is a computer system or device that enables network interconnection at the transport layer and acts as a translator. It bridges the gap between two systems using different communication protocols, data formats, languages, or even completely different architectures. Gateway 130 also provides filtering and security functions. Messages sent from target terminal 110 to server 140 are forwarded to the corresponding server 140 via gateway 130. Messages sent from server 140 to target terminal 110 are also forwarded to the corresponding target terminal 110 via gateway 130.
[0125] Server 140 refers to a computer system capable of providing statement recommendation services to target terminal 110. Compared to target terminal 110, server 140 has higher requirements in terms of stability, security, and performance. Server 140 can be a single high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a single high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines). Server 140 can also communicate with the Internet 120 via wired or wireless means to exchange data.
[0126] The embodiments disclosed herein can be applied in various scenarios, such as Figure 2 The diagram shows an example of how the recommended statement method is applied in an input method interface.
[0127] Reference Figure 2 In the XX application, the user inputs sentences using an input method. The user inputs "Jintian" into the input method, and the input method, built based on the sentence recommendation method provided in this embodiment, processes the input to generate recommended sentences such as "What to eat today" and "Where to go today," for the user to choose from. The input method can quickly respond to the user's input to generate recommended sentences, and the generated recommended sentences meet the user's needs with high accuracy.
[0128] It should be understood that the above description only illustrates some application scenarios of this disclosure. The business scenarios to which this disclosure can be applied may include, but are not limited to, the specific embodiments described above.
[0129] General Description of Embodiments in this Disclosure
[0130] It should be emphasized that the embodiments disclosed herein are applicable to a variety of application scenarios, such as Figure 2The examples illustrate input method sentence recommendation scenarios. In related technologies, sentence recommendation methods take too long to traverse the reference sentence library tree. Two methods to shorten the recommendation time are: one is to limit the number of sub-paths traversed in the reference sentence library tree, which results in poor accuracy; the other is to pre-determine multiple preferred sub-paths for each node through comparison and store them under that node, which requires a large amount of memory. Some embodiments of this disclosure provide a sentence recommendation method, related apparatus, and medium that can reduce memory usage while maintaining a shorter sentence recommendation time and higher recommendation accuracy.
[0131] The statement recommendation method processes the input string to provide recommended statements. This method reduces memory usage while maintaining low recommendation time and high accuracy.
[0132] The statement recommendation method of this disclosure can be executed on the target terminal 110, or on the server 140, or partly on the target terminal 110 and partly on the server 140.
[0133] like Figure 3 As shown, according to one embodiment of this disclosure, the statement recommendation method includes:
[0134] Step 310: Obtain the reference sentence library tree. The reference sentence library tree includes multiple levels of nodes. Except for the root node at the top level, each node in the reference sentence library tree is connected to a node at the next higher level. Each node corresponds to a word. Each path downward from the root node corresponds to a reference sentence in the reference sentence library tree.
[0135] Step 320: For each node in the reference sentence library tree, determine the downward recommendation sub-path in the reference sentence library tree, and use the node identifier of the node to set the ancestor node identifier of each node in the downward recommendation sub-path;
[0136] Step 330: Receive the input string;
[0137] Step 340: Based on the order of the characters in the input string, traverse the reference sentence library tree starting from the root node until the target node corresponding to the last character in the input string is found;
[0138] Step 350: Based on the ancestor node identifiers of each lower-level node of the target node, determine the target downward recommendation sub-path of the target node, and based on the input string and the target downward recommendation sub-path, determine the recommendation statement.
[0139] Steps 310 to 350 are described in detail below.
[0140] In step 310, a reference sentence library tree is obtained. The reference sentence library tree includes multiple levels of nodes, wherein, except for the root node at the top level, each node of the reference sentence library tree is connected upward to a node at a higher level. Each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree.
[0141] A reference sentence tree is a tree structure used to store a large number of sentences in a sentence database, i.e., reference sentences. A reference sentence tree can be represented by various tree forms such as unordered trees, ordered trees, Huffman trees, and hash trees. To improve sentence recommendation efficiency, this embodiment uses a trie as the reference sentence tree, which minimizes unnecessary string comparisons and has higher query efficiency than a hash tree.
[0142] The root node refers to the top-level node in the reference sentence library tree. The root node is a node without a parent node and does not contain any words. By mapping a path starting from the root node and ending at a node in the reference sentence library tree to a corresponding reference sentence, and connecting the words along that path, we can obtain the reference sentence for that path. Furthermore, the endpoint of the path can be a leaf node in the reference sentence library tree, i.e., a node without child nodes. For example, Figure 4B The path ending for the reference sentence "I don't understand" is the leaf node "white". The path ending can also be other nodes in the reference sentence library tree, for example... Figure 4B The path ending point for the reference sentence "I don't" is the node "no".
[0143] The reference sentence database tree stores reference sentences in multiple languages, including English and Chinese. Except for the root node at the top level, each node in the reference sentence database tree corresponds to a single character. Specifically, for example... Figure 4A The reference sentence tree shown stores English letters in each node, such as... Figure 4B Each node of the reference sentence library tree shown stores Chinese characters.
[0144] In step 320, for each node in the reference sentence library tree, a downward recommendation sub-path is determined in the reference sentence library tree, and the ancestor node identifier of each node in the downward recommendation sub-path is set using the node identifier of the node.
[0145] The downward recommended sub-path corresponds to a node in the reference sentence library tree, and the reference sentence corresponding to the downward recommended sub-path is a statement under that node that better suits the object's needs. (Reference) Figure 4A The paths corresponding to statements EHK and EI are the downward recommended sub-paths under node E.
[0146] It should be noted that the downward recommended sub - paths corresponding to a node can be one or multiple. The number of downward recommended sub - paths corresponding to each node in the reference sentence library tree can be the same or different. The specific number of downward recommended sub - paths can be set according to actual needs.
[0147] The ancestor node identifier refers to the identifier recorded on the node, and the ancestor node identifier of a node is the identifier of a certain ancestor node of the node. The node is located on the downward recommended sub - path of the corresponding ancestor node. Among them, the ancestor node refers to the node that is on the same path as the node and is above the node.
[0148] In addition, the ancestor node identifier corresponds to the downward recommended sub - path. After determining the downward recommended sub - path, use the node identifier of the node to set the ancestor node identifiers of each node in the downward recommended sub - path. This ancestor node identifier can be set to be the same as the node identifier of the node. For example, referring to Figure 4A , for the downward recommended sub - paths EHK and EI under node E, set the ancestor node identifiers of nodes H, node K, and node I to be the node identifier of node E, which is 5. In addition, the ancestor node identifier can also be set to a number less than the node identifier, a number greater than the node identifier, the square of the node identifier, etc. This ancestor node identifier only needs to be set based on the node identifier of the node to meet the condition of distinguishing whether each node is located on the downward recommended path based on the ancestor node identifier.
[0149] In step 330, receive the input string.
[0150] The input string refers to the received string, which is usually the string input by the object on the input method interface.
[0151] It should be noted that the object can input on the input method end through pinyin, Wubi, etc., and the input string can be determined based on the pinyin, strokes, etc. input by the object. For example, referring to Figure 2 , the object inputs "Jintian" on the input method end, and then determines that the input string is "今天".
[0152] In step 340, based on the order of each character in the input string, traverse from the root node in the reference sentence library tree until the target node corresponding to the last character in the input string is found.
[0153] The target node is the node position of the last character in the input string in the reference sentence library tree. The determination of the target node requires querying and traversing in the reference sentence library tree based on the order of each character in the input string. For example, referring to Figure 2, for the input string "BE", first traverse from the multiple child nodes of the root node to query node B. Then traverse the multiple child nodes of node B to query node E. Since E is the last character of the input string "BE", the target node corresponding to the input string is node E located on the third layer of the reference sentence library tree. Additionally, Figure 4B The reference sentence library tree shown corresponds to the input string "我不", and the target node corresponding to the input string is the node "不" located on the third layer of the reference sentence library tree.
[0154] In step 350, based on the ancestor node identifiers of each lower-level node of the target node, determine the target downward recommendation sub-path of the target node, and based on the input string and the target downward recommendation sub-path, determine the recommended sentence.
[0155] The target downward recommendation sub-path is the downward recommendation sub-path of the target node. Since the ancestor node identifiers of the lower-level nodes are all set using the node identifiers of the upper-level nodes, then based on the ancestor identifiers of each lower-level node of the target node, it can be judged whether the lower-level node is on the downward recommendation sub-path of the target node, and then the target downward recommendation sub-path can be determined.
[0156] It should be noted that the target downward recommendation sub-path can be one or multiple, and its specific quantity corresponds to the number of downward recommendation sub-paths of each node in the reference sentence library tree.
[0157] The recommended sentence refers to the sentence corresponding to the input string and recommended to the input object. The recommended sentence is determined based on the input string and the target downward recommendation sub-path. The prefix of the recommended sentence is the input string, and the suffix of the recommended sentence is determined based on the target downward recommendation sub-path. Connect the characters corresponding to the multiple nodes passed by the target downward recommendation sub-path to obtain the suffix of the recommended sentence.
[0158] Refer to Figure 4A , the input string is "BE", the target node is E, the node identifier of the target node is 5. Based on the ancestor node identifiers of each lower-level node of the target node, it is successively determined that node H, node K, and node I belong to the target downward recommendation sub-path to be found. The target downward recommendation sub-paths are two, namely EHK and EI, and then the recommended sentences BEHK and BEI are obtained.
[0159] Refer to Figure 4B , the input string is "我不", the target node is "不", the node identifier of the target node is 5. Compare the node identifier with the ancestor node identifiers of the lower-level nodes, and it is successively determined that the nodes "懂", "明", and "白" are on the target downward recommendation sub-path, and then the target downward recommendation sub-paths are determined as "不懂" and "不明白", so the finally obtained recommended sentences are "我不懂" and "我不明白".
[0160] It should be noted that there can be multiple target downward recommendation paths corresponding to the input string, and therefore, there can also be multiple recommended statements determined based on the input string and the target downward recommendation paths. To improve the accuracy of statement recommendations, these multiple recommended statements can be sorted. For example, refer to... Figure 2 The input string "J i nt i an" corresponds to recommended phrases such as "What to eat today" and "Where to go today". Then, the multiple recommended phrases are reordered and displayed on the input method interface.
[0161] Reference Figure 5 The first step in sentence recommendation is to obtain a reference sentence library tree. In this tree, for each node's downward recommendation sub-path, the ancestor node identifiers of the lower-level nodes are set using the node identifier of that node. Therefore, for an input string, the target node corresponding to the last character in the input string is determined in the reference sentence library tree, and the tree is traversed starting from the target node. Specifically, based on the ancestor node identifiers of each lower-level node of the target node, multiple target downward recommendation sub-paths are determined. These sub-paths are then sorted, and the recommended sentence is determined based on the input string and the target downward recommendation sub-paths.
[0162] The embodiments of steps 310 to 350 above involve determining the downward recommendation sub-path for each node in the reference sentence library tree. Unlike related technologies that directly write these downward recommendation sub-paths into the node's memory, this method only maintains an ancestor node identifier for each node in the downward recommendation sub-path. This ancestor node identifier is set using the node's node identifier, for example, set to be consistent with the node's node identifier. When the input string is actually received, the target node corresponding to the last character of the input string is found in the reference sentence library tree, and then the target downward recommendation sub-path is searched by traversing below the target node. When searching for the target downward recommendation sub-path, since the ancestor node identifiers of the lower-level nodes are all set using the node identifiers of the upper-level nodes, it is possible to determine whether these lower-level nodes belong to the target downward recommendation sub-path based on the ancestor node identifiers of each lower-level node of the target node. In this way, since only the ancestor node identifiers of the lower-level nodes need to be judged, the sentence recommendation time is shorter and the recommendation accuracy is higher. Because this method only requires the node to store the ancestor node identifier and does not need to store all downward recommendation sub-paths, memory usage is reduced.
[0163] The above is a general description of steps 310 to 350. Since step 330 has been described in sufficient detail above, the specific implementation processes of steps 310 to 320 and steps 340 to 350 will be described in detail below.
[0164] Detailed description of step 310
[0165] In step 310, a reference sentence library tree is obtained. The reference sentence library tree includes multiple levels of nodes, wherein, except for the root node at the top level, each node of the reference sentence library tree is connected upward to a node at a higher level. Each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree.
[0166] In one embodiment, reference is made to Figure 6 Step 310 includes:
[0167] Step 610: Obtain a set of reference sentences, which includes multiple reference sentences;
[0168] Step 620: For each reference sentence, take the first character of the reference sentence as the second anchor character and the root node as the first anchor layer;
[0169] Step 630: Execute the fourth process.
[0170] The fourth process includes:
[0171] Step 631: When it is determined that there is no second anchor word in the next lower layer of the first anchor layer, write the second anchor word into the next lower layer of the first anchor layer as a node in the next lower layer.
[0172] Step 632: When it is determined that a second anchor word exists in a layer below the first anchor layer, do not write the second anchor word;
[0173] Step 633: Update the second anchor word with the next word in the reference sentence, and update the first anchor layer with the next lower layer of the first anchor layer. Repeat the fourth process until multiple reference sentences have been traversed.
[0174] Steps 610 to 630 are described in detail below.
[0175] In step 610, a set of reference sentences is obtained, which includes multiple reference sentences.
[0176] A reference sentence is a grammatically correct statement, which can be an English sentence, a Chinese sentence, etc. A set of reference sentences is a collection of multiple reference sentences.
[0177] The set of reference sentences may include multiple reference sentences on the target platform of the application sentence recommendation method, or reference sentences entered by the object during the process of using the input method of the sentence recommendation method provided in the embodiments of this disclosure.
[0178] In step 620, for each reference sentence, the first character of the reference sentence is used as the second anchor character, and the root node is used as the first anchor layer.
[0179] The second anchor word is the first word of the reference sentence. For example, in the reference sentence "you and who", the corresponding second anchor word is "you", while in the reference sentence "I know", the corresponding second anchor word is "I".
[0180] The first anchor level is the level in which the root node is located in the reference sentence library tree. Since the root node has no parent node, the first anchor level can be regarded as the first level of the reference sentence library tree.
[0181] In step 630, the fourth process is performed. The fourth process refers to processing multiple reference sentences to obtain a reference sentence library tree.
[0182] The fourth process is specifically implemented through steps 631 to 633.
[0183] In step 631, when it is determined that there is no second anchor word in the layer below the first anchor layer, the second anchor word is written into the layer below the first anchor layer as a node in the layer below the first anchor layer.
[0184] The layer below the first anchor layer refers to multiple child nodes located in the next lower layer of the first anchor layer. When the second anchor word does not exist in the words corresponding to multiple child nodes, a new node is added in the layer below the first anchor layer, and the second anchor word is written to that node.
[0185] In one embodiment, assuming the reference sentence is "you and who", then the second anchor word is "you". Next, the system searches the first anchor level (the level below the root node) in the reference sentence library tree to see if there is a node corresponding to the second anchor word "you". If not, "you" is written into the level below the first anchor level as a node in that level.
[0186] In step 632, if it is determined that a second anchor word exists in a layer below the first anchor layer, the second anchor word is not written.
[0187] Assuming the reference sentence is "you and who", then the second anchor word is "you". If the reference sentence database tree is as follows... Figure 7A As shown, it can be determined that there is a second anchor word in the next lower layer of the first anchor layer, and there is no need to write the second anchor word into the reference sentence library tree.
[0188] In step 633, the second anchor word is updated with the word following the second anchor word in the reference sentence, and the first anchor layer is updated with the next lower layer of the first anchor layer. The fourth process is repeated until multiple reference sentences are traversed.
[0189] After determining whether the first character of the reference sentence needs to be written into the reference sentence library tree and performing the corresponding operation, the next character of the second anchor character in the reference sentence is taken as the new second anchor character, and the next lower level of the first anchor layer is taken as the new first anchor layer. The fourth process is repeated, that is, steps 631 to 633 are repeated until the current reference sentence is traversed.
[0190] For each reference sentence in the reference sentence set, the fourth process is performed to write the reference sentence into the reference sentence library tree, thereby storing the reference sentence set through the reference sentence library tree.
[0191] In one embodiment, assuming the reference sentence is "I don't understand", the sentence tree before writing the reference sentence is as follows: Figure 7A As shown. First, "I" is set as the second anchor word. Then, it's checked whether the second anchor word exists at the first anchor level, which is the level below the root node. Since the nodes at the level below the root node are "you" and "I", the second anchor word already exists at the level below the first anchor level, so there's no need to add "I" to the second anchor word. Next, the second anchor word is updated to "no", the node "I" is updated to the first anchor level, and then the node "I"'s child nodes are checked for the existence of "no". Figure 7A The node "I" shown only has the node "know" as a child node. Therefore, "not" is written into the next level below the first anchor level as a node in that next level. Furthermore, since node "not" is a newly added node with no child nodes, the words after "not" in the reference sentence need to be written into the sentence library tree sequentially until the reference sentence traversal is complete. The sentence library tree after writing the reference sentence is as follows: Figure 7B As shown.
[0192] Steps 610 to 630 above include a fourth process, which writes multiple reference sentences from the reference sentence set into the reference sentence library tree. This ensures that the reference sentences are correctly written into the reference sentence library tree, thereby ensuring the accuracy and completeness of the final recommended sentences. Furthermore, the more reference sentences written into the reference sentence library tree, i.e., the more reference sentences stored in the reference sentence library tree, the more input strings the sentence recommendation method provided in this embodiment can be applied to, and the more accurate the recommended sentences given for the input strings.
[0193] Detailed description of step 320
[0194] In step 320, for each node in the reference sentence library tree, a downward recommendation sub-path is determined in the reference sentence library tree, and the ancestor node identifier of each node in the downward recommendation sub-path is set using the node identifier of the node.
[0195] In one embodiment, reference is made to Figure 8 Step 320 includes:
[0196] Step 810: Assign ascending node identifiers to each node in the reference sentence library tree;
[0197] Step 820: Extract the nodes from the reference sentence library tree in ascending order, and determine the downward recommendation sub-path for each extracted node in the reference sentence library tree;
[0198] Step 830: For the sub-path nodes in the downward recommendation sub-path, if the sub-path node does not have an ancestor node identifier set, set the ancestor node identifier to the node identifier; if the sub-path node has an ancestor node identifier set, keep the set ancestor node identifier.
[0199] Steps 810 and 830 are described in detail below.
[0200] In step 810, ascending node identifiers are assigned to each node in the reference sentence library tree.
[0201] After the reference sentence library tree is determined, starting from the root node, node identifiers are assigned to each node in the tree in ascending order, from top to bottom. In this case, the node identifier of each node in the reference sentence library tree is less than the node identifier of its corresponding next-level node. Specifically, refer to... Figure 9A , Figure 9A The sentence database tree shown is a reference sentence database tree after node identifier allocation. For node B, its next level includes nodes D, E, and F. The node identifier of node B is set to 2, node D to 4, node E to 5, and node F to 6. It is clear that the node identifier of node B is lower than the node identifiers of several nodes in its next level. Furthermore, the node identifiers of nodes A and C, which are in the same level as node B, are also lower than the node identifiers of several nodes in the next level of node B.
[0202] It should be noted that, in this embodiment of the disclosure, node identifiers can also be assigned to each node in ascending order from the bottom level of the reference sentence library tree. That is, starting from the root node of the reference sentence library tree, node identifiers are assigned to each node in the reference sentence library tree in descending order. In this case, the node identifier of each node in the reference sentence library tree is less than the node identifier of its corresponding next-level node.
[0203] It should be noted that, in this embodiment of the disclosure, a node identifier can be assigned to the root node of the top level of the reference sentence library tree. For example, assuming that ascending node identifiers are assigned to each node in the reference sentence library tree starting from the root node, the node identifier of the root node can be set to 0 or 1. Alternatively, in this embodiment of the disclosure, a node identifier may not be assigned to the root node of the top level of the reference sentence library tree.
[0204] In step 820, nodes in the reference sentence library tree are extracted in ascending order, and for each extracted node, a downward recommended sub-path is determined in the reference sentence library tree.
[0205] Assuming that the node identifiers of each node in the reference sentence library tree are assigned starting from the root node at the top level, then the nodes in the reference sentence library tree are retrieved in ascending order. Specifically, assuming the reference sentence library tree is as follows: Figure 9AAs shown, the node with node identifier 1, i.e., node A, is extracted first. Then, according to the order of the node identifiers, nodes B, C, etc., are extracted in sequence, and downward recommended sub-paths are determined for the extracted nodes in order.
[0206] It should be noted that if the node identifiers of each node in the reference sentence tree are assigned in reverse order from the root node of the top level, then the nodes in the reference sentence tree need to be retrieved in reverse order.
[0207] For each extracted node, the downward recommendation sub-paths of each node in the reference sentence library tree are determined sequentially. Specifically, the extracted node is identified as the subtree of the root node in the reference sentence library tree, and multiple paths in this subtree correspond to the extracted node. Then, the downward recommendation sub-paths corresponding to the extracted node are determined from these multiple paths.
[0208] In step 830, for the sub-path nodes in the downward recommendation sub-path, if the sub-path node does not have an ancestor node identifier set, the ancestor node identifier is set to the node identifier of the node; if the sub-path node has an ancestor node identifier set, the set ancestor node identifier is retained.
[0209] For sub-path nodes in the downward recommendation sub-path, if an ancestor node identifier has been set for a sub-path node, it means that the sub-path node is located on the downward recommendation sub-path of a previously retrieved node. To ensure that the previously retrieved node corresponds to the ancestor node identifier of each node in the downward recommendation sub-path of that node, the already set ancestor node identifier is maintained. Specifically, refer to... Figure 9B Node H has a node identifier of 8. Paths HJ and HK are recommended downward sub-paths of node H. Additionally, path EHK is a recommended downward sub-path of node E. The ancestor node identifier of node K is set to correspond to that of node E. When setting the ancestor node identifier of each node in the recommended downward sub-paths of node H, the ancestor node identifier of sub-path node K has already been set. Therefore, the ancestor node identifier of node K remains unchanged; that is, the ancestor node identifier of node K is the same as that of node E, which is 5.
[0210] For sub-path nodes in the downward recommendation sub-path, if a sub-path node does not have an ancestor node identifier set, it means that the sub-path node is not located on the downward recommendation sub-path of any previously retrieved node. In this case, the ancestor node identifier is set to the node identifier of the currently retrieved node. For example, refer to... Figure 9B For the currently retrieved node H, the ancestor node J of its corresponding downward recommended sub-path HJ has no ancestor node identifier set. Therefore, the ancestor node identifier of node J is set to be consistent with that of node H, which is 8.
[0211] It should be noted that in the reference sentence tree, if a node is not on any of the downward recommended sub-paths of its corresponding ancestor node, then the ancestor node identifier of that node can be set to empty or set to the node identifier of that node.
[0212] In the embodiments of steps 810 to 830 above, each node in the reference sentence database tree is assigned an ascending node identifier, and an ancestor node identifier is set for each sub-path node in the downward recommendation sub-path of each node in sequence. If a sub-path node already has an ancestor node identifier, the set ancestor node identifier is retained. This ancestor node identifier can correspond to the node identifier of a previously retrieved node. When the target node corresponding to the input string is a previously retrieved node, the target downward recommendation sub-path of that target node can be correctly obtained, further ensuring the accuracy of the recommended sentence. Furthermore, in this embodiment, each node only needs to store the ancestor node identifier, which significantly reduces memory usage compared to related technologies.
[0213] The above is a general description of steps 810 to 830. Step 830 has been described in sufficient detail above; the following will only describe in detail the specific implementation process of steps 810 and 820.
[0214] In step 810, ascending node identifiers are assigned to each node in the reference sentence library tree.
[0215] In one embodiment, reference is made to Figure 10 Step 810 includes:
[0216] Step 1010: Assign node identifiers to each node in the reference sentence library tree, such that the higher the layer where the node is located, the smaller the node identifier;
[0217] Step 1020: Assign node identifiers in the same layer in a manner that increases from left to right.
[0218] Steps 1010 and 1020 are described in detail below.
[0219] In step 1010, node identifiers are assigned to each node in the reference sentence library tree, such that the higher the layer in which the node is located, the smaller the node identifier.
[0220] Assign node identifiers to each node in the reference sentence library tree in ascending order, starting from the root node of the top level of the reference sentence library tree, so that the node identifiers of each node in the final reference sentence library tree increase from top to bottom.
[0221] In step 1020, node identifiers are assigned in the same layer in a manner that increases from left to right.
[0222] For multiple nodes at the same level, node identifiers are assigned sequentially from left to right in ascending order, so that the node identifiers of each node at the same level in the final reference sentence library tree increase from left to right.
[0223] In one embodiment, reference is made to Figure 9A Node identifiers are assigned in ascending order, starting from the root node. First, nodes at the next level down from the root node (the second level of the reference sentence library tree) are extracted. These nodes are A, B, and C, arranged from left to right in the tree. The node identifier for A is set to 1, for B to 2, and for C to 3. After determining the identifiers for the nodes at the second level, node identifiers are assigned to the nodes at the third level. The leftmost node at this level is D, and its identifier is set to 4, making it greater than all other identifiers at the second level. Then, node identifiers are assigned to each node in the reference sentence library tree sequentially. After the identifiers are assigned, the higher the level a node is at, the smaller its identifier. For multiple nodes at the same level, the further left a node is at, the smaller its identifier.
[0224] It should be noted that, in the embodiments of this disclosure, node identifiers can also be allocated in the same layer in a manner that the node identifiers gradually decrease from left to right, or node identifiers can be allocated in the same layer in a random manner, as long as the node identifier of a node is less than the node identifiers of the multiple child nodes corresponding to that node.
[0225] The embodiments of steps 1010 and 1020 above assign node identifiers to each node in the reference sentence library tree, such that the higher the layer a node is in, the smaller its node identifier; and within the same layer, the further to the left a node is, the smaller its node identifier. The node identifier settings are determined based on the position of each node in the reference sentence library tree, ensuring that the ancestor node identifiers of each node in the downward recommendation sub-path are systematically ordered. This allows for the rapid determination of the target node's target downward recommendation path, shortening the sentence recommendation time.
[0226] In another embodiment, the reference sentences in the reference sentence set are added based on the input sentences of the object in applying the statement recommendation method. When a new reference sentence is added, a path corresponding to the new reference sentence is added to the reference sentence library tree, which includes at least one new node. The node identifiers of each node in the reference sentence library tree can be renumbered, or node identifiers can be assigned individually to new nodes. The node identifiers of multiple new nodes are greater than the node identifiers of all nodes in the original reference sentence library tree, and the node identifiers of upper-level new nodes are greater than the node identifiers of lower-level new nodes. For new paths, the higher the level of the new node, the smaller its node identifier.
[0227] In step 820, the nodes in the reference sentence library tree are sequentially extracted in ascending order, and for the extracted nodes, the downward recommendation sub-path is determined in the reference sentence library tree.
[0228] In one embodiment, reference is made to Figure 11 Step 820 includes:
[0229] Step 1110: For the extracted node, determine multiple candidate downward paths for the node in the reference sentence library tree;
[0230] Step 1120: Obtain the candidate substring corresponding to each candidate downward sub-path;
[0231] Step 1130: Based on the target object, after inputting the input string, input the first frequency of each candidate string, and determine the score corresponding to each candidate downward sub-path;
[0232] Step 1140: Based on the scores corresponding to each candidate downward sub-path, determine the recommended downward sub-path among each candidate downward sub-path.
[0233] Steps 1110 to 1140 are described in detail below.
[0234] In step 1110, for the extracted node, multiple candidate downward paths for the node are determined in the reference sentence library tree.
[0235] A candidate downward path is a path determined by extending downwards from the retrieved node in the reference sentence library tree. The starting point of a candidate downward path is the retrieved node, and the ending point is either a leaf node or another node located below the retrieved node.
[0236] Reference Figure 9A If the extracted node is node E, then the multiple candidate downward paths of this node are EG, EHJ, EHK, EHL and EI.
[0237] In step 1120, the candidate substring corresponding to each candidate downward sub-path is obtained.
[0238] Candidate strings refer to the strings corresponding to candidate downward paths. Candidate strings are determined based on the strings corresponding to multiple nodes traversed by the candidate downward path.
[0239] In step 1130, based on the first frequency of each candidate string after the target object inputs the input string, the score corresponding to each candidate downward sub-path is determined.
[0240] The target object refers to the object containing the input string, and it is also the object to which the recommendation statement is made. For Figure 2The interface shown is for the object that is entered using the input method: "J nt i an".
[0241] First frequency refers to the measure of how frequently a target user inputs each candidate string after using the input method recommended by the application statement, i.e., after inputting the input string. The higher the first frequency, the more frequently the candidate string is input.
[0242] The score of a candidate downward path measures the likelihood of an object selecting a candidate string. A higher score indicates a greater likelihood that the object will choose the candidate string corresponding to that path. Furthermore, the score of a candidate downward path is determined based on a primary frequency; the score is directly proportional to the primary frequency, and a higher primary frequency results in a higher score. Therefore, the more frequently the target object inputs candidate strings after receiving the input string, the higher the score of the corresponding candidate downward path will be.
[0243] There are many methods for determining the scores of candidate downward paths based on the first frequency. For example, the scores of candidate downward paths can be determined by looking up the first frequency in a table. An increasing function can also be established between the scores of candidate downward paths and the first frequency to satisfy the condition that the higher the first frequency, the higher the score.
[0244] In step 1140, based on the scores corresponding to each candidate downward sub-path, a downward recommended sub-path is determined among each candidate downward sub-path.
[0245] The recommended downward path is determined based on the scores of each candidate downward path. The higher the score of a candidate downward path, the greater its likelihood of becoming a recommended downward path.
[0246] If the number of recommended statements provided to the target audience needs to be a fixed value, then multiple candidate downward paths need to be sorted first, and a preset number of paths are selected as downward recommended paths from the sorted candidate downward paths. The preset number is consistent with the fixed value of the number of recommended statements. The downward recommended paths can also be determined based on the scores of the candidate downward paths; candidate downward paths with scores greater than a preset score are selected as downward recommended paths. The preset score can be determined according to actual needs. Furthermore, the number of downward recommended paths can also be determined based on the candidate downward paths. Specifically, this embodiment of the disclosure sets a preset coefficient, and the number of downward recommended paths is determined based on the preset coefficient and the number of candidate downward paths. Then, downward recommended paths are selected from the sorted candidate downward paths based on this number.
[0247] In one embodiment, in Figure 4AIn the reference sentence library tree shown, if node E is the retrieved node, then there are a total of 5 candidate downward paths, and the candidate strings corresponding to the 5 candidate downward paths are BEG, BEHJ, BEHK, BEHL, and BEI, respectively. (Refer to...) Figure 12 Based on the first frequency of each candidate string after the target object inputs the input string, the score corresponding to each candidate downward sub-path is determined. The score for candidate downward sub-path 1 is 57, for candidate downward sub-path 2 it is 62, for candidate downward sub-path 3 it is 93, for candidate downward sub-path 4L it is 76, and for candidate downward sub-path 5 it is 88. If the preset number is set to 2, the candidate downward sub-paths corresponding to candidate strings BEHK and BE I are used as the recommended downward sub-paths for node E. If the preset score is set to 80, the paths with scores greater than 80, i.e., candidate downward sub-paths 3 and 5, are used as the recommended downward sub-paths for node E.
[0248] Steps 1110 to 1140 above determine the downward recommendation path based on the scores corresponding to each candidate downward sub-path. Since the scores corresponding to the candidate downward sub-paths are determined based on the first frequency of the target object's input candidate string, the higher the probability that the target object will input the downward recommendation path, the higher the probability that the target object will input the string corresponding to the target's downward recommendation path after inputting the target string, and the higher the accuracy of the final determined recommendation statement, thereby improving the accuracy of the recommendation statement.
[0249] The above is a general description of steps 1110 to 1140. Since step 1140 has been explained in sufficient detail above, the specific implementation process of steps 1110 to 1130 will be described in detail below.
[0250] In step 1110, for the extracted node, multiple candidate downward paths for the node are determined in the reference sentence library tree.
[0251] In one embodiment, reference is made to Figure 13 Step 1110 includes:
[0252] Step 1310: Use the extracted node as the first anchor node;
[0253] Step 1320: Execute the first process, which includes: determining each lower-level node connected to the first anchor node in the reference sentence tree, updating the first anchor node with each lower-level node, repeating the first process until a leaf node is reached, which is a node that is not connected to a lower-level node.
[0254] Step 1330: Take the ordered set of all nodes that the node taken out in the first process passes through to reach a leaf node as a candidate downward path.
[0255] Steps 1310 to 1330 are described in detail below.
[0256] In step 1310, the extracted node is used as the first anchor node.
[0257] The first anchor node is the node retrieved sequentially from the reference sentence library tree in ascending order. For example, for Figure 4A If node B is the currently retrieved node, then node A will be used as the first anchor node.
[0258] In step 1320, a first process is performed, which includes: determining each lower-level node connected to the first anchor node in the reference sentence tree, updating the first anchor node with each lower-level node, and repeating the first process until a leaf node is reached, which is a node that is not connected to a lower-level node.
[0259] The first process refers to the traversal from the first anchor node down to the lower-level nodes. Specifically, refer to... Figure 4A If the first anchor node is node B, first determine the multiple lower-level nodes connected to the first anchor node, i.e., the multiple child nodes of node B, namely nodes D, E, and F. Nodes D and F are leaf nodes of the reference sentence library tree, so the traversal stops at nodes D and F. Node E is not a leaf node, therefore, node E is updated to the first anchor node, and the traversal to the lower levels is repeated until a leaf node is reached.
[0260] In step 1330, the ordered set of all nodes that the node is taken from the extracted node to a leaf node in the first process is taken as a candidate downward path.
[0261] The candidate downward path is an ordered set of all nodes traversed from the extracted node to a leaf node in the first process. (Refer to...) Figure 4A The node extracted is node B. For leaf node G, the candidate downward paths are the set of nodes B, E and G.
[0262] It should be noted that the endpoint of a candidate downward path can also be a node in the lower level of the extracted node. For example, refer to... Figure 7A "I know" is a complete reference sentence. Therefore, if the extracted node is the node "I", then the ordered combination of the nodes "I", "know", and "way" is a candidate downward path.
[0263] In the embodiments of the above steps 1310 to 1330, the candidate downward sub-paths of the extraction node are determined by executing the first process. In the first process, the traversal of the nodes one layer below the first anchor node ensures that all candidate downward sub-paths of the extraction node in the reference sentence library tree can be exhausted, making the obtained recommended downward sub-paths more accurate and reliable. Moreover, the first process can ensure the integrity of the reference sentences determined based on the candidate downward sub-paths, the extracted node, and its corresponding ancestor nodes, thereby ensuring the accuracy of the recommended sentences.
[0264] In step 1120, the candidate character strings corresponding to each candidate downward sub-path are obtained.
[0265] In one embodiment, referring to Figure 14 , step 1120 includes:
[0266] Step 1410: For each candidate downward sub-path, obtain the characters corresponding to each node in the candidate downward sub-path;
[0267] Step 1420: Concatenate the characters in the order of the nodes in the candidate downward sub-path to form a candidate character string.
[0268] [[ID=,17]]The following provides a detailed description of steps 1410 and 1420.
[0269] In step 1410, for each candidate downward sub-path, obtain the characters corresponding to each node in the candidate downward sub-path.
[0270] A candidate downward sub-path passes through multiple nodes. For each candidate downward sub-path, determine the characters corresponding to each node in the candidate sentence library tree. For example, referring to Figure 4B , assuming that the extracted node is the node "not", and one of the candidate downward sub-paths successively passes through the nodes with node identifiers 5 and 7, then the characters corresponding to the multiple nodes in this candidate downward sub-path are "not" and "understand" respectively.
[0271] In step 1420, concatenate the characters in the order of the nodes in the candidate downward sub-path to form a candidate character string.
[0272] The candidate character string is determined based on the various nodes passed through by the candidate downward sub-path. After determining the characters corresponding to each node, concatenate the characters in the order of the nodes in the candidate downward sub-path to form a candidate character string. It should be noted that the multiple characters are concatenated in ascending order of the levels of the corresponding nodes.
[0273] In addition, the node identifiers of the various nodes in the candidate downward sub-path are determined, and the node identifiers are assigned to the nodes in ascending order starting from the root node. Then, it is also possible to obtain the node identifiers corresponding to each node in the candidate downward sub-path and concatenate the characters in ascending order of the node identifiers to obtain the candidate character string.
[0274] Refer to Figure 4B , refer to Figure 4B , assuming the retrieved node is the node "not", and the characters corresponding to each node in one of the candidate downward branching paths are "not", "understand", and "clear" respectively. Concatenate the multiple characters in the order of the nodes in the candidate downward branching path to obtain the candidate character string "not understand".
[0275] In the embodiments of step 1410 and step 1420 above, for each candidate downward branching path, the characters corresponding to the respective nodes passed through are concatenated into a candidate character string in the order of the nodes in the candidate downward branching path, so that the word order of the obtained candidate character string is correct, ensuring the accuracy of the scores of each candidate downward branching path, and further improving the accuracy of sentence recommendation.
[0276] In step 1130, based on the first frequency of each candidate character string input by the target object after inputting the input character string, determine the score corresponding to each candidate downward branching path.
[0277] In one embodiment, refer to Figure 15 , step 1130 includes:[[]]
[0278] Step 1510, obtain the respective first counts of each candidate character string input by the target object after inputting the input character string within a predetermined time period before the current time;
[0279] Step 1520, based on the respective first counts and the duration of the predetermined time period, determine the first frequency of inputting each candidate character string;
[0280] Step 1530, based on the first frequency of inputting each candidate character string, determine the score corresponding to each candidate downward branching path.
[0281] The following describes steps 1510 to 1530 in detail.
[0282] In step 1510, obtain the respective first counts of each candidate character string input by the target object after inputting the input character string within a predetermined time period before the current time.
[0283] The predetermined time period refers to the time period for counting the first counts of each candidate character string. The specific duration of the predetermined time period can be set as needed, and it can also be determined according to the usage duration of the target object in the input method application constructed based on the embodiments of the present disclosure.
[0284] The first count refers to the number of times the target object inputs the candidate character string within the predetermined time period between the current times. The first count corresponds to the candidate character string. If the number of times the target object inputs candidate character string A within the predetermined time period between the current times is 10 times, then the first count corresponding to candidate character string A is 10.
[0285] In step 1520, the first frequency of each input candidate string is determined based on each first number and the duration of the predetermined time period.
[0286] The first frequency of the candidate string is determined based on the first count and the duration of a predetermined time period. Specifically, in this embodiment, the ratio of the first count to the duration of the predetermined time period is used as the first frequency, i.e., first frequency = first count / duration of the predetermined time period. Assuming that the target object inputs the candidate string 60 times in the 10 minutes between the current time and the input string, then the first frequency is 10 times per minute.
[0287] In step 1530, the score corresponding to each candidate downward sub-path is determined based on the first frequency of each candidate string.
[0288] The score of a candidate downward path is determined based on the first frequency of the candidate string. The score is directly proportional to the first frequency; the higher the first frequency, the higher the score. The score of a candidate downward path can be determined by methods such as table lookup or establishing a functional relationship.
[0289] Reference Figure 16 Assuming multiple candidate downward paths correspond to candidate strings A, B, C, ..., N, the first input count of each candidate string is determined within a predetermined time period before the current time. Based on this first count and the duration of the predetermined time period, a first frequency is determined, thus obtaining the score of the candidate downward path. For example, for candidate string A, the first input count A within the predetermined time period before the current time is taken as the first count A. The ratio of the first count A to the duration of the predetermined time period is taken as the first frequency A. Then, methods such as lookup tables and functional relationships can be used to process the first frequency A to determine the score A of the candidate downward path A.
[0290] The embodiments of steps 1510 to 1530 above determine the first frequency based on the first occurrence of each candidate string after the input string within a predetermined time period before the current time, and the duration of the predetermined time period, thereby determining the score of the candidate downward sub-path. Since the score of the candidate downward sub-path is determined based on the target object, the downward recommendation sub-path determined from each candidate downward sub-path based on the score is more in line with the needs of the target object, thus improving the accuracy of the recommended statement.
[0291] In another embodiment, reference Figure 17 Step 1130 includes:
[0292] Step 1710: Obtain the second frequency of each candidate string after the input string is entered into the target platform. The target platform is the platform used by the statement recommendation method. The target platform includes multiple platform objects, and the multiple platform objects include the target object.
[0293] Step 1720: Determine the total frequency based on the first frequency and the second frequency;
[0294] Step 1730: Based on the total frequency, determine the score corresponding to each candidate downward sub-path.
[0295] Steps 1710 to 1730 are described in detail below.
[0296] In step 1710, the second frequency of each candidate string is obtained after the input string is input to the target platform. The target platform is the platform to which the statement recommendation method is applied. The target platform includes multiple platform objects, and the multiple platform objects include the target object.
[0297] The target platform is the platform on which the statement recommendation method is applied. Figure 2 In the input method interface shown, the target platform refers to the platform on which the input method is located. A platform object refers to an object that uses the statement recommendation service on the target platform; multiple platform objects include the target object.
[0298] The second frequency refers to the frequency with which multiple platform objects on the target platform input each candidate string after inputting the input string. It can measure the frequency of input of each candidate string on the target platform.
[0299] In step 1720, the total frequency is determined based on the first frequency and the second frequency.
[0300] Total frequency is a metric used to measure the overall frequency of input for each candidate string. Total frequency is determined based on the first frequency and the second frequency. There are various methods for determining the total frequency; it can be the average of the first and second frequencies, or it can be determined using lookup tables, functional relationships, etc.
[0301] In step 1730, the score corresponding to each candidate downward sub-path is determined based on the total frequency.
[0302] The score of a candidate downward path measures the likelihood of an object selecting a candidate string. A higher score indicates a greater likelihood that the object will choose the candidate string corresponding to that path. Furthermore, the score is determined based on the total frequency; the score is directly proportional to the total frequency, meaning a higher total frequency results in a higher score. Therefore, the more frequently the target object inputs candidate strings after receiving the input string, the higher the score of the corresponding candidate downward path will be.
[0303] There are many methods for determining the scores of candidate downward sub-paths based on the total frequency. For example, the scores of candidate downward sub-paths can be determined by looking up the total frequency using a lookup table. An increasing function can also be established between the scores of candidate downward sub-paths and the first frequency, for example, y = ax + b, where y is the score of the candidate downward sub-path, x is the first frequency of the candidate string, and a and b are constants.
[0304] Reference Figure 18 The second frequency of each candidate string is the frequency of each candidate string input by the target platform after the input string. Assuming multiple candidate strings include candidate string A, candidate string B, candidate string C, ..., candidate string N, the total frequency is determined based on the second and first frequencies of each candidate string. For example, the total frequency A of candidate string A is determined based on the first frequency A and the second frequency A. Then, based on the total frequency, the score corresponding to the downward subdivision path of each candidate string is determined.
[0305] The embodiments of steps 1710 to 1730 above determine the total frequency by using the second frequency of the target platform and the first frequency of the target object, and then determine the score of each candidate downward sub-path. Determining the second frequency makes the scores of each candidate downward sub-path more accurate. Furthermore, for input strings that the target object has not previously entered, the target downward recommendation sub-path is determined by the data from the target platform. This embodiment of the disclosure can also provide corresponding recommendation statements, thereby improving the applicability of the statement recommendation method.
[0306] The above is a general description of steps 1710 to 1730. Step 1730 has been explained in detail above. The specific implementation process of steps 1710 and 1720 will be described in detail below.
[0307] In step 1710, the second frequency of each candidate string is obtained after the input string is input to the target platform. The target platform is the platform to which the statement recommendation method is applied. The target platform includes multiple platform objects, and the multiple platform objects include the target object.
[0308] In one embodiment, reference is made to Figure 19 Step 1710 includes:
[0309] Step 1910: Obtain the second number of each candidate string after the input string in the predetermined time period before the current time on the target platform;
[0310] Step 1920: Determine the second frequency of each input candidate string based on each second number and the duration of the predetermined time period.
[0311] Steps 1910 and 1920 are described in detail below.
[0312] In step 1910, the second count of each candidate string input after the input string is obtained within a predetermined time period before the current time on the target platform.
[0313] The predetermined time period refers to the time interval during which the second occurrence of each candidate string is counted. The specific duration of the predetermined time period can be set as needed. It can also be determined based on the usage time of multiple target objects on the target platform.
[0314] The second count refers to the number of times the target platform inputs the candidate string within a predetermined time period between the current times; that is, the number of times multiple platform objects input the candidate string within a predetermined time period between the current times. The second count corresponds to the candidate string. If the target platform inputs candidate string A 360 times within a predetermined time period between the current times, then the first count for candidate string A is 360.
[0315] In step 1920, the second frequency of each input candidate string is determined based on each second number and the duration of the predetermined time period.
[0316] The second frequency of the candidate string is determined based on the second number and the duration of the predetermined time period. Specifically, in this embodiment, the ratio of the second number to the duration of the predetermined time period is used as the second frequency, i.e., second frequency = second number / duration of the predetermined time period. Assuming that the target platform inputs the candidate string 3600 times after inputting the input string within one hour between the current time and the input string, then the first frequency is 60 times per minute.
[0317] Reference Figure 20 Assuming multiple candidate downward paths correspond to candidate strings A, B, C, ..., N, the second number of times each candidate string is input within a predetermined time period before the current time is determined. Based on this second number and the duration of the predetermined time period, a second frequency is determined, thus obtaining the score for each candidate downward path. For example, the number of times candidate string A is input within the predetermined time period before the current time is the second number A, and the ratio of the second number A to the duration of the predetermined time period is taken as the second frequency A.
[0318] The embodiments of steps 1910 and 1920 above determine a second frequency based on the second number of times each candidate string is input after the input string within a predetermined time period before the current time on the target platform, and the duration of the predetermined time period. This second frequency is then used to determine the score of the candidate downward recommendation path based on the first and second frequencies. For input strings that have not been input before, the setting of the second frequency can determine the target downward recommendation path corresponding to the input string, thus improving the applicability of the statement recommendation method.
[0319] In step 1720, the total frequency is determined based on the first frequency and the second frequency.
[0320] In one embodiment, reference is made to Figure 21 Step 1720 includes:
[0321] Step 2110: Obtain the first weight of the first frequency and the second weight of the second frequency;
[0322] Step 2120: Based on the first weight and the second weight, perform a weighted sum of the first frequency and the second frequency to obtain the total frequency.
[0323] Steps 2110 and 2220 are described in detail below.
[0324] In step 2110, the first weight of the first frequency and the second weight of the second frequency are obtained.
[0325] The first weight refers to the weight of the first frequency in the total frequency, and the second weight refers to the weight of the second frequency in the total frequency. Since the total frequency is determined based on the first and second frequencies, the sum of the first and second weights is 1. Assuming the first weight of the first frequency is 0.7, the second weight of the second frequency is 0.3.
[0326] It's important to note that a larger first weight and a smaller second weight, indicating a higher proportion of the first frequency in the total frequency and a lower proportion of the second frequency, will lead to a downward recommendation path that favors the selection of the target object. Conversely, a smaller first weight and a larger second weight, indicating a lower proportion of the first frequency in the total frequency and a higher proportion of the second frequency, will lead to a downward recommendation path that favors the selection of multiple platform objects within the target platform. The specific settings for the first and second weights can be determined based on the downward recommendation path's bias towards the target object and target platform.
[0327] In step 2120, the first frequency and the second frequency are weighted and summed based on the first weight and the second weight to obtain the total frequency.
[0328] The total frequency is a weighted sum of the first and second frequencies. The formula for calculating the total frequency can be expressed as:
[0329] f total =αf1 + βf2,
[0330] Among them, f total Let f1 be the total frequency of the candidate strings, α be the first frequency, f2 be the second frequency, and β be the second weight. Assuming the first frequency is 10 times per minute and the first weight is 0.7, the second frequency is 60 times per minute and the second weight is 0.3, then the total frequency is 21 times per minute.
[0331] In the embodiments of steps 2110 and 2120 above, the total frequency is obtained by calculating the weighted sum of the first frequency and the second frequency. The first weight and the second weight are set to balance the first frequency and the second frequency in the total frequency, so that the accuracy of the finally determined recommended statement is higher.
[0332] Detailed description of step 340
[0333] In step 340, based on the order of each word in the input string, traversal starts from the root node in the reference sentence library tree until the target node corresponding to the last word in the input string is found.
[0334] In one embodiment, referring to Figure 22 , step 340 includes:
[0335] Step 2210: Take the first word in the input string as the first anchor word and the root node as the third anchor node;
[0336] Step 2220: Execute the third process.
[0337] Among them, the third process includes:
[0338] Step 2221: Search for the node corresponding to the first anchor word among the nodes at the next lower level of the third anchor node, and update the third anchor node with the found node; <00007I94>Step 2222: Update the first anchor word with the next word after the first anchor word. If the first anchor word is not the last word, repeat the third process until the first anchor word is the last word, and determine the node corresponding to the first anchor word as the target node.
[0340] The following gives a detailed description of step 2210 and step 22I0.
[0341] In step 2210, take the first word in the input string as the first anchor word and the root node as the third anchor node.
[0342] The first anchor word is the first word in the input string, and the third anchor node is the root node at the topmost layer of the reference sentence library tree. Assume the input string is "I don't", then take "I" as the first anchor word and the root node as the third anchor node.
[0343] In step 2220, execute the third process. The third process refers to the process of determining the target node corresponding to the last word in the input string based on the input string in the reference sentence library tree.
[0344] The execution of the third process is specifically realized through step 2221 and step 2222.
[0345] In step 2221, search for the node corresponding to the first anchor word among the nodes at the lower layer of the third anchor node, and update the third anchor node with the found node.
[0346] The nodes at the lower layer of the third anchor node refer to the multiple child nodes of the third anchor node. Determine the node with the first anchor word written on it among the multiple child nodes of the third anchor node, and use this node as the new first anchor node. Refer to Figure 4B , assuming the input string is "I don't", the first anchor word is "I", and the nodes at the lower layer of the third anchor node, that is, the root node, are respectively the node "you", the node "I", and the node "he". The node "I" corresponds to the first anchor word, and it is used as the new third anchor node.
[0347] In step 2222, update the first anchor word with the next word of the first anchor word. If the first anchor word is not the last word, repeat the third process until the first anchor word is the last word, and determine the node corresponding to the first anchor word as the target node.
[0348] After the third anchor node is updated, update the first anchor word. Specifically, use the next word of the first anchor word as the new first anchor word. If the first anchor word is not the last word, repeat the update of the third anchor node and the first anchor word until the first anchor word is the last word of the input string, and determine the node corresponding to the first anchor word as the target node.
[0349] Refer to Figure 4B , the input string is "I don't", the first anchor word is "I". First, search for the node corresponding to "I" among the nodes at the lower layer of the root node, that is, the third anchor node, and update the third anchor node with the node "I". Then, use "don't" as the new first anchor word. Among the child nodes of the third anchor node, determine that the node "don't" corresponds to the first anchor word. And "don't" is the last word of the input string, so the node "don't" is used as the target node.
[0350] The embodiments of the above steps 2210 and 2220 are provided with a third process, and traverse in the reference sentence library tree through the third process to search for the target node corresponding to the last word of the input string, determine the accurate position of the target node, and facilitate the search for the target downward recommendation sub-path of the target node.
[0351] In one embodiment, refer to Figure 23 , after step 2221, the third process includes:
[0352] Step 2310, if the node corresponding to the first anchor word is not found among the nodes at the lower layer, determine the semantic similarity degree between the words corresponding to each node at the lower layer and the first anchor word;
[0353] Step 2320: Determine the distance between the word corresponding to each lower-level node and the first anchor word in the knowledge graph;
[0354] Step 2330: Based on the semantic similarity and distance, determine the target lower-level node among each lower-level node;
[0355] Step 2340: Update the third anchor node with the target lower-level node.
[0356] The following provides a detailed description of Steps 2310 to 2340.
[0357] In Step 2310, if no node corresponding to the first anchor word is found among the lower-level nodes, determine the semantic similarity between the word corresponding to each lower-level node and the first anchor word.
[0358] The semantic similarity refers to the degree of approximation in semantics between the word corresponding to the lower-level node of the third anchor node and the first anchor word.
[0359] If no node corresponding to the first anchor word is found among the lower-level nodes, it means that there is no reference sentence with the input string as the prefix among the multiple reference sentences corresponding to the current reference sentence library tree. Then, in order to obtain the recommended sentence, it is necessary to determine the semantic similarity between the word corresponding to each lower-level node and the first anchor word.
[0360] In one embodiment, referring to Figure 24A , assume that the input string is "I like", the first anchor word is "like", and there is no node corresponding to the first anchor word among the lower-level nodes corresponding to the node "I". Then, it is necessary to determine the semantic similarity between the words corresponding to the nodes "am", "love", and "not" and the first anchor word "like" respectively.
[0361] In Step 2320, determine the distance between the word corresponding to each lower-level node and the first anchor word in the knowledge graph.
[0362] The knowledge graph is a structured semantic knowledge base used to quickly describe the concepts in the physical world and their interrelationships. It effectively processes, processes, and integrates the data of complex documents, transforms them into simple and clear "entity, relationship, entity" triples, and finally aggregates a large amount of knowledge to achieve rapid response and reasoning of knowledge.
[0363] The distance between two words in the knowledge graph can represent the semantic correlation between the two words. The smaller the distance, the stronger the semantic correlation between the two words.
[0364] In Step 2330, based on the semantic similarity and distance, determine the target lower-level node among each lower-level node.
[0365] Based on semantic similarity and distance, determine the word closest to the first anchor word among the words corresponding to each lower-level node, and use the node corresponding to this word as the target lower-level node.
[0366] It should be noted that in the embodiments of the present disclosure, weights corresponding to semantic similarity and distance can be set, and the semantic similarity and distance are weighted and summed through these weights, so as to determine the target lower-level node among each lower-level node based on the weighted sum.
[0367] In one embodiment, referring to Figure 24A , assume that the input string is "I like", the first anchor word is "like", and there is no node corresponding to the first anchor word among the lower-level nodes corresponding to the node "I". Then, determine the semantic similarity between the word corresponding to the lower-level node of the node "I" and the first anchor word, and the distance from the first anchor word in the knowledge graph. Referring to Figure 24B , the semantic similarity between the word corresponding to the node "be" and the first anchor word is 30%, and the knowledge graph distance is 8; the semantic similarity between the word corresponding to the node "love" and the first anchor word is 90%, and the knowledge graph distance is 2; the semantic similarity between the word corresponding to the node "not" and the first anchor word is 20%, and the knowledge graph distance is 7. The higher the semantic similarity and the smaller the knowledge graph distance, the closer the similarity between the two words. Therefore, the node "love" is used as the target lower-level node.
[0368] In step 2340, update the third anchor node with the target lower-level node.
[0369] Use the target lower-level node as the new third anchor node to continue traversing the reference sentence library tree to determine the target node corresponding to the last word of the input string.
[0370] In one embodiment, referring to Figure 24A and Figure 24B , for the input string "I like", when the first anchor word is "like", use the node "love" as the third anchor node. There is no word semantically similar to "change" among the words corresponding to the lower-level nodes of "love", and "love" can be used for synonymous replacement of "like". Therefore, the node "love" is used as the target node of the input string "I like".
[0371] When the embodiments from step 2310 to step 2340 do not find a node corresponding to the first anchor word among the lower-level nodes, the target lower-level node is determined among each lower-level node through semantic approximation and knowledge graph distance to update the third anchor node. This method can ensure that recommended sentences can be provided to the object, and the calculation of semantic similarity and knowledge graph distance makes the target node highly corresponding to the input string, thereby improving the accuracy of the recommended sentences.
[0372] Detailed description of step 350
[0373] In step 350, the target downward recommended sub-path is determined based on the ancestor node identifiers of each lower-level node of the target node.
[0374] In steps 810 to 830, ascending node identifiers are assigned to each node in the reference sentence library tree, and nodes are retrieved in ascending order to set the ancestor node identifiers of each node in the downward recommendation sub-path using the node identifiers. In this embodiment, the reference... Figure 25 Step 350 includes:
[0375] Step 2510: Use the target node as the second anchor node;
[0376] Step 2520: Perform the second process;
[0377] Step 2530: Use the ordered set of each lower-level node determined in the second process as the target to recommend a sub-path downwards.
[0378] The second process includes:
[0379] Step 2521: In the reference sentence tree, determine the node whose ancestor node identifier is less than or equal to the target node identifier among the nodes connected to the second anchor node at the next lower level;
[0380] Step 2522: If the determined node is not a leaf node, update the second anchor node with the determined node, and repeat the second process until a leaf node is reached. A leaf node is a node that is not connected to a node at the next lower level.
[0381] Steps 2510 to 2530 are described in detail below.
[0382] In step 2510, the target node is used as the second anchor node.
[0383] The second anchor node is the target node corresponding to the last character of the input string. (See reference...) Figure 4A If the input string is BE, then the second anchor node is node E. (Refer to...) Figure 4B If the input string is "I don't", then the second anchor node is the node "not".
[0384] In step 2520, the second process is executed. The second process refers to the traversal of the reference sentence library tree from the target node down to the lower-level nodes.
[0385] The second process is specifically implemented through steps 2521 and 2522.
[0386] In step 2521, the node in the reference sentence library tree that is connected to the second anchor node and whose ancestor node identifier is less than or equal to the target node identifier is determined.
[0387] The next lower level node connected to the second anchor node refers to the child node of the second anchor node, while the node whose ancestor node identifier is less than or equal to the node identifier of the target node is located on the downward recommended path of the target node.
[0388] In one embodiment, reference is made to Figure 4A The input string is BE, and the second anchor node, i.e., the target node, is node E. The next-level nodes connected to node E include nodes G, H, and I. The ancestor node identifier of node G is empty, the ancestor node identifier of node H is 5, the ancestor node identifier of node I is 5, and the node identifier of node E is 5. Therefore, in the reference sentence tree, nodes H and I are identified as the next-level nodes connected to the second anchor node.
[0389] In another embodiment, reference Figure 9B Assuming the input string is BEH and node H is the target node, the second process is executed with node H as the second anchor node. The next-level nodes connected to node H are nodes J, K, and L. The ancestor node identifier of node J is 8, the ancestor node identifier of node K is 5, and the node identifier of node L is empty. Since the node identifier of node H is 8, the determined next-level nodes are nodes J and K.
[0390] In step 2522, if the determined node is not a leaf node, the second anchor node is updated with the determined node, and the second process is repeated until a leaf node is reached. A leaf node is a node that is not connected to a node at the next lower level.
[0391] If the identified node is not a leaf node, it means that the words corresponding to the currently identified nodes and the input string cannot form a complete sentence. Therefore, the second anchor node needs to be updated with the identified node, and the second process needs to be repeated until the identified node is a leaf node.
[0392] A leaf node is a node that is not connected to any node at the next lower level; that is, a leaf node is a node that has no child nodes.
[0393] In one embodiment, reference is made to Figure 4A Assuming the input string is BE, the second process is executed with node E as the second anchor node. The initially identified nodes are node H and node I. Since node I is a leaf node, traversal of node I stops. However, node H is not a leaf node, so it needs to be used as the new anchor node. Among the multiple lower-level nodes connected to node H, node K is determined; if node K is a leaf node, traversal stops.
[0394] In step 2530, the ordered set of each lower-level node determined in the second process is used as the target to recommend a sub-path downwards.
[0395] An ordered set refers to a set in which the nodes of the next lower level, determined in the second process, are arranged in a specific order. Alternatively, it can be a set where the nodes of the next lower level are arranged in descending order of their respective levels. The target downward recommendation path refers to the result obtained by connecting multiple nodes in the ordered set.
[0396] It should be noted that when there are multiple downward recommendation paths to the target, there are also multiple ordered sets, the specific number of which is determined by the number of nodes between the leaf node and the target node.
[0397] In one embodiment, reference is made to Figure 4A For the target node E, in the second process, there are two ordered sets of each lower-level node. One ordered set is the set of nodes H and K, and the other ordered set only includes node I. Thus, the target downward recommended sub-paths are determined to be EHK and EI.
[0398] The embodiments of steps 2510 to 2530 described above include a second process, through which the target node's downward recommendation sub-path is determined. In the second process, only nodes whose ancestor node identifiers are smaller than the target node's identifier are updated as second anchor nodes, and the second process is repeated. This significantly reduces the number of traversed paths, thereby improving the generation speed of recommendation statements.
[0399] The above is a general description of steps 2510 to 2530. The second process of step 2520 will be further described below.
[0400] In one embodiment, reference is made to Figure 26 Following step 2521, the second process includes:
[0401] Step 2610: Identify that the ancestor node corresponding to the identified ancestor node is not the upstream node of the target node. The upstream node is a node in the reference sentence tree that has a downward path to the target node.
[0402] Step 2620: Discard the identified nodes.
[0403] Steps 2610 and 2620 are described in detail below.
[0404] In step 2610, the ancestor node of the identified node is not an upstream node of the target node. The upstream node is a node in the reference sentence tree that has a downward path to the target node.
[0405] An upstream node is a node in the reference sentence tree that is above the target node, and that has a downward path leading to the target node.
[0406] If the reference sentence tree is faulty, or if there are multiple overlapping nodes, the ancestor node identifier of a node record may not be the upstream node of the target node. For example, referencing... Figure 27 If the ancestor node identifier of node G is 7, which is less than the node identifier of node E (5), then node G is included in the identified nodes. The ancestor node corresponding to the ancestor identifier of node G is node D, which is not an upstream node of the target node E.
[0407] In step 2620, the identified nodes are discarded.
[0408] If the ancestor node of the identified node is not an upstream node of the target node, then the identified node is not located on the downward recommended path of node E. Therefore, the identified node needs to be discarded.
[0409] Reference Figure 27 Since the ancestor node identifier of node G is not an upstream node of the target node E, node G needs to be discarded during the second process.
[0410] The embodiments of steps 2610 and 2620 described above identify the determined nodes and determine whether the ancestor node corresponding to the node identifier of the identified node is an upstream node of the target node. If not, the determined node is discarded, thereby ensuring the accuracy of the recommended sentences. In addition, this identification process is applicable to situations such as errors in the reference sentence library tree and the existence of multiple node intersections, thus expanding the applicability of the sentence recommendation method.
[0411] In step 350, a recommended statement is determined by recommending a sub-path based on the input string and the target.
[0412] In one embodiment, reference is made to Figure 28 Step 350 includes:
[0413] Step 2810: Connect the characters corresponding to each node in the downward recommendation path of the target to obtain the predicted character string;
[0414] Step 2820: Concatenate the input string and the predicted string to obtain the recommended statement.
[0415] Steps 2810 and 2820 are described in detail below.
[0416] In step 2810, the characters corresponding to each node in the target downward recommendation sub-path are concatenated to obtain the predicted character string.
[0417] The predicted string refers to the result obtained by concatenating the characters corresponding to each node in the downward recommendation path of the target. (See reference...) Figure 4A If the multiple nodes in the downward recommended path of the target are node E, node H and node K respectively, then the predicted string is EHK.
[0418] In step 2820, the input string and the predicted string are concatenated to obtain the recommended statement. The recommended statement is the concatenation result of the input string and the predicted string.
[0419] It should be noted that the last character of the input string is the same as the last character of the prediction string. Therefore, one of the characters needs to be deleted before concatenating the input string and the prediction string to obtain the recommended statement.
[0420] Reference Figure 4A If the input string is BE and the predicted string is EHK, then the recommended statement is BEHK. (See reference...) Figure 4B If the input string is "I don't", and the predicted string is "Understand", then the recommended statement is "I don't understand".
[0421] The embodiments of steps 2810 and 2820 above connect the characters corresponding to each node in the target downward recommendation sub-path to obtain the predicted character string. Then, the recommended statement is determined based on the predicted character string and the input character string to ensure that the predicted character string and the input character string can be correctly connected to obtain the correct recommended statement.
[0422] Detailed implementation diagrams of the statement recommendation method in this embodiment.
[0423] The following reference Figure 29 The following provides a detailed and exemplary description of the implementation details of the statement recommendation method in the embodiments of this disclosure.
[0424] In step 2910, a set of reference sentences is obtained, wherein the set of reference sentences includes multiple reference sentences.
[0425] In step 2920, a reference sentence library tree is determined based on the reference sentence set.
[0426] In one embodiment, for each reference sentence, the first character of the reference sentence is used as the second anchor character, and the root node is used as the first anchor layer. Then, a fourth process is executed. The fourth process includes: when it is determined that there is no second anchor character in the layer below the first anchor layer, the second anchor character is written into the layer below the first anchor layer as a node in the layer below the first anchor layer; when it is determined that there is a second anchor character in the layer below the first anchor layer, the second anchor character is not written; the second anchor character is updated with the next character in the reference sentence, and the first anchor layer is updated with the layer below the first anchor layer; the fourth process is repeated until multiple reference sentences have been traversed.
[0427] In step 2931, ascending node identifiers are assigned to each node in the reference sentence library tree.
[0428] In one embodiment, node identifiers are assigned to each node in the reference sentence tree, such that the higher the layer a node is in, the smaller the node identifier. Within the same layer, node identifiers are assigned in ascending order from left to right.
[0429] In step 2932, nodes in the reference sentence library tree are retrieved in ascending order.
[0430] In step 2933, for the extracted node, multiple candidate downward paths for the node are determined in the reference sentence library tree.
[0431] In one embodiment, the extracted node is used as the first anchor node. Then, a first process is executed, which includes: determining each lower-level node connected to the first anchor node in the reference sentence tree, updating the first anchor node with each lower-level node, and repeating the first process until a leaf node is reached. A leaf node is a node that is not connected to any lower-level node. The ordered set of all nodes traversed from the extracted node to a leaf node in the first process is used as a candidate downward path.
[0432] In step 2934, the candidate substring corresponding to each candidate downward sub-path is obtained.
[0433] In one embodiment, for each candidate downward sub-path, the character corresponding to each node in the candidate downward sub-path is obtained. The characters are then concatenated into a candidate character string according to the order of the nodes in the candidate downward sub-path.
[0434] In step 2935, based on the first frequency of each candidate string after the target object inputs the input string, the score corresponding to each candidate downward sub-path is determined.
[0435] In one embodiment, the second frequency of each candidate string input after the input string is obtained by the target platform. The target platform is the platform to which the statement recommendation method is applied, and includes multiple platform objects, including the target object. Based on the first and second frequencies, the total frequency is determined. Based on the total frequency, the score corresponding to each candidate's downward sub-path is determined.
[0436] In one embodiment, the first occurrence count of each candidate string inputted by the target object within a predetermined time period before the current time, following the input string, is obtained. Based on each first occurrence count and the duration of the predetermined time period, the first frequency of each candidate string input is determined.
[0437] In one embodiment, the second frequency of each candidate string input after the input string is obtained within a predetermined time period before the current time on the target platform. Based on each second frequency and the duration of the predetermined time period, the second frequency of each candidate string input is determined.
[0438] In step 2936, based on the scores corresponding to each candidate downward sub-path, a recommended downward sub-path is determined from each candidate downward sub-path. For sub-path nodes in the recommended downward sub-path, if the sub-path node does not have an ancestor node identifier set, the ancestor node identifier is set to the node identifier of the node; if the sub-path node has an ancestor node identifier set, the set ancestor node identifier is retained.
[0439] In step 2940, the input string is received.
[0440] In step 2951, the first character in the input string is taken as the first anchor character, and the root node is taken as the third anchor node.
[0441] In step 2952, a third process is performed, which includes: searching for the node corresponding to the first anchor word in the next lower level node of the third anchor node, updating the third anchor node with the found node, updating the first anchor word with the next word of the first anchor word, repeating the third process if the first anchor word is not the last word, until the first anchor word is the last word, and determining the node corresponding to the first anchor word as the target node.
[0442] In one embodiment, if no node corresponding to the first anchor word is found in the next lower level nodes, the semantic similarity between the words corresponding to each next lower level node and the first anchor word is determined. The distance between the words corresponding to each next lower level node and the first anchor word in the knowledge graph is determined. Based on the semantic similarity and distance, a target next lower level node is determined in each next lower level node. The third anchor node is updated using the target next lower level node.
[0443] In step 2953, the target node corresponding to the last character in the input string is determined.
[0444] In step 2960, the target node is designated as the second anchor node. A second process is executed, which includes: identifying nodes in the reference sentence tree that are connected to the second anchor node and whose ancestor node identifier is less than or equal to the target node's identifier. If the identified node is not a leaf node, the second anchor node is updated with the identified node. This second process is repeated until a leaf node is reached (a leaf node is a node not connected to any lower-level node). The ordered set of all lower-level nodes identified in the second process is used as the target to recommend a downward sub-path.
[0445] In one embodiment, if the ancestor node of the identified node is not an upstream node of the target node, the identified node needs to be discarded. Here, the upstream node is a node in the reference sentence tree that has a downward path to the target node.
[0446] In step 2970, the target downward recommendation sub-path of the target node is determined based on the ancestor node identifiers of each lower-level node of the target node, and the recommendation statement is determined based on the input string and the target downward recommendation sub-path.
[0447] In one embodiment, the target node is used as the second anchor node. A second process is performed, which includes: determining, in the reference sentence tree, nodes in the next lower level connected to the second anchor node whose ancestor node identifier is less than or equal to the target node's identifier; if the determined node is not a leaf node, updating the second anchor node with the determined node, and repeating the second process until a leaf node is reached (a leaf node is a node not connected to any next lower level node). The ordered set of each next lower level node determined in the second process is used as the target to recommend a sub-path downwards.
[0448] It should be noted that if the ancestor node identified by the identified node is not an upstream node of the target node, the identified node will be discarded. An upstream node is a node in the reference sentence tree from which there exists a downward path to the target node.
[0449] In one embodiment, the characters corresponding to each node in the downward recommendation path of the target are concatenated to obtain the predicted character string. The input character string and the predicted character string are then concatenated to obtain the recommended statement.
[0450] Description of apparatus and devices according to embodiments of this disclosure
[0451] It is understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this embodiment, 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 above flowcharts 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 in other steps.
[0452] It should be noted that in various specific embodiments of this application, when processing data related to the characteristics of the task content, such as task content attribute information or attribute information sets, is required, permission or consent from the task content provider is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require obtaining task content attribute information, separate permission or consent from the task content provider is obtained through pop-ups or redirection to a confirmation page. Only after obtaining this separate permission or consent is granted does the necessary task content-related data for the normal operation of the embodiments of this application become available.
[0453] Figure 30 A schematic diagram of the structure of a sentence recommendation device 3000 provided in an embodiment of this disclosure. The sentence recommendation device 3000 includes:
[0454] The acquisition unit 3010 is used to acquire a reference sentence library tree, which includes multiple layers of nodes. Except for the root node at the top level, each node of the reference sentence library tree is connected to a node at a higher level. Each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree.
[0455] The first determining unit 3020 is used to determine the downward recommendation sub-path in the reference sentence library tree for each node in the reference sentence library tree, and to set the ancestor node identifier of each node in the downward recommendation sub-path using the node identifier of the node.
[0456] The receiving unit 3030 is used to receive the input string;
[0457] Traversal unit 3040 is used to traverse the reference sentence library tree from the root node based on the order of the characters in the input string until the target node corresponding to the last character in the input string is found.
[0458] The second determining unit 3050 is used to determine the target downward recommendation sub-path of the target node based on the ancestor node identifiers of each lower-level node of the target node, and to determine the recommendation statement based on the input string and the target downward recommendation sub-path.
[0459] Optionally, the first determining unit 3020 is specifically used for:
[0460] Assign ascending node identifiers to each node in the reference sentence tree;
[0461] In ascending order, nodes in the reference sentence library tree are sequentially extracted, and for each extracted node, a downward recommendation sub-path is determined in the reference sentence library tree.
[0462] For sub-path nodes in the downward recommendation sub-path, if the sub-path node does not have an ancestor node identifier set, set the ancestor node identifier to the node identifier; if the sub-path node has an ancestor node identifier set, keep the set ancestor node identifier.
[0463] Optionally, the first determining unit 3020 is further used for:
[0464] Assign node identifiers to each node in the reference sentence tree, such that the higher the level of the node, the smaller the node identifier;
[0465] Within the same layer, node identifiers are assigned in ascending order from left to right.
[0466] Optionally, the first determining unit 3020 is further used for:
[0467] For each extracted node, multiple candidate downward paths are determined in the reference sentence library tree;
[0468] Obtain the candidate substring corresponding to each candidate downward sub-path;
[0469] Based on the first frequency of each candidate string after the target object inputs the input string, the score corresponding to each candidate downward sub-path is determined.
[0470] Based on the scores corresponding to each candidate downward sub-path, the downward recommendation sub-path is determined from each candidate downward sub-path.
[0471] Optionally, the first determining unit 3020 is further used for:
[0472] Use the extracted node as the first anchor node;
[0473] The first process is performed, which includes: determining each lower-level node connected to the first anchor node in the reference sentence tree, updating the first anchor node with each lower-level node, and repeating the first process until a leaf node is reached. A leaf node is a node that is not connected to any lower-level node.
[0474] The ordered set of all nodes traversed from the extracted node to a leaf node in the first process is taken as a candidate downward path.
[0475] Optionally, the first determining unit 3020 is further used for:
[0476] For each candidate downward path, obtain the word corresponding to each node in the candidate downward path;
[0477] The words are concatenated into a candidate word string according to the order of the nodes in the candidate downward path.
[0478] Optionally, the first determining unit 3020 is further used for:
[0479] Get the first count of each candidate string after the input string for the target object within a predetermined time period before the current time;
[0480] Based on the first frequency of each input and the duration of the predetermined time period, determine the first frequency of each candidate string.
[0481] Based on the first frequency of each candidate string, determine the score corresponding to each candidate's downward subdivision path.
[0482] Optionally, the first determining unit 3020 is further used for:
[0483] The second frequency of each candidate string is obtained after the input string is input into the target platform. The target platform is the platform used by the statement recommendation method. The target platform includes multiple platform objects, and the multiple platform objects include the target object.
[0484] The total frequency is determined based on the first and second frequencies;
[0485] Based on the total frequency, the score corresponding to each candidate downward sub-path is determined.
[0486] Optionally, the first determining unit 3020 is further used for:
[0487] Get the second count of each candidate string after the input string in the predetermined time period before the current time on the target platform;
[0488] Based on each second frequency and the duration of the predetermined time period, the second frequency of each candidate string in the input is determined.
[0489] Optionally, the first determining unit 3020 is further used for:
[0490] Obtain the first weight for the first frequency and the second weight for the second frequency;
[0491] Based on the first weight and the second weight, the first frequency and the second frequency are weighted and summed to obtain the total frequency.
[0492] Optionally, the second determining unit 3050 is specifically used for:
[0493] Use the target node as the second anchor node;
[0494] The second process is performed, which includes: in the reference sentence tree, determining the node whose ancestor node identifier is less than or equal to the target node's identifier among the nodes connected to the second anchor node at the next lower level; if the determined node is not a leaf node, updating the second anchor node with the determined node, and repeating the second process until a leaf node is reached, which is a node that is not connected to any node at the next lower level.
[0495] The ordered set of each lower-level node determined in the second process is used as the target to recommend sub-paths downwards.
[0496] Optionally, the statement recommendation device 3000 also includes:
[0497] The first identification unit is used to identify that the ancestor node corresponding to the ancestor node identifier of the determined node is not the upstream node of the target node. The upstream node is a node in the reference sentence library tree that has a downward path to the target node.
[0498] The discard unit is used to discard the identified nodes.
[0499] Optionally, the second determining unit 3050 is further used for:
[0500] The characters corresponding to each node in the downward recommendation path of the target are concatenated to obtain the predicted character string;
[0501] The input string and the predicted string are concatenated to obtain the recommended statement.
[0502] Optionally, traversing unit 3040 is specifically used for:
[0503] Use the first character in the input string as the first anchor character and the root node as the third anchor node;
[0504] The third process is performed, which includes: finding the node corresponding to the first anchor word in the next lower level node of the third anchor node, updating the third anchor node with the found node, updating the first anchor word with the next word of the first anchor word, repeating the third process if the first anchor word is not the last word, until the first anchor word is the last word, and determining the node corresponding to the first anchor word as the target node.
[0505] Optionally, the statement recommendation device 3000 also includes:
[0506] The third determining unit is used to determine the semantic similarity between the characters corresponding to each lower-level node and the first anchor character if no node corresponding to the first anchor character is found in the lower-level nodes.
[0507] The fourth determining unit is used to determine the distance between the word corresponding to each lower-level node and the first anchor word in the knowledge graph;
[0508] The fifth determining unit is used to determine the next lower level node of the target among each lower level node based on semantic similarity and distance;
[0509] The update unit is used to update the third anchor node by moving the target to the next lower level node.
[0510] Optionally, the acquisition unit 3010 is specifically used for:
[0511] Retrieve a set of reference sentences, which includes multiple reference sentences;
[0512] For each reference sentence, the first character of the reference sentence is used as the second anchor character, and the root node is used as the first anchor layer;
[0513] The fourth process is performed, which includes: when it is determined that there is no second anchor word in the next lower level of the first anchor layer, the second anchor word is written into the next lower level of the first anchor layer as a node of the next lower level; when it is determined that there is a second anchor word in the next lower level of the first anchor layer, the second anchor word is not written; the second anchor word is updated with the next word in the reference sentence, the first anchor layer is updated with the next lower level of the first anchor layer, and the fourth process is repeated until multiple reference sentences are traversed.
[0514] Reference Figure 31 , Figure 31 To implement the statement recommendation method of this disclosure, a partial structural block diagram of the terminal includes: a radio frequency (RF) circuit 3110, a memory 3115, an input unit 3130, a display unit 3140, a sensor 3150, an audio circuit 3160, a wireless fidelity (WiFi) module 3170, a processor 3180, and a power supply 3190, etc. Those skilled in the art will understand that... Figure 31 The terminal structure shown does not constitute a limitation on mobile phones or computers and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0515] The RF circuit 3110 can be used to receive and transmit signals during information transmission or calls. In particular, it receives downlink information from the base station and processes it with the processor 3180; in addition, it transmits uplink data to the base station.
[0516] The memory 3115 can be used to store software programs and modules, and the processor 3180 executes various functional applications and data processing of the content terminal by running the software programs and modules stored in the memory 3115.
[0517] The input unit 3130 can be used to receive input numeric or character information, and to generate key signal inputs related to the settings and function control of the content terminal. Specifically, the input unit 3130 may include a touch panel 3131 and other input devices 3132.
[0518] Display unit 3140 can be used to display input or provided information, as well as various menus of the content terminal. Display unit 3140 may include display panel 3141.
[0519] Audio circuitry 3160, speaker 3161, and microphone 3162 provide an audio interface.
[0520] In this embodiment, the processor 3180 included in the terminal can execute the statement recommendation method of the previous embodiment.
[0521] The terminals disclosed in this embodiment include, but are not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The embodiments of this invention can be applied to various scenarios, including but not limited to content recommendation and data filtering.
[0522] Figure 32 This is a partial structural block diagram of a server 140 for implementing the statement recommendation method of this disclosure embodiment. The server 140 can vary significantly due to different configurations or performance, and may include one or more central processing units (CPUs) 3222 (e.g., one or more processors) and memory 3232, and one or more storage media 3230 (e.g., one or more mass storage devices) for storing application programs 3242 or data 3244. The memory 3232 and storage media 3230 may be temporary or persistent storage. The program stored in the storage media 3230 may include one or more modules (not shown in the figure), each module including a series of instruction operations on the server 140. Furthermore, the CPU 3222 may be configured to communicate with the storage media 3230 and execute the series of instruction operations in the storage media 3230 on the server 140.
[0523] Server 140 may also include one or more power supplies 3226, one or more wired or wireless network interfaces 3250, one or more input / output interfaces 3258, and / or one or more operating systems 3241, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0524] The central processing unit 3222 in server 140 can be used to execute the statement recommendation method of embodiments of this disclosure.
[0525] This disclosure also provides a computer-readable storage medium for storing program code for executing the statement recommendation method of the foregoing embodiments.
[0526] This disclosure also provides a computer program product comprising a computer program. A processor of a computer device reads and executes the computer program, causing the computer device to perform the method for implementing the statements described above.
[0527] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in this disclosure and the foregoing drawings are used to distinguish similar terms and are not necessarily used to describe a particular order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this disclosure described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “including,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.
[0528] It should be understood that in this disclosure, "at least one item" refers to one or more items, and "more than one item" refers to two or more items. "And / or" is used to describe the relationship between related content, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related content are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0529] It should be understood that in the description of the embodiments of this disclosure, "multiple" means two or more, "greater than", "less than", "exceeding" etc. are understood to exclude the number itself, and "above", "below", "within" etc. are understood to include the number itself.
[0530] In the embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections between devices or units through some interfaces, and may be electrical, mechanical, or other forms.
[0531] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0532] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0533] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to related technologies, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server 140, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.
[0534] It should also be understood that the various implementation methods provided in this disclosure can be combined arbitrarily to achieve different technical effects.
[0535] The above is a detailed description of the embodiments of this disclosure. However, this disclosure is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this disclosure. All such equivalent modifications or substitutions are included within the scope defined by the claims of this disclosure.
Claims
1. A statement recommendation method, characterized in that, include: Obtain a reference sentence library tree, which includes multiple levels of nodes, wherein, except for the root node at the top level, each node of the reference sentence library tree is connected upward to a node at a higher level, each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree; For each node in the reference sentence library tree, a downward recommendation sub-path is determined in the reference sentence library tree, and the ancestor node identifier of each node in the downward recommendation sub-path is set using the node identifier of the node; Receive input string; Based on the order of the characters in the input string, the reference sentence library tree is traversed starting from the root node until the target node corresponding to the last character in the input string is found; Based on the ancestor node identifiers of each lower-level node of the target node, the target downward recommendation sub-path of the target node is determined, and based on the input string and the target downward recommendation sub-path, the recommendation statement is determined.
2. The statement recommendation method according to claim 1, characterized in that, The step involves determining a downward recommendation sub-path for each node in the reference sentence library tree, and setting the ancestor node identifier of each node in the downward recommendation sub-path using the node identifier of the node, including: Assign ascending node identifiers to each node in the reference sentence library tree; According to the ascending order, the nodes in the reference sentence library tree are sequentially extracted, and for the extracted nodes, the downward recommendation sub-path is determined in the reference sentence library tree; For the sub-path nodes in the downward recommendation sub-path, if the sub-path node has not set the ancestor node identifier, set the ancestor node identifier to the node identifier of the node; if the sub-path node has already set the ancestor node identifier, keep the set ancestor node identifier.
3. The statement recommendation method according to claim 2, characterized in that, Assigning ascending node identifiers to each node in the reference sentence tree includes: Assign a node identifier to each node in the reference sentence tree, such that the higher the layer in which the node is located, the smaller the node identifier; Within the same layer, the node identifiers are assigned in a manner that increases from left to right.
4. The statement recommendation method according to claim 2, characterized in that, For the extracted node, determining the downward recommendation sub-path in the reference sentence library tree includes: For the extracted node, multiple candidate downward sub-paths for the node are determined in the reference sentence library tree; Obtain the candidate substring corresponding to each of the candidate downward sub-paths; Based on the first frequency of each candidate string after the target object inputs the input string, the score corresponding to each candidate downward sub-path is determined; Based on the scores corresponding to each of the candidate downward sub-paths, the downward recommendation sub-path is determined among each of the candidate downward sub-paths.
5. The statement recommendation method according to claim 4, characterized in that, For the extracted node, determining multiple candidate downward paths for the node in the reference sentence library tree includes: The extracted node is used as the first anchor node; Perform a first process, which includes: determining each lower-level node connected to the first anchor node in the reference sentence tree, updating the first anchor node with each lower-level node, repeating the first process until a leaf node is reached, wherein the leaf node is a node that is not connected to a lower-level node. The ordered set of all nodes traversed from the extracted node to a leaf node in the first process is taken as a candidate downward sub-path.
6. The statement recommendation method according to claim 4, characterized in that, The step of obtaining the candidate string corresponding to each candidate downward sub-path includes: For each candidate downward sub-path, obtain the word corresponding to each node in the candidate downward sub-path; The words are concatenated into the candidate word string according to the order of the nodes in the candidate downward sub-path.
7. The statement recommendation method according to claim 4, characterized in that, The step of determining the score corresponding to each candidate downward subdivision path based on the first frequency of each candidate string input by the target object after inputting the input string includes: Obtain the first count of each candidate string after the input string is entered in the target object within a predetermined time period before the current time; Based on each of the first counts and the duration of the predetermined time period, the first frequency of each of the input candidate strings is determined; Based on the first frequency of each of the input candidate strings, the score corresponding to each candidate downward sub-path is determined.
8. The statement recommendation method according to claim 4, characterized in that, The step of determining the score corresponding to each candidate downward subdivision path based on the first frequency of each candidate string input by the target object after inputting the input string includes: The second frequency of each candidate string is obtained after the input string is input to the target platform. The target platform is the platform to which the statement recommendation method is applied. The target platform includes multiple platform objects, and the multiple platform objects include the target object. Based on the first frequency and the second frequency, determine the total frequency; Based on the total frequency, the score corresponding to each of the candidate downward sub-paths is determined.
9. The statement recommendation method according to claim 8, characterized in that, The process of obtaining the second frequency of each candidate string after the target platform inputs the input string includes: Obtain the second count of each candidate string after the input string is entered into the target platform within a predetermined time period before the current time; The second frequency of each of the candidate strings is determined based on the second frequency and the duration of the predetermined time period.
10. The statement recommendation method according to claim 8, characterized in that, Determining the total frequency based on the first frequency and the second frequency includes: Obtain the first weight of the first frequency and the second weight of the second frequency; Based on the first weight and the second weight, the first frequency and the second frequency are weighted and summed to obtain the total frequency.
11. The statement recommendation method according to claim 2, characterized in that, The process of determining the target downward recommendation sub-path for the target node based on the ancestor node identifiers of each lower-level node of the target node includes: The target node is used as the second anchor node; Perform a second process, which includes: determining in the reference sentence tree a node whose ancestor node identifier is less than or equal to the node identifier of the target node among the next-lower-level nodes connected to the second anchor node; if the determined node is not a leaf node, updating the second anchor node with the determined node; repeating the second process until the leaf node is reached, which is a node that is not connected to the next-lower-level node. The ordered set of each lower-level node determined in the second process is used as the target to recommend sub-paths downwards.
12. The statement recommendation method according to claim 1, characterized in that, The step of determining the recommended statement based on the input string and the target downward recommendation path includes: Connect the characters corresponding to each node in the downward recommendation sub-path of the target to obtain the predicted character string; The input string and the predicted string are concatenated to obtain the recommended statement.
13. The statement recommendation method according to claim 1, characterized in that, The step of traversing the reference sentence tree from the root node based on the order of the characters in the input string until the target node corresponding to the last character in the input string is found includes: The first character in the input string is taken as the first anchor character, and the root node is taken as the third anchor node; Perform a third process, which includes: searching for a node corresponding to the first anchor word in the next lower level node of the third anchor node; updating the third anchor node with the found node; updating the first anchor word with the next word of the first anchor word; repeating the third process if the first anchor word is not the last word until the first anchor word is the last word; and determining the node corresponding to the first anchor word as the target node.
14. The statement recommendation method according to claim 1, characterized in that, The process of obtaining the reference sentence library tree includes: Obtain a set of reference sentences, which includes multiple reference sentences; For each of the reference sentences, the first character of the reference sentence is taken as the second anchor character, and the root node is taken as the first anchor layer; The fourth process includes: when it is determined that the second anchor word does not exist in the layer below the first anchor layer, writing the second anchor word into the layer below the first anchor layer as a node of the layer below the first anchor layer; when it is determined that the second anchor word exists in the layer below the first anchor layer, not writing the second anchor word; updating the second anchor word with the next word in the reference sentence, updating the first anchor layer with the layer below the first anchor layer, and repeating the fourth process until multiple reference sentences have been traversed.
15. A statement recommendation device, characterized in that, include: An acquisition unit is used to acquire a reference sentence library tree, the reference sentence library tree including multiple layers of nodes, wherein, except for the root node of the top layer, each node of the reference sentence library tree is connected upward to a node of a higher layer, each node corresponds to a word, and each path downward from the root node corresponds to a reference sentence in the reference sentence library tree; The first determining unit is configured to determine a downward recommendation sub-path in the reference sentence library tree for each node in the reference sentence library tree, and to set the ancestor node identifier of each node in the downward recommendation sub-path using the node identifier of the node. The receiving unit is used to receive the input string; The traversal unit is used to traverse the reference sentence library tree from the root node based on the order of the characters in the input string until the target node corresponding to the last character in the input string is found. The second determining unit is used to determine the target downward recommendation sub-path of the target node based on the ancestor node identifiers of each lower-level node of the target node, and to determine the recommendation statement based on the input string and the target downward recommendation sub-path.
16. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the statement recommendation method according to any one of claims 1 to 14.
17. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the statement recommendation method according to any one of claims 1 to 14.
18. A computer program product comprising a computer program that is read and executed by a processor of a computer device, causing the computer device to perform the statement recommendation method according to any one of claims 1 to 14.