Information input method, device, equipment, storage medium and program product
By determining the target node in the target tree structure and extracting candidate information in the target heap structure, the problem of high ordering processing time consumption in the prior art is solved, and efficient information input and storage space savings are achieved.
Patent Information
- Application Number
- CN202210787466.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-04
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2042-07-04
AI Technical Summary
When querying associative information from the prefix tree, the prior art needs to sort all information prefixed with the input string, resulting in a large amount of time consumption and affecting the efficiency of information input.
By determining the target node in the target tree structure and extracting candidate information from the target heap structure corresponding to the target node, and arranging the candidate information according to the order of search weights, the association information is directly extracted without complex sorting processing.
It reduces the time required to determine the association information during the information input process, improves the efficiency of information input, and saves storage space.
Smart Images

Figure CN115113740B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to artificial intelligence technology, and in particular to an information input method, device, equipment, storage medium and program product. Background Art
[0002] Providing associative information to users based on the string they input is a common application of artificial intelligence in the information input process. For example, a search engine pushes related words with the string as a prefix to users based on the string they input, to help users complete information input.
[0003] However, in the related art, when searching for associative information from a prefix tree, it is necessary to sort all information prefixed with the input string, so that it takes a long time to obtain the associative information, which affects the efficiency of information input. Summary of the invention
[0004] The embodiments of the present application provide an information input method, apparatus, device, computer-readable storage medium, and computer program product, which can improve the efficiency of information input.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The present application provides an information input method, including:
[0007] In response to an input operation on a character input area in the information input interface, obtaining an input character string;
[0008] For the input string, determine a target node from a target tree structure, wherein the target tree structure stores strings through paths between nodes, and the target node is a node at the end of the path corresponding to the input string;
[0009] Extracting at least one associative information corresponding to the input string from a plurality of candidate information of the target heap structure corresponding to the target node, wherein the plurality of candidate information are arranged in the target heap structure in order of search weights;
[0010] In the information display area of the information input interface, display at least one of the associated information;
[0011] In response to a selection operation on at least one target information in the associative information, the target information is displayed in the character input area to complete the information input.
[0012] An embodiment of the present application provides an information input device, including:
[0013] A character acquisition module, used for acquiring an input character string in response to an input operation on a character input area in the information input interface;
[0014] A node determination module, configured to determine a target node from a target tree structure for the input string, wherein the target tree structure stores strings through paths between nodes, and the target node is a node at the end of the path corresponding to the input string;
[0015] An information extraction module, configured to extract at least one associative information corresponding to the input string from a plurality of candidate information of a target heap structure corresponding to the target node, wherein the plurality of candidate information are arranged in the target heap structure in the order of search weights;
[0016] The information display module is used to display at least one of the associative information in the information display area of the information input interface; in response to a selection operation on a target information in at least one of the associative information, the target information is displayed in the character input area to complete the information input.
[0017] In some embodiments of the present application, the target heap structure includes: K candidate information; the information extraction module is also used to extract the candidate information of the kth round from the top of the iterative heap structure of the kth round; wherein 1≤k≤K, K is an integer; the iterative heap structure of the first round is the target heap structure; the remaining Kk candidate information are regenerated with the heap structure to obtain the iterative heap structure of the k+1th round; when k is iterated K, the candidate information of the Kth round iteration is determined as at least one of the associative information.
[0018] In some embodiments of the present application, the node determination module is also used to determine the matching node of the i+1th input character in the input string from the child nodes of the matching node of the i-th input character in the input string; wherein, 1≤i≤Q, Q is the total number of input characters contained in the input string; the matching node of the 1st input character is obtained by traversing the child nodes of the root node of the target tree structure; when a matching node is determined for the Q-th input character, the matching node of the Q-th input character is determined as the target node of the input string.
[0019] In some embodiments of the present application, the information input device also includes: a structure generation module; the structure generation module is used to obtain historical search information and determine the corresponding historical weight for the historical search information; encode the historical search information to obtain search coding data; wherein the search coding data is used to search the historical search information; for the coded characters in the search coding data, add matching nodes to the initial tree structure to obtain the target tree structure; the target node is included in the matching node corresponding to the coded character; based on the historical weight, the search coding data and the historical search information, for the matching node corresponding to the coded character in the target tree structure, construct a corresponding heap structure; the target heap structure is included in the heap structure of the matching node corresponding to the coded character in the search coding data.
[0020] In some embodiments of the present application, the structure generation module is also used to create a matching node for the sth coded character when no node corresponding to the sth coded character in the search coded data is found from the initial tree structure; wherein, 1≤s≤S, s is an integer, and S is the total number of coded characters contained in the search coded data; by determining the parent node for the matching node of the sth coded character in the initial tree structure, the matching node of the sth coded character is added to the initial tree structure; when s is iterated to S, the initial tree structure to which the matching nodes of the S coded characters are added is used as the target tree structure.
[0021] In some embodiments of the present application, the structure generation module is further used to compress the target tree structure by merging the sth coded character to the Sth coded character in the search coded data to obtain a compressed target tree structure;
[0022] The node determination module is further used to determine the target node from the compressed target tree structure with respect to the input character string.
[0023] In some embodiments of the present application, the structure generation module is also used to extract the prefix character corresponding to the sth coded character from the search coded data; determine the benchmark coded data for the search coded data based on the prefix character; when the sth coded character of the search coded data is different from the sth benchmark character of the benchmark coded data, determine the sth coded character as the starting point character of the single branch structure.
[0024] In some embodiments of the present application, the historical search information includes: N search information, the search coding data includes: N coding data corresponding to the N search information, and the historical weight includes: N weights corresponding to the N search information;
[0025] The structure generation module is also used to extract K matching coded data with prefix characters corresponding to the coded characters as prefixes from the N coded data; wherein N is a positive integer, K≤N; extract K candidate information corresponding to the K matching coded data from the N search information, and extract K search weights corresponding to the K matching coded data from the N weights; and obtain a heap structure of matching nodes corresponding to the coded characters in the target tree structure by constructing a heap structure for the K candidate information according to the K search weights.
[0026] In some embodiments of the present application, the structure generation module is also used to perform identifier mapping on the coded characters in the search coded data to obtain the character identifier corresponding to the coded character of the search coded data; the storage space required by the character identifier is smaller than the storage space required by the coded character; for the character identifier, a matching node is added to the initial tree structure to obtain the target tree structure.
[0027] In some embodiments of the present application, the structure generation module is also used to obtain historical search terms and historical search objects; extract subject words from the historical search objects to obtain historical subject terms; and obtain the historical search information from the historical subject terms and the historical search terms.
[0028] In some embodiments of the present application, the information display module is further used to display an information search interface corresponding to the target information; in the information search interface, search results for the target information are displayed.
[0029] The present application provides an information input device, including:
[0030] A memory for storing executable instructions;
[0031] The processor is used to implement the information input method provided in the embodiment of the present application when executing the executable instructions stored in the memory.
[0032] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute and implement the information input method provided by the embodiment of the present application.
[0033] An embodiment of the present application provides a computer program product, including a computer program or instructions, wherein the computer program or instructions are executed by a processor to implement the information input method provided in the embodiment of the present application.
[0034] The embodiments of the present application have the following beneficial effects: by arranging multiple candidate information in the order of search weights in a heap structure, during the information input process, only the target node is determined from the target tree structure that stores the string through the path between the nodes based on the input string of the object being used, and then the associative information is directly extracted from the multiple candidate information that has been arranged in the corresponding target heap structure, thereby obtaining the associative information without the need for complex sorting processing, thereby reducing the time required to determine the associative information during the information input process, and ultimately improving the efficiency of information input. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic diagram of the architecture of the information input system provided in the embodiment of the present application;
[0036] Figure 2 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application;
[0037] Figure 3 It is a flowchart of the information input method provided in the embodiment of the present application;
[0038] Figure 4 is a schematic diagram of an input string provided in an embodiment of the present application;
[0039] Figure 5 is another schematic diagram of an input string provided in an embodiment of the present application;
[0040] Figure 6 It is a schematic diagram showing the association information provided by the embodiment of the present application;
[0041] Figure 7 is a schematic diagram showing target information provided by an embodiment of the present application;
[0042] Figure 8 is another flowchart of the information input method provided in an embodiment of the present application;
[0043] Fig. 9 This is another flowchart of the information input method provided in the embodiment of the present application;
[0044] Fig.10 is a schematic diagram of a compression target tree structure provided by an embodiment of the present application;
[0045] Fig.11 is a schematic diagram of determining the starting character of a single branch structure provided in an embodiment of the present application;
[0046] Fig.12 is a schematic diagram of an information search interface provided in an embodiment of the present application;
[0047] Fig.13It is a schematic diagram of the process of associative word query provided by an embodiment of the present application;
[0048] Fig.14 It is a format diagram of search terms and weights after text preprocessing provided in an embodiment of the present application;
[0049] Fig.15 It is a schematic diagram of the format of data for constructing a prefix tree provided in an embodiment of the present application;
[0050] Fig.16 It is a schematic diagram of the structure of a node of a prefix tree provided in an embodiment of the present application;
[0051] Fig.17 It is a schematic diagram of a small root pile of a node provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0053] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0055] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0056] 1) Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0057] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0058] 2) Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between humans and computer science using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, language understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0059] 3) Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning and other technologies.
[0060] 4) Associative information refers to the process of selecting corresponding information from the associative information to replace the input information during the information input process. How to determine associative information is an important direction in machine learning and natural language processing.
[0061] 5) A prefix tree is a tree structure used to store strings. Each node in the prefix tree has multiple child nodes, and the paths leading to different child nodes have different strings.
[0062] 6) Heap structure refers to a complete binary tree structure implemented with an array. Heap structures can be divided into small root heaps and large root heaps. If the maximum value of each subtree in a complete binary tree is at the top, it is a large root heap. If the minimum value of each subtree in a complete binary tree is at the top, it is a small root heap.
[0063] 7) Hash table, can directly access the storage location in the memory according to the key, that is, can find the value corresponding to the key through the key. The hash table maps the key to the bucket through the hash function, and the bucket contains the value corresponding to the key.
[0064] 8) Byte is a unit of measurement used to measure storage capacity. It also represents data types and language characters in some computer programming languages. A byte stores an 8-bit unsigned number, and the stored value range is 0-255.
[0065] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as smart home scenarios, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. With the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0066] Providing associative information to users based on the string they input is a common application of artificial intelligence in the information input process. For example, a search engine pushes associative words with the string as a prefix to users based on the string they input, to help users complete information input.
[0067] In the related art, most of the associative information is queried through a prefix tree. For example, by searching for a string with an input string as a prefix in the prefix tree, the associative information is obtained. In order to improve the search efficiency, the arrangement structure of the prefix tree is also optimized in the related art. For example, the child nodes in each layer of the prefix tree are arranged from left to right according to the number of occurrences. The more left the node is, the more times it appears, which is convenient for searching.
[0068] Regardless of whether the arrangement structure of the prefix tree is optimized, the related art stores all its child nodes in each node in the form of a hash table, that is, stores the node corresponding to the information with the string corresponding to the node as the prefix. However, when information is input, only the most likely information to be used needs to be returned to the user. Therefore, in the related art, when querying associative information from the prefix tree, it is necessary to sort all the information with the input string as the prefix, obtain the optimal information and return it. It can be seen that in the related art, a large amount of sorting processing and a lot of time are required to obtain the associative information, which affects the efficiency of information input.
[0069] At the same time, storing all child nodes in each node in the form of a hash table will consume a lot of memory. As the number of nodes in the prefix tree increases, the storage resources required will also increase. In addition, when building a prefix tree, each time a node is inserted into the prefix tree, all nodes on the same layer will be reordered, which will consume a lot of computing resources.
[0070] The embodiments of the present application provide an information input method, apparatus, device, computer-readable storage medium, and computer program product, which can improve the efficiency of information input. The following describes an exemplary application of the information input device provided by the embodiments of the present application. The device provided by the embodiments of the present application can be implemented as various types of terminals such as a laptop computer, a tablet computer, a desktop computer, a set-top box, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device), and can also be implemented as a server. Below, an exemplary application when the information input device is implemented as a terminal will be described.
[0071] See also Figure 1 , Figure 1 1 is a schematic diagram of the architecture of the information input system provided in the embodiment of the present application. In order to support an information input application, in the information input system 100, the terminal (terminal 400-1 and terminal 400-2 are shown as examples) is connected to the server 200 via the network 300, and the network 300 can be a wide area network or a local area network, or a combination of the two. The information input system 100 is also provided with a database 500 to provide data support to the server 200. The database 500 can be configured in the server 200, or it can be independent of the server 200. Figure 1 The database 500 is shown to be independent of the server 200 .
[0072] Terminal 400-1 and terminal 400-2 are used to respond to input operations on the character input area in the information input interface in the graphical interface 410-1 and the graphical interface 410-2, respectively, to obtain an input string; for the input string, determine a target node from a target tree structure, wherein the target tree structure stores strings through paths between nodes, and the target node is a node at the end of the path corresponding to the input string; extract at least one associative information corresponding to the input string from multiple candidate information of a target heap structure corresponding to the target node, wherein the multiple candidate information is arranged in the target heap structure in the order of search weights; display at least one associative information in the information display area of the information input interface; in response to a selection operation on the target information in the at least one associative information, display the target information in the character input area to complete the information input. Terminal 400-1 and terminal 400-2 also send the target information to server 200 through network 300.
[0073] The server 200 is used to search for information according to the received target information, and return the search result for the target information to the terminal 400 - 1 and the terminal 400 - 2 .
[0074] Terminal 400 - 1 and terminal 400 - 2 may display search results in graphical interface 410 - 1 and graphical interface 410 - 2 , respectively.
[0075] In some embodiments, server 200 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminals 400-1 and 400-2 may be smart phones, tablet computers, laptop computers, desktop computers, smart speakers, smart watches, smart home appliances, car terminals, etc., but are not limited thereto. The terminals and servers may be directly or indirectly connected via wired or wireless communications, which is not limited in the embodiments of the present invention.
[0076] See also Figure 2 , Figure 2 is a schematic diagram of the structure of a terminal (an implementation of an information input device) provided in an embodiment of the present application, Figure 2 The terminal 400 shown includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430. The various components in the terminal 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 440 is not shown in FIG. Figure 2 Various buses are labeled as bus system 440 .
[0077] Processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0078] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0079] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.
[0080] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0081] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0082] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0083] A network communication module 452, used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, Wireless Fidelity (Wi-Fi), and Universal Serial Bus (USB), etc.;
[0084] a presentation module 453 for enabling presentation of information via one or more output devices 431 (e.g., display screen, speaker, etc.) associated with the user interface 430 (e.g., a user interface for operating peripherals and displaying content and information);
[0085] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.
[0086] In some embodiments, the information input device provided in the embodiments of the present application can be implemented in a software manner. Figure 2The information input device 455 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a character acquisition module 4551, a node determination module 4552, an information extraction module 4553, an information display module 4554 and a structure generation module 4555. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0087] In other embodiments, the information input device provided in the embodiments of the present application can be implemented in hardware. As an example, the information input device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the information input method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0088] In some embodiments, the terminal (an implementation of the information input device) can implement the information input method provided in the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a search engine APP, an input method APP, etc.; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0089] The embodiments of the present application can be applied to information input scenarios of cloud technology, artificial intelligence, smart transportation, vehicle-mounted, etc. The information input method provided by the embodiments of the present application will be described below in conjunction with the exemplary application and implementation of the information input device provided by the embodiments of the present application.
[0090] See also Figure 3 , Figure 3 is a flow chart of the information input method provided in the embodiment of the present application, which will be combined with Figure 3 The steps shown are explained.
[0091] S101. In response to an input operation on a character input area in an information input interface, obtain an input string.
[0092] The embodiments of the present application are implemented in a scenario where a user performs information input. For example, the user enters the name of a term to be searched in a search engine, or enters the name of an item to be purchased on an e-commerce platform, etc. After the information input process is triggered, the information input device creates and displays an information input interface, in which a character input area and an information display area are provided. The character input area is used to obtain the input string of the user, and the information display area is used to display the associated information determined for the input string of the user. When the information input device detects that the user enters characters in the character input area through external devices such as a virtual keyboard or a graphics tablet, it obtains each input character in the character input area and concatenates them in order to form an input string.
[0093] It can be understood that the sizes and positions of the character input area and the information display area can be set according to actual situations, and are not limited herein in the embodiments of the present application.
[0094] It should be noted that the input string can be an English string, a Chinese character string, a pinyin string, a numeric string, a string that mixes pinyin and Chinese characters, or a string that mixes English and Chinese characters, etc., and is not limited herein in the embodiments of the present application.
[0095] Exemplarily, Figure 4 FIG. 4 is a schematic diagram of an input string provided by an embodiment of the present application. In the character input area 4-11 in the information input interface 4-1, the input string 4-111 entered through the virtual keyboard 4-2 is displayed, that is, the Chinese character "手机" (mobile phone). Figure 5 FIG. 5 is another schematic diagram of an input string provided by an embodiment of the present application. In the character input area 5-11 in the information input interface 5-1, the input string 5-111 entered through the virtual keyboard 5-2 is displayed, that is, a combination of Chinese characters and pinyin "shou机" (mobile phone).
[0096] S102. Determine a target node from a target tree structure for the input string.
[0097] After obtaining the input string, the information input device will start matching from the root node of the target tree structure in the order of the input characters of the input string. When a node is matched from the target tree structure for each input character match, the node corresponding to the next character of the input character will continue to be matched in the child nodes of the node. In this way, the information input device can determine a unique path in the target tree structure for the input string, and determine the node at the end of the path as the target node. That is, the target node is the node at the end of the path corresponding to the input string.
[0098] It should be noted that in the embodiment of the present application, the target tree structure stores character strings through paths between nodes, that is, the path from any node in the target tree structure to the root node will have a corresponding character string.
[0099] It can be understood that the target tree structure in the embodiment of the present application can be a prefix tree, or a tree structure obtained by deforming the prefix tree, and the embodiment of the present application does not limit this.
[0100] S103. Extract at least one associative information corresponding to the input string from a plurality of candidate information of the target heap structure corresponding to the target node, wherein the plurality of candidate information are arranged in the target heap structure in order of search weights.
[0101] In the embodiment of the present application, each node in the target tree structure has a corresponding heap structure, and in the heap structure, multiple information that can be pushed to the user object, i.e., candidate information, is arranged according to the size of the search weight. The information input device first extracts the target heap structure corresponding to the target node from the heap structures corresponding to all the nodes of the target tree structure, and then extracts information from the multiple candidate information in the target heap structure, and determines the extracted information as associative information. In this way, the information input device can obtain at least one associative information.
[0102] It should be noted that multiple candidate information are arranged in the target heap structure in the order of search weights. Therefore, the information input device can directly extract the associative information that needs to be returned to the user object from the multiple candidate information according to the order of search weights, without having to sort and calculate all information with the input string as a prefix. In this way, the time-consuming sorting and calculation process can be omitted in the process of determining the associative information.
[0103] In some embodiments, the multiple candidate information may be the best information selected from all the information prefixed with the input string according to the search weight, and the multiple candidate information may be the N pieces of information with the largest search weight, or may be information with a search weight greater than a weight threshold. For example, when the input string is "mobile phone", the candidate information may be "mobile phone case", "mobile phone film", etc.
[0104] In other embodiments, the plurality of candidate information may also be information that has semantic association with the input string (which can be obtained by semantically analyzing the input string and filtering based on the analyzed semantics), or information associated with other dimensions such as entity association (which can be obtained by searching in a graph structure storing associations between different entities), that is, the candidate information may not necessarily be prefixed with the input string, but may be information that is different from the input string at the character level but is associated with the input string in the semantic dimension or entity dimension. For example, when the input string is "mobile phone", the candidate information may be "charger", "data cable", etc.
[0105] In the embodiment of the present application, the target heap structure can be directly stored in the node data of the target node, or can be stored independently, as long as a corresponding relationship with the target node is established.
[0106] S104: Display at least one associative information in the information display area of the information input interface.
[0107] After determining at least one associative information, the information input device can display at least one associative information in the information display area in the order of search weight, or can display at least one associative information in the information display area in a random order, so that the user can select the information he wants to input from the displayed associative information.
[0108] For example, Figure 6 6-111, i.e., "mobile phone", is displayed in the character input area 6-11 of the information input interface 6-1. At this time, in the information display area 6-12 of the information input interface 6-1, the associated information 6-121 corresponding to "mobile phone" is displayed, such as "mobile phone case", "mobile phone film", "first-time mobile phone gift for one year", "charger", "data cable", etc.
[0109] S105 . In response to a selection operation on target information in at least one associative information, the target information is displayed in a character input area to complete information input.
[0110] When the information input device detects that the user performs a selection operation on any associative information in the at least one associative information, the associative information is determined as the target information finally input by the user, and the target information is displayed in the character input area so that the user can understand the input information. At this point, the information input device completes the information input process.
[0111] It can be understood that the selection operation can be any one of a click operation, a double-click operation, a slide operation and a long press operation, or it can be other operations that can achieve the selection function, and the embodiments of the present application are not limited here.
[0112] For example, based on Figure 6 , see Figure 7 , Figure 7 6-11 is a schematic diagram showing target information provided by an embodiment of the present application. When the user selects "mobile phone case" as target information 7-1 from the associative information 6-121 through a click operation, the information input device will display "mobile phone case" in the character input area 6-11 to complete the information input process.
[0113] It is understandable that, compared with the related art, when querying associative information through a prefix tree, a large amount of sorting processing is required to obtain the associative information, resulting in low information input efficiency. In the embodiment of the present application, by arranging multiple candidate information in the heap structure in the order of search weight, during the information input process, only the target node is determined from the target tree structure that stores the string through the path between the nodes based on the input string of the object being used, and then the associative information is directly extracted from the multiple candidate information that has been arranged in the corresponding target heap structure. Therefore, the associative information can be obtained without complicated sorting processing, which reduces the time required to determine the associative information during the information input process, and ultimately improves the efficiency of information input.
[0114] based on Figure 3 , see Figure 8 , Figure 8 It is another flow chart of the information input method provided by the embodiment of the present application. In some embodiments of the present application, the target heap structure includes: K candidate information, and at least one associative information corresponding to the input string is extracted from the multiple candidate information of the target heap structure corresponding to the target node, that is, the implementation process of S103 may include: S1031-S1033, as follows:
[0115] S1031 . Extract candidate information of the kth round from the top of the iterative heap structure of the kth round.
[0116] Wherein, 1≤k≤K, and the first round of iteration heap structure is the target heap structure. That is, the information input device determines the target heap structure as the first round of iteration heap structure, that is, determines the target heap structure as the start of iteration to start extracting candidate information. In each round of iteration, the information input device extracts a candidate information at the top of the iteration heap structure of that round to obtain the candidate information of the kth round.
[0117] It can be understood that the candidate information at the top of the iterative heap structure can be the candidate information with the largest search weight among the candidate information contained in the iterative heap structure, or it can be the candidate information with the smallest search weight among the candidate information contained in the iterative heap structure. The embodiments of the present application are not limited here.
[0118] S1032. Regenerate the heap structure of the remaining Kk candidate information to obtain the iterative heap structure of the k+1th round.
[0119] Whenever the number of candidate information in the heap structure changes, the heap structure needs to be re-heaped, that is, the heap structure needs to be regenerated. Therefore, after extracting the candidate information of the kth round, the information input device will re-heap the remaining Kk candidate information according to their corresponding search weights to obtain the iterative heap structure of the k+1th round.
[0120] S1033: When k is iterated by K, the candidate information of the K-round iteration is determined as at least one associative word.
[0121] After K rounds of iteration, the information input device will determine all candidate information of all iteration rounds, that is, candidate information of K rounds of iteration, as associative information. In this way, the information input device obtains at least one associative information.
[0122] Furthermore, since the top of the heap structure can only be the candidate information with the largest search weight or the candidate information with the smallest search weight among the candidate information contained in the heap structure, the information input device can arrange the extracted K candidate information in order of search weight from large to small or from small to large by taking only the candidate information at the top of the heap in each iteration round, thereby obtaining at least one associative information and also arranged in order of search weight, so as to improve the display effect of at least one associative information.
[0123] In some embodiments of the present application, for an input string, determining a target node from a target tree structure, that is, a specific implementation process of S102, may include: S1021-S1022 (not shown in the figure), as follows:
[0124] S1021. Determine a matching node for the (i+1)th input character in the input string from the child nodes of the matching node for the i-th input character in the input string.
[0125] Wherein, 1≤i≤Q, Q is the total number of input characters contained in the input string. That is to say, the information input device determines the corresponding matching node for the next input character of each input character in the child node of the matching node of each input character in the input string, so that it can ensure that there is a "connection" relationship between the matching nodes corresponding to each input character of the input string, and thus determine the corresponding path for the input string based on the relationship.
[0126] It should be noted that, in the embodiment of the present application, the matching node of the first input character is obtained by traversing the child nodes of the root node of the target tree structure. That is, the information input device first determines the matching node from the child nodes corresponding to the root node for the first input character, and then obtains the matching node of the second input character from the child nodes of the matching node of the first input character, and so on, until the matching nodes are determined for all input characters.
[0127] S1022. When a matching node is determined for the Qth input character, the matching node of the Qth input character is determined as the target node of the input character string.
[0128] After the information input device determines matching nodes for all input characters, it determines the matching node of the last input character as the target node of the input string. At this point, the information input device has completed the determination of the target node.
[0129] based on Figure 3 , see Fig. 9 , Fig. 9 It is another flowchart of the information input method provided by the embodiment of the present application. In some embodiments of the present application, in response to the input operation on the character input area in the information input interface, before obtaining the input string, that is, before S101, the method may include: S106-S109, as follows:
[0130] S106: Obtain historical search information, and determine corresponding historical weights for the historical search information.
[0131] It can be understood that historical search information refers to information that the user has searched for in the historical time, and the historical weight is calculated based on the search frequency, click-through rate, conversion rate and other data of the historical search information. It is an indicator used to measure whether the historical search information is commonly used search information.
[0132] S107. Encode the historical search information to obtain search encoding data, wherein the search encoding data is used to search the historical search information.
[0133] Since the input string of the object can be in various formats such as Chinese characters, English letters, pinyin, etc., the information input device needs to encode the historical search information in the format of English letters, pinyin, etc., so as to obtain search code data in different formats. For example, when the historical search information is "fruit", the information input device can encode the search code data of "shuiguo" in the pinyin format, or encode the search code data of "fruit" in the English letter format.
[0134] It should be noted that the information input device can also directly determine the original text of the historical search information as the search coding data, and the embodiment of the present application does not limit this.
[0135] It is understandable that the historical search information, search coding data and historical weight in the embodiments of the present application do not refer to a specific content, but are general. That is, the historical search information may include multiple search information, the search coding data may include the coding data of multiple search information, and accordingly, the historical weight may also include the weight of multiple search information.
[0136] S108. Add matching nodes to the initial tree structure for the coded characters in the search coded data to obtain a target tree structure.
[0137] The search code data includes multiple code characters, and the information input device inserts the search code data into the initial tree structure in the order of the code characters, that is, adds matching nodes for each code character in the initial tree structure in order. After the matching nodes of all code characters are added, the target tree structure is obtained.
[0138] It should be noted that the target node is included in the matching nodes corresponding to the coded characters. That is, the target node corresponding to the input string of the object to be used is determined from the matching nodes corresponding to the coded characters of the search coded data.
[0139] It is understandable that the initial tree structure can be an empty tree structure obtained through the initialization operation, or a non-empty tree structure to which matching nodes of some characters have been added. When the initial tree structure is a non-empty tree structure, when the information input device adds a matching node for a coded character, it can first determine whether the string formed by the path from the character to the root node in the initial tree structure is the same as the string corresponding to the coded character in the searched coded data (the string consisting of the coded character and the characters before the coded character). If they are the same, the matching node of the added character is directly determined as the matching node of the coded character.
[0140] S109: Based on the historical weight, the search encoding data and the historical search information, a corresponding heap structure is constructed for the matching nodes corresponding to the encoded characters in the target tree structure.
[0141] After completing the construction of the target tree structure, the information input device will establish a heap structure for the matching nodes in the target tree structure corresponding to the coded characters in the search coded data, thereby obtaining a heap structure corresponding to each matching node.
[0142] It can be understood that the target heap structure is included in the heap structure of the matching node corresponding to the encoded character in the search encoded data.
[0143] In some embodiments of the present application, for searching for coded characters in the coded data, a matching node is added to the initial tree structure to obtain a target tree structure, that is, a specific implementation process of S108, which may include: S1081-S1083 (not shown in the figure), as follows:
[0144] S1081. When no node corresponding to the s-th coded character in the search coded data is found from the initial prefix tree, a matching node is created for the s-th coded character.
[0145] Wherein, 1≤s≤S, s is an integer, and S is the total number of coded characters contained in the search coded data. The information input device performs a node query in the initial prefix tree for each coded character in the search coded data, that is, determines whether each coded character appears in the child node of the matching node corresponding to the previous coded character. When the information input device fails to query the corresponding node for each coded character, a new node is created for the coded character, and the created node is determined as the matching node.
[0146] S1082. Determine a parent node for a matching node of the s-th coded character in the initial tree structure, and add the matching node of the s-th coded character to the initial tree structure.
[0147] It should be noted that when s is 1, the information input device determines the root node of the initial tree structure as the parent node of the matching node of the sth coded character. When s is not 1, the information input device determines the matching node of the s-1th coded character as the parent node of the matching node of the sth coded character. In this way, the information input device can add a matching node in the initial tree structure for each coded character.
[0148] S1083. When s iterates to S, the initial tree structure to which the matching nodes of the S encoded characters are added is used as the target tree structure.
[0149] When the last round is completed, that is, the matching node of the Sth coded character information is added to the initial tree structure, the information input device will determine the initial tree structure after adding the matching nodes of the S coded characters as the target tree structure. At this point, the information input device has completed the construction of the target tree structure, so as to query the corresponding target node for the input string of the user object in the future.
[0150] In some embodiments of the present application, the sth coded character is the starting character of the single-branch structure. In this case, after the initial tree structure to which the matching nodes of the S coded characters are added is used as the target tree structure, that is, after S1083, the method may further include: S1084 (not shown in the figure), as follows
[0151] S1084. Compress the target tree structure by merging the sth coded character to the Sth coded character in the search coded data to obtain a compressed target tree structure.
[0152] When the information input device determines that the sth coded character is the starting character of a single-branch structure, it will merge the coded characters from the sth to the Sth into one character to obtain a merged character, and then use the merged character to determine the content of the matching node corresponding to the sth coded character, and delete the matching nodes corresponding to the s+1th to the Sth coded characters respectively, so as to compress the target tree structure, thereby reducing the storage space required for the target tree structure.
[0153] It should be noted that each node in a single branch structure has at most one child node. Since a hash table requires a certain amount of memory space to store hash mapping relationships, if a single branch structure is used to store its child nodes in a node in the manner of a hash table, a large amount of memory space will be wasted. However, through the embodiments of the present application, the remaining nodes of the single branch structure in the tree structure can be compressed into one node, reducing the number of nodes in the target tree structure, so that the space of the compressed target tree structure can be greatly reduced.
[0154] For example, Fig.1010-1 is a schematic diagram of a compressed target tree structure provided in an embodiment of the present application. The search coding data stored in the target tree structure 10-1 include "cebeibao", "cdji", "cebao" and "cebai zi", wherein the e-node 10-11, the d-node 10-12 and the i-node 10-13 are all nodes corresponding to the starting characters of the single branch structure, so that the information input device will merge these coded characters and the coded characters after these coded characters to obtain the compressed target tree structure 10-2. It can be seen that in the compressed target tree structure 10-2, the content in the e-node 10-11 has become "eibao", the content in the d-node 10-12 has become "dji", and the content in the i-node 10-13 has become "izi". Compared with the target tree structure 10-1, the compressed target tree structure 10-2 requires less storage space.
[0155] In some embodiments of the present application, determining whether the sth coded character is the starting character of the single-branch structure can be implemented through S201-S203 (not shown in the figure):
[0156] S201. Extract the prefix character corresponding to the sth coded character from the search coded data.
[0157] The information input device will search the coded data and extract all characters before the s-th coded character, and the obtained characters are the prefix characters of the s-th coded character.
[0158] Exemplarily, when the searched coded data is "cebeibao" and the s-th coded character is e, then "ceb" is the prefix character of the s-th coded character.
[0159] S202. Determine reference coding data for the search coding data based on the prefix character.
[0160] The information input device determines the code data having the prefix character as a prefix and arranged after the search code data according to the dictionary as the reference code data of the search code data. That is, the search code data and the reference code data have the same prefix.
[0161] For example, when the search code data is "cebeibao", the reference code data may be "cebao".
[0162] S203: When the s-th coded character of the searched coded data is different from the s-th reference character of the reference coded data, the s-th coded character is determined as the starting point character of the single branch structure.
[0163] The information input device extracts the sth reference character from the reference coding data and compares the sth reference character with the sth coded character of the search coding data. When it is determined that the sth coded character is different from the sth reference character, that is, when it is determined that the sth coded character is the first coded character that is different from the reference character in the reference coding data, the sth coded character is determined as the starting point character of the single branch structure.
[0164] Fig.11 This is a schematic diagram of determining the starting character of a single branch structure provided by an embodiment of the present application. The sth coded character in the search coded data 11-1 is e, and the sth coded character in the reference coded data 11-2 is a, so the information input device will determine the sth coded character e as the starting character of the single branch structure.
[0165] It can be understood that in the embodiment of the present application, the information input device can determine whether the coded character is the starting character of a single branch structure by judging whether the coded character is the same as the benchmark character at the same position in the benchmark coding data, and when it is determined that the coded character is the starting character of the single branch structure, the coded character is merged with the coded character after the coded character, that is, the nodes in the single branch structure are compressed into the same node, so as to realize the pruning operation of the target tree structure and save storage space.
[0166] In some embodiments of the present application, the historical search information includes: N search information, the search coding data includes: N coding data corresponding to the N search information, and the historical weight includes: N weights corresponding to the N search information. In this case, based on the historical weight, the search coding data and the historical search terms, for the matching nodes corresponding to the coded characters in the target tree structure, a corresponding heap structure is constructed, that is, the specific implementation process of S109, which may include: S1091-S1093 (not shown in the figure), as follows:
[0167] S1091. Extract K matching coded data with prefix characters corresponding to the coded characters as prefixes from the N coded data.
[0168] The information input device can directly use any coded character as the corresponding prefix character, or use the coded character and a string consisting of the characters before the coded character as the prefix character corresponding to the coded character, and then extract the coded data with the prefix character from the N coded data to obtain K matching coded data.
[0169] It should be noted that N is a positive integer and K is a positive integer. N and K may be equal or unequal, but K cannot be greater than N, that is, K≤N.
[0170] S1092. Extract K candidate information corresponding to the K matching coded data from the N search information, and extract K search weights corresponding to the K matching coded data from the N weights.
[0171] After obtaining K matching coded data, the information input device will extract the search information and weights corresponding to the K matching coded data from the N search information and the N weights, respectively, and use the extracted search information as candidate information and the extracted weights as search weights. In this way, the information input device can obtain K candidate information and M search weights.
[0172] S1093. By constructing a heap structure for K candidate information according to K search weights, a heap structure of matching nodes corresponding to the encoded characters in the target tree structure is obtained.
[0173] The information input device can determine the position of any candidate information in the heap structure by adding it to the end of the heap structure, and according to the relationship between its search weight and the search weight of the candidate information already added to the heap structure. This cycle is repeated until all the candidate information is added to the end of the heap and sorted, and a heap structure of matching nodes corresponding to the encoded characters is obtained. It is understandable that the heap structure can be a large root heap structure or a small root heap structure, which is not limited in the embodiments of the present application.
[0174] At this point, the information input device has completed the construction of the heap structure, so as to obtain the target heap structure corresponding to the target node.
[0175] In some embodiments of the present application, after encoding the historical search information to obtain the search encoding data, that is, after S107, the method may further include: S110-S111 (not shown in the figure), as follows:
[0176] S110, performing identifier mapping on the coded characters in the search coded data to obtain character identifiers corresponding to the coded characters in the search coded data.
[0177] S111. For the character identifier, add a matching node to the initial tree structure to obtain a target tree structure.
[0178] After obtaining the search coded data, the information input device can also generate a corresponding character identifier for each coded character in the search coded data, and the storage space required by the generated character identifier is smaller than the storage space required by the coded character. Afterwards, the information input device uses the character identifier to replace the coded character, that is, the character identifier is added to the initial tree structure so that the storage space required for the node data of the matching node is smaller, thereby effectively reducing the storage space required by the target tree structure.
[0179] For example, there are about 5,000 common Chinese characters. If corresponding digital identifiers (character identifiers) are assigned to common Chinese characters, then depending on the number of characters, 2 to 3 bytes can generally be used to represent the encoded characters. Compared with using hash table key values to store encoded characters, a lot of storage space can be saved.
[0180] In some embodiments of the present application, the specific implementation process of obtaining historical search information, that is, S106, may include: S1061-S1063 (not shown in the figure), as follows:
[0181] S1061. Obtain historical search terms and historical search objects.
[0182] It is understood that the historical search terms refer to the terms directly input by the user. The historical search objects refer to the products or contents viewed by the user in the search results returned for the user's input information. For example, if the user inputs "nutritional supplements" and views the product "fruit" in the returned search results, then "fruit" is the historical search object.
[0183] S1062. Extract subject words from the historical search object to obtain historical subject terms.
[0184] The information input device can extract subject words for the historical search object through natural language processing (NLP), thereby obtaining the historical subject entries corresponding to the historical search.
[0185] S1063. Obtain historical search information from historical subject terms and historical search terms.
[0186] The information input device may return at least one of the historical subject terms and the historical search terms as historical search information. In some embodiments, the information input device may also preprocess the historical subject terms and the historical search terms, for example, removing redundant punctuation marks, aligning characters, etc., and return at least one of the preprocessed historical subject terms and the historical search terms as historical search information. In this way, the information input device can obtain historical search information to facilitate the construction of the target tree structure.
[0187] In some embodiments of the present application, in response to a selection operation on target information in at least one associative information, the target information is displayed in the character input area. After the information input is completed, that is, after S105, the method may further include: S112-S113 (not shown in the figure), as follows:
[0188] S112: Displaying the information search interface corresponding to the target information
[0189] S113. Displaying search results for target information in the information search interface.
[0190] For example, when the target information is "fruit", the information input device will display an information search interface about fruit, and in the information search interface, display search results about fruit, such as the price of the fruit, the place of production, etc., so that the user can understand the detailed information of the fruit.
[0191] For example, Fig.12 1 is a schematic diagram of an information search interface provided by an embodiment of the present application. When the information input device displays the target information 12-111 selected by the user, i.e., "mobile phone case", in the character input area 12-11 of the information input interface 12-1, the information input device will also jump from the information input interface 12-1 to the information search interface 12-2, and display search results 12-21 related to "mobile phone case", i.e., various mobile phone case products, in the information search interface 12-2. In this way, the information input device can provide a search function for target information.
[0192] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.
[0193] The embodiment of the present application is implemented in a scenario where a server (information input device) performs an associative word query for characters input in a search input box (character input area) to obtain possible inputs of a user object.
[0194] Fig.13 Schematic diagram of the process of associative word search provided by the embodiment of the present application. Fig.13 , the process may include:
[0195] S301, obtain all search terms and calculate weights.
[0196] The search terms can be derived from the search terms of all the objects used in history (historical search terms), or from the subject terms (historical subject terms) extracted from all the historical search objects (historical search objects) as the search terms. The weight can be calculated based on the search frequency corresponding to the search terms, or the click rate of the objects used.
[0197] S302: Perform text preprocessing on the search terms.
[0198] Next, the server performs text preprocessing on the search terms, including but not limited to removing invalid punctuation marks, unifying upper and lower case, removing spaces, etc. For example, for "apple [fruit] 5KG", after text preprocessing, "apple fruit 5kg" is obtained.
[0199] Fig.14 It is a format diagram of search terms and weights after text preprocessing provided by the embodiment of the present application. Each search term 14-1 has its corresponding weight 14-2. For example, the weight of "tablet computer" is 0.963192, the weight of "fruit" is 0.914012, the weight of "mobile phone" is 0.898341, the weight of "computer" is 0.871022, and so on.
[0200] S303, generating different coded texts for the preprocessed entries.
[0201] Since the user may enter Chinese characters, letters, pinyin, pinyin initials and other abbreviations when entering the search term, the server needs to generate different encoding texts (search encoding data) for the pre-processed entries (historical search information). For example, "fruit" is encoded as the full pinyin "shuiguo", the pinyin initials "sg", and the default encoding method, that is, the original text "fruit".
[0202] S304, sort the encoded text in lexicographical order.
[0203] After all the entries are converted to the corresponding codes, the coded data for searching and matching can be obtained. Then, the server sorts the coded texts of the entries in lexicographic order (ie alphabetical order), thereby obtaining data for constructing a prefix tree.
[0204] For example, Fig.15 It is a schematic diagram of the format of data for constructing a prefix tree provided by an embodiment of the present application. In the data, each search term 15-1 has a coded text 15-2 and a weight 15-3, and all coded texts 15-2 are arranged in alphabetical order.
[0205] S305: Build a prefix tree.
[0206] The server inserts the sorted encoded text into the prefix tree (initial prefix tree) in sequence. The prefix tree consists of several nodes. Fig.16 It is a schematic diagram of the structure of the node of the prefix tree provided by the embodiment of the present application. The node 16-1 of the prefix tree may contain three parts, the first is a hash table 16-11, which is used to maintain the child node information; the second is a small root heap 16-12 of k words, which is used to store k optimal candidate words (candidate information); the third is a compressed suffix string 16-13, that is, a suffix string composed of compressed and merged child nodes under a single branch.
[0207] When the server constructs a prefix tree, it first initializes an empty root node and its corresponding empty child nodes, and then inserts the encoded text of all entries into the prefix tree character by character. In more detail, the server can determine whether the current character appears in the current child node. If so, it moves the pointer to the current child node. If not, it creates a new child node (matching node) and determines whether the current character is the first node (starting character) of a single-branch structure. If it is a single-branch structure, the remaining nodes of the single-branch structure are compressed into one node, and the current node position is moved to the compressed node to complete the pruning of the prefix tree. For example, Fig.10 The "ebiao" in is used as the content of the e-node.
[0208] The method for determining whether it is a single-branch structure is as follows: when inserting the coded text sorted in lexicographic order into the prefix tree, if at least the first character (prefix character) is equal, the character (reference character) at the same position of the current text encoding and the next text encoding (reference encoding data) in lexicographic order is compared to determine whether the first different character position is the starting point of the single-branch structure, and the characters after the starting point (the sth coded character to the Sth coded character) are merged into the character content of the current node. In this way, the prefix tree can save 50% of the node space.
[0209] A character corresponds to a Chinese character, and an English or Pinyin character corresponds to a letter. In this way, the server can traverse all characters in the encoded text (encoded characters), map the characters to numbers (character identifiers), and the Chinese characters in the scene are generally 5,000, plus English letters. After digital encoding, two bytes of unit16 can generally be used to represent the characters according to the number of characters. Compared with the character representation of strings, Chinese characters generally occupy 3 characters, so digital encoding can effectively reduce the storage space occupied by the hash table key value of the storage child node.
[0210] After executing the above steps, the entry currently traversed is added to the tail of the small root heap of size K (K is the number of associative words to be returned) in the current node, and the small root heap is re-heapified (constructing a heap structure). When the heap is full, it is determined whether the weight of the newly added entry is greater than the top element of the heap. If greater, the top element of the heap is first deleted and the heap is re-heapified, and then the new entry is added to the tail of the heap, and the heap is heapified here. In this way, through the small root heap of size K, it can be ensured that the K entries (candidate information) with the largest weight (search weight) are always stored in the node, and the time complexity of heap sorting is O (NlogK), and the space complexity is O (1), which can effectively improve the sorting efficiency and return the K associative words with the highest weight to the user object.
[0211] For example, Fig.17Schematic diagram of the small root heap of the node provided in the embodiment of the present application. The server constructs a small root heap 17-2 for the node 17-1 of the character "h", and stores K=7 entries with the highest weights in the small root heap, namely: "huafei", weight 0.708; "huaduo", weight 0.753, "huawen", weight 0.8109; "huanle", weight 0.845; "hua", weight 0.851; "huijia", weight 0.922; "huifu", weight 0.971.
[0212] S306: In response to the input of the usage object, perform prefix matching.
[0213] S307: The associated words are sequentially removed from the stack and returned to the user.
[0214] In response to the query request for the object, the server obtains the input word (input string) of the object, and starts traversing from the first character (input character) at the root node of the constructed prefix tree (target tree structure). If a leaf node is successfully reached, it means that the input word of the object is in the prefix tree, and the small root heap data corresponding to the node is obtained, and the heap is removed in turn to obtain K associated words in reverse order of weight. For example, for Fig.17 The "h" node in the root heap is directly retrieved and returned. If no corresponding node is found in the end, an empty result is returned. In this way, the server can complete the return of the associated word.
[0215] It is understandable that in the embodiments of the present application, user information is involved, such as input strings, historical search information and other related data. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0216] The following is a description of an exemplary structure of the information input device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2 As shown, the software modules stored in the information input device 455 of the memory 450 may include:
[0217] The character acquisition module 4551 is used to acquire an input character string in response to an input operation on a character input area in the information input interface;
[0218] A node determination module 4552 is used to determine a target node from a target tree structure for the input string, wherein the target tree structure stores strings through paths between nodes, and the target node is a node at the end of the path corresponding to the input string;
[0219] The information extraction module 4553 is used to extract at least one associative information corresponding to the input string from a plurality of candidate information of the target heap structure corresponding to the target node; wherein the plurality of candidate information are arranged in the target heap structure in the order of search weights;
[0220] The information display module 4554 is used to display at least one of the associative information in the information display area of the information input interface; in response to a selection operation on a target information in at least one of the associative information, the target information is displayed in the character input area to complete the information input.
[0221] In some embodiments of the present application, the target heap structure includes: K candidate information; the information extraction module 4553 is also used to extract the candidate information of the kth round from the top of the iterative heap structure of the kth round; wherein 1≤k≤K, K is an integer; the iterative heap structure of the first round is the target heap structure; the remaining Kk candidate information are regenerated with the heap structure to obtain the iterative heap structure of the k+1th round; when k is iterated K, the candidate information of the Kth round iteration is determined as at least one of the associative information.
[0222] In some embodiments of the present application, the node determination module 4552 is also used to determine the matching node of the i+1th input character in the input string from the child nodes of the matching node of the i-th input character in the input string; wherein, 1≤i≤Q, Q is the total number of input characters contained in the input string; the matching node of the 1st input character is obtained by traversing the child nodes of the root node of the target tree structure; when a matching node is determined for the Q-th input character, the matching node of the Q-th input character is determined as the target node of the input string.
[0223] In some embodiments of the present application, the information input device 455 also includes: a structure generation module 4555; the structure generation module 4555 is used to obtain historical search information and determine the corresponding historical weight for the historical search information; encode the historical search information to obtain search coding data; wherein the search coding data is used to search the historical search information; for the coded characters in the search coding data, add matching nodes to the initial tree structure to obtain the target tree structure; the target node is included in the matching node corresponding to the coded character; based on the historical weight, the search coding data and the historical search information, for the matching node corresponding to the coded character in the target tree structure, construct a corresponding heap structure; the target heap structure is included in the heap structure of the matching node corresponding to the coded character in the search coding data.
[0224] In some embodiments of the present application, the structure generation module 4555 is also used to create a matching node for the sth coded character when no node corresponding to the sth coded character in the search coded data is found from the initial tree structure; wherein, 1≤s≤S, s is an integer, and S is the total number of coded characters contained in the search coded data; by determining the parent node for the matching node of the sth coded character in the initial tree structure, the matching node of the sth coded character is added to the initial tree structure; when s is iterated to S, the initial tree structure to which the matching nodes of the S coded characters are added is used as the target tree structure.
[0225] In some embodiments of the present application, the structure generation module 4555 is further used to compress the target tree structure by merging the sth coded character to the Sth coded character in the search coded data to obtain a compressed target tree structure;
[0226] The node determination module 4552 is further used to determine the target node from the compressed target tree structure with respect to the input string.
[0227] In some embodiments of the present application, the structure generation module 4555 is also used to extract the prefix character corresponding to the sth coded character from the search coded data; determine the benchmark coded data for the search coded data based on the prefix character; when the sth coded character of the search coded data is different from the sth benchmark character of the benchmark coded data, determine the sth coded character as the starting point character of the single branch structure.
[0228] In some embodiments of the present application, the historical search information includes: N search information, the search coding data includes: N coding data corresponding to the N search information, and the historical weight includes: N weights corresponding to the N search information;
[0229] The structure generation module 4555 is also used to extract K matching coded data with the prefix character corresponding to the coded character as a prefix from the N coded data; wherein N is a positive integer, K≤N; extract K candidate information corresponding to the K matching coded data from the N search information, and extract K search weights corresponding to the K matching coded data from the N weights; and obtain the heap structure of the matching nodes corresponding to the coded characters in the target tree structure by constructing a heap structure for the K candidate information according to the K search weights.
[0230] In some embodiments of the present application, the structure generation module 4555 is also used to perform identifier mapping on the coded characters in the search coded data to obtain the character identifier corresponding to the coded character of the search coded data; the storage space required by the character identifier is smaller than the storage space required by the coded character; for the character identifier, a matching node is added to the initial tree structure to obtain the target tree structure.
[0231] In some embodiments of the present application, the structure generation module 4555 is also used to obtain historical search terms and historical search objects; extract subject words from the historical search objects to obtain historical subject terms; and obtain the historical search information from the historical subject terms and the historical search terms.
[0232] In some embodiments of the present application, the information display module 4554 is also used to display an information search interface corresponding to the target information; in the information search interface, the search results for the target information are displayed.
[0233] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the information input method described in the embodiment of the present application.
[0234] The embodiment of the present application provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the information input method provided by the embodiment of the present application, for example, Figure 3 The information input method shown.
[0235] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0236] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0237] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0238] As an example, executable instructions may be deployed to be executed on one electronic device (ie, an information input device), or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected by a communication network.
[0239] In summary, through the embodiments of the present application, by arranging multiple candidate information in the order of search weights in the heap structure, during the information input process, it is only necessary to determine the target node from the target tree structure that stores the string through the path between the nodes based on the input string of the object being used, and then directly extract the associative information from the multiple candidate information that have been arranged in the corresponding target heap structure, thereby obtaining the associative information without the need for complex sorting processing, thereby reducing the time required to determine the associative information during the information input process, and ultimately improving the efficiency of information input; the nodes in the single branch structure in the tree structure are compressed into the same node to implement the pruning operation on the target tree structure and save storage space.
[0240] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A method for inputting information, characterized in that: The method comprises: Encoding the acquired historical search information to obtain search encoding data, and determining a corresponding historical weight for the historical search information, wherein the search encoding data is used to search the historical search information; When no node corresponding to the s-th coded character in the search coded data is found from the initial tree structure, a matching node is created for the s-th coded character, a parent node is determined for the matching node of the s-th coded character in the initial tree structure, the matching node of the s-th coded character is added to the initial tree structure, and when s is iterated to S, the initial tree structure to which the matching nodes of the S coded characters are added is used as the target tree structure; wherein, , s is an integer, and S is the total number of coded characters contained in the search coded data; Extracting a prefix character corresponding to the sth coded character from the search coded data, determining reference coded data for the search coded data based on the prefix character, and compressing the target tree structure by merging the sth coded character to the Sth coded character in the search coded data when the sth coded character of the search coded data is different from the sth reference character of the reference coded data; the target node is included in the matching node corresponding to the coded character; Based on the historical weight, the search coding data and the historical search information, a corresponding heap structure is constructed for the matching node corresponding to the coding character in the target tree structure; the target heap structure is included in the heap structure of the matching node corresponding to the coding character in the search coding data; In response to an input operation on a character input area in the information input interface, obtaining an input character string; For the input string, determine a target node from the target tree structure, wherein the target tree structure stores strings through paths between nodes, and the target node is a node at the end of the path corresponding to the input string; Extracting at least one associative information corresponding to the input string from a plurality of candidate information of the target heap structure corresponding to the target node, wherein the plurality of candidate information are arranged in the target heap structure in order of search weights; In the information display area of the information input interface, display at least one of the associated information; In response to a selection operation on at least one target information in the associative information, the target information is displayed in the character input area to complete the information input.
2. The method according to claim 1, characterized in that The target heap structure includes: K candidate information; the step of extracting at least one associative information corresponding to the input string from the multiple candidate information of the target heap structure corresponding to the target node includes: From the top of the iterative heap structure of the kth round, the candidate information of the kth round is extracted; wherein, , K is an integer; the iterative heap structure of the first round is the target heap structure; The remaining Kk candidate information is regenerated into a heap structure to obtain the iterative heap structure of the k+1th round; When k is iterated K times, candidate information of K rounds of iteration is determined as at least one of the association information.
3. The method according to claim 1, characterized in that The step of determining a target node from the target tree structure for the input string includes: Determine, from the child nodes of the matching node of the ith input character in the input string, a matching node of the i+1th input character in the input string; in, , Q is the total number of input characters contained in the input string; the matching node of the first input character is obtained by traversing the child nodes of the root node of the target tree structure; When a matching node is determined for the Qth input character, the matching node of the Qth input character is determined as the target node of the input character string.
4. The method according to claim 1, characterized in that The historical search information includes: N search information, the search coding data includes: N coding data corresponding to the N search information, and the historical weight includes: N weights corresponding to the N search information; The step of constructing a corresponding heap structure for a matching node corresponding to a coded character in the target tree structure based on the historical weight, the search coding data and the historical search information includes: From the N coded data, K matching coded data with prefix characters corresponding to the coded characters as prefixes are extracted; wherein N is a positive integer, ; Extracting K candidate information corresponding to the K matching coded data from the N search information, and extracting K search weights corresponding to the K matching coded data from the N weights; By constructing a heap structure for the K pieces of candidate information according to the K search weights, a heap structure of matching nodes corresponding to the encoded characters in the target tree structure is obtained.
5. The method according to claim 1, characterized in that After encoding the acquired historical search information to obtain search encoding data, the method further includes: Performing identifier mapping on the coded characters in the search coded data to obtain character identifiers corresponding to the coded characters in the search coded data; the storage space required by the character identifiers is smaller than the storage space required by the coded characters; For the character identifier, matching nodes are added to the initial tree structure to obtain the target tree structure.
6. The method according to claim 4, characterized in that The historical search information is obtained by the following processing, including: Get historical search terms and historical search objects; Extracting subject words from the historical search object to obtain historical subject words; The historical search information is acquired from the historical subject terms and the historical search terms.
7. The method according to any one of claims 1 to 3, characterized in that: In response to the selection operation of the target information in at least one of the associative information, the target information is displayed in the character input area, and after the information input is completed, the method further includes: Displaying an information search interface corresponding to the target information; In the information search interface, search results for the target information are displayed.
8. An information input device, characterized in that: The device comprises: A structure generation module is used to encode the acquired historical search information to obtain search coding data, and determine the corresponding historical weight for the historical search information, wherein the search coding data is used to search the historical search information; when a node corresponding to the s-th coded character in the search coding data is not found from the initial tree structure, a matching node is created for the s-th coded character, and a parent node is determined for the matching node of the s-th coded character in the initial tree structure, and the matching node of the s-th coded character is added to the initial tree structure, and when s is iterated to S, the initial tree structure to which the matching nodes of the S coded characters are added is used as the target tree structure; wherein, , s is an integer, S is the total number of coded characters contained in the search coded data; extracting a prefix character corresponding to the s-th coded character from the search coded data, determining the benchmark coded data for the search coded data based on the prefix character, and when the s-th coded character of the search coded data is different from the s-th benchmark character of the benchmark coded data, compressing the target tree structure by merging the s-th coded character to the S-th coded character in the search coded data; the target node is included in the matching node corresponding to the coded character; based on the historical weight, the search coded data and the historical search information, constructing a corresponding heap structure for the matching node corresponding to the coded character in the target tree structure; the target heap structure is included in the heap structure of the matching node corresponding to the coded character in the search coded data; A character acquisition module, used for acquiring an input character string in response to an input operation on a character input area in the information input interface; a node determination module, configured to determine a target node from the target tree structure for the input string, wherein the target tree structure stores strings through paths between nodes, and the target node is a node at the end of the path corresponding to the input string; An information extraction module, configured to extract at least one associative information corresponding to the input string from a plurality of candidate information of a target heap structure corresponding to the target node, wherein the plurality of candidate information are arranged in the target heap structure in the order of search weights; The information display module is used to display at least one of the associative information in the information display area of the information input interface; in response to a selection operation on a target information in at least one of the associative information, the target information is displayed in the character input area to complete the information input.
9. An information input device, characterized in that: The information input device comprises: A memory for storing executable instructions; A processor, configured to implement the information input method according to any one of claims 1 to 7 when executing the executable instructions stored in the memory.
10. A computer-readable storage medium storing executable instructions, characterized in that: When the executable instructions are executed by a processor, the information input method according to any one of claims 1 to 7 is implemented.
11. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the information input method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Word completion method and device
CN113946719A