Adjustment method and device of dictionary tree, equipment, storage medium and product

By building shared nodes in the dictionary tree and merging the structure of child nodes, the problem of inefficient storage of dictionary tree is solved, and more efficient storage and space utilization is achieved.

CN119807478AActive Publication Date: 2025-04-11ZHEJIANG ZEEKR INTELLIGENT TECH CO LTD +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411861889.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-11
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

Because nodes store characters independently, the storage space of the dictionary tree increases linearly, and there is a lot of redundancy, resulting in insufficiency of storage.

Method used

By obtaining the number of occurrences of the dictionary tree node, it is determined whether the occurrences of the node are greater than the preset number threshold. If they exist, the node and its parent node are constructed as a shared node, and the child nodes are structured merged to dynamically adjust the structure of the dictionary tree.

Benefits of technology

By compressing frequently accessed nodes into shared nodes, the shared storage of characters is realized, the redundancy of character storage is reduced, and the storage efficiency and space utilization of the dictionary tree are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807478A_ABST
    Figure CN119807478A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for adjusting a dictionary tree, equipment, a storage medium and a product, relates to the technical field of data storage, and discloses the method for adjusting the dictionary tree, which comprises the following steps: after nodes of the dictionary tree are updated, obtaining the occurrence frequency of each node under the current dictionary tree; judging whether nodes exist in the dictionary tree or not, wherein the occurrence frequency of the nodes is greater than a preset frequency threshold; and if the occurrence frequency of a node is greater than a preset frequency threshold, constructing the node and at least one father node of the node into a shared node of the dictionary tree, and based on the shared node, performing structure combination on child nodes of the node to obtain the structure-adjusted dictionary tree. According to the method and the device, the frequently accessed nodes are compressed into the shared nodes, so that shared storage of characters instead of independent storage of the characters is realized, the space utilization rate of the dictionary tree is improved, the redundancy of character storage of the dictionary tree is reduced, and the storage efficiency of the dictionary tree is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data storage technology, and in particular to a dictionary tree adjustment method, device, equipment, storage medium and product. Background Art

[0002] At present, with the rapid development of information technology, the demand for processing and storing large-scale string data is growing. In this context, Trie, as an efficient string retrieval data structure, is widely used in fields such as auto-completion, spelling check, and word frequency statistics.

[0003] In the related art, the dictionary tree is composed of nodes, each node contains a character and a mapping to the next layer of nodes, and each node stores characters independently. However, as the number and length of strings increase, the storage space of the above dictionary tree increases linearly, and the structure of independently storing characters will cause a lot of redundancy in data storage, resulting in low storage efficiency of the dictionary tree.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide a dictionary tree adjustment method, aiming to solve the technical problem of low storage efficiency of the dictionary tree.

[0006] To achieve the above purpose, the present application proposes a method for adjusting a dictionary tree, and the method for adjusting the dictionary tree includes:

[0007] When the nodes of the dictionary tree are updated, the number of occurrences of each node under the current dictionary tree is obtained;

[0008] Determine whether there is a node in the dictionary tree whose occurrence number is greater than a preset number threshold;

[0009] If the number of occurrences of a node is greater than a preset threshold, the node and at least one of its parent nodes are constructed as shared nodes of the dictionary tree, and based on the shared nodes, the child nodes of the node are structurally merged to obtain a dictionary tree with adjusted structure.

[0010] Optionally, the step of constructing the node and at least one of its parent nodes as shared nodes of the dictionary tree includes:

[0011] Get the length of the character sequence of the node;

[0012] Determining whether the length of the character sequence is less than a preset length threshold;

[0013] If the length of the character sequence is less than a preset length threshold, the node and the parent nodes corresponding to the length of the character sequence are constructed as shared nodes of the dictionary tree.

[0014] Optionally, before the step of determining whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold, the method includes:

[0015] Obtain the performance indicator size and number threshold of the current dictionary tree;

[0016] Based on the size of the performance indicator, the number threshold is adjusted to obtain an adjusted number threshold;

[0017] The step of determining whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold comprises:

[0018] It is determined whether there is a node in the dictionary tree whose number of occurrences is greater than the adjusted number threshold.

[0019] Optionally, the step of adjusting the number threshold based on the size of the performance indicator to obtain an adjusted number threshold includes:

[0020] Determine whether the performance index meets the preset index condition;

[0021] If the performance indicator size does not meet the preset indicator condition, obtaining an indicator mapping table, wherein the indicator mapping table includes a mapping relationship between each performance indicator size and a corresponding number threshold;

[0022] Based on the indicator mapping table, a target number threshold corresponding to the performance indicator size is determined, and the number threshold is adjusted to the target number threshold to obtain an adjusted number threshold.

[0023] Optionally, after the step of structurally merging the subnodes of the node based on the shared node to obtain a dictionary tree with adjusted structure, the method includes:

[0024] Get the string to be inserted;

[0025] Matching the character information of the shared node with the character string to be inserted to obtain a matching result;

[0026] If the matching result is a successful match, the string to be inserted is merged under the shared node to obtain a dictionary tree with updated nodes.

[0027] Optionally, if the matching result is a successful match, then after the step of merging the string to be inserted into the shared node to obtain a dictionary tree after the node is updated, the method includes:

[0028] If the matching result is a matching failure, a child node corresponding to the string to be inserted is created in the dictionary tree to obtain an expanded and updated dictionary tree.

[0029] In addition, to achieve the above purpose, the present application also proposes a dictionary tree adjustment device, the dictionary tree adjustment device comprising:

[0030] An acquisition module is used to acquire the number of occurrences of each node under the current dictionary tree after the node of the dictionary tree is updated;

[0031] A judging module, used for judging whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold;

[0032] The adjustment module is used to construct the node and at least one of its parent nodes as shared nodes of the dictionary tree if the number of occurrences of the node is greater than a preset number threshold, and based on the shared node, structurally merge the child nodes of the node to obtain a dictionary tree with adjusted structure.

[0033] In addition, to achieve the above-mentioned purpose, the present application also proposes a dictionary tree adjustment device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the dictionary tree adjustment method as described above.

[0034] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the dictionary tree adjustment method described above are implemented.

[0035] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the dictionary tree adjustment method as described above.

[0036] One or more technical solutions proposed in this application have at least the following technical effects:

[0037] Compared with the related art, the dictionary tree is composed of nodes, each node contains a character and a mapping to the next layer of nodes, and each node stores characters independently. However, as the number and length of the character strings increase, the storage space of the above dictionary tree increases linearly, and the structure of independently storing characters will cause a lot of redundancy in the storage of data, resulting in low storage efficiency of the dictionary tree. In this application, when the nodes of the dictionary tree are updated, the number of occurrences of each node under the current dictionary tree is obtained; it is determined whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold; if there is a node whose number of occurrences is greater than the preset number threshold, the node and at least one of its parent nodes are constructed as shared nodes of the dictionary tree, and based on the shared node, the child nodes of the node are structurally merged to obtain a dictionary tree with adjusted structure. It can be understood that the present application constructs a node whose appearance times in the dictionary tree is greater than a preset threshold and at least one of its parent nodes as a shared node of the dictionary tree, and merges the child nodes of the node into the shared node, so as to dynamically adjust the structure of the dictionary tree, that is, to compress frequently accessed nodes into shared nodes, realize shared storage of characters rather than independent storage of characters, thereby improving the space utilization of the dictionary tree, reducing the redundancy of character storage in the dictionary tree, and improving the storage efficiency of the dictionary tree. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0040] Figure 1 A flowchart diagram of the first embodiment of the method for adjusting the dictionary tree of the present application;

[0041] Figure 2 A diagram of the dictionary tree structure of the dictionary tree adjustment method of the present application;

[0042] Figure 3 A flowchart diagram of a second embodiment of a method for adjusting a dictionary tree of the present application;

[0043] Figure 4 A schematic diagram of the module structure of the dictionary tree adjustment device of the embodiment of the present application;

[0044] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the dictionary tree adjustment method in the embodiment of the present application.

[0045] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0046] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0047] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0048] The main solution of the embodiment of the present application is: when the nodes of the dictionary tree are updated, the number of occurrences of each node under the current dictionary tree is obtained; it is determined whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold; if there is a node whose number of occurrences is greater than the preset number threshold, the node and at least one of its parent nodes are constructed as shared nodes of the dictionary tree, and based on the shared node, the child nodes of the node are structurally merged to obtain a dictionary tree with adjusted structure.

[0049] In this embodiment, the dictionary tree adjustment device is used as the execution body. For the convenience of description, it will be explained as "device" hereinafter.

[0050] In the related art, the dictionary tree is composed of nodes, each node contains a character and a mapping to the next layer of nodes, and each node stores characters independently. However, as the number and length of strings increase, the storage space of the above dictionary tree increases linearly, and the structure of independently storing characters will cause a lot of redundancy in data storage, resulting in low storage efficiency of the dictionary tree.

[0051] The present application provides a solution to achieve dynamic adjustment of the dictionary tree and improve the storage efficiency of the dictionary tree.

[0052] It can be seen from the above embodiments that the present application constructs a node whose appearance times in the dictionary tree is greater than a preset threshold and at least one of its parent nodes as a shared node of the dictionary tree, and merges the child nodes of the node into the shared node, so as to dynamically adjust the structure of the dictionary tree, that is, to compress frequently accessed nodes into shared nodes, to achieve shared storage of characters rather than independent storage of characters, thereby improving the space utilization of the dictionary tree, reducing the redundancy of character storage in the dictionary tree, and improving the storage efficiency of the dictionary tree.

[0053] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a terminal system, etc. that can realize the above functions. The following takes the dictionary tree adjustment device as an example to illustrate this embodiment and the following embodiments.

[0054] Based on this, the present application embodiment provides a method for adjusting a dictionary tree, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the method for adjusting the dictionary tree of the present application.

[0055] In this embodiment, the dictionary tree adjustment method includes steps S100 to S300:

[0056] Step S100, when the nodes of the dictionary tree are updated, the number of occurrences of each node under the current dictionary tree is obtained;

[0057] It should be noted that, refer to Figure 2 ,A dictionary tree is a tree data structure, which is often used to store a set of strings, where each node represents a character, and the path from the root node to a certain node represents a string; node update refers to the change of nodes in the dictionary tree due to insertion, deletion or modification operations, for example, inserting a new string into the dictionary tree, or deleting a string from the dictionary tree.

[0058] It is understandable that the number of node occurrences refers to the number of times the character corresponding to each node appears in all stored strings in the dictionary tree, where the number of node occurrences reflects the frequency with which the character is accessed, that is, the information on the number of node occurrences is used to optimize storage or improve retrieval efficiency.

[0059] In the specific implementation, after the nodes of the dictionary tree are updated, the number of occurrences of each node needs to be recalculated and recorded to ensure that these statistical information are up-to-date and reflect the latest data status of the dictionary tree.

[0060] Step S200, determining whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold;

[0061] It should be noted that the preset number threshold is a pre-defined value used to determine whether the number of node occurrences meets the corresponding standard, wherein the number threshold is set based on application requirements or performance optimization considerations.

[0062] In a specific implementation, the device determines whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold. This process involves traversing the dictionary tree or checking related data structures to determine whether there is a node counter (recording the number of occurrences) that exceeds the set threshold. Specifically, when constructing a compressed dictionary tree, nodes exceeding the threshold will be determined as shared nodes to reduce storage redundancy.

[0063] In a specific implementation, before the device determines whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold, the method includes:

[0064] The performance indicator size and the number threshold of the current dictionary tree are obtained; based on the performance indicator size, the number threshold is adjusted to obtain the adjusted number threshold.

[0065] It should be noted that the performance index size refers to the size or value of a series of key data that measure the performance of the dictionary tree, which reflects the efficiency and effect of the dictionary tree in different aspects. Performance indicators include but are not limited to storage efficiency, that is, the memory space occupied by the dictionary tree; retrieval efficiency, that is, the average response time or speed of query operations; insertion and deletion efficiency, that is, the speed of adding or deleting entries to the dictionary tree; the depth or width of the node, that is, the node distribution that affects the length of the retrieval path; the number threshold refers to the preset number threshold currently used for the dictionary tree operation.

[0066] In a specific implementation, the device dynamically adjusts the number threshold according to the collected performance indicator data, wherein the purpose of the adjustment is to optimize the performance of the dictionary tree to make it more suitable for current usage and data characteristics. Specific adjustment strategies include but are not limited to: if the performance indicator shows that the storage efficiency is low, the number threshold needs to be lowered to reduce the repeated storage of nodes and improve storage efficiency; if the retrieval efficiency decreases, the number threshold needs to be increased to merge more shared prefixes, reduce the number of nodes, and thus improve the retrieval speed; according to the efficiency of the insertion and deletion operations, the number threshold is adjusted to balance memory usage and operation speed.

[0067] In a specific implementation, after the above adjustment process, the device obtains an adjusted number threshold, which will be used for subsequent dictionary tree operations in the hope of achieving a better performance balance. That is, the above process is a dynamic optimization process, which involves monitoring the current dictionary tree performance and adjusting the operation parameters (number threshold) according to the performance data in the hope of finding the best balance point between different performance indicators, thereby improving the overall performance of the dictionary tree.

[0068] In a specific implementation, the device adjusts the number threshold based on the size of the performance indicator to obtain the adjusted number threshold, including:

[0069] Determine whether the performance indicator size meets the preset indicator condition; if the performance indicator size does not meet the preset indicator condition, obtain an indicator mapping table, wherein the indicator mapping table includes a mapping relationship between each performance indicator size and a corresponding number threshold; based on the indicator mapping table, determine a target number threshold corresponding to the performance indicator size, and adjust the number threshold to the target number threshold to obtain an adjusted number threshold.

[0070] In the specific implementation, first, the device needs to compare the currently measured performance indicators (such as storage efficiency, retrieval efficiency, etc.) with the pre-set performance target or threshold, where the pre-set indicator condition is a condition corresponding to a standard value of the dictionary tree performance management. If the current performance indicator fails to meet the preset standard, further adjustment measures need to be taken.

[0071] Furthermore, the indicator mapping table is a predefined data structure, which contains the mapping relationship between different performance indicator sizes and corresponding number thresholds. The mapping table is a decision support tool for selecting an appropriate number threshold based on the current performance indicator size. Using the indicator mapping table, a target number threshold is determined based on the current performance indicator size. This target number threshold is the performance optimization goal that is expected to be achieved by adjusting the number threshold. The current node occurrence number threshold is adjusted to the target number threshold. This adjustment is based on the guidance of the performance indicator mapping table, and its purpose is to make the performance of the dictionary tree closer to the preset performance indicator conditions. After the above adjustment, a new number threshold is obtained, and this value will be used for subsequent dictionary tree operations to achieve a better performance balance.

[0072] In a specific implementation, the step of determining whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold value also includes:

[0073] The device determines whether there is a node in the dictionary tree that meets the adjusted number threshold based on the number of occurrences.

[0074] In the specific implementation, after the above adaptive adjustment mechanism based on performance feedback, the performance of the dictionary tree is optimized by comparing the actual performance with the preset target, using the mapping table to determine the adjustment direction, and finally adjusting the number threshold, so that it can remain efficient and stable under different workloads.

[0075] Step S300, if the number of occurrences of a node is greater than a preset number threshold, the node and at least one of its parent nodes are constructed as shared nodes of the dictionary tree, and based on the shared node, the child nodes of the node are structurally merged to obtain a dictionary tree with adjusted structure.

[0076] In a specific implementation, if the number of occurrences of a node is greater than a preset number threshold, that is, the number of occurrences of a node exceeds the preset threshold, the node is a high-frequency node. The device constructs the high-frequency node and at least one parent node of the high-frequency node as a shared node, wherein a shared node refers to a node shared by multiple paths in the dictionary tree, which can reduce redundant storage.

[0077] In a specific implementation, based on a shared node, the device will structurally merge the child nodes of the node. That is, if multiple child nodes have the same subsequent paths, these paths can be merged into a single path, thereby reducing the number of nodes and optimizing the structure of the dictionary tree.

[0078] In the specific implementation, after the above steps, the structure of the dictionary tree will change, nodes will be merged, and shared nodes will be created, and finally a dictionary tree with a more compact structure and higher storage efficiency will be obtained.

[0079] In a specific embodiment, the device records the number of occurrences of each node and tracks the frequency with which the node is visited. When the number of occurrences of a node reaches or exceeds a threshold value (e.g., 5 times), the device will consider the node to be a high-frequency node. Once it detects that the number of occurrences of a node exceeds the threshold, the device will begin to compress the node and the structure below it. Specifically, the device merges shared prefixes into a single node and merges all similar structures below it. For example, when multiple strings share the prefix "ap", the device will merge the prefix to reduce the storage of redundant nodes.

[0080] In a specific implementation, the step of constructing the node and at least one of its parent nodes as shared nodes of the dictionary tree includes:

[0081] Obtain the character sequence length of the node; determine whether the character sequence length is less than a preset length threshold; if the character sequence length is less than the preset length threshold, construct the node and the corresponding number of parent nodes of the character sequence length as shared nodes of the dictionary tree.

[0082] It should be noted that each node in the dictionary tree is usually associated with a character, and the character sequence length refers to the total number of characters on the path from the root node to the current node. For example, if the path is "cat", then the character sequence length to the node with the suffix "cat" is 3; the preset length threshold is a predefined value used to determine whether the node meets the requirements for being constructed as a shared node. Specifically, the length threshold proposed in this application is to avoid the shared prefix being too long and affecting the query efficiency. If the prefix length exceeds this limit, the device will retain the first few bits of the prefix, and the remaining part will continue to be allocated as different child nodes.

[0083] In the specific implementation, if the length of the character sequence is less than the preset length threshold, the current node and its parent nodes (the number is equal to the length of the character sequence) are constructed as shared nodes. That is, the above nodes are shared by multiple strings in the dictionary tree, so they can be merged to reduce redundant storage. For example, if the length of the character sequence is 2, then two nodes from the current node are counted upwards, and these two nodes and the current node will be constructed as shared nodes.

[0084] In the specific implementation, the purpose of this optimization is to reduce the total number of nodes in the dictionary tree and improve storage efficiency by merging those short, shared paths. The creation of shared nodes can reduce memory usage and may improve query performance because shared nodes only need to be stored once. The above process is a decision mechanism based on the length of the character sequence to determine whether to merge certain nodes into shared nodes to optimize the structure and performance of the dictionary tree.

[0085] In a specific embodiment, when the device detects that the number of occurrences of a node exceeds a threshold, it will start to compress the node and the structure below it, specifically merging the shared prefix into a single node and merging all similar structures below it. For example, when multiple strings share the prefix ap and the prefix length is less than the length threshold, the device will merge the prefix to reduce the storage of redundant nodes.

[0086] In the specific implementation, this application effectively compresses the storage space and improves the space utilization rate by real-time analysis and adjustment of the dictionary tree structure, especially when storing a large number of strings with repeated prefixes. And through the adaptive adjustment mechanism, this application can dynamically adjust the dictionary tree structure according to the actual data situation to adapt to different storage requirements, which is more flexible than the static structure. It also adopts the strategy of dynamically creating nodes on demand, avoiding unnecessary node allocation, reducing memory usage, and improving runtime efficiency.

[0087] Compared with the related art, the dictionary tree is composed of nodes, each node contains a character and a mapping to the next layer of nodes, and each node stores characters independently. However, as the number and length of the character strings increase, the storage space of the above dictionary tree increases linearly, and the structure of independently storing characters will cause a lot of redundancy in the storage of data, resulting in low storage efficiency of the dictionary tree. In this application, when the nodes of the dictionary tree are updated, the number of occurrences of each node under the current dictionary tree is obtained; it is determined whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold; if there is a node whose number of occurrences is greater than the preset number threshold, the node and at least one of its parent nodes are constructed as shared nodes of the dictionary tree, and based on the shared node, the child nodes of the node are structurally merged to obtain a dictionary tree with adjusted structure. It can be understood that the present application constructs a node whose appearance times in the dictionary tree is greater than a preset threshold and at least one of its parent nodes as a shared node of the dictionary tree, and merges the child nodes of the node into the shared node, so as to dynamically adjust the structure of the dictionary tree, that is, to compress frequently accessed nodes into shared nodes, realize shared storage of characters rather than independent storage of characters, thereby improving the space utilization of the dictionary tree, reducing the redundancy of character storage in the dictionary tree, and improving the storage efficiency of the dictionary tree.

[0088] Based on the above first embodiment, the present application also proposes another embodiment, referring to Figure 3 , the adjustment method of the dictionary tree includes:

[0089] In a specific implementation, after the device performs structural merging of the subnodes of the node based on the shared node to obtain a dictionary tree with adjusted structure, the method includes:

[0090] Step A100, obtaining the character string to be inserted;

[0091] In a specific implementation, the step in which the device obtains the string to be inserted is the beginning of the insertion operation. The string to be inserted refers to the string to be inserted into the dictionary tree, that is, the string is a data item to be added to the dictionary tree.

[0092] Step A200, matching the character information of the shared node with the character string to be inserted to obtain a matching result;

[0093] In a specific implementation, a shared node refers to a node shared by multiple character strings. The device compares the characters of the character string to be inserted with the character information of the shared node to check whether the prefix of the character string to be inserted already exists in the dictionary tree.

[0094] It is understandable that the matching result includes a successful match or a failed match, depending on whether the prefix of the string to be inserted matches the path of the shared node.

[0095] Step A300, if the matching result is successful, then merge the string to be inserted into the shared node to obtain a dictionary tree with updated nodes;

[0096] In a specific implementation, if the matching result is a successful match, that is, if the prefix of the string to be inserted successfully matches the path of the shared node, it means that the prefix already exists in the dictionary tree. In this case, there is no need to recreate a new node to store the common prefix, but the remaining part of the string to be inserted (if any) is merged under the shared node.

[0097] For example, if the dictionary tree already has "cat" as a shared node, and the string to be inserted is "catalog", then just add "alog" under the "cat" node.

[0098] Step A400: If the matching result is a matching failure, a child node corresponding to the string to be inserted is created in the dictionary tree to obtain an expanded and updated dictionary tree.

[0099] In the specific implementation, if the prefix of the string to be inserted does not match the path of the shared node, it means that the prefix does not exist in the dictionary tree. In this case, a new child node needs to be created for each character of the string to be inserted and added to the dictionary tree.

[0100] For example, if "cat" already exists as a shared node in the dictionary tree, and the string to be inserted is "dog", then you need to create a "d" node under the root node, followed by an "og" node, to form a path for "dog".

[0101] In the specific implementation, the above process describes two situations of inserting strings into the dictionary tree: one is that the prefix of the string to be inserted already exists in the dictionary tree and can be directly merged; the other is that the prefix of the string to be inserted does not exist in the dictionary tree and a new node needs to be created. This insertion mechanism enables the dictionary tree to efficiently store and retrieve string collections while reducing redundant storage.

[0102] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the adjustment method of the dictionary tree of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0103] This application also provides a dictionary tree adjustment device, please refer to Figure 4 , the dictionary tree adjustment device includes:

[0104] The acquisition module 10 is used to acquire the number of occurrences of each node under the current dictionary tree after the node of the dictionary tree is updated;

[0105] A judging module 20 is used to judge whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold;

[0106] The adjustment module 30 is used to construct the node and at least one of its parent nodes as shared nodes of the dictionary tree if the number of occurrences of the node is greater than a preset number threshold, and based on the shared node, structurally merge the child nodes of the node to obtain a dictionary tree with adjusted structure.

[0107] Optionally, the adjustment module 30 includes:

[0108] The length acquisition module is used to obtain the length of the character sequence of the node;

[0109] A length determination module, used to determine whether the length of the character sequence is less than a preset length threshold;

[0110] A construction module is used to construct the node and the parent nodes corresponding to the length of the character sequence as shared nodes of the dictionary tree if the length of the character sequence is less than a preset length threshold.

[0111] Optionally, the dictionary tree adjustment device further includes:

[0112] A performance indicator acquisition module is used to obtain the performance indicator size and number threshold of the current dictionary tree;

[0113] A threshold adjustment module, used to adjust the number threshold based on the size of the performance indicator to obtain an adjusted number threshold;

[0114] Optionally, the judging module 20 further includes:

[0115] The threshold judgment module is used to judge whether there is a node in the dictionary tree whose number of appearances is greater than the adjusted number threshold.

[0116] Optionally, the threshold adjustment module includes:

[0117] An indicator judgment module is used to judge whether the size of the performance indicator meets the preset indicator condition;

[0118] A mapping table acquisition module, used for acquiring an indicator mapping table if the performance indicator size does not meet the preset indicator condition, wherein the indicator mapping table includes a mapping relationship between each performance indicator size and a corresponding number threshold;

[0119] The times threshold adjustment module is used to determine the target times threshold corresponding to the performance indicator size based on the indicator mapping table, and adjust the times threshold to the target times threshold to obtain the adjusted times threshold.

[0120] Optionally, the dictionary tree adjustment device further includes:

[0121] A string acquisition module is used to acquire the string to be inserted;

[0122] A matching module, used for matching the character information of the shared node with the character string to be inserted to obtain a matching result;

[0123] The insertion module is used to merge the string to be inserted into the shared node if the matching result is a successful match, so as to obtain a dictionary tree with updated nodes.

[0124] Optionally, the dictionary tree adjustment device further includes:

[0125] A creation module is used to create a child node corresponding to the string to be inserted in the dictionary tree if the matching result is a matching failure, so as to obtain an expanded and updated dictionary tree.

[0126] The dictionary tree adjustment device provided by the present application adopts the dictionary tree adjustment method in the above embodiment, which can solve the technical problem of dictionary tree adjustment. Compared with the prior art, the beneficial effect of the dictionary tree adjustment device provided by the present application is the same as the beneficial effect of the dictionary tree adjustment method provided by the above embodiment, and the other technical features in the dictionary tree adjustment device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0127] The present application provides a dictionary tree adjustment device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the dictionary tree adjustment method in the above-mentioned embodiment one.

[0128] Reference below Figure 5 , which shows a schematic diagram of the structure of a dictionary tree adjustment device suitable for implementing the embodiment of the present application. The dictionary tree adjustment device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The dictionary tree adjustment device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0129] like Figure 5As shown, the dictionary tree adjustment device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the dictionary tree adjustment device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the dictionary tree adjustment device to communicate wirelessly or wired with other devices to exchange data. Although the diagram shows a dictionary tree adjustment device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0130] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0131] The dictionary tree adjustment device provided by the present application adopts the dictionary tree adjustment method in the above embodiment, which can solve the technical problem of dictionary tree adjustment. Compared with the prior art, the beneficial effects of the dictionary tree adjustment device provided by the present application are the same as the beneficial effects of the dictionary tree adjustment method provided by the above embodiment, and the other technical features in the dictionary tree adjustment device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0132] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0133] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0134] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the dictionary tree adjustment method in the above-mentioned embodiment.

[0135] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0136] The computer-readable storage medium may be included in the adjustment device of the dictionary tree; or may exist independently without being assembled into the adjustment device of the dictionary tree.

[0137] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the dictionary tree adjustment device, the dictionary tree adjustment device performs: dictionary tree adjustment.

[0138] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0140] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0141] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned dictionary tree adjustment method, and can solve the technical problem of dictionary tree adjustment. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the dictionary tree adjustment method provided by the above-mentioned embodiment, and will not be repeated here.

[0142] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned dictionary tree adjustment method when executed by a processor.

[0143] The computer program product provided by the present application can solve the technical problem of adjusting the dictionary tree. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the dictionary tree adjustment method provided by the above embodiment, which will not be repeated here.

[0144] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A method for adjusting a dictionary tree, characterized in that: The method for adjusting the dictionary tree includes: When the nodes of the dictionary tree are updated, the number of occurrences of each node under the current dictionary tree is obtained; Determine whether there is a node in the dictionary tree whose occurrence number is greater than a preset number threshold; If the number of occurrences of a node is greater than a preset threshold, the node and at least one of its parent nodes are constructed as shared nodes of the dictionary tree, and based on the shared nodes, the child nodes of the node are structurally merged to obtain a dictionary tree with adjusted structure.

2. The method for adjusting a dictionary tree according to claim 1, wherein: The step of constructing the node and at least one of its parent nodes as shared nodes of the dictionary tree includes: Get the length of the character sequence of the node; Determining whether the length of the character sequence is less than a preset length threshold; If the length of the character sequence is less than a preset length threshold, the node and the parent nodes corresponding to the length of the character sequence are constructed as shared nodes of the dictionary tree.

3. The method for adjusting a dictionary tree according to claim 1, wherein: Before the step of determining whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold, the method includes: Obtain the performance index size and number threshold of the current dictionary tree; Based on the size of the performance indicator, the number threshold is adjusted to obtain an adjusted number threshold; The step of determining whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold comprises: Determine whether there is a node in the dictionary tree whose number of occurrences is greater than the adjusted number threshold.

4. The method for adjusting a dictionary tree according to claim 3, wherein: The step of adjusting the number threshold based on the size of the performance indicator to obtain the adjusted number threshold includes: Determine whether the performance index meets the preset index condition; If the performance indicator size does not meet the preset indicator condition, obtaining an indicator mapping table, wherein the indicator mapping table includes a mapping relationship between each performance indicator size and a corresponding number threshold; Based on the indicator mapping table, a target number threshold corresponding to the performance indicator size is determined, and the number threshold is adjusted to the target number threshold to obtain an adjusted number threshold.

5. The method for adjusting a dictionary tree according to claim 1, wherein: After the step of structurally merging the subnodes of the node based on the shared node to obtain a dictionary tree with adjusted structure, the method includes: Get the string to be inserted; Matching the character information of the shared node with the character string to be inserted to obtain a matching result; If the matching result is a successful match, the string to be inserted is merged under the shared node to obtain a dictionary tree with updated nodes.

6. The method for adjusting a dictionary tree according to claim 5, characterized in that: If the matching result is a successful match, then after the step of merging the string to be inserted into the shared node to obtain a dictionary tree after the node is updated, the method includes: If the matching result is a matching failure, a child node corresponding to the string to be inserted is created in the dictionary tree to obtain an expanded and updated dictionary tree.

7. A dictionary tree adjustment device, characterized in that: The device comprises: An acquisition module is used to acquire the number of occurrences of each node under the current dictionary tree after the node of the dictionary tree is updated; A judging module, used for judging whether there is a node in the dictionary tree whose number of occurrences is greater than a preset number threshold; The adjustment module is used to construct the node and at least one of its parent nodes as shared nodes of the dictionary tree if the number of occurrences of the node is greater than a preset number threshold, and based on the shared node, structurally merge the child nodes of the node to obtain a dictionary tree with adjusted structure.

8. A dictionary tree adjustment device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the method for adjusting the dictionary tree according to any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the method for adjusting the dictionary tree according to any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method for adjusting the dictionary tree according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Mode matching method for dynamically adding tree node and unit based on common prefix

    CN105871726A

  • Conversation process control method and device of customer service robot, server and medium

    CN114528822A

  • Log compression and decompression method and device, electronic equipment and storage medium

    CN116471336A

  • Data query method and device, equipment and storage medium

    CN116610808A

  • Enterprise management information sharing system based on Internet and data analysis

    CN118869204A