Word retrieval method, device and equipment, computer readable storage medium and computer program product

By linking the phonetic tree and character tree in a dual-tribe structure, the word retrieval process is optimized, solving the problems of redundant storage and inefficiency caused by storing the phonetic trie and the word trie independently, thus improving word retrieval efficiency and user experience.

CN121996080APending Publication Date: 2026-05-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-11-05
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Because the pinyin dictionary and word dictionary are stored independently, redundant storage and low retrieval efficiency result in wasted memory and a poor user experience.

Method used

It adopts a dual-tribe tree structure, including a phonological tree with the full pinyin string as nodes and a character tree with Chinese characters as nodes. It performs word retrieval in combination with different retrieval scenarios, and optimizes the dictionary storage and retrieval process through the association between the phonological tree and the character tree.

Benefits of technology

It improves the efficiency of word retrieval, reduces lag during user input, lowers the memory usage of the dictionary, saves service resources, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121996080A_ABST
    Figure CN121996080A_ABST
Patent Text Reader

Abstract

The invention provides a word retrieval method, device and equipment, a computer readable storage medium and a computer program product. The method comprises the steps that in response to a word retrieval request for an input character string, double dictionary trees are obtained, and the double dictionary trees comprise a first dictionary tree and a second dictionary tree associated with the first dictionary tree; wherein the first dictionary tree comprises a sound tree taking a simple spelling string of a full spelling string as a node, and the second dictionary tree comprises a word tree taking a Chinese character as a node; determining a retrieval scene corresponding to the character string; and based on the retrieval scene, in combination with the sound tree and the word tree, retrieving from the double-dictionary tree to obtain a word corresponding to the character string. Through the method and the device, the word retrieval efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to computer technology, and more particularly to a word retrieval method, apparatus, device, computer-readable storage medium, and computer program product. Background Technology

[0002] In related technologies, the Pinyin dictionary and the word dictionary are stored independently. The Pinyin dictionary includes a Pinyin tree with syllables as nodes, as well as a word area. The word dictionary includes a word dictionary with Chinese characters as nodes, as well as a Pinyin area. This leads to redundant storage, resulting in a large waste of memory. When the dictionary is large, word retrieval is prone to lag. When performing word retrieval in different scenarios, it is difficult to flexibly respond to complex searches, resulting in low retrieval efficiency, poor performance, and a poor user experience. Summary of the Invention

[0003] This application provides a word retrieval method, apparatus, device, computer-readable storage medium, and computer program product that can improve the efficiency of word retrieval.

[0004] The technical solution of this application embodiment is implemented as follows:

[0005] This application provides a word retrieval method, the method comprising:

[0006] In response to a word search request for an input string, a dual trie is obtained, the dual trie comprising a first trie and a second trie associated with the first trie;

[0007] The first trie includes a phonological tree with the simplified pinyin string of the full pinyin string as nodes, and the second trie includes a character tree with Chinese characters as nodes.

[0008] Determine the retrieval scenario corresponding to the string;

[0009] Based on the retrieval scenario, and combining the phonetic tree and the character tree, the word corresponding to the string is retrieved from the dual dictionary tree.

[0010] This application provides a word retrieval device, wherein the hybrid expert model includes a gating network and multiple expert models, and the device includes:

[0011] The acquisition module is used to acquire a dual dictionary tree in response to a word retrieval request for an input string. The dual dictionary tree includes a first dictionary tree and a second dictionary tree associated with the first dictionary tree. The first dictionary tree includes a phonetic tree with the simplified pinyin string of the full pinyin string as nodes, and the second dictionary tree includes a character tree with Chinese characters as nodes.

[0012] The scenario determination module is used to determine the retrieval scenario corresponding to the string;

[0013] The retrieval module is used to retrieve the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree.

[0014] In the above scheme, the retrieval scenario includes a full-spelling retrieval scenario. The first dictionary tree further includes a vowel area associated with the phonological tree and a first node position area associated with the vowel area. The vowel area is used to store the vowels in the full-spelling string excluding the simplified spelling string, and the first node position area is used to store the node positions corresponding to the Chinese characters in the character tree. The retrieval module is further used to split the string into a first simplified spelling string and a first vowel, and to search the first simplified spelling string layer by layer in the phonological tree to obtain a first retrieval result. Based on the first retrieval result and the first vowel, a target vowel matching the full-spelling string is determined in the vowel area. The node position pointed to by the target vowel is determined in the first node position area. Based on the node position pointed to by the target vowel, the word corresponding to the string is found in the character tree.

[0015] In the above scheme, the number of the first simplified spelling strings is at least one, the first retrieval result includes the last first simplified spelling string retrieved in the phonological tree, the node corresponding to the last retrieved first simplified spelling string is the first node, the retrieval module is further used to determine the vowel pointed to by the first node, and determine the vowel pointed to by the next sibling node of the first node; based on the vowel pointed to by the first node and the vowel pointed to by the next sibling node of the first node, determine the vowel range of the first simplified spelling string in the vowel area; within the vowel range of the first simplified spelling string in the vowel area, determine the vowel that matches the first vowel, and take the vowel that matches the first vowel as the target vowel that matches the full spelling string.

[0016] In the above scheme, the retrieval scenario includes a simplified spelling retrieval scenario, the string includes at least one simplified spelling string, the first trie further includes a first node position area, the first node position area is used to store the node positions corresponding to the Chinese characters in the character tree; the retrieval module is further used to retrieve the at least one simplified spelling string layer by layer in the phonetic tree, and take the node corresponding to the last retrieved simplified spelling string as the second node; in the first node position area, determine the node position pointed to by the second node, and determine the node position pointed to by the next sibling node of the second node; based on the node position pointed to by the second node and the node position pointed to by the next sibling node of the second node, find the word corresponding to the string in the character tree.

[0017] In the above scheme, the retrieval module is further configured to determine a node position range in the first node position area, with the node position pointed to by the second node as the initial node position and the node position pointed to by the next sibling node of the second node as the ending position; search for Chinese characters within the node position range in the character tree, and concatenate the Chinese characters found in the character tree to obtain the word corresponding to the string.

[0018] In the above scheme, the retrieval scenario includes a word prediction scenario. The first trie further includes a first node position area, which is used to store the node positions corresponding to the Chinese characters in the character tree. The second trie also includes a second node position area, which is used to store the node positions of the word prediction results in the character tree. The retrieval module is further used to determine the abbreviated string corresponding to the string, and in the first node position area, determine the node position pointed to by the abbreviated string; based on the node position pointed to by the abbreviated string, find the corresponding Chinese character in the character tree; in the second node position area, determine the node position of the word prediction result pointed to by the Chinese character; and based on the node position of the word prediction result, find the word corresponding to the string in the character tree.

[0019] In the above scheme, the retrieval scenario includes a word association scenario, the string includes at least one Chinese character, and the second trie further includes a second node position area, which is used to store the node positions of the word prediction results in the character tree; the retrieval module is further used to retrieve the at least one Chinese character layer by layer in the character tree, and take the node corresponding to the last retrieved Chinese character as the third node; in the second node position area, determine the node position pointed to by the third node, and determine the node position pointed to by the next sibling node of the third node; with the node position pointed to by the third node as the initial node position and the node position pointed to by the next sibling node of the third node as the ending position, determine the node position range in the second node position area; search for Chinese characters within the node position range in the character tree, and concatenate the Chinese characters found in the character tree to obtain the word corresponding to the string.

[0020] In the above scheme, the retrieval module is also used to find the Chinese character of the corresponding node in the character tree for each node position within the node position range, and based on the parent node pointed to by the node, traverse layer by layer until the root node of the character tree is reached, and concatenate the Chinese characters obtained by traversing layer by layer to obtain the word corresponding to the string.

[0021] In the above scheme, the retrieval scenario includes a mixed scenario, the string includes a first pinyin string and Chinese characters, the first dictionary tree also includes a vowel area associated with the phonology tree and a first node position area associated with the vowel area; the retrieval module is further used to retrieve Chinese characters in the string layer by layer in the character tree to obtain a second retrieval result; based on the second retrieval result, determine the second pinyin string corresponding to the Chinese character in the phonology tree and the vowel area; combine the first pinyin string and the second pinyin string to obtain a pinyin string combination; determine the node position corresponding to the pinyin combination in the first node position area of ​​the first dictionary tree, and based on the node position, find the word corresponding to the pinyin combination in the character tree.

[0022] In the above scheme, the word retrieval device further includes: a construction module, used to construct the dual dictionary tree before obtaining the dual dictionary tree; serialize the dual dictionary tree and store the serialization result of the dual dictionary tree; the acquisition module is also used to acquire the serialization result of the dual dictionary tree; compress the serialization result of the dual dictionary tree and load the compressed result.

[0023] In the above scheme, the number of words corresponding to the string is multiple, and the second trie also includes an attribute area for storing word frequencies; the word retrieval device further includes: a recommended word determination module, used to determine the word frequencies of each word corresponding to the string from the attribute area of ​​the second trie; and to determine the recommended word corresponding to the string from the multiple words corresponding to the string based on the word frequencies of each word.

[0024] This application provides an electronic device, including:

[0025] Memory is used to store executable instructions or computer programs.

[0026] When a processor executes computer-executable instructions or computer programs stored in the memory, it implements the word retrieval method provided in the embodiments of this application.

[0027] This application provides a computer-readable storage medium storing computer-executable instructions or computer programs, which, when executed by a processor, implement the word retrieval method provided in this application.

[0028] This application provides a computer program product, including computer-executable instructions or a computer program, which, when executed by a processor, implements the word retrieval method provided in this application.

[0029] The embodiments of this application have the following beneficial effects:

[0030] In this application, during the word retrieval process based on the input string, a first trie and a second trie with an association relationship are used. The first trie includes a phonetic tree with abbreviated pinyin strings as nodes, and the second trie includes a character tree with Chinese characters as nodes. Word retrieval is performed in combination with the retrieval scenario corresponding to the string. In this way, the performance of word retrieval in different scenarios can be improved, the lag during the user input process can be reduced, the memory occupation of the dictionary can be reduced, and service resources can be saved. Attached Figure Description

[0031] Figure 1 This is a schematic diagram of an optional architecture of the word retrieval system provided in the embodiments of this application;

[0032] Figure 2 This is a schematic diagram of the structure of an electronic device for implementing a word retrieval method provided in an embodiment of this application;

[0033] Figure 3 This is a schematic diagram of the first process of the word retrieval method provided in the embodiments of this application;

[0034] Figure 4 This is a schematic diagram of the dual trie structure provided in an embodiment of this application;

[0035] Figure 5 This is a schematic diagram of the second process of the word retrieval method provided in the embodiments of this application;

[0036] Figure 6 This is a schematic diagram of full-spelling retrieval provided in an embodiment of this application;

[0037] Figure 7 This is a schematic diagram of the third process of the word retrieval method provided in the embodiments of this application;

[0038] Figure 8 This is a schematic diagram of a simplified spelling search provided in an embodiment of this application;

[0039] Figure 9 This is a schematic diagram of the fourth process of the word retrieval method provided in the embodiments of this application;

[0040] Figure 10 This is a schematic diagram of word prediction retrieval provided in the embodiments of this application;

[0041] Figure 11 This is a schematic diagram of the fifth process of the word retrieval method provided in the embodiments of this application;

[0042] Figure 12 This is a schematic diagram of word association retrieval provided in the embodiments of this application;

[0043] Figure 13 This is a schematic diagram of the sixth process of the word retrieval method provided in the embodiments of this application;

[0044] Figure 14 This is a schematic diagram of a hybrid retrieval method provided in an embodiment of this application;

[0045] Figure 15 This is a schematic diagram of the lexicon structure provided by related technologies;

[0046] Figure 16 This is a schematic diagram of the serialized double trie structure provided in the embodiments of this application. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0048] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is 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.

[0049] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0050] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0051] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0052] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0053] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0054] 1) Syllable: The smallest unit of pronunciation in a language, usually composed of one or more phonemes, including vowels and consonants. For example, tian and di are monosyllabic words.

[0055] 2) Trie: Also known as a prefix tree or trie, it is a data structure used to quickly retrieve keys in a string dataset. It achieves efficient storage and retrieval of strings by using the characters of each key as nodes of the tree and storing the common prefixes of these characters on the path of the tree. In a trie, each node represents a character, the path from the root node to a node represents a prefix of a string, and the path to a leaf node represents a complete string.

[0056] 3) In response, used to indicate the conditions or states on which the operation performed depends. When the conditions or states on which it depends are met, one or more operations performed can be performed in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations are performed.

[0057] During their research, the inventors discovered that because the Pinyin dictionary and the word dictionary are stored independently, the Pinyin dictionary includes a Pinyin tree with syllables as nodes, as well as a word area, while the word dictionary includes a word dictionary with Chinese characters as nodes, as well as a Pinyin area. This results in redundant storage, causing a significant waste of memory. In different word retrieval scenarios, the retrieval performance is poor and the efficiency is low. When the dictionary is large, it is very easy to experience lag.

[0058] Based on this, embodiments of this application provide a word retrieval method, apparatus, device, computer-readable storage medium, and computer program product, improving the word retrieval performance of the thesaurus in various scenarios. The following describes exemplary applications of electronic devices provided in embodiments of this application for implementing the word retrieval method. The devices provided in embodiments of this application can be implemented as various types of terminals such as laptops, tablets, desktop computers, set-top boxes, smartphones, smart speakers, smartwatches, smart TVs, and in-vehicle terminals, or as servers.

[0059] The following describes an exemplary application system architecture for implementing the word retrieval method provided in this embodiment of the invention, using an electronic device as an example. See also: Figure 1 , Figure 1This is an optional architecture diagram of the word retrieval system provided in the embodiments of this application. To support a word retrieval application, in Figure 1 In the word retrieval system 100, the terminal 400 connects to the server 200 through the network 300, which can be a wide area network or a local area network, or a combination of both.

[0060] Terminal 400 is used to send a word search request to server 200 via network 300 in response to a user entering a string in the client.

[0061] Server 200 is used to respond to word retrieval requests for input strings, obtain a dual dictionary tree, which includes a first dictionary tree and a second dictionary tree associated with the first dictionary tree. The first dictionary tree includes a phonetic tree with the simplified pinyin of the full pinyin string as nodes, and the second dictionary tree includes characters with Chinese characters as nodes. The server determines the retrieval scenario corresponding to the string, and based on the retrieval scenario, combines the phonetic tree and the character tree to retrieve the word corresponding to the string from the dual dictionary tree.

[0062] Server 200 is also used to send the words corresponding to the retrieved strings to terminal 400.

[0063] In other embodiments, the word retrieval method provided by the present invention can also be implemented independently by a terminal. The terminal is equipped with a client that can implement the word retrieval method. When a user inputs a string in the client and requests word retrieval, the client responds to the word retrieval request for the input string by obtaining a dual dictionary tree. The dual dictionary tree includes a first dictionary tree and a second dictionary tree associated with the first dictionary tree. The first dictionary tree includes a phonetic tree with the abbreviated pinyin string as nodes, and the second dictionary tree includes a character tree with Chinese characters as nodes. The retrieval scenario corresponding to the string is determined. Based on the retrieval scenario, the word corresponding to the string is retrieved from the dual dictionary tree by combining the phonetic tree and the character tree.

[0064] The client running on the terminal can also embed a word search plugin to implement word search methods locally on the client. For example, after receiving a word search request, the terminal calls the word search plugin to implement the word search method. In response to a word search request for an input string, it obtains a dual dictionary, which includes a first dictionary and a second dictionary associated with the first dictionary. The first dictionary includes a phonetic tree with the abbreviated pinyin of the full pinyin string as nodes, and the second dictionary includes a character tree with Chinese characters as nodes. The search scenario corresponding to the string is determined, and based on the search scenario, the word corresponding to the string is retrieved from the dual dictionary by combining the phonetic tree and the character tree.

[0065] In some embodiments, server 200 may be a standalone physical server, a server cluster consisting of multiple physical servers, or a distributed system. Terminals and servers can be connected directly or indirectly via wired or wireless communication, and this embodiment does not impose any limitations.

[0066] In this way, the efficiency of word retrieval in different scenarios is improved, the lag during user input is reduced, the memory usage of the dictionary is reduced, and service resources are saved.

[0067] See Figure 2 , Figure 2 This is a schematic diagram of the structure of an electronic device for implementing a word retrieval method provided in an embodiment of this application. In practical applications, the electronic device can be implemented as various types of terminals such as laptops, tablets, desktop computers, smartphones, smart speakers, smartwatches, smart TVs, and vehicle terminals. It can also be implemented as a server or as a device cluster composed of servers and terminals. Figure 2 The illustrated electronic device 500 includes at least one processor 510, a memory 550, at least one network interface 520, and a user interface 530. The various components in the electronic device 500 are coupled together via a bus system 540. It is understood that the bus system 540 is used to implement communication between these components. In addition to a data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 2 The general labeled all buses as Bus System 540.

[0068] The processor 510 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. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0069] User interface 530 includes one or more output devices 531 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0070] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 550 may optionally include one or more storage devices physically located away from the processor 510.

[0071] The memory 550 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 550 described in this application embodiment is intended to include any suitable type of memory.

[0072] In some embodiments, memory 550 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.

[0073] Operating system 551 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, and driver layer, for implementing various basic business functions and handling hardware-based tasks.

[0074] The network communication module 552 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including Bluetooth, WiFi, and Universal Serial Bus (USB).

[0075] Presentation module 553 enables the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 531 (e.g., a display screen, a speaker, etc.) associated with user interface 530.

[0076] The input processing module 554 is used to detect one or more user inputs or interactions from one or more input devices 532, and to translate the detected inputs or interactions.

[0077] In some embodiments, the word retrieval device provided in this application can be implemented in software. Figure 2 A word retrieval device 555 stored in memory 550 is shown. This device can be software in the form of programs or plug-ins, and includes the following software modules: an acquisition module 5551, a scene determination module 5552, and a retrieval module 5553. These modules are logically linked and can therefore be arbitrarily combined or further separated according to their implemented functions. The functions of each module will be described below.

[0078] The word retrieval method provided in this application will now be described based on the electronic device and system provided in the embodiments of this application.

[0079] See Figure 3, Figure 3 This is the first process schematic diagram of the word retrieval method provided by an embodiment of the present application. In practical applications, this method can be implemented independently by a terminal or a server, or jointly implemented by a terminal and a server. Hereinafter, taking the implementation by the server as an example, the word retrieval method provided by an embodiment of the present application will be described in conjunction with Figure 3 the steps shown.

[0080] In step 101, in response to a word retrieval request for an input string, a double dictionary tree is obtained.

[0081] Here, the double dictionary tree includes a first dictionary tree and a second dictionary tree associated with the first dictionary tree. The first dictionary tree includes a sound tree with the abbreviated string of the full spelling string as nodes, and the second dictionary tree includes a character tree with Chinese characters as nodes.

[0082] It can be understood that the full spelling string includes at least one syllable, and all syllables in the full spelling string are complete. For example, for "ni'hao", it contains two complete syllables "ni" and "hao". The abbreviated string is the initial consonant part corresponding to the full spelling string. The abbreviated string of the full spelling string refers to the abbreviated string corresponding to the full spelling string. For example, for the input string "你们好" (ni'men'hao in pinyin), its full spelling string is "ni'men'hao", then the abbreviated string of the full spelling string is "n'm'h".

[0083] In some embodiments, the first dictionary tree further includes a rhyming vowel area associated with the sound tree and a first node position area associated with the rhyming vowel area, and the second dictionary tree further includes a second node position area and an attribute area.

[0084] It should be noted that the node of the sound tree points to the position of the first rhyming vowel corresponding to this node in the rhyming vowel area, and also points to the node position in the first node position area. Here, the node position means the position of the last Chinese character in the first word among all the words corresponding to this sound tree node, in the node position of the character tree; the node of the character tree points to the attribute area, and also points to the node position in the second node position area. Here, the node position means the position of the last Chinese character in the first word prediction result among all the word prediction results corresponding to this character tree node, in the node position of the character tree.

[0085] Among them, the vowel area is used to store the vowels in the full spelling string except the abbreviated spelling string. For example, for the full spelling string "ni'men'hao" of "你们好" after removing the abbreviated spelling string "n'm'h", the vowels "i'en'ao" are obtained and stored in a certain vowel block in the vowel area. In the vowel area, the vowels corresponding to the same abbreviated spelling string are stored continuously. In this way, all the vowels under the current node can be determined by the position of the first vowel pointed to by the current phonetic tree node and the position pointed to by the next sibling node of the current phonetic tree node, improving the performance of word retrieval. Moreover, the vowel area also points to the node position in the first node position area. Here, the node position refers to the position of the last Chinese character in the first word among all the words corresponding to this vowel in the character tree.

[0086] The first node position area is used to store the node positions corresponding to the Chinese characters in the character tree. Among them, the node position corresponding to the Chinese character in the character tree refers to the position of the last Chinese character of the current word in the character tree node. For example, for the word "你们好", the first node position area is used to store the position of "好" in the character tree of "你们好". In this way, each character in the word can be obtained layer by layer through the parent node pointed to by the character tree node where the last Chinese character in the word is located, and finally the word can be obtained by splicing.

[0087] The second node position area is used to store the node positions of the word prediction results in the character tree. Here, the word prediction result refers to the word corresponding to the word in the string or the full spelling string in the string or the abbreviated spelling string in the string, and is a longer word associated with the above-mentioned word. For example, for the word "你们好" in the string, then "你们好厉害" can be used as the corresponding word prediction result; for the full spelling string "wan'shi" in the string, then "万事如意" can be used as the corresponding word prediction result. The node position of the word prediction result in the character tree refers to the position of the last Chinese character in the word prediction result in the character tree. For example, for the word prediction result "你们好厉害", the content stored correspondingly in the second node position area is the position of "害" in the character tree of "你们好厉害".

[0088] The attribute area is used to store the word frequency of the word corresponding to the string. The word frequency is used to represent the degree of relevance and importance of the word corresponding to the retrieved string to the string. In this way, the words corresponding to the retrieved string can be output according to the size of the word frequency. The attribute area is also used to store the position information of the vowels in the vowel area and the node position information in the phonetic tree.

[0089] It should be noted that the storage order in the finals area and the first node position area is consistent with the node order in the phonology tree. All finals corresponding to the same abbreviation are stored consecutively in the finals area. The node positions of words corresponding to the same phonology tree node are stored consecutively in the first position area. The storage order in the attribute area and the second node position area is consistent with the node order in the character tree. The word frequency, final position information, and node position information in the phonology tree corresponding to the same word are stored consecutively. The node positions of words corresponding to the same character tree node are stored consecutively in the second position area.

[0090] As an example, see Figure 4 , Figure 4 This is a schematic diagram of a dual trie structure provided in an embodiment of this application. The diagram includes a first trie 401 and a second trie 404. The first trie is a phonological tree with the simplified pinyin of the full pinyin string as nodes, and the second trie is a character tree with Chinese characters as nodes. The first trie 401 also includes a vowel area 402 and a first node position area 403, and the second trie also includes an attribute area 405 and a second node position area 406.

[0091] In this way, the phonetic tree with the simplified pinyin string as nodes and the character tree with Chinese characters as nodes are associated, forming a dual-tribe tree dictionary structure, which reduces the memory usage of the dictionary and ensures the stability and response speed of word retrieval.

[0092] In step 102, the retrieval scenario corresponding to the string is determined.

[0093] In step 103, based on the retrieval scenario, the word corresponding to the string is retrieved from the dual dictionary tree by combining the phonetic tree and the character tree.

[0094] In some embodiments, the search scenarios include full-spelling search scenarios, abbreviated-spelling search scenarios, word prediction scenarios, word association scenarios, and mixed scenarios.

[0095] When the search scenario is a full-spell search scenario, see the corresponding section. Figure 5 , Figure 5 This is a schematic diagram of the second process of the word retrieval method provided in the embodiments of this application. Figure 3 Step 103 shown can be implemented through steps 1031A to 1034A, which are explained in detail below.

[0096] In step 1031A, the string is split into a first abbreviated string and a first vowel, and the first abbreviated string is searched layer by layer in the phonological tree to obtain the first search result.

[0097] Here, the full - spelling retrieval scenario means that the input string is a full - spelling string, and words corresponding to the full - spelling string are retrieved based on the input full - spelling string. It can be understood that in pinyin, the initial is the beginning part of a Chinese character's pinyin, and the final is the part except the initial. Splitting the string into the first simple - spelling string and the first final means splitting the full - spelling string into a sequence composed of its initials and a sequence composed of its finals.

[0098] It should be noted that the layer - by - layer retrieval here starts from the current node. In each layer of nodes, the parent node of the current node is found, and traversal is performed layer by layer upward until the root node of the character tree is reached.

[0099] In step 1032A, based on the first retrieval result and the first final, the target final that matches the full - spelling string is determined in the final area.

[0100] In some embodiments, the number of the first simple - spelling strings is at least one. The first retrieval result includes the last - retrieved first simple - spelling string in the phonetic tree. The node corresponding to the last - retrieved first simple - spelling string is the first node. Correspondingly, based on the first retrieval result and the first final, the target final that matches the full - spelling string can be determined in the final area through the following method: determine the final pointed to by the first node and the final pointed to by the next sibling node of the first node; based on the final pointed to by the first node and the final pointed to by the next sibling node of the first node, determine the final range of the first simple - spelling string in the final area; within the final range of the first simple - spelling string in the final area, determine the final that matches the first final, and use the final that matches the first final as the target final that matches the full - spelling string.

[0101] Here, within the final range, the final that matches the first final can be determined through methods such as binary search, interpolation search, linear search, etc., which are not limited in the embodiments of this application.

[0102] In step 1033A, the node position pointed to by the target final is determined in the first - node position area.

[0103] In step 1034A, based on the node position pointed to by the target final, the word corresponding to the string is found in the character tree.

[0104] Among them, the node position pointed to by the target final is the node position in the character tree corresponding to the last Chinese character in the first word among all the words corresponding to the target final. For example, for the final "i'en'ao", taking the first word among all the words corresponding to this final as "你们好" as an example, the node position pointed to by the target final is the node position in the character tree corresponding to "好" in "你们好".

[0105] It should be noted that the node positions corresponding to all words in the full - spelling string in the character tree can be determined by the target final sound pointing to the node positions in the first node position area and the next final sound of the target final sound pointing to the node positions in the first node position area. Based on the positions of each node pointed to by the target final sound, for each node, each Chinese character is obtained layer by layer through the parent node pointed to by the node, and the obtained Chinese characters are concatenated into words, so that the words corresponding to the string can be found.

[0106] As an example, see Figure 6 , Figure 6 which is the full - spelling retrieval schematic diagram provided by the embodiment of the present application. Taking the string as the full - spelling string "ni'men'hao" as an example, the string is correspondingly split into the first simple - spelling string "n'm'h" and the first final sound "i'en'ao". Starting from the root node of the sound tree, the first simple - spelling string "n'm'h" is retrieved layer by layer until the last element "h" in the first simple - spelling string is matched. "h" is the first retrieval result, and the corresponding node 601 is the first node. Based on the final sound pointed to by the first node 601 and the final sound pointed to by the next sibling node 602 of the first node, the range of the final sound in the final - sound area of the first simple - spelling string is determined. By means of binary search, the final sound 603 that matches the first final sound "i'en'ao" is determined and used as the target final sound 603 that matches the full - spelling string. Based on the target final sound 603 and the next final sound 604, the positions pointing to the first node position area are used to determine the node positions x1, x2, x3 in the character tree of the last Chinese character in all the words corresponding to the full - spelling string. Taking x2 as an example, based on x2, the node 605 in the character tree is found, corresponding to the Chinese character "好". The parent node pointed to by the node 605 is the node 606, corresponding to the Chinese character "们", and then obtained layer by layer. The parent node 607 pointed to by the node 606 is found, corresponding to the Chinese character "你". Finally, "你", "们", and "好" are concatenated into "你们好", that is, the word "你们好" corresponding to the string "ni'men'hao".

[0107] In this way, the words corresponding to the full - spelling string input by the user can be quickly retrieved, improving the retrieval efficiency and accuracy, reducing resource consumption at the same time, supporting large - scale data retrieval, and providing flexible scalability.

[0108] When the retrieval scenario is a simple - spelling retrieval scenario, the string includes at least one simple - spelling string. Correspondingly, see Figure 7 , Figure 7 which is the third process schematic diagram of the word retrieval method provided by the embodiment of the present application. Figure 3 The step 103 shown can be implemented through the following steps 1031B to step 1033B, which will be specifically described below.

[0109] In step 1031B, at least one abbreviated string is retrieved layer by layer in the sound tree, and the node corresponding to the last retrieved abbreviated string is taken as the second node.

[0110] In step 1032B, in the first node location area, the node location pointed to by the second node is determined, and the node location pointed to by the next sibling node of the second node is determined.

[0111] In step 1033B, based on the node position pointed to by the second node and the node position pointed to by the next sibling node of the second node, the word corresponding to the string is found in the word tree.

[0112] In some embodiments, the word corresponding to the string can be found in the character tree based on the node position pointed to by the second node and the node position pointed to by the next sibling node of the second node. This can be achieved by: determining the node position range in the first node position area with the node position pointed to by the second node as the initial node position and the node position pointed to by the next sibling node of the second node as the ending position; searching for Chinese characters within the node position range in the character tree, and concatenating the Chinese characters found in the character tree to obtain the word corresponding to the string.

[0113] Here, in the scenario of abbreviated spelling retrieval, the string includes at least one abbreviated spelling string. Starting from the root node of the phonetic tree, at least one abbreviated spelling string is retrieved layer by layer until the node corresponding to the last retrieved abbreviated spelling string is identified. This node is designated as the second node. The second node points to the node position in the first node's position area. Here, the node position refers to the last Chinese character in the first word among all words corresponding to the second node, corresponding to the node position in the character tree. The next sibling node of the second node also points to the node position in the first node's position area. Here, the node position refers to the last Chinese character in the first word among all words corresponding to the second node's next sibling node. The last Chinese character in a word corresponds to a node position in the character tree. Using the node position pointed to by the second node as the initial node position and the node position pointed to by the next sibling node of the second node as the ending position, we can determine the range of node positions within the first node position area. This range represents the range of node positions for the last Chinese character in all words corresponding to the abbreviated string of the second node. We then search for nodes within this range in the character tree. For each node, we retrieve each Chinese character layer by layer through its parent node. By concatenating the found characters in the character tree, we can find the word corresponding to the string.

[0114] As an example, see Figure 8 , Figure 8It is a schematic diagram of simple spelling retrieval provided by an embodiment of the present application. Taking the string "n'm'h" as an example, starting from the root node of the sound tree, "n", "m", and "h" are retrieved layer by layer until the end "h" of the simple spelling string is matched. The corresponding node 801 is used as the second node. The second node 801 points to the node position x1 in the first node position area. The next sibling node 802 of the second node points to the node position x6 in the first node position area. Taking the node position x1 pointed to by the second node as the initial node position and the node position x6 pointed to by the next sibling node of the second node as the end position, the node position range x1, x2, x3, x4, x5 is determined in the first node position area. Taking x4 as an example, the node 803 of the corresponding subtree is found, and the corresponding Chinese character is "good". Each Chinese character "men" and "ni" is obtained layer by layer through the parent node pointed to by the node 803, and the Chinese characters found in the subtree are concatenated to obtain the word "you are good" corresponding to the string.

[0115] In this way, through the efficient retrieval characteristics of the first dictionary tree and the second dictionary tree with an associated relationship and the convenience of simple spelling, the efficiency of the input method and the user experience are improved.

[0116] When the retrieval scenario is a word prediction scenario, correspondingly, refer to Figure 9 , Figure 9 It is the fourth process schematic diagram of the word retrieval method provided by an embodiment of the present application. Figure 3 The step 103 shown can be implemented through the following steps 1031C to 1034C, which will be specifically described below.

[0117] In step 1031C, the simple spelling string corresponding to the string is determined, and in the first node position area, the node position pointed to by the simple spelling string is determined.

[0118] Here, the string can be a full spelling string or a simple spelling string. When the string is a full spelling string, the node position pointed to by the simple spelling string can be determined in the first node position area through the above steps 1031A - 1033A. When the string is a simple spelling string, at least one simple spelling string is retrieved layer by layer in the sound tree, and in the first node position area, the node position pointed to by the node corresponding to the last retrieved simple spelling string is determined.

[0119] In step 1032C, based on the node position pointed to by the simple spelling string, the corresponding Chinese character is found in the subtree.

[0120] In step 1033C, in the second node position area, the node position of the word prediction result pointed to by the Chinese character is determined.

[0121] In step 1034C, based on the node position of the word prediction result, the word corresponding to the string is found in the subtree.

[0122] It should be noted that the word prediction scenario refers to matching a string, determining the word corresponding to the input string, and giving a longer word that is associated with the word corresponding to the input string. For example, for the input string "mei'lun", the word "美轮美奂" corresponding to the string is retrieved in the character tree. The node position of the word prediction result refers to the node position of the last Chinese character corresponding to the word prediction result in the character tree.

[0123] Here, the node position pointed to by the node corresponding to the abbreviated pinyin string in the first node position area can be used as the initial node position, and the node position pointed to by the next sibling node of the node corresponding to the abbreviated pinyin string in the first node position area can be used as the end position to determine the node position range in the first node position area. Search for Chinese characters within the node position range in the character tree. In the second node position area, for each node corresponding to a Chinese character, determine the node position of the word prediction result pointed to by the node. Based on the node position of the word prediction result, determine the node corresponding to the node position, and retrieve each character layer by layer through the parent node pointed to by this node, and then splice the words to find the word corresponding to the string.

[0124] As an example, see Figure 10 , Figure 10 FIG. is a schematic diagram of word prediction retrieval provided by an embodiment of the present application. Taking the string as the abbreviated pinyin string "m'l" as an example, start retrieving "m" and "l" layer by layer from the root node of the sound tree until the end "l" of the abbreviated pinyin string is matched. The node position x1 pointed to by the node 1001 corresponding to it is used as the initial node position, and the node position x5 pointed to by the next sibling node of the node 1001 is used as the end position to determine the node position range x1, x2, x3, x4 in the first node position area. Taking x4 as an example, find the corresponding Chinese character "轮" in the character tree, corresponding to the node 1002 of the character tree. The node 1002 points to l1 in the second node position area, and the next sibling node of the node 1002 points to l3 in the second node position area. Using l1 as the initial node position and l3 as the end position, determine the node position range l1, l2 in the second node position area. Taking l2 as an example, find the node 1003 based on l2, corresponding to the Chinese character "奂", and obtain the Chinese characters "美", "轮", "美" layer by layer through the parent node pointed to by the node 1003, and splice the obtained Chinese characters to get the word corresponding to the string "m'l" as "美轮美奂".

[0125] In this way, in the word prediction scenario, it is possible to quickly match the abbreviated pinyin or full pinyin string input by the user and intelligently recommend a longer word, thereby improving the input efficiency, reducing the user input burden, and optimizing the user experience.

[0126] When the retrieval scenario is the word association scenario, the string includes at least one Chinese character. Correspondingly, see Figure 11 , Figure 11It is the fifth process schematic diagram of the word retrieval method provided by the embodiments of the present application. Figure 3 The shown step 103 can be implemented through the following steps 1031D to 1034D, which will be specifically described below.

[0127] In step 1031D, at least one Chinese character is retrieved layer by layer in the character tree, and the node corresponding to the last retrieved Chinese character is used as the third node.

[0128] It should be noted that the word association scenario refers to retrieving words associated with a string containing at least one Chinese character without inputting other strings. For example, for the string "meilun", the word "meihuan" is retrieved when the user does not input other strings.

[0129] Among them, retrieving at least one Chinese character layer by layer in the character tree means retrieving each Chinese character in the string layer by layer in the character tree.

[0130] In step 1032D, in the second node position area, the node position pointed to by the third node is determined, and the node position pointed to by the next sibling node of the third node is determined.

[0131] Here, the node position pointed to by the third node is the node position of the last Chinese character in the first word prediction result among all the word prediction results corresponding to the third node in the character tree.

[0132] In this way, when there are multiple node positions corresponding to the third node, through the node position pointed to by the third node and the node position pointed to by the next sibling node of the third node, the word corresponding to the string can be obtained, thereby more effectively using memory resources and saving storage space.

[0133] In step 1033D, with the node position pointed to by the third node as the initial node position and the node position pointed to by the next sibling node of the third node as the end position, the node position range is determined in the second node position area.

[0134] In step 1034D, the Chinese characters within the node position range are searched for in the character tree, and the Chinese characters found in the character tree are concatenated to obtain the word corresponding to the string.

[0135] In some embodiments, step 1034D can be implemented in the following manner: for each node position within the node position range, the Chinese character of the corresponding node is searched for in the character tree, and based on the parent node pointed to by the node, traversed layer by layer until reaching the root node of the character tree, and the Chinese characters obtained by layer-by-layer traversal are concatenated to obtain the word corresponding to the string.

[0136] Here, for each node position within the node range, the Chinese characters corresponding to the nodes at the node positions can be found in the character tree. For each node, traverse layer by layer through the parent nodes pointed to by the node, and splice the Chinese characters obtained from the traversal to obtain the word corresponding to the string.

[0137] As an example, refer to Figure 12 , Figure 12 which is a schematic diagram of word association retrieval provided by an embodiment of the present application. Taking the string "Hello to you" as an example, search for "你", "们", and "好" layer by layer in the character tree, and determine the node 1201 corresponding to the last retrieved Chinese character "好" as the third node. In the second node position area, the node position pointed to by the third node 1201 is l1, and the node position pointed to by the next sibling node of the third node is l3. Taking l1 as the initial node position and l3 as the end position, determine the node position range as l1, l2. Taking the node position l2 as an example, the node position of l2 corresponds to node 1202, and the Chinese character corresponding to this node is "棒". Traverse layer by layer through the parent nodes pointed to by this node to obtain the Chinese characters "好", "们", "你", and splice the Chinese characters obtained from the layer-by-layer traversal to obtain the word "你们好棒" corresponding to the string "Hello to you".

[0138] In this way, through steps 1031D - 1034D, efficient retrieval in the scenario of word association is achieved, improving the retrieval performance. Moreover, when using the first trie and the second trie with an associated relationship for word retrieval, while maintaining the function, unnecessary memory occupation is reduced, saving service resources.

[0139] When the retrieval scenario is a mixed scenario, the string includes a first pinyin string and Chinese characters. Correspondingly, refer to Figure 13 , Figure 13 which is the sixth process schematic diagram of the word retrieval method provided by an embodiment of the present application. Figure 3 The steps shown in 103 can be implemented through the following steps 1031E to 1034E, which will be specifically described below.

[0140] In step 1031E, search for the Chinese characters in the string layer by layer in the character tree to obtain a second retrieval result.

[0141] Here, layer-by-layer search means that in the character tree, in accordance with the order of Chinese characters in the string, starting from the root node, search for and match each Chinese character one by one until all Chinese characters in the string have been retrieved. The second retrieval result refers to the node corresponding to the last retrieved Chinese character when searching layer by layer in the character tree.

[0142] In step 1032E, based on the second retrieval result, determine the second pinyin string corresponding to the Chinese character in the pinyin tree and the vowel area.

[0143] Here, in the attribute area, based on the positions pointed to by the second search result and the position pointed to by the next sibling node of the second search result, the simple spellings corresponding to the Chinese characters in the string can be determined, as well as the corresponding finals in the finals area. The combination of the simple spelling and the final is the second pinyin string.

[0144] In step 1033E, the first pinyin string and the second pinyin string are combined to obtain a pinyin string combination.

[0145] In step 1034E, in the first node position area of the first trie tree, the node position corresponding to the pinyin combination is determined, and based on the node position, the word corresponding to the pinyin combination is searched for in the word tree.

[0146] Among them, the mixed scenario means that based on the Chinese characters in the string and in combination with the first pinyin string in the string, a word associated with the Chinese characters in the string and matching the first pinyin string in the string is searched for. Here, the first pinyin string can be a full spelling string, or a simple spelling string, or a combination of a full spelling string and a simple spelling string. For example, for the Chinese characters "你们好" included in the string, if the pinyin of the string is the full spelling "li'hai", then "厉害" can be used as the retrieved word; for the Chinese characters "你们好" included in the string, if the pinyin of the string is the simple spelling "m'l", then "美丽" can be used as the retrieved word.

[0147] When the first pinyin string is a full spelling string, the pinyin string combination is the result of concatenating the first pinyin string and the second pinyin string. For example, for the Chinese characters "你们好" in the string, if the first pinyin string is the full spelling string "li'hai", it can be determined that the second pinyin string is "ni'men'hao", then the pinyin string combination is "ni'men'hao'li'hai".

[0148] When the first pinyin string is a simple spelling string, the pinyin string combination is the result of concatenating the first pinyin string and the simple spelling string corresponding to the second pinyin string. For example, for the Chinese characters "你们好" in the string, if the first pinyin string is the full spelling string "m'l", it can be determined that the second pinyin string is "ni'men'hao", and the simple spelling string corresponding to the second pinyin string is "n'm'h", then the pinyin string combination is "n'm'h'm'l".

[0149] It should be noted that when the first pinyin string is a simple pinyin string, after obtaining the pinyin string combination, the pinyin string combination is retrieved layer by layer in the phonetic tree, and the node corresponding to the last retrieved simple pinyin string is used as the second node. In the first node position area, the node position pointed to by the second node is determined, and the node position pointed to by the next sibling node of the second node is determined. Taking the node position pointed to by the second node as the initial node position and the node position pointed to by the next sibling node of the second node as the end position, the node position range is determined in the first node position area. The Chinese characters within the node position range are searched in the character tree, and the Chinese characters found in the character tree are concatenated. The concatenated word is matched with the Chinese characters in the string. If the concatenated word contains the Chinese characters in the string, it is used as the word corresponding to the pinyin combination. If the concatenated word does not contain the Chinese characters in the string, it cannot be used as the word corresponding to the pinyin combination.

[0150] For example, for a string containing the Chinese characters "你们好" (nǐ men hǎo) and the first pinyin string being the simple pinyin string "b", the concatenated words obtained finally include "你们好棒" (nǐ men hǎo bàng), "那么好吧" (nà me hǎo ba), etc. Since "你们好棒" contains the Chinese characters "你们好" in the string, it can be used as the word corresponding to the pinyin combination, while "那么好吧" cannot be used as the word corresponding to the pinyin combination.

[0151] As an example, refer to Figure 14 , Figure 14This is a schematic diagram of hybrid retrieval provided by an embodiment of the present application. Taking the string including the Chinese characters "你们好" (Hello) and the first pinyin string with the simple pinyin string "b" as an example, the Chinese characters "你" (nǐ), "们" (men), and "好" (hǎo) in the string are retrieved layer by layer in the character tree. The node 1401 corresponding to the last retrieved Chinese character "好" (hǎo) is used as the second retrieval result. Based on the positions of node 1401 and its next sibling node 1402 pointing to the attribute area, it can be determined that the second pinyin string corresponding to the Chinese characters "你们好" (nǐ men hǎo) in the string is "ni'men'hao", and the simple pinyin string corresponding to the second pinyin string is "n'm'h". The pinyin string combination "n'm'h'b" can be obtained. The pinyin string combination "n'm'h'b" is retrieved layer by layer in the pinyin tree, and the node 1403 corresponding to the last retrieved simple pinyin string is used as the second node. In the first node position area, the node position x1 pointed to by node 1403 is determined, and the node position x5 pointed to by the next sibling node of node 1403 is determined. Taking the node position x1 pointed to by node 1403 as the initial node position and the node position x5 pointed to by the next sibling node of node 1403 as the end position, the node position range x1, x2, x3, x4 is determined in the first node position area. Taking x4 as an example, the node 1404 of the corresponding character tree is found, and the corresponding Chinese character is "棒" (bàng). Each Chinese character "好" (hǎo), "们" (men), and "你" (nǐ) is obtained layer by layer through the parent node pointed to by node 1404. The Chinese characters found in the character tree are concatenated, and the word "你们好棒" (nǐ men hǎo bàng) corresponding to the pinyin combination is found. When pushing to the client, the Chinese characters "你们好" (nǐ men hǎo) in the string are removed, and the final word pushed to the client is "棒" (bàng).

[0152] In this way, through steps 101 to 103, a double dictionary tree including a pinyin tree and a character tree is used for word retrieval. It not only supports full pinyin retrieval and simple pinyin retrieval, but can also be applied to retrieval scenarios such as word prediction, word association, and mixing, increasing the flexibility and convenience of retrieval, and can more accurately match the input string. Whether it is a full pinyin string or a simple pinyin string, the corresponding word can be quickly found, improving the retrieval efficiency and accuracy. At the same time, the memory occupation of the word library is reduced, saving service resources.

[0153] In some embodiments, before obtaining the double dictionary tree, the double dictionary tree is constructed, serialized, and the serialized result of the double dictionary tree is stored. Correspondingly, the obtaining of the double dictionary tree in step 301 above can be implemented in the following manner: obtaining the serialized result of the double dictionary tree, compressing the serialized result of the double dictionary tree, and loading the compressed result.

[0154] It can be understood that serializing a double trie is to convert the data structure of the double trie into a format that can be stored or transmitted. In this way, a serialized data for storage can be obtained. Storing the serialized data can reduce the occupation of storage space, improve data persistence, and at the same time maintain the integrity of the tree structure and the fast retrieval ability.

[0155] For the phonetic trie, each node in the phonetic trie is compressed and stored in the order of breadth-first traversal. Each phonetic trie node stores the short form string identifier, the position of the first child node, the storage position of the finals other than the short form string in the finals area in the full form string, and the word corresponding to this phonetic trie node in the storage position in the first node position area of the character trie.

[0156] Here, the short form string identifier is to IDize the short form string data, map the short form string to a continuous memory area, and assign a unique identifier (ID) to it. In this way, the storage of duplicate short form strings can be reduced, significantly reducing the use of memory. Moreover, the ID can be used to quickly locate a specific node in the trie, accelerating the node retrieval process, thereby improving the retrieval efficiency.

[0157] For the finals area, multiple finals blocks are stored in the finals area. It can be understood that each phonetic trie node may correspond to multiple finals blocks. Each finals block stores the finals identifier and the position of the first word corresponding to all words corresponding to this finals in the first node area.

[0158] Here, the finals identifier is to IDize the finals. After IDizing the finals, multiple finals IDs are compressed into a number. For example, for the IDs ID1, ID2, ID3 corresponding to the finals "i'en'ao", the finals can be compressed as (ID1<<2x)|(ID2<<x)|ID3, where x is the number of bits (bit) of the finals ID. In this way, by combining multiple finals IDs into an integer, the space required to store multiple independent IDs can be reduced, and multiple pieces of information are encoded into a single numerical value, thereby reducing the overall storage requirement.

[0159] In the embodiments of the present application, the phonetic trie, character trie, finals area, first node position area, second node position area, and attribute area in the double trie are all divided into several sub-regions according to the word length. In this way, each node position information is relative to each sub-region, narrowing the value range of the node position information. Moreover, the node position information in the double trie can be replaced by an index instead of an offset, thereby further narrowing the value range of the node position information, which is beneficial to compressed storage and reduces memory consumption.

[0160] It should be noted that after serializing the dual trie, the serialized result can be compressed and stored, and the compressed dual trie serialization result can be obtained and loaded. Alternatively, the dual trie can be serialized, the dual trie serialization result can be stored, the dual trie serialization result can be obtained, the dual trie serialization result can be compressed, and the compressed result can be loaded. No limitation is made in the embodiments of this application.

[0161] In this way, storage space can be saved, transmission efficiency can be improved, and the word retrieval performance of the dual-tribe tree can be enhanced.

[0162] In some embodiments, the number of words corresponding to a string is multiple. After retrieving the words corresponding to the string from the dual trie, the word frequency of each word corresponding to the string is determined from the attribute area of ​​the second trie. Based on the word frequency of each word, the recommended word corresponding to the string is determined from the multiple words corresponding to the string.

[0163] Here, the attribute area stores the word frequency of the words corresponding to the string. The word frequency is used to represent the relevance and importance of the words corresponding to the retrieved string to the string. The higher the word frequency, the higher the relevance of the corresponding word to the string, and the more important the word. Therefore, words with high word frequency can be displayed first.

[0164] In practical applications, the word frequency of each word corresponding to a string is determined from the attribute area of ​​the second trie. Among the words corresponding to multiple strings, the word with the highest word frequency is selected as the recommended word and sent to the terminal so that the terminal can display the recommended word. Alternatively, the word frequency of each word corresponding to a string is determined from the attribute area of ​​the second trie, and the words corresponding to multiple strings are sorted according to their corresponding word frequencies from high to low. The sorted word sequence is then used as the recommended word sequence and sent to the terminal so that the terminal can display the recommended words in descending order of word frequency.

[0165] The word frequency can be a pre-set fixed value, or it can be continuously adjusted by a neural network model based on the user's historical input to predict the user's preferences. This application does not impose any limitations on this.

[0166] In this way, by determining the recommended words corresponding to a string from the words corresponding to multiple strings based on word frequency, users can find the words they want to obtain more quickly when inputting, which is more in line with user needs and improves user experience.

[0167] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.

[0168] See Figure 15 , Figure 15This is a schematic diagram of the lexicon structure provided by related technologies. The lexicon in these technologies mainly consists of three parts:

[0169] 1. Trie index 101. Trie nodes use syllables as keys, and each node points to the position of the first word in the attribute area.

[0170] 2. Attribute area 102 mainly stores the attribute information of words, such as word frequency, tags, etc., and also stores the position of the word in the word area.

[0171] 3. Word section 103: The specific word can be found in the word section by using the word section location stored in the attribute section.

[0172] The current status of word retrieval using the above thesaurus structure:

[0173] Scenario 1: For full-word search (i.e., the full-word search scenario mentioned above) py1'py2'...'pyn, start from the root node of the trie tree (i.e., the dictionary tree mentioned above) and search layer by layer for pii until the end of the full-word string pyn is matched. Then, by using the position of the first word pointed to by the current trie tree node and the position pointed to by the next sibling node of the current node, all the words corresponding to the full-word string can be determined.

[0174] Scenario 2: For abbreviated spelling search (i.e., the abbreviated spelling search scenario mentioned above) jp1'jp2'...'jpn, first expand the abbreviated spelling into full spelling and then perform a complete combination: [py11, py12, ..., py1m1] × [py21, py22, ..., py2m2] × ... × [pyn1, pyn2, ..., pynm] n Each combination of full-character strings is searched using the full-character search method, resulting in m1+m2+...+m n A combination of full pinyin, m i The number of characters in the abbreviated pinyin can be expanded into the full pinyin, which can be considered a constant of about 30. n is the number of syllables in the input string. The retrieval performance increases exponentially with n. The longer the input string and the more syllables, the worse the retrieval performance.

[0175] Scenario 3: For long word prediction (i.e., the word prediction scenario mentioned above), it is divided into long word prediction under full pinyin and long word prediction under abbreviated pinyin. For full pinyin, the end of the pinyin string is first matched using a trie tree. Then, the subtrees are traversed with the current node as the root node. Finally, the words corresponding to each path in the subtree are retrieved. The performance of long word prediction is related to the size of the vocabulary (the size of the trie tree). If the vocabulary is too large, there will be performance problems. For abbreviated pinyin, the performance will increase explosively. Currently, a relatively crude pruning method is adopted, which is to traverse at most N paths, resulting in very poor recall.

[0176] Scenario 4: For the association scenario (i.e., the word association scenario mentioned above), similar to long word prediction, it matches the end of the word through a trie tree, then traverses the subtree with the current node as the root node, and finally retrieves the word corresponding to each path in the subtree. The association does not use pinyin, so it directly searches by word. Therefore, it is necessary to build a trie tree index with characters as the key. In addition to the retrieval performance issue, there is also the problem of memory waste. This is because there will be a pinyin trie tree (i.e., the sound tree mentioned above) dictionary and a word trie tree (i.e., the character tree mentioned above) dictionary. There is redundancy in the attribute area and the word area, which leads to a lot of memory waste. In addition, the dictionary of some services is not serialized, causing memory explosion, exceeding 50G, and an additional 80G memory node needs to be applied for.

[0177] Scenario 5: Word + Pinyin Mixed Search (i.e., the mixed scenario mentioned above). Based on both Pinyin trie tree lexicon and word trie tree lexicon, it is not possible to directly achieve mixed word + Pinyin retrieval. A potential solution is to annotate the preceding text with Pinyin, and then concatenate the annotated results with Pinyin for retrieval. The main problem with this solution is that it is highly dependent on the phonetic annotation algorithm, which cannot guarantee the accuracy of the phonetic annotation, affecting the recall effect; if all possible phonetic annotation results are considered, there may be a large number of Pinyin combinations, resulting in poor retrieval performance.

[0178] During implementation, the applicant discovered the following problems with the relevant technology for word retrieval:

[0179] 1. Performance: Except for full Pinyin search, which has no problem, the performance of abbreviated Pinyin search, long word prediction, and association scenarios is very poor, especially when the word database is extremely large, it is very easy to experience lag.

[0180] 2. Memory: There are two independent lexicons: the pinyin trie tree lexicon and the word trie tree lexicon. The attribute area and word area are redundant, resulting in a lot of wasted memory. Furthermore, the trie tree is loaded into memory directly without serialization. Moreover, the lexicon is very large, causing memory usage to explode and completely exceed the memory of a normal machine.

[0181] 3. Mixed word + pinyin search is not supported.

[0182] Based on this, this application provides a phonetic word double trie tree (i.e., the double dictionary tree mentioned above) structure, see [link to relevant documentation]. Figure 4 , Figure 4 This is a schematic diagram of the dual trie structure provided in the embodiments of this application. The left side is the trie tree, which mainly includes three parts:

[0183] 1. Pinyin trie tree index 401. Pinyin trie tree nodes use the abbreviated pinyin (i.e., the abbreviated pinyin of the full pinyin string mentioned above) as the key. The node will point to two areas: one is the position of the first word in the word trie tree node, and the other is the position of the first vowel in the vowel area.

[0184] 2. The vowel area 402 mainly stores the vowel information in the full spelling string except for the abbreviated spelling. It also stores the position of the first word in the word trie tree node (i.e., the node position corresponding to the word in the word tree mentioned above). In addition, all vowels corresponding to the same abbreviated spelling are stored contiguously. All vowels under the current node can be determined by the position of the first vowel pointed to by the current node and the position pointed to by the next sibling node of the current node.

[0185] 3. Word trie tree node position area 403 (i.e., the first node position area mentioned above) stores the position of the word trie tree node where the word is located. The position of the word trie tree node can be obtained in two ways: one is to obtain it directly by matching the abbreviated trie tree, and the other is to obtain it by matching the full spelling (abbreviated trie tree + vowel).

[0186] Figure 4 The right side of the middle section is a word trie tree, which also consists of three parts:

[0187] 1. The word trie tree index is 404. The word trie tree node uses the character (i.e., the Chinese character mentioned above) as the key. The node will point to four areas: first, it points to its parent node; second, it points to the corresponding phonetic trie tree node; third, it points to the position of the attribute corresponding to the word; and fourth, it points to the position of the trie tree node of the first long word prediction result corresponding to the word (i.e., the node position of the word prediction result in the character tree mentioned above).

[0188] 2. Attribute area 405 mainly stores word attribute information, such as word frequency and tags.

[0189] 3. The word trie tree node position area 406 where the long word prediction result is located (i.e., the second node position area mentioned above) stores the position of the word trie tree node where the long word prediction result is located. The long word prediction result under the current node can be determined by the position of the trie tree node of the first long word prediction result pointed to by the current node and the position pointed to by the next sibling node of the current node.

[0190] The word retrieval method provided in this application will now be described from a technical perspective.

[0191] Scenario 1: Full Pinyin search for py1'py2'...'pyn. The full Pinyin is split into abbreviated Pinyin plus finals jp1'jp2'...'jpn + ym1'ym2'...'ymn. First, using the abbreviated Pinyin string jp1'jp2'...'jpn, the search proceeds layer by layer from the root node of the phonological trie tree until the end of the abbreviated Pinyin string jpn is matched. Then, the position of the first final pointed to by the current trie tree node and the position pointed to by the next sibling node of the current node determine the range of finals under this abbreviated Pinyin. Next, a binary search is performed within this range of finals to find the matching finals in the final string ym1'ym2'...'ymn. Then, the position of the first word pointed to by the current final in the word trie tree and the position pointed to by the next final determine the node positions of all corresponding words in the word trie tree under the full Pinyin string. Finally, each character in the word is retrieved layer by layer from the parent node pointed to by the word trie tree node, and finally, the words are concatenated.

[0192] Scenario 2: Abbreviated spelling search jp1'jp2'…'jpn. Starting from the root node of the phonetic trie tree, search jpi layer by layer until the end of the abbreviated spelling string jpn is matched. Then, by using the position of the first word pointed to by the current trie tree node in the word trie tree node and the position pointed to by the next sibling node of the current node, the node positions of all words corresponding to the abbreviated spelling string in the word trie tree can be determined. Then, by using the parent node pointed to by the word trie tree node, each character in the word is obtained layer by layer, and finally concatenated into a word.

[0193] Scenario 3: Long word prediction. Regardless of whether it is abbreviated or full spelling, the node positions of all words corresponding to the abbreviated string in the word trie tree can be determined by following the methods in Scenario 1 or Scenario 2 above. Then, by using the trie tree node position of the first long word prediction result pointed to by the word trie tree node and the position pointed to by the next sibling node of the current node, the position of the word trie tree node of the long word prediction result under the current node can be determined. Then, by using the parent node pointed to by the long word prediction trie tree node, each character in the word is obtained layer by layer, and finally concatenated into a word.

[0194] Scenario 4: Association. For characters z1z2…zn, start from the root node of the word trie tree and search layer by layer for zi until the end of the preceding text zn is matched. Then, by using the position of the trie tree node of the first long word prediction result pointed to by the current node and the position pointed to by the next sibling node of the current node, the position of the word trie tree node of the long word prediction result under the current node can be determined. Then, by using the parent node pointed to by the long word prediction trie tree node, each character in the word is obtained layer by layer, and finally concatenated into a word.

[0195] Scenario Five: Word + Pinyin Mixture z1z2…zn+py1'py2...'pym. Start from the root node of the word trie tree and retrieve zi layer by layer until the end zn of the above text is matched. Then, start retrieving the pinyin string from the node of the phonetic trie tree pointed to by the current node. For full pinyin, it is the same as Scenario One, and for abbreviated pinyin, it is the same as Scenario Two. Finally, remove the prefix part of the obtained word.

[0196] From the perspective of memory, serialize the word library. Refer to Figure 16 , Figure 16 which is the schematic diagram of the serialized double trie tree structure provided by the embodiment of the present application, mainly including six regions:

[0197] 1. Phonetic trie tree (i.e., Figure 16 the phonetic dictionary tree in Figure 16 ). Compress and store each node in the order of breadth-first traversal. Each node stores key, that is, the abbreviated pinyin id (i.e., the abbreviated pinyin identifier in Figure 16 ), and store the id-ized abbreviated pinyin data, the position of the first child node, the storage position of the information of the first vowel of the full pinyin corresponding to the abbreviated pinyin, and the position information of the corresponding first word trie tree node.

[0198] 2. Vowel region, mainly storing the vowel information corresponding to the abbreviated pinyin (i.e., the vowels in the full pinyin string except the abbreviated pinyin string mentioned above), in the same order as the nodes of the phonetic trie tree. Each node of the phonetic trie tree may correspond to multiple vowel blocks, and each block stores vowel information. That is, all vowels are id-ized first, and then multiple vowel ids are combined into a number. For example, if the vowels corresponding to n'm'h are i'en'ao, then the vowel information can be compressed into (id1<<2x)|(id2<<x)|id3, where x is the number of bits of the vowel id, and the storage position of the corresponding first word trie tree node position information.

[0199] 3. Word trie tree node position region (i.e., Figure 16 the word dictionary tree node position region in Figure 16 ), mainly storing the node positions of the words corresponding to the pinyin in the word trie tree (i.e., the node positions corresponding to the Chinese characters in the sub-tree mentioned above), also in the same order as the nodes of the phonetic trie tree. Each node of the phonetic trie tree or each vowel block may correspond to multiple words, that is, multiple trie tree node positions.

[0200] 4. Word trie tree (i.e., Figure 16 the word dictionary tree in Figure 16 ). Compress and store each node in the order of breadth-first traversal. Each node stores key, that is, the character id (i.e., the character identifier in Figure 16 ), and store the id-ized character, the position of the first child node, the position of the parent node, the position of the corresponding phonetic trie tree node, and the position of the vowel data block, the position of the attribute data, and the position information of the corresponding first long word trie tree node.

[0201] 5. Attribute area: mainly stores the attribute data corresponding to words, such as word frequency, which is consistent with the order of the word trie tree nodes and has a one-to-one correspondence.

[0202] 6. Long word trie tree node location area (i.e. Figure 16 The long word trie node position area mainly stores the node position of the long word corresponding to the word in the trie tree. It is also consistent with the order of the trie tree nodes. Each trie tree node may correspond to multiple long words, that is, multiple trie tree node positions.

[0203] Compression details:

[0204] 1. For the above six parts, each part is divided into several sub-regions according to the word length. On the one hand, the position information can be relative to each sub-region, which can reduce the range of position information values ​​and is more conducive to compression. On the other hand, all data in the dictionary can be of fixed length, and the position information can be replaced by the index instead of the offset, further reducing the range of position information values, and the word length does not need to be stored.

[0205] 2. Convert the key value into an ID, including the abbreviation, character, and vowel. This converts the string into a relatively small number, resulting in better compression.

[0206] 3. For a case where a key (k) is paired with multiple values ​​(v), it is generally necessary to store the position of the first v and the number of v. However, here, the range of v corresponding to the current k can be determined by the positions of the first v pointed to by the current k and the next k, respectively, so it is not necessary to store the number of v.

[0207] In this way, the above word retrieval methods reduce lag during user input, improve the retrieval performance of the massive word database in various scenarios, reduce the memory usage of the massive word database, thereby saving service resources, and well support word + sound mixed input, thus improving the user input experience.

[0208] The following description continues to illustrate the exemplary structure of the word retrieval device 555 provided in the embodiments of the present invention as a software module. In some embodiments, such as... Figure 2 As shown, the software modules of the word retrieval device 555 may include: an acquisition module 5551, a scene determination module 5552, and a retrieval module 5553.

[0209] The acquisition module 5551 is used to acquire a dual dictionary tree in response to a word retrieval request for an input string. The dual dictionary tree includes a first dictionary tree and a second dictionary tree associated with the first dictionary tree. The first dictionary tree includes a phonetic tree with the simplified pinyin string as nodes, and the second dictionary tree includes a character tree with Chinese characters as nodes.

[0210] The scenario determination module 5552 is used to determine the retrieval scenario corresponding to the string.

[0211] The retrieval module 5553 is used to retrieve the word corresponding to the string from the dual dictionary tree based on the retrieval scenario and in combination with the phonetic tree and the character tree.

[0212] In some embodiments, the retrieval scenario includes a full-spelling retrieval scenario. The first dictionary tree further includes a vowel area associated with the phonological tree and a first node position area associated with the vowel area. The vowel area is used to store the vowels in the full-spelling string excluding the simplified spelling string, and the first node position area is used to store the node positions corresponding to the Chinese characters in the character tree. The retrieval module 5553 is further used to split the string into a first simplified spelling string and a first vowel, and to retrieve the first simplified spelling string layer by layer in the phonological tree to obtain a first retrieval result. Based on the first retrieval result and the first vowel, a target vowel matching the full-spelling string is determined in the vowel area. The node position pointed to by the target vowel is determined in the first node position area. Based on the node position pointed to by the target vowel, the word corresponding to the string is found in the character tree.

[0213] In some embodiments, the number of the first simplified spelling strings is at least one, the first retrieval result includes the last first simplified spelling string retrieved in the phonological tree, the node corresponding to the last retrieved first simplified spelling string is a first node, the retrieval module 5553 is further configured to determine the vowel pointed to by the first node, and determine the vowel pointed to by the next sibling node of the first node; based on the vowel pointed to by the first node and the vowel pointed to by the next sibling node of the first node, determine the vowel range of the first simplified spelling string in the vowel area; within the vowel range of the first simplified spelling string in the vowel area, determine the vowel that matches the first vowel, and take the vowel that matches the first vowel as the target vowel that matches the full spelling string.

[0214] In some embodiments, the retrieval scenario includes a simplified spelling retrieval scenario, the string includes at least one simplified spelling string, the first trie further includes a first node position area, the first node position area is used to store the node positions corresponding to the Chinese characters in the character tree; the retrieval module 5553 is further used to retrieve the at least one simplified spelling string layer by layer in the phonetic tree, and take the node corresponding to the last retrieved simplified spelling string as the second node; in the first node position area, determine the node position pointed to by the second node, and determine the node position pointed to by the next sibling node of the second node; based on the node position pointed to by the second node and the node position pointed to by the next sibling node of the second node, find the word corresponding to the string in the character tree.

[0215] In some embodiments, the retrieval module 5553 is further configured to determine a node position range in the first node position area with the node position pointed to by the second node as the initial node position and the node position pointed to by the next sibling node of the second node as the ending position; search for Chinese characters within the node position range in the character tree; and concatenate the Chinese characters found in the character tree to obtain the word corresponding to the string.

[0216] In some embodiments, the retrieval scenario includes a word prediction scenario. The first trie further includes a first node position area, which is used to store the node positions corresponding to Chinese characters in the character tree. The second trie further includes a second node position area, which is used to store the node positions of word prediction results in the character tree. The retrieval module 5553 is further configured to determine the abbreviated string corresponding to the string, and determine the node position pointed to by the abbreviated string in the first node position area; find the corresponding Chinese character in the character tree based on the node position pointed to by the abbreviated string; determine the node position of the word prediction result pointed to by the Chinese character in the second node position area; and find the word corresponding to the string in the character tree based on the node position of the word prediction result.

[0217] In some embodiments, the retrieval scenario includes a word association scenario, the string includes at least one Chinese character, and the second trie further includes a second node position area, which is used to store the node positions of the word prediction results in the trie; the retrieval module 5553 is further used to retrieve the at least one Chinese character layer by layer in the trie, and take the node corresponding to the last retrieved Chinese character as the third node; in the second node position area, determine the node position pointed to by the third node, and determine the node position pointed to by the next sibling node of the third node; take the node position pointed to by the third node as the initial node position and the node position pointed to by the next sibling node of the third node as the ending position, and determine the node position range in the second node position area; search for Chinese characters within the node position range in the trie, and concatenate the Chinese characters found in the trie to obtain the word corresponding to the string.

[0218] In some embodiments, the retrieval module 5553 is further configured to find the corresponding Chinese character in the character tree for each node position within the node position range, and based on the parent node pointed to by the node, traverse layer by layer until the root node of the character tree is reached, and concatenate the Chinese characters obtained by traversing layer by layer to obtain the word corresponding to the string.

[0219] In some embodiments, the retrieval scenario includes a mixed scenario, the string includes a first pinyin string and Chinese characters, the first dictionary tree further includes a vowel area associated with the phonology tree and a first node position area associated with the vowel area; the retrieval module 5553 is further configured to retrieve the Chinese characters in the string layer by layer in the character tree to obtain a second retrieval result; based on the second retrieval result, determine the second pinyin string corresponding to the Chinese character in the phonology tree and the vowel area; combine the first pinyin string and the second pinyin string to obtain a pinyin combination; determine the node position corresponding to the pinyin combination in the first node position area of ​​the first dictionary tree, and based on the node position, find the word corresponding to the pinyin combination in the character tree.

[0220] In some embodiments, the word retrieval device further includes: a construction module, configured to construct the dual dictionary tree before obtaining the dual dictionary tree; serialize the dual dictionary tree and store the serialization result of the dual dictionary tree; the acquisition module is further configured to acquire the serialization result of the dual dictionary tree; compress the serialization result of the dual dictionary tree and load the compressed result.

[0221] In some embodiments, the number of words corresponding to the string is multiple, and the second trie further includes an attribute area for storing word frequencies; the word retrieval device further includes: a recommended word determination module, used to determine the word frequencies of each word corresponding to the string from the attribute area of ​​the second trie; and to determine recommended words corresponding to the string from the multiple words corresponding to the string based on the word frequencies of each word.

[0222] This application provides a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. The processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the word retrieval method described above in this application.

[0223] This application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the word retrieval method provided in this application. For example, ... Figure 3 , Figure 5 , Figure 7 The methods shown are as follows.

[0224] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.

[0225] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, 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 stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.

[0226] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).

[0227] As an example, computer-executable instructions can be deployed to execute on a single electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed across multiple locations and interconnected via a communication network.

[0228] In summary, the embodiments of this application utilize a first and a second trie that are related. The first trie includes a phonetic tree with abbreviated strings as nodes, and the second trie includes a character tree with Chinese characters as nodes. By combining the search scenarios corresponding to the strings, word retrieval can be performed. This can improve the performance of word retrieval in different scenarios, reduce lag during user input, reduce the memory usage of the dictionary, and save service resources.

[0229] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

Claims

1. A word retrieval method, characterized in that, The method includes: In response to a word search request for an input string, a dual trie is obtained, the dual trie comprising a first trie and a second trie associated with the first trie; The first trie includes a phonological tree with the simplified pinyin string of the full pinyin string as nodes, and the second trie includes a character tree with Chinese characters as nodes. Determine the retrieval scenario corresponding to the string; Based on the retrieval scenario, and combining the phonetic tree and the character tree, the word corresponding to the string is retrieved from the dual dictionary tree.

2. The method according to claim 1, characterized in that, The search scenarios include full-spelling search scenarios, and the first dictionary tree also includes a vowel area associated with the phonological tree and a first node position area associated with the vowel area; The vowel area is used to store the vowels in the full pinyin string excluding the simplified pinyin string, and the first node position area is used to store the node positions corresponding to the Chinese characters in the character tree. The step of retrieving the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree, includes: The string is split into a first abbreviated string and a first vowel, and the first abbreviated string is searched layer by layer in the phonological tree to obtain the first search result; Based on the first search result and the first vowel, a target vowel that matches the full pinyin string is determined in the vowel area; Within the first node location area, determine the node location to which the target vowel points; Based on the node position pointed to by the target vowel, the word corresponding to the string is found in the character tree.

3. The method according to claim 2, characterized in that, The number of the first abbreviated spellings is at least one, and the first retrieval result includes the last abbreviated spellings retrieved in the phonetic tree, and the node corresponding to the last abbreviated spelling is the first node; The step of determining the target final that matches the full pinyin string in the final region based on the first search result and the first final includes: Determine the vowel pointed to by the first node, and determine the vowel pointed to by the next sibling node of the first node; Based on the vowel pointed to by the first node and the vowel pointed to by the next sibling node of the first node, the vowel range of the first abbreviated string in the vowel area is determined; Within the vowel range of the first simplified spelling string in the vowel area, determine the vowel that matches the first vowel, and use the vowel that matches the first vowel as the target vowel that matches the full spelling string.

4. The method according to claim 1, characterized in that, The retrieval scenario includes a simplified spelling retrieval scenario, the string includes at least one simplified spelling string, and the first trie also includes a first node position area, which is used to store the node positions corresponding to the Chinese characters in the trie; The step of retrieving the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree, includes: The at least one abbreviated string is retrieved layer by layer in the sound tree, and the node corresponding to the last retrieved abbreviated string is taken as the second node; In the first node location area, determine the node location pointed to by the second node, and determine the node location pointed to by the next sibling node of the second node; Based on the node position pointed to by the second node and the node position pointed to by the next sibling node of the second node, the word corresponding to the string is found in the word tree.

5. The method according to claim 4, characterized in that, The step of finding the word corresponding to the string in the word tree based on the node position pointed to by the second node and the node position pointed to by the next sibling node of the second node includes: The node position range is determined within the first node position area, with the node position pointed to by the second node as the initial node position and the node position pointed to by the next sibling node of the second node as the ending position. The Chinese characters that fall within the range of the node positions are searched in the character tree, and the Chinese characters found in the character tree are concatenated to obtain the word corresponding to the string.

6. The method according to claim 1, characterized in that, The retrieval scenario includes a word prediction scenario. The first trie further includes a first node position area, which is used to store the node positions corresponding to Chinese characters in the character tree. The second trie also includes a second node position area, which is used to store the node positions of word prediction results in the character tree. The step of retrieving the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree, includes: Determine the abbreviated string corresponding to the string, and in the first node position area, determine the node position pointed to by the abbreviated string; Based on the node position pointed to by the abbreviated string, the corresponding Chinese character is found in the character tree; In the second node location area, determine the node position of the word prediction result pointed to by the Chinese character; Based on the node position of the word prediction result, the word corresponding to the string is found in the word tree.

7. The method according to claim 1, characterized in that, The retrieval scenario includes a word association scenario, the string includes at least one Chinese character, and the second trie also includes a second node position area, which is used to store the node position of the word prediction result in the trie. The step of retrieving the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree, includes: The at least one Chinese character is retrieved layer by layer in the character tree, and the node corresponding to the last retrieved Chinese character is taken as the third node. In the second node location area, determine the node location pointed to by the third node, and determine the node location pointed to by the next sibling node of the third node; The node position range is determined in the second node position area, with the node position pointed to by the third node as the initial node position and the node position pointed to by the next sibling node of the third node as the ending position. The Chinese characters that fall within the range of the node positions are searched in the character tree, and the Chinese characters found in the character tree are concatenated to obtain the word corresponding to the string.

8. The method according to claim 7, characterized in that, The step of searching for Chinese characters within the node position range in the character tree and concatenating the found Chinese characters in the character tree to obtain the word corresponding to the string includes: For each node position within the specified node position range, the corresponding Chinese character is found in the character tree. Based on the parent node pointed to by the node, the process is traversed layer by layer until the root node of the character tree is reached. The Chinese characters obtained through the layer-by-layer traversal are then concatenated to obtain the word corresponding to the string.

9. The method according to claim 1, characterized in that, The retrieval scenario includes a mixed scenario, the string includes a first pinyin string and Chinese characters, and the first trie also includes a vowel area associated with the phonology tree and a first node position area associated with the vowel area; The step of retrieving the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree, includes: The Chinese characters in the string are retrieved layer by layer in the character tree to obtain the second search result; Based on the second search result, the second pinyin string corresponding to the Chinese character is determined in the phonological tree and the vowel area; The first and second pinyin strings are combined to obtain a pinyin string combination; In the first node position area of ​​the first trie, the node position corresponding to the pinyin combination is determined, and based on the node position, the word corresponding to the pinyin combination is found in the character tree.

10. The method according to claim 1, characterized in that, Before obtaining the dual trie, the method further includes: Construct the aforementioned dual trie; The dual trie is serialized, and the serialization result of the dual sub-trie is stored; The process of obtaining the dual trie includes: Obtain the serialization result of the bivariate tree; The serialization result of the dual trie is compressed, and the compressed result is loaded.

11. The method according to any one of claims 1 to 10, characterized in that, The number of words corresponding to the string is multiple, and the second trie also includes an attribute area, which is used to store the word frequency; After retrieving the word corresponding to the string from the dual trie, the method further includes: From the attribute area of ​​the second trie, determine the word frequency of each word corresponding to the string; Based on the word frequency of each of the aforementioned words, the recommended word corresponding to each string is determined from the words corresponding to the multiple strings.

12. A word retrieval device, characterized in that, The device includes: The acquisition module is used to acquire a dual dictionary tree in response to a word retrieval request for an input string. The dual dictionary tree includes a first dictionary tree and a second dictionary tree associated with the first dictionary tree. The first dictionary tree includes a phonetic tree with the simplified pinyin string of the full pinyin string as nodes, and the second dictionary tree includes a character tree with Chinese characters as nodes. The scenario determination module is used to determine the retrieval scenario corresponding to the string; The retrieval module is used to retrieve the word corresponding to the string from the dual dictionary tree based on the retrieval scenario, combined with the phonetic tree and the character tree.

13. An electronic device, characterized in that, The electronic device includes: Memory is used to store executable instructions or computer programs. A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the word retrieval method according to any one of claims 1 to 11.

14. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, the word retrieval method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, the word retrieval method according to any one of claims 1 to 11 is implemented.