Word query method and device of input method, electronic equipment, computer readable storage medium and computer program product

Through the combination of word segmentation characters and dictionary trees, the problem of low efficiency and poor accuracy of input candidate word query is solved, efficient and accurate word query is achieved, adapting to errors and missing stroke input, and improving user experience.

CN120407710APending Publication Date: 2025-08-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410152894.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-31
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

The existing input methods are inefficient and have poor accuracy when acquiring candidate words, and cannot handle errors or missing strokes, and cannot flexibly query candidate words in the middle of the stroke sequence.

Method used

By using word segments to divide the stroke sequence into multiple stroke units, use the dictionary tree to query the offset and data length of the target stroke, query the target words from the word file, and obtain candidate words from the word group file, combine wildcard characters and error correction strategies to filter candidate words that do not match the word length, and generate word query results.

Benefits of technology

It improves the speed and accuracy of candidate word query, enhances the correlation between word query results and stroke sequence, enhances the applicability and flexibility of the input method, and avoids query failure caused by stroke input errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407710A_ABST
    Figure CN120407710A_ABST
Patent Text Reader

Abstract

The invention provides a word query method and device for an input method, electronic equipment, a computer readable storage medium and a computer program product. The method comprises the steps that a to-be-queried stroke sequence is obtained, the stroke sequence comprises at least one stroke, at least one wildcard character and at least one word segmentation character, and the word segmentation character is used for dividing the stroke sequence into a plurality of stroke units; determining at least one stroke belonging to the same stroke unit as a target stroke; querying offset and data length corresponding to at least one target stroke from the dictionary tree; querying a target character corresponding to the at least one target stroke from a character file according to the offset and the data length; querying a plurality of candidate words corresponding to the target word from the word combination file; determining the word length according to the number of the word segmentation characters, and filtering out candidate words which do not accord with the word length from the plurality of candidate words; and generating a word query result based on the residual candidate words after filtering. By means of the method and device, the word query result of the input method can be efficiently and accurately obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to computer technology, and in particular, to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for querying words in an input method. Background Art

[0002] In the related art, when a user inputs information on a terminal, they need to rely on an input method. For example, when writing a document, sending an email, chatting using an instant messaging software, browsing the web, etc., an input method is required to generate the desired text content. The efficiency and convenience of the input method are directly related to the user experience of the terminal.

[0003] The stroke input method is a common input method, and users obtain word candidates by inputting strokes. The related art can find the corresponding candidate words according to the strokes input by the user for the user to select and use. However, in some cases (for example, when the user forgets some strokes of a character or is not clear about the specific stroke order of a character), when the user uses wildcards to obtain candidate words, the accuracy and search efficiency of the candidate words provided by the related art are relatively low. Summary of the Invention

[0004] Embodiments of this application provide a method, apparatus, electronic device, computer-readable storage medium, and computer program product for querying words in an input method, which can efficiently and accurately obtain the word query result of the input method.

[0005] The technical solution of the embodiments of this application is implemented as follows:

[0006] Embodiments of this application provide a method for querying words in an input method, the method including:

[0007] Obtain a stroke sequence to be queried, where the stroke sequence includes at least one stroke, at least one wildcard, and at least one word segment separator, and the word segment separator is used to divide the stroke sequence into multiple stroke units;

[0008] Determine at least one of the strokes belonging to the same stroke unit as the target stroke;

[0009] Query the offset and data length corresponding to at least one of the target strokes from a trie;

[0010] Query the target character corresponding to at least one of the target strokes from a character file according to the offset and the data length;

[0011] Query multiple candidate words corresponding to the target character from a word combination file;

[0012] Determine the word length according to the number of word segment separators, and filter out the candidate words that do not meet the word length from the multiple candidate words;

[0013] A word query result is generated based on the candidate words remaining after filtering.

[0014] The present invention provides a word search method for an input method, the method comprising:

[0015] Display the stroke input area of the input method;

[0016] In response to receiving a stroke sequence to be queried in the stroke input area, a word query result is displayed, wherein the word query result is obtained by the word query method of the input method mentioned above.

[0017] The present invention provides a word search device for an input method, the device comprising:

[0018] an acquisition module, configured to acquire a stroke sequence to be queried, wherein the stroke sequence includes at least one stroke, at least one wildcard, and at least one word separator, wherein the word separator is used to divide the stroke sequence into a plurality of stroke units;

[0019] a determination module, configured to determine at least one stroke belonging to the same stroke unit as a target stroke;

[0020] A query module is configured to query an offset and a data length corresponding to at least one target stroke from a dictionary tree; query a target character corresponding to at least one target stroke from a character file based on the offset and the data length; and query a plurality of candidate words corresponding to the target character from a word group file;

[0021] A filtering module, configured to determine a word length according to the number of word separators, and filter out candidate words that do not meet the word length from the multiple candidate words;

[0022] A generation module is used to generate a word query result based on the candidate words remaining after filtering.

[0023] The present invention provides a word search device for an input method, the device comprising:

[0024] A first display module, used for displaying the stroke input area of the input method;

[0025] The second display module is configured to display a word query result in response to receiving a stroke sequence to be queried in the stroke input area, wherein the word query result is obtained by the word query method of the input method.

[0026] An embodiment of the present application provides an electronic device, comprising:

[0027] a memory for storing computer-executable instructions;

[0028] A processor, when executing computer-executable instructions stored in the memory, implements the word query method of the input method provided in the embodiments of the present application.

[0029] The embodiments of the present application provide a computer-readable storage medium storing a computer program or computer-executable instructions, which are used to implement the word query method of the input method provided in the embodiments of the present application when executed by a processor.

[0030] The embodiments of the present application provide a computer program product including a computer program or computer-executable instructions, which implement the word query method of the input method provided in the embodiments of the present application when the computer program or computer-executable instructions are executed by a processor.

[0031] The embodiments of the present application have the following beneficial effects:

[0032] By using a segmentation character to divide the stroke sequence into multiple stroke units, candidate words can be determined according to the strokes in the multiple stroke units, improving the diversity of the word query method; using a trie tree to query the offset and data length corresponding to the target stroke, and then according to the offset and data length, query the target word corresponding to the target stroke in the character file and query the candidate words corresponding to the target word from the word combination file. Compared with the related art that directly queries all words corresponding to strokes in the trie tree, only the offset and data length corresponding to the strokes are stored in the trie tree, and the word query steps are decomposed, and the query of the target word and the query of the candidate words including the target word are respectively performed, so that each level of query can be quickly located according to the result queried in the previous level, saving storage space, improving the query speed of candidate words, and shortening the query time; filtering candidate words that do not meet the word length according to the word length to generate a word query result, enhancing the relevance between the word query result and the stroke sequence, and improving the accuracy of the word query. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 is a schematic structural diagram of a word query system 100 of the input method provided in the embodiments of the present application;

[0034] Figure 2A is a schematic structural diagram of a server 200 provided in the embodiments of the present application;

[0035] Figure 2B is a schematic structural diagram of a terminal 400 provided in the embodiments of the present application;

[0036] Figure 3A is a first flowchart of the word query method of the input method provided in the embodiments of the present application;

[0037] Figure 3B is a second flowchart of the word query method of the input method provided in the embodiments of the present application;

[0038] Figure 3C It is the schematic diagram of the third process of the word query method of the input method provided by the embodiment of the present application;

[0039] Figure 3D It is the schematic diagram of the fourth process of the word query method of the input method provided by the embodiment of the present application;

[0040] Figure 3E It is the schematic diagram of the fifth process of the word query method of the input method provided by the embodiment of the present application;

[0041] Figure 3F It is the schematic diagram of the sixth process of the word query method of the input method provided by the embodiment of the present application;

[0042] Figure 3G It is the schematic diagram of the seventh process of the word query method of the input method provided by the embodiment of the present application;

[0043] Figure 3H It is the schematic diagram of the eighth process of the word query method of the input method provided by the embodiment of the present application;

[0044] Figure 3I It is the schematic diagram of the ninth process of the word query method of the input method provided by the embodiment of the present application;

[0045] Figure 4 It is the schematic diagram of the tenth process of the word query method of the input method provided by the embodiment of the present application;

[0046] Figure 5 It is the schematic diagram of the structure of the trie tree provided by the embodiment of the present application;

[0047] Figure 6 It is the schematic diagram of the structure of the stroke input method provided by the embodiment of the present application;

[0048] Figure 7 It is the schematic diagram of the structure of the trie tree when the strokes are in digital form provided by the embodiment of the present application;

[0049] Figure 8 It is the schematic diagram of the structure of the character file provided by the embodiment of the present application;

[0050] Figure 9 It is the schematic diagram of the structure of the word formation file provided by the embodiment of the present application;

[0051] Figure 10 It is the application schematic diagram of generating the word query result provided by the embodiment of the present application. Detailed implementation manners

[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following will further describe this application in detail with reference to the accompanying drawings. The described embodiments should not be construed as limitations on this application. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.

[0053] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.

[0054] If similar descriptions such as "first / second" appear in the application documents, the following explanation is added. In the following description, the terms "first / second / third" are only used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence when permitted, so that the embodiments of this application described here can be implemented in an order other than that illustrated or described here.

[0055] In the embodiments of this application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other relevant parts to achieve a predetermined goal and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of the overall module or unit that includes the function of that module or unit.

[0056] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used in the embodiments of this application are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0057] Unless otherwise specified, "at least one" as described below refers to a situation of one or more, and "multiple" can refer to a situation of two or more.

[0058] Before further elaborating on the embodiments of this application, the nouns and terms involved in the embodiments of this application are explained. The nouns and terms involved in the embodiments of this application are subject to the following explanations.

[0059] 1) A trie tree, also known as a prefix tree or a key tree, is a tree-shaped structure that is a variant of a hash tree and is used to store the strokes corresponding to characters in a tree-shaped structure in each node in sequence. The node stores the offset corresponding to the stroke and the data length.

[0060] 2) Node links, which store the complete stroke sequence of any character in the dictionary in order. The node corresponding to the first stroke of the complete stroke sequence of a character in the dictionary in the dictionary tree is used as the start of a node link; the node corresponding to the last stroke of the complete stroke sequence of a character in the dictionary in the dictionary tree is used as the end of a node link. For example, a node link stores the complete stroke sequence of the Chinese character "王" in the dictionary, and uses the node corresponding to the first stroke "—" in the complete stroke sequence "——丨—" of "王" as the start of the node link, and the node corresponding to the last stroke "—" in the complete stroke sequence "——丨—" of "王" as the end of the node link.

[0061] 3) Offset. In computer assembly language, this refers to the distance between a node's actual position in the trie and its position in the node chain to which it belongs. For example, if the target stroke is "丨", the node chain to which the target stroke corresponds is <—, —, 丨, —>. The node corresponding to the target stroke "丨" is at position 3 in the node chain, and the actual position of the node corresponding to the target stroke "丨" in the trie is 28. Therefore, the offset of the node corresponding to the target stroke "丨" is 25.

[0062] 4) Data length refers to the number of characters that match the target stroke, including characters that completely match the target stroke and characters that do not completely match the target stroke. For example, the target stroke is "——丨—", the characters that completely match the target stroke are "王", and the characters that do not completely match the target stroke are "现", "理" and "班", then the data length corresponding to the target stroke "——丨—" is 7.

[0063] 5) The character file is a hash table that continuously stores the characters corresponding to the target strokes in the dictionary tree, sorts all the characters in ascending order according to the offset of the target stroke, sorts the characters with the same target stroke according to the degree of matching, and puts the characters that completely match the target stroke in front of the characters that do not completely match the target stroke. The characters that do not completely match the target stroke are sorted according to the frequency of use.

[0064] 6) Word group files: These files store candidate words corresponding to each character in the dictionary. Different word group files correspond to different positions of candidate words. For example, if "你好", "你", and "邂逅" are the three candidate words, and "你" is in the first, second, and third positions, respectively, then the corresponding word group files for these three words will also be different.

[0065] 7) Stroke sequence, that is, the sequence of strokes that make up a character. Taking Chinese characters as an example, the strokes of Chinese characters include "horizontal, vertical, left-falling stroke, dot, and turn". The strokes in a stroke sequence can be represented in various forms, including characters, numbers, and letters, etc. For example, "horizontal, vertical, left-falling stroke, dot, and turn" can be represented by the corresponding strokes "—, 丨, 丿, 丶, ", or by the numbers "1, 2, 3, 4, 5", or by the letters "a, b, c, d, e".

[0066] 8) Stroke unit, which can store a collection of strokes. A stroke unit can be used to represent a character or a word. When used to represent a character, a stroke unit can include all or part of the character's strokes; when used to represent a word, a stroke unit can include all or part of the word's strokes.

[0067] 9) Word separators: symbols used to distinguish different stroke units in a stroke sequence, such as “'”, “*”, and “#”.

[0068] The applicant has discovered that the following problems exist when performing word search in the input method in the related art:

[0069] 1. When obtaining candidate words, the input method of the related art searches through exhaustive enumeration of all words in the dictionary tree, but cannot improve the query efficiency through multi-level query, resulting in a very slow word query speed.

[0070] 2. The related technology does not filter the candidate words found in the query, resulting in low pertinence and accuracy of the word query results.

[0071] 3. When the strokes input by the user are incorrect, the accuracy of the word query cannot be guaranteed by replacing the incorrect strokes with wildcards, resulting in a low accuracy of the word query.

[0072] 4. When searching for candidate words through a stroke sequence, the related technology can only start searching from the first stroke of the stroke sequence, and cannot search for candidate words through any stroke in the middle of the stroke sequence, resulting in low flexibility.

[0073] Based on the above analysis, the applicant found that the word query method of the input method of the related technology cannot perform multi-level query to ensure the speed of querying candidate words, and it is also unable to accurately obtain the word corresponding to the stroke sequence when the strokes are missing or incorrect. To address the above problems, the embodiment of the present application provides a word query method of the input method, which can efficiently and accurately obtain the word query results of the input method.

[0074] The embodiments of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for querying words in an input method, which can efficiently and accurately obtain the word query results of the input method. The following describes an exemplary application of the electronic device provided by the embodiments of the present application. The electronic device provided by the embodiments of the present application can be implemented as various types of user terminals such as laptop computers, tablet computers, desktop computers, set-top boxes, mobile devices (such as mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable game devices), smart phones, smart speakers, smart watches, smart TVs, in-vehicle terminals, etc., or can also be implemented as a server. Below, the exemplary application when the electronic device is implemented as a server will be described.

[0075] See Figure 1 , Figure 1 FIG. is a schematic structural diagram of a word query system 100 for an input method provided by the embodiments of the present application. To support a word query application of an input method, the terminal 400 is connected to the server 200 through the network 300. The network 300 can be a wide area network, a local area network, or a combination of the two.

[0076] The word query process of the input method can be processed locally offline. The terminal 400 displays the stroke input area of the input method, and in response to receiving a stroke sequence to be queried in the stroke input area, queries the word query result corresponding to the stroke sequence and displays the word query result in the graphical interface 410.

[0077] The terminal 400 is used to display an input method panel in the graphical interface 410. The server 200 is used to obtain the stroke sequence received in the stroke input area to query the word query result corresponding to the stroke sequence, and send the word query result to the terminal 400 through the network 300. The terminal 400 displays the received word query result in the input method panel of the graphical interface 410.

[0078] In some embodiments, the server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The terminal 400 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an in-vehicle terminal, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, which are not limited in the embodiments of the present application.

[0079] See Figure 2A , Figure 2AIt is a schematic structural diagram of the server 200 provided by an embodiment of the present application. Figure 2A The illustrated server 200 includes: at least one processor 210, a memory 230, and at least one network interface 220. Each component in the server 200 is coupled together through a bus system 240. It can be understood that the bus system 240 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 240 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 2A all kinds of buses are labeled as the bus system 240.

[0080] The processor 210 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. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0081] The memory 230 can be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memories, hard disk drives, optical disc drives, etc. The memory 230 optionally includes one or more storage devices that are physically remote from the processor 210.

[0082] The memory 230 includes volatile memory or non-volatile memory, and can also include both volatile and non-volatile memory. The non-volatile memory can be a read-only memory (ROM, Read Only Memory), and the volatile memory can be a random access memory (RAM, Random Access Memory). The memory 230 described in the embodiments of the present application is intended to include any suitable type of memory.

[0083] In some embodiments, the memory 230 is capable of storing data to support various operations. Examples of such data include programs, modules, and data structures, or subsets or supersets thereof, which are illustrated below.

[0084] An operating system 231, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0085] A network communication module 232, for reaching other electronic devices via one or more (wired or wireless) network interfaces 220. Exemplary network interfaces 220 include: Bluetooth, Wi-Fi (Wireless Fidelity), and Universal Serial Bus (USB), etc.;

[0086] In some embodiments, the device provided by the embodiments of the present application may be implemented in software. Figure 2A Shown is a word query device 233 of an input method stored in the memory 230, which may be software in the form of a program, a plug-in, etc., and includes the following software modules: an acquisition module 2331, a determination module 2332, a query module 2333, a filtering module 2334, and a generation module 2335. These modules are logical, and thus can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0087] See Figure 2B , Figure 2B which is a schematic structural diagram of a terminal 400 provided by the embodiments of the present application. Figure 2B The shown terminal 400 includes: at least one processor 410, a memory 450, at least one network interface 420, and a user interface 430. Each component in the terminal 400 is coupled together through a bus system 440. It can be understood that the bus system 440 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 440 further includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 2B all kinds of buses are labeled as the bus system 440.

[0088] The processor 410 may 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. Among them, the general-purpose processor may be a microprocessor or any conventional processor, etc.

[0089] The user interface 430 includes one or more output devices 431 capable of presenting media content, including one or more speakers and / or one or more visual display screens. The user interface 430 further includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, a mouse, a microphone, a touch screen display, a camera, and other input buttons and controls.

[0090] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memories, hard disk drives, optical disc drives, etc. The memory 450 optionally includes one or more storage devices that are physically located away from the processor 410.

[0091] The memory 450 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.

[0092] In some embodiments, the memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.

[0093] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, and driver layer, which are used to implement various basic services and process hardware-based tasks;

[0094] A network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420. Exemplary network interfaces 420 include Bluetooth, Wi-Fi, and Universal Serial Bus (USB);

[0095] a presentation module 453 for enabling presentation of information via one or more output devices 431 (e.g., a display screen, a speaker, etc.) associated with the user interface 430 (e.g., a user interface for operating peripheral devices and displaying content and information);

[0096] The input processing module 454 is configured to detect one or more user inputs or interactions from one of the one or more input devices 432 and to translate the detected inputs or interactions.

[0097] In some embodiments, the apparatus provided in the embodiments of the present application may be implemented in software. Figure 2B The input method word query device 455 stored in the memory 450 is shown. This device can be software in the form of a program or plug-in, and includes the following software modules: a first display module 4551 and a second display module 4552. These modules are logical and can be arbitrarily combined or further separated according to the functions they implement. The functions of each module will be described below.

[0098] In some embodiments, the terminal or server can implement the word query method of the input method provided in the embodiment of the present application by running various computer executable instructions or computer programs. For example, the computer executable instructions can be commands, machine instructions or software instructions at the microprogram level. The computer program can be a native program or software module in the operating system; it can be a local (Native) application (APPlication, APP), that is, a program that needs to be installed in the operating system to run, such as an input method APP; it can also be a small program that can be embedded in any APP, that is, a program that only needs to be downloaded to a browser environment to run. In short, the above-mentioned computer executable instructions can be instructions in any form, and the above-mentioned computer program can be an application, module or plug-in in any form.

[0099] The word query method of the input method provided in the embodiment of the present application will be explained in combination with the exemplary application and implementation of the electronic device provided in the embodiment of the present application.

[0100] The following embodiments are described using the strokes of Chinese characters as an example, but are not limited to the strokes of Chinese characters. The strokes of other types of characters may also be used, such as Korean characters, Japanese characters, and the like.

[0101] See also Figure 3A , Figure 3A This is a first flow chart of the word query method of the input method provided by the embodiment of the present application, which can be completed by the above-mentioned terminal or server alone, or by the terminal and server in collaboration. Figure 3A The steps shown are explained.

[0102] In step 101, a stroke sequence to be queried is obtained, wherein the stroke sequence includes at least one stroke, at least one wildcard and at least one word separator, and the word separator is used to divide the stroke sequence into a plurality of stroke units.

[0103] In some embodiments, the stroke sequence includes one or more strokes, one or more wildcards, and one or more word separators, and each stroke unit includes at least one stroke or at least one wildcard.

[0104] For example, the stroke sequence can be "—*丨—'*—", where * is a wildcard, ' is a word separator, and the rest are strokes. The stroke sequence is divided into two stroke units by a word separator, the first stroke unit is "—*丨—", and the second stroke unit is "*—".

[0105] In step 102, at least one stroke belonging to the same stroke unit is determined as a target stroke.

[0106] In some embodiments, see Figure 3B , Figure 3BThis is a second flow chart of the word query method of the input method provided in an embodiment of the present application. Figure 3A Step 102 can be achieved by Figure 3B Steps 1021A to 1023A are implemented as described below.

[0107] In step 1021A, a plurality of stroke units are arranged in writing order.

[0108] In some embodiments, the writing order refers to the input order of multiple stroke units in the stroke sequence.

[0109] For example, for any character, such as "王", its writing order is "——丨—"; for a stroke sequence, its writing order is the order of the strokes input by the user from left to right; arranging multiple stroke units in writing order is to arrange multiple stroke units in the order of the strokes input by the user from left to right, for example, the stroke sequence is "—*丨—'*—'**丨", where the stroke units include "—*丨—", "*—" and "**丨", and arranging multiple stroke units in writing order is "—*丨—", "*—", "**丨".

[0110] In step 1022A, the first stroke unit including the stroke is taken as the first target stroke unit.

[0111] For example, if the stroke sequence is "—*丨—'*—'**丨", where "'" is a word separator, the stroke unit "—*丨—" is taken as the first target stroke unit; if the stroke sequence is "*'*—'**丨", "*—" is taken as the first target stroke unit.

[0112] In step 1023A, at least one stroke in the first target stroke unit is used as a target stroke.

[0113] For example, if the stroke sequence is “—*丨—'*—'**丨”, and the first target stroke unit is “—*丨—”, the stroke “—” or “丨” can be used as the target stroke.

[0114] In some embodiments, step 102 may also be implemented in the following manner: arbitrarily select a stroke unit including a stroke from a plurality of stroke units, for example, select the second stroke unit including a stroke, and take at least one stroke in the stroke unit as the target stroke.

[0115] In some embodiments, see Figure 3C , Figure 3C This is a third flow chart of the word query method of the input method provided in an embodiment of the present application. Figure 3A Step 102 can also be done by Figure 3CSteps 1021B to 1023B are implemented as described below.

[0116] In step 1021B, the number of strokes in each stroke unit is determined.

[0117] In some embodiments, the number of strokes of a stroke unit is the total number of strokes included in the stroke unit (excluding wildcards).

[0118] For example, if the stroke sequence is "—*丨—'*—'**丨", the number of strokes of the stroke unit "—*丨—" is 3, the number of strokes of the stroke unit "*—" is 2, and the number of strokes of the stroke unit "**丨" is 1.

[0119] In step 1022B, the stroke unit with the maximum number of strokes is used as the second target stroke unit, wherein the maximum number of strokes is the maximum value of the number of strokes.

[0120] For example, if the stroke sequence is "—*丨—'*—'**丨", since the number of strokes of the stroke unit "—*丨—" is 3, the number of strokes of the stroke unit "*—" is 2, and the number of strokes of the stroke unit "**丨" is 1, the stroke unit "—*丨—" is taken as the second target stroke unit.

[0121] In step 1023B, at least one stroke of the second target stroke unit is used as a target stroke.

[0122] For example, if the second target stroke unit is “—*丨—”, the stroke “—” or “丨” can be used as the target stroke.

[0123] In some embodiments, step 1023B may also be implemented in the following manner:

[0124] Method 1: In response to the number of stroke units with the largest number of strokes being plural, the stroke unit with the largest number of strokes and the first character of which does not include a wildcard is used as the second target stroke unit.

[0125] For example, if the stroke sequence is "—*丨—'*—*—'**丨", where the number of strokes of the stroke unit "—*丨—" and the stroke unit "*—*—" is 3, both stroke units are stroke units with the maximum number of strokes. Since the first digit of the stroke unit "—*丨—" is not a wildcard, the stroke unit "—*丨—" is taken as the second target stroke unit.

[0126] Method 2: In response to the fact that there are multiple stroke units with the maximum number of strokes and the first digit of each stroke unit includes a wildcard, the multiple stroke units with the maximum number of strokes are sorted in a preset order, and the first stroke unit in the sorting result is used as the second target stroke unit, wherein the preset order is the order of the appearance position of the first stroke in the stroke unit from front to back.

[0127] For example, if the stroke sequence is "*—*丨—'**——'**丨", where the number of strokes in the stroke unit "*—*丨—" and the stroke unit "**——" is 3, and the first digit of both includes a wildcard, where the first stroke in the stroke unit "*—*丨—" appears in the second position, and the first stroke in the stroke unit "**——" appears in the third position, then the stroke unit "*—*丨—" is taken as the second target stroke unit.

[0128] Continue to see Figure 3A In step 103, the offset and data length corresponding to at least one target stroke are queried from the dictionary tree.

[0129] In some embodiments, a dictionary tree includes multiple nodes, divided into a root node and leaf nodes. Each leaf node except the root node includes a stroke. The strokes included in any node link in the dictionary tree correspond to the complete stroke sequence of a character in the dictionary. The node links include nodes at different levels. Each node link starts from the leaf node corresponding to the first stroke in the complete stroke sequence of a character in the dictionary under the root node and ends with the leaf node corresponding to the last stroke in the complete stroke sequence of a character in the dictionary. The node links generate corresponding levels from low to high according to the storage order of the leaf nodes. The position of each target stroke in the stroke unit to which it belongs has a corresponding level in the dictionary tree.

[0130] For example, see Figure 5 , Figure 5 This is a schematic diagram of the structure of the dictionary tree provided by the embodiment of the present application. Figure 5In the dictionary, the dictionary tree 501 includes multiple nodes, such as a root node 502 and a leaf node 503. Nodes other than the root node 502 are leaf nodes. Each leaf node includes a stroke. The strokes included in any node link in the dictionary correspond to a complete stroke sequence of a character in the dictionary. For example, the node link 504 corresponds to the complete stroke sequence "——丨—" of the Chinese character "王" in the dictionary. For each node link, the leaf node corresponding to the first stroke of the complete stroke sequence of a character in the dictionary is used as the beginning of the node link, and the leaf node corresponding to the last stroke of the complete stroke sequence of a character in the dictionary is used as the end of the node link. For example, the node link 504 starts from the leaf node 505 corresponding to the first stroke "—" in the complete stroke sequence "——丨—" of the character "王" and ends with the leaf node 503 corresponding to the last stroke "—" in the complete stroke sequence "——丨—" of the character "王", thereby forming a node link 504. Each leaf node in a node link has a corresponding level, where the level of a leaf node corresponds to its storage position in the node link to which it belongs. For example, if leaf node 503 is stored in the fourth position in node link 504, then the level corresponding to leaf node 503 is level 4. The position of each target stroke in the stroke unit to which it belongs has a corresponding level in the dictionary tree. For example, if the last "—" in the stroke unit "——丨—" is used as the target stroke, then this target stroke is in the fourth position in the stroke unit, which corresponds to the level of leaf node 503, i.e. level 4.

[0131] In some embodiments, step 103 can also be implemented in the following manner: determine the position of at least one target stroke in the stroke unit to which it belongs; in the level corresponding to the position in the dictionary tree, query at least one node that matches the at least one target stroke, and read the preset offset and data length from the last node of the at least one node as the offset and data length corresponding to the at least one target stroke.

[0132] For example, the target stroke "丨—" is located at the third and fourth positions in the stroke unit "——丨—". Therefore, among all the leaf nodes at the third and fourth levels of the dictionary tree, two leaf nodes matching the target stroke "丨—" are searched, and the preset offset and data length are read from the leaf node with the lower ranking among the two leaf nodes as the offset and data length corresponding to the target stroke "丨—". Figure 5 The target stroke "丨—" corresponds to leaf node 506 and leaf node 503. Since leaf node 503 is behind leaf node 506, the offset 30 and data length 7 preset in leaf node 503 are read, and the offset 30 and data length 7 are used as the offset and data length corresponding to the target stroke "丨—".

[0133] In some embodiments, the nodes in the dictionary tree may also include numbers or letters corresponding to the strokes. For example, the strokes "horizontal, vertical, left-falling stroke, dot, and turn" are recorded as the numbers 1, 2, 3, 4, and 5 respectively. Then for the "王" in the dictionary, the corresponding node link in the dictionary tree is <root node, 1, 1, 2, 1>; for another example, the strokes "horizontal, vertical, left-falling stroke, dot, and turn" are recorded as the letters a, b, c, d, and e respectively. Then for the "王" in the dictionary, the corresponding node link in the dictionary tree is <root node, a, a, b, a>.

[0134] The embodiment of the present application uses a dictionary tree to store the offset and data length corresponding to the strokes, and stores words with the same first stroke under the same parent node, thereby improving query efficiency and shortening query time.

[0135] In step 104, a target character corresponding to at least one target stroke is searched from the character file according to the offset and the data length.

[0136] In some embodiments, the word file stores each word in the dictionary in sequence according to the offset and data length preset by the node in the dictionary tree.

[0137] In some embodiments, see Figure 3D , Figure 3D This is a fourth flow chart of the word search method of the input method provided by the embodiment of the present application. When executing step 104, you can also execute Figure 3D Step 201 is described in detail below.

[0138] In step 201, in response to not finding a target character corresponding to at least one target stroke from the character file, any stroke in the stroke unit to which the target stroke belongs is replaced with a wildcard, and the process proceeds to the step of determining at least one stroke belonging to the same stroke unit as the target stroke.

[0139] In some embodiments, when a target word corresponding to at least one target stroke is not found in the word file due to a stroke input error, any stroke in the stroke unit to which the target stroke belongs is replaced with a wildcard to form a new stroke sequence, and then the new stroke sequence is executed at step 102.

[0140] For example, if the original stroke sequence is "*—*丨—'**——'**丨", and the user incorrectly enters the target stroke "" in the stroke unit "*—*丨—" as "丨", the stroke "丨" can be replaced with a wildcard, and the new stroke sequence is "*—**—'**——'**丨". At this time, at least one stroke belonging to the same stroke unit is determined from the stroke sequence "*—**—'**——'**丨" as the target stroke, for example, "——" is determined as the target stroke from the stroke unit "**——".

[0141] In some embodiments, see Figure 3E , Figure 3E This is a fifth flow chart of the word search method of the input method provided by the embodiment of the present application. When executing step 104, you can also execute Figure 3E Step 301 is described in detail below.

[0142] In step 301, in response to not finding a target character corresponding to at least one target stroke from the character file, and other stroke units include strokes, at least one stroke in the other stroke units with the highest priority is used as a new target stroke, and based on the new target stroke, the step of querying the offset and data length corresponding to at least one target stroke from the dictionary tree is entered.

[0143] In some embodiments, when a target word corresponding to at least one target stroke is not found in the word file due to a stroke input error, other stroke units that do not contain the target stroke can be sorted according to priority, and at least one stroke in the other stroke units with the highest priority can be used as a new target stroke, and the process proceeds to execution step 103.

[0144] For example, if the stroke sequence is "*—*丨—'**——'**丨", the user inputs the target stroke "" in the stroke unit "*—*丨—" incorrectly as "丨", resulting in the character corresponding to the target stroke "丨—" not being found in the character file, then the other stroke units "**——" and "**丨" are sorted according to priority, wherein the priority used for sorting can be the priority defined above, specifically: at least one stroke of the other stroke unit with the largest number of strokes is used as the new target stroke, for example, the stroke sequence is "—*丨—'**—'**丨", the stroke unit "**—" is the stroke unit containing the target stroke "", "—*丨— ” and “**丨” are other stroke units. When the target character corresponding to the target stroke “” is not found in the character file, the number of strokes of the other stroke unit “—*丨—” is 3, and the number of strokes of the other stroke unit “**丨” is 1. Therefore, the other stroke unit “—*丨—” has the highest priority, and at least one stroke of the other stroke unit “—*丨—” is selected as the new target stroke, for example, “丨—” is selected as the new target stroke; in response to the number of other stroke units with the largest number of strokes being multiple, at least one stroke of the other stroke unit with the largest number of strokes and the first stroke not including a wildcard is selected as the new target stroke, for example, the other stroke unit “—*丨—” and the other stroke unit “**丨” ——" have 3 strokes each, and both stroke units are other stroke units with the largest number of strokes. Since the first position of the other stroke unit "—*丨—" does not include a wildcard, the other stroke unit "—*丨—" has the highest priority, and at least one stroke of the other stroke unit "—*丨—" is selected as the new target stroke, for example, "丨—" is selected as the new target stroke; in response to the fact that there are multiple other stroke units with the largest number of strokes, and the first positions all include a wildcard, the multiple other stroke units with the largest number of strokes are sorted in a preset order, and at least one stroke of the first other stroke unit in the sorting result is selected as the new target stroke, wherein the preset order is other stroke units. The order of the appearance position of the first stroke in the element from front to back, for example, the number of strokes of the other stroke unit "*—*丨—" and the other stroke unit "**——" are both 3, the two other stroke units are the other stroke units with the largest number of strokes, and the first position of the two other stroke units includes a wildcard, but since the first stroke "—" of the other stroke unit "*—*丨—" appears in the second position, and the first stroke "—" of the other stroke unit "**——" appears in the third position, the other stroke unit "*—*丨—" has the highest priority, and at least one stroke of the other stroke unit "*—*丨—" is selected as the new target stroke, for example, "丨—" is taken as the new target stroke.

[0145] In the embodiments of the present application, by replacing strokes with wildcards to re-find the target stroke, or selecting strokes in other stroke units as the target stroke, the situation where the query cannot be performed due to incorrect user stroke input is avoided, and the flexibility and adaptability of the query are improved; at the same time, the offset and data length corresponding to the stroke are stored in the character file to query the corresponding character. After determining the offset and data length from the trie, the character corresponding to the target stroke can be quickly located, enhancing the speed of finding the character.

[0146] Continue to refer to Figure 3A In step 105, multiple candidate words corresponding to the target character are queried from the word combination file.

[0147] In some embodiments, the index position of the word combination file is the first character of the included candidate words. The word combination file includes the candidate words corresponding to when multiple candidate characters are respectively at the first position. The candidate character is any character in the dictionary.

[0148] For example, for the candidate words "hello", "you are", "where are you", "people", "flip flops", the first characters of these candidate words are "you" and "people" respectively. Therefore, the index positions of the word combination file include the positions of "you" and "people" in the word combination file.

[0149] In some embodiments, step 105 can be implemented by performing the following operations: query the pre-set offset table according to the target character to obtain the offset corresponding to the target character in the word combination file, and from the word combination file, starting from the position corresponding to the offset, obtain multiple candidate words corresponding to the target character.

[0150] For example, in the pre-set offset table, the offset corresponding to the target character "you" is 22. Then, starting from the position with the offset of 22, record the candidate words starting with the target character "you", such as "hello", "you are", "where are you", etc. All candidate words starting with "you" can be obtained according to the offset corresponding to the target character "you" in the word combination file.

[0151] In some embodiments, the word combination file includes word combination blocks corresponding to multiple candidate characters respectively. Each word combination block includes at least one data block, and each data block stores multiple candidate words starting with the candidate character; when the word combination block includes multiple data blocks, the multiple data blocks are sorted in ascending order according to the length of the included candidate words; when the data block includes multiple candidate words, the multiple candidate words are sorted in descending order according to the word frequency.

[0152] For example, the candidate character can be any character in the dictionary. For example, the word group file includes a word group block corresponding to the candidate character "王". All candidate words stored in the word group block start with "王". In the word group block, the candidate words can be divided into multiple data blocks according to their length. For example, candidate words with a length of 2 can be placed in one data block, such as "Prince", "Kingdom", "Throne", etc. The data block with a length of 2 is followed by a data block with a length of 3, such as "Princes", "Wang Zhaojun", etc., and so on. The data blocks in the same word group block are sorted in ascending order according to the length of the candidate words; for multiple candidate words in the same data block, they are sorted according to word frequency. For example, the word frequency of "Prince" is 500, the word frequency of "Kingdom" is 400, and the word frequency of "Throne" is 300. Then the storage order of the candidate words in the data block with a length of 2 is "Prince", "Kingdom", "Throne".

[0153] In some embodiments, there are multiple word grouping files, and the index position of a word grouping file is any one of the first position, middle position, and last position of the candidate words included therein, and the index position of the same word grouping file is fixed.

[0154] For example, for the candidate word "Who are you", if "you", "is" and "who" are used as target words respectively, then when different target words are queried, the word group files corresponding to the target words are also different. When the target word is "you", the index position of the corresponding word group file can only be the first position of the included candidate words, and in this word group file, all words starting with "you" can be found; similarly, when the target word is "is", the index position of the corresponding word group file can only be the second position of the included candidate words, and in this word group file, all words with "is" as the second character can be found; similarly, when the target word is "who", the index position of the corresponding word group file can only be the last position of the included candidate words, and in this word group file, all words with "who" as the last character can be found.

[0155] In some embodiments, see Figure 3F , Figure 3F This is the sixth flow chart of the word query method of the input method provided in the embodiment of the present application. Figure 3A Step 105 can also be done by Figure 3F Steps 1051 to 1053 are implemented as described below.

[0156] In step 1051, the target position of the target stroke unit to which the target stroke belongs in the stroke sequence is determined.

[0157] For example, if the stroke sequence is "*—*丨—'**——'**丨", and the target stroke is "——", then the target stroke unit to which the target stroke belongs is "**——", which is the second position in the stroke sequence, and the second position is used as the target position.

[0158] In step 1052 , a target word group file is determined, wherein the target word group file is a word group file that uses the target position as an index position and includes the target character at the index position.

[0159] For example, for a stroke sequence "**—*丨'*丨*'**—", if the target stroke is "丨", it can be seen that the stroke unit "*丨*" to which the target stroke belongs is in the second position of the stroke sequence, that is, the target character corresponding to the target stroke "丨" is in the second position of the candidate word, such as the target character "车", then the word group file with the second character of the candidate word as the index position is selected as the target word group file.

[0160] In step 1053, a plurality of candidate words corresponding to the target character are obtained from the target word group file.

[0161] For example, multiple candidate words corresponding to the target word "car" are selected from the target word group file, such as "car", "car", "waiting room", "previous lesson", etc.

[0162] The embodiment of the present application associates different word grouping files according to the target position of the target stroke unit to which the target stroke belongs in the stroke sequence, so that when querying candidate words in different situations, the corresponding word grouping file can be determined first, and a corresponding word grouping file is set for each situation, thereby improving the efficiency of queries in various situations.

[0163] In some embodiments, "obtaining multiple candidate words corresponding to the target word from the target word group file" in step 1053 can be implemented in the following way: reading a preset number of candidate words from the target word group file in order of priority from high to low, wherein the priority sorting rules include: the priority of the candidate words whose characters at the target position completely match the target word is higher than the priority of the candidate words whose characters at the target position do not completely match the target word; among the candidate words whose characters at the target position completely match the target word, the priority of the candidate words with high word frequency is higher than the priority of the candidate words with low word frequency; among the candidate words whose characters at the target position do not completely match the target word, the priority of the candidate words with high word frequency is higher than the priority of the candidate words with low word frequency.

[0164] For example, when a preset number of candidate words are read from the target word group file, the priority of the candidate words whose characters at the target position completely match the target character is higher than the priority of the candidate words whose characters at the target position do not completely match the target character. For example, the stroke sequence is "丿'****'—丨—丶", the target character is "去" searched based on the target strokes "—丨—丶", and the target position is the third in the stroke sequence. For the candidate words "你去" and "你却", the priority of "你去" is higher than the priority of "你却", because the strokes of the third character "去" in "你去" are "—丨—丶", the character "去" at the target position completely matches the target character "去", while "你却" "The third character "却" has the same strokes as "—丨—丶" as "去", which is a partial match, that is, an incomplete match. Therefore, "你去" has a higher priority. For the two candidate words "你去" and "他们去", the characters at the target position are all completely matched with the target characters. Among them, the word frequency of "你去" is 500, and the word frequency of "他们去" is 200. Therefore, the priority of "你去" is higher than that of "他们去"; For the two candidate words "你却" and "他们却", the characters at the target position are not completely matched with the target characters. Among them, the word frequency of "你的却" is 100, and the word frequency of "他们却" is 30. Therefore, the priority of "你的却" is higher than that of "他们却".

[0165] The embodiment of the present application reads a preset number of candidate words in the word group file according to priority, and sorts the candidate words, so that the query of the candidate words is more targeted, the query speed of the candidate words is improved, and the query time is shortened.

[0166] Continue to see Figure 3A In step 106, the word length is determined according to the number of word separators, and candidate words that do not meet the word length are filtered out from multiple candidate words.

[0167] In some embodiments, see Figure 3G , Figure 3G This is the seventh flow chart of the word query method of the input method provided in the embodiment of the present application. Figure 3A Step 106 can be achieved by Figure 3G Steps 1061 to 1062 are implemented as described below.

[0168] In step 1061, the sum of the number of word separators and 1 is used as the word length of the stroke sequence.

[0169] For example, if the stroke sequence is "*—*丨'**'**丨", and the number of word separators is 2, then the word length of the stroke sequence is 3.

[0170] In step 1062, candidate words whose word length is different from the word length of the stroke sequence are filtered out from the plurality of candidate words.

[0171] For example, if the word length of the stroke sequence is 3, and the multiple candidate words are "Hello", "Where are you", "Who are you", "You can", "Where are you going", since the word length of "Hello" is 2 and the word length of "Where are you going" is 4, "Hello" and "Where are you going" are filtered out.

[0172] Continue to refer to Figure 3A In step 107, a word query result is generated based on the candidate words remaining after filtering.

[0173] In some embodiments, refer to Figure 3H , Figure 3H is the eighth process schematic diagram of the word query method of the input method provided by the embodiments of the present application. Figure 3A Step 107 of Figure 3H can be implemented by steps 1071A to 1072A of

[0174] In step 1071A, the candidate words remaining after filtering are sorted in descending order of word frequency.

[0175] For example, if the candidate words remaining after filtering are "Where are you", "Who are you", "You can", among which the word frequency of "Where are you" is 1059, the word frequency of "Who are you" is 823, and the word frequency of "You can" is 372, then the result of sorting the candidate words remaining after filtering in descending order of word frequency is: "Where are you", "Who are you", "You can".

[0176] In step 1072A, a preset number of candidate words are selected starting from the first candidate word in the descending order sorting result as the word query result.

[0177] For example, if the descending order sorting result is: "Where are you", "Who are you", "You can", and the preset number is 2, then the word query result is "Where are you" and "Who are you".

[0178] By sorting the candidate words according to the priority in the embodiments of the present application, candidate words with a high matching degree with the target stroke and a high word frequency can be preferentially queried, so that the selected preset number of candidate words are more representative and targeted.

[0179] In some embodiments, refer to Figure 3I , Figure 3I is the ninth process schematic diagram of the word query method of the input method provided by the embodiments of the present application. Figure 3A Step 107 of Figure 3I can also be implemented by steps 1071B to 1075B of

[0180] In step 1071B, the stroke unit including the target stroke is used as the target stroke unit.

[0181] For example, if the stroke sequence is "*—*丨'**'**丨" and the target stroke is "", then the stroke unit "**" is used as the target stroke unit.

[0182] In step 1072B, when other stroke units include the target stroke, any stroke included in the other stroke units is taken as a candidate stroke, wherein the other stroke unit is any stroke unit in the stroke sequence except the target stroke unit.

[0183] For example, if the stroke sequence is "*—*丨'**'***" and the target stroke unit is "**", then the stroke unit "*—*丨" can be used as another stroke unit.

[0184] In some embodiments, when there are multiple other stroke units, they can be sorted according to the number of strokes included in the other stroke units, and any stroke in the other stroke unit with the largest number of strokes can be selected as an alternative stroke; when there are multiple other stroke units with the largest number of strokes, any stroke included in the front other stroke unit can be selected as an alternative stroke according to the order of the other stroke units in the stroke sequence.

[0185] In step 1073B, the offset and data length corresponding to the candidate strokes are queried in the dictionary tree.

[0186] In some embodiments, the process of searching for the offset and data length corresponding to the candidate strokes is similar to the process of searching for the offset and data length corresponding to the target stroke described above.

[0187] In step 1074B, at least one candidate character corresponding to the candidate stroke is searched from the character file based on the offset and data length corresponding to the candidate stroke.

[0188] For example, if the candidate strokes are "丿丨丿*", the candidate character can be "你".

[0189] In step 1075B, candidate words that do not include alternative characters are filtered out again from the candidate words remaining after filtering, and a word query result is generated based on the candidate words remaining after filtering again.

[0190] For example, the remaining candidate words after filtering include "where are you", "who are you", "you can", and "flip-flops". If the candidate word is "you", "flip-flops" is filtered out, and "where are you", "who are you", and "you can" are used as word search results.

[0191] The embodiment of the present application filters candidate words to obtain word query results, so that the final word query results are more consistent with the stroke sequence, thereby improving the accuracy and adaptability of the word query results.

[0192] See also Figure 4 , Figure 4 This is the tenth flow chart of the word query method of the input method provided in the embodiment of the present application, which takes the terminal as the main body and combines Figure 4 The steps shown are explained.

[0193] In step 401, a stroke input area of the input method is displayed.

[0194] For example, see Figure 6 , Figure 6 This is a schematic diagram of the structure of the stroke input method provided in the embodiment of the present application. Figure 6 In the figure, a stroke input area 601 of the input method is displayed, wherein the stroke input area 601 of the input method includes strokes, wildcards and word separators.

[0195] In step 402, in response to receiving a stroke sequence to be queried in the stroke input area, a word query result is displayed, wherein the word query result is obtained by the word query method of the input method described above.

[0196] For example, see Figure 6 , the word query result is displayed in area 602, wherein the word query result displayed in area 602 is obtained through the word query method of the above-mentioned input method.

[0197] The following describes an exemplary application of the embodiments of the present application in a practical application scenario.

[0198] Taking the stroke input method as an example, Figure 6 In the search, there are five stroke types: horizontal, vertical, left-falling stroke, dot, and hook (—, 丨, 丿, 丶, ). There are also wildcards * and word separators '. Entering "——丨—" will search for the Chinese character "王." Wildcards can be used to replace any input stroke. For example, entering the stroke sequence "—*丨—" in stroke input area 601 will also search for the Chinese character "王." Word separators are used to separate multiple Chinese characters to form sentences. For example, entering the stroke sequence "—*丨—'*—" in stroke input area 601 will search for the word "王子" and display it in area 602. Strokes are not limited to the five types mentioned above. For example, horizontal, vertical, left-falling stroke, dot, right-falling stroke, hook, and hook can also be used as strokes.

[0199] There are two key points in the process of candidate word query in the stroke input method: one is the dictionary file design, and the other is the search strategy design. The dictionary file is a file stored on the disk, which records the stroke information, index, and word grouping information of Chinese characters in a specific format (for example, the Chinese character "王" is composed of "horizontal, horizontal, vertical, and horizontal", and "王子" is a word). The search strategy is based on the dictionary file. Under specific input conditions, several candidate words that meet the user's needs are searched in the dictionary file. Obviously, a reasonable dictionary file design and search strategy are the key to affecting the effectiveness of the input method. The effect here mainly refers to the search speed, memory usage, and search range size.

[0200] The following introduces the dictionary file design. The dictionary file consists of four files: dictionary tree file, character file, single-character stroke lookup file and word group file. They work together to enable the stroke input method to operate.

[0201] A trie file is a dictionary tree. Each node stores a stroke, and also stores the data offset and length corresponding to this node in the word file. The data offset and length are pre-set or derived based on facts. The trie file is stored in a disk file, but it can also be stored in memory if there is sufficient memory, but the data structure will change slightly. The word corresponding to a stroke can be queried through the trie file. First, a word file must be generated. In the word file, all data are arranged in sequence. For example, the data of node 1121 is located at the 12345th byte of the word file, that is, the offset is 12345, and the length of the data is the actual length of the data. First find the 1121 node in the trie file, and then you can quickly locate the actual data location of the word file. In order to save storage space, the strokes "horizontal, vertical, left-falling, dot, and right-falling" are recorded as the numbers 1, 2, 3, 4, and 5 respectively. They can also be represented by letters or symbols, such as a, b, c, d, and e. See Figure 7 , Figure 7 This is a schematic diagram of the structure of the dictionary tree when the strokes are in digital form provided by the embodiment of this application. The actual dictionary tree is very large and contains all Chinese characters. Figure 7 In the figure, only a small portion of the trie is shown. For example, the bottommost node 610, which corresponds to node 1121, corresponds to the Chinese character "王" (king) and some Chinese characters beginning with "横横竖横". The trie can compress nodes. For example, if a node has only one child, the child node can be compressed together to improve query efficiency.

[0202] A character file is a flat storage file that stores several Chinese characters continuously. Figure 8 , Figure 8 This is a schematic diagram of the structure of the word file provided in the embodiment of this application. Figure 8In the above tree, starting with the 30th character, the seven consecutive characters stored correspond to the data for node 1121 in the above trie file. Since the character "王" (王) perfectly matches the strokes "横横竖横", it is ranked first. Other characters beginning with the strokes "横横竖横" are sorted according to certain rules: 1) Characters that completely match the strokes are ranked before those that do not completely match; 2) For characters that also completely match (there may be multiple characters for the same strokes), characters with higher word frequency are ranked first; 3) For characters that also do not completely match, characters with higher word frequency are ranked first. Word frequency refers to the frequency of use of a character, which is calculated based on the frequency of use of a large number of users.

[0203] The node coded as 521 in the dictionary tree has an offset of 180 and a length of 5. This node corresponds to the 5 consecutive Chinese characters starting from 180 in the character file. Figure 8 , the node coded 521 in the dictionary tree corresponds to "子, 卫, 巴, ..." in the character file. For another example, the node coded 11 in the dictionary tree stores the Chinese characters "二, 王...", where "二" is a complete match, and "王" is also in the character file corresponding to node 11 because its stroke prefix is a horizontal stroke.

[0204] Each node in the dictionary tree must be a complete match or a prefix of some Chinese character strokes, or both. If neither of these conditions is met, it will not appear in the dictionary tree. Therefore, the size of the dictionary tree is limited. For example, the "11111" node does not exist because there are no Chinese characters consisting of or starting with five consecutive horizontal strokes. In practice, the number of Chinese characters that have complete stroke matches corresponding to each dictionary tree node is usually small or even zero, but the results of prefix matches can be very large. For example, node 1 can contain all Chinese characters that begin with a horizontal stroke. Therefore, a selection rule can be set: in the character file, all Chinese characters that have complete matches are retained, and up to 30 Chinese characters that have prefix matches are retained. Among them, the number of Chinese characters that retain prefix matches can be set by yourself.

[0205] A single-character stroke lookup file is a hash table. The input is a single character, and the output is the corresponding strokes. Strokes can be replaced by numbers. For example, if you query the character "王," the output is "1121." The single-character stroke lookup file isn't limited to a hash table; it can also be a sequential array based on Unicode.

[0206] The word group file is a dictionary of legal terms, containing several words such as "你好," "可以," and "输入法." The word group file is stored as follows: words beginning with the same Chinese character are stored consecutively. For example, all words beginning with "你" are stored consecutively in the file, called a word group block for that character. Words of the same length are stored together in a data block. The words in each data block are sorted from most frequent to least frequent, and the word frequencies themselves are also recorded in the file. Different data blocks are sorted from smallest to largest in terms of length. To save disk space, data blocks do not store the Chinese characters themselves. Word groups consist of several data blocks, each containing words of the same length. For example, the words beginning with "你" include: {"你好," "大家," "是我哪," "你哪," "你去哪," "你去哪"}. The word group block for "你" consists of three data blocks: the first block contains "好," "们," "是," the second block contains "在哪," "谁," and the third block contains "去哪." Different word blocks are stored consecutively in the file. The word file as a whole is a hash table, and the location of the word block can be queried by a certain Chinese character.

[0207] For example, see Figure 9 , Figure 9 This is a schematic diagram of the structure of the word group file provided in the embodiment of this application. Figure 9 In the file, there are two word blocks, namely the word blocks of the Chinese character "你" and the Chinese character "人", and the two word blocks are stored consecutively. The following takes the word block of the Chinese character "你" as an example to illustrate the process of querying candidate words through the word block file. First of all, as described above, the word block file as a whole is a hash table. The storage location of the word block of the Chinese character "你" is the 0x122th (hexadecimal representation) byte from the beginning of the file. Therefore, by inputting the Chinese character "你", you can query the position of the 0x122th byte, that is, the location of the word block of "你". In this example, "你" has two data blocks. The first data block stores all words of length 2. There are two words in total, "你好" (word frequency 1782) and "大家" (word frequency 430). These two words are sorted by word frequency. There are three words in the second data block, namely "哪哪哪", "嘿嘿" and "你可以", which are also sorted by word frequency. Combined with Figure 9, the storage structure of the word group file also includes: the first position at the beginning of each word group block saves the maximum word length of this word group block minus 1, for example, the position of the 0x122th byte of the file, that is, the word group block of "you", stores a value of 2, because the maximum length of the word starting with "you" is 3; then the number of words contained in the first data block is saved, for example, the value stored at the 0x123th position of the file is 2, because there are a total of 2 two-character words starting with "you"; then all two-character words starting with "you" and word frequencies are stored continuously. Since each Chinese character occupies 4 storage spaces and the word frequency also occupies 4 storage spaces, the data block of two-character words starting with "you" and word frequency occupies a total of 1+2x(4+4)=17 bytes. Since 17 is a decimal representation, it is converted to hexadecimal as 0x11, that is, the data block occupies from the 0x122th byte to the 0x133rd byte of the file. Similarly, the data block for the next three-character word beginning with "你" and the word frequency starts at byte 0x134; then the data block with a word group length of 3 is saved. Its format is the same as the previous data block. The only difference is that since the word has become longer, each character occupies 4 bytes, a total of 2 characters, and the word frequency occupies another 4 bytes, so the space for storing each word is 4x2+4=12 bytes, and the subsequent storage is similar.

[0208] From the above storage method, it can be seen that a significant feature of the word group file is that each data block is aligned and the length is easy to calculate. The length is: 1+data volume*(4*(word group length-1)+4). Therefore, this storage method can quickly find the word group data block of the specified length.

[0209] The search strategy is introduced below. First, a simple strategy without error correction and wildcards is introduced: 1) After the user enters a stroke, the corresponding node of the stroke is found in the dictionary tree. The node records the data offset and length of the word file, so that all single-word candidates (including complete matches and completion candidates) can be found from the word file. For example, if you enter "3135234", it corresponds to the Chinese character "你", and also includes a completion-generated "你". 2) If the user only wants to enter a single word, then the process ends here, and there are a total of 2 candidates for the user to choose from. 3) If the user wants to form a word, enter a word separator, and the candidate word corresponding to the Chinese character "你" is found in the word formation file. Since there is only one word separator, there are 2 words with a query length of 2, which are displayed to the user. 4) Query the two-word group word corresponding to "你" and display it to the user.

[0210] This simple strategy presents several issues. First, when inputting a stroke sequence, if error correction and wildcards are used, there may be many characters to choose from, making sorting a challenge. Furthermore, if there are many characters to choose from, the algorithm for searching for the corresponding word group for each character becomes very complex. Furthermore, after the user enters the word separator, they will continue to enter the strokes of the next character. For example, if they enter "3135234'1," "你好" (good) should not be displayed, as "好" (good) does not begin with a horizontal stroke. These issues can be addressed using the following strategy.

[0211] See also Figure 10 , Figure 10 This is a schematic diagram of the application of generating word query results provided by the embodiment of this application. Figure 10 In the example, let the input be "3'****'*5". First, find the first Chinese character, which is the input "3" before the first word separator. There may be multiple characters corresponding to "3", which can be sorted according to the following rules: 1) The first complete match is ranked first; 2) The word with the highest frequency is ranked first; 3) If there are more than k candidates, only the first k are taken, where k can be set by yourself. Figure 10 In , assuming k is 2, there are only two candidates "你" and "人". If there is a wildcard in the first Chinese character, traverse all child nodes in the dictionary tree to generate candidate characters. For example, if the first input is "3*", try to query "31", "32", "33", "34" and "35" nodes at the same time. If there is subsequent input, continue to query these 5 nodes separately. Secondly, for these at most k single characters, search for the corresponding word groups respectively, and the length of the word group must be the number of word separators plus one. Figure 10 There are 2 word separators in total, so when searching for three-character words, there are 5 candidate words: "Where are you", "Hello", "You can", "The best", and "Flip-flops". Then, split the input of each word according to the word separator, and start from the second input according to the reverse filtering rules to remove the candidates that do not meet the requirements. The specific filtering rules are: 1) Query the strokes of each corresponding Chinese character from the single-character stroke search file. 2) If the strokes of the Chinese character are inconsistent with the user input and are not prefixed with the user input, it is judged to be illegal. 3) The wildcard * can be counted as any input, but only one. Then, in Figure 10, a total of 3 inputs are split. They are "3", "****" and "*5". For the second input, since there are 4 *, it can match any word of length not less than 4. Since "上" is less than 4 strokes, the candidate "人上人" is filtered out. For the third input "*5", since the second stroke of "好" is not 5 (拐), "你好" is filtered out, and similarly "你的" is also filtered out. In the end, only "你哪" meets expectations. Similarly, for the candidate words starting with "人", only the candidate word "人翻沙" meets expectations. Then, for all candidates that meet expectations, sort them according to their word group frequency. Finally, if the final number of candidates is less than n, return to process 1 and increase the value of k.

[0212] When there are erroneous strokes in the stroke sequence input by the user, an error correction strategy can be used to re-query. Error correction is defined as: replacing a certain input with another input, that is, even if the stroke input by the user is wrong, the correct candidate can still be searched. For example, the Chinese character "王" has the strokes of horizontal, horizontal, vertical, and horizontal. If the user inputs a horizontal, left-falling, vertical, and horizontal stroke, the second left-falling stroke will be replaced by a wildcard through the error correction strategy, thereby searching for the Chinese character "王". The specific implementation scheme of the error correction strategy is: replace a non-wildcard stroke input by the user with a wildcard, and only do it once, and the rest of the search strategy remains unchanged. That is to say, if the user inputs 4 strokes, one of the non-wildcards in the 4 strokes will be replaced with a wildcard. The number of error corrections can be any number of times, but too many times will slow down the calculation speed. Considering the complexity of the algorithm, only one such attempt is made in the embodiment of the present application, and the number of input strokes will not be changed.

[0213] When error correction and wildcards are not considered, the complexity of searching for a single word in the dictionary tree is O(N), where N is the length of the input. Searching for Chinese characters from the character file only requires one query, so the algorithm complexity is O(1). The algorithm complexity of searching for candidate words from the word group file is O(N*k), where N represents the number of candidate words corresponding to the single word and k is the number of single words. The error correction strategy is actually equivalent to replacing any stroke with a wildcard. Each time a wildcard is added, the complexity is multiplied by the number of strokes in the Chinese character. Since there are five strokes in the above example, except for the complexity of multi-way merge sort, the complexity of all other links will be multiplied by 5. However, since the word search results are determined by multi-way merge sort, even if the user enters multiple wildcards, as long as the data is pulled down, no calculation will be performed. Therefore, the algorithm complexity will not be continuously multiplied by 5 due to the increase in the number of wildcards.

[0214] In the embodiments of the present application, by using word segmentation symbols, users can input multiple characters simultaneously for combined queries. At the same time, by using wildcards, the situation where users cannot retrieve due to forgetting some strokes is avoided, improving the user experience and facilitating fuzzy queries for users. The trie tree is used to query the offset and data length corresponding to the target stroke, and then according to the offset and data length, the target character corresponding to the target stroke is queried in the character file, and the candidate words corresponding to the target character are queried from the word combination file. Compared with the related art that directly queries all words corresponding to strokes in the trie tree, only the offset and data length corresponding to the strokes are stored in the trie tree, and the word query steps are decomposed, respectively querying the target character and the candidate words including the target character, so that each level of query can be quickly located according to the result queried in the previous level, saving storage space, improving the query speed of candidate words, shortening the query time, and reducing the algorithm complexity of word query. According to the target position of the target stroke unit to which the target stroke belongs in the stroke sequence, different word combination files are associated, so that when querying candidate words in different situations, the corresponding word combination file can be determined first, and a corresponding word combination file is set for each situation, improving the query efficiency in multiple situations. At the same time, the storage order of characters and words is set in the character file and the word combination file respectively, which also improves the query speed of characters and candidate words and shortens the query time. The candidate words are selected according to the priority, improving the diversity and selectivity of the candidate words. According to the word length and the strokes in other stroke units, the candidate words that do not meet the word length or do not contain the alternative characters are filtered to generate the word query result, enhancing the relevance between the word query result and the stroke sequence and improving the accuracy of word query. Through the error correction strategy, the situation where candidate words cannot be searched due to incorrect stroke input is avoided, enhancing the applicability of the word query method.

[0215] The following continues to describe the exemplary structure of the software module implementation of the word query device 233 of the input method provided by the embodiments of the present application. In some embodiments, as Figure 2A shown, the software module in the word query device 233 of the input method stored in the memory 230 may include:

[0216] An acquisition module 2331, configured to acquire a stroke sequence to be queried, where the stroke sequence includes at least one stroke, at least one wildcard, and at least one word segmentation symbol, and the word segmentation symbol is used to divide the stroke sequence into multiple stroke units.

[0217] A determination module 2332, which determines at least one stroke belonging to the same stroke unit as the target stroke.

[0218] A query module 2333, configured to query offsets and data lengths corresponding to at least one target stroke from a trie; according to the offsets and data lengths, query target characters corresponding to the at least one target stroke from a character file; and query multiple candidate words corresponding to the target characters from a word combination file.

[0219] A filtering module 2334, configured to determine a word length according to the number of word segment separators, and filter out candidate words that do not meet the word length from the multiple candidate words.

[0220] A generation module 2335, configured to generate a word query result based on the remaining candidate words after filtering.

[0221] In some embodiments, a determination module 2332 is further configured to arrange multiple stroke units in a writing order; use the first stroke unit including a stroke as a first target stroke unit; and use at least one stroke in the first target stroke unit as a target stroke.

[0222] In some embodiments, the determination module 2332 is further configured to determine the number of strokes in each stroke unit; use the stroke unit with the largest number of strokes as a second target stroke unit, where the largest number of strokes is the maximum value of the number of strokes; and use at least one stroke in the second target stroke unit as a target stroke.

[0223] In some embodiments, when the number of stroke units with the largest number of strokes is multiple, the determination module 2332 is further configured to use the stroke unit with the largest number of strokes and without a wildcard at the beginning as the second target stroke unit.

[0224] In some embodiments, when the number of stroke units with the largest number of strokes is multiple and all of them include wildcards at the beginning, the determination module 2332 is further configured to sort the multiple stroke units with the largest number of strokes in a preset order, and use the first stroke unit in the sorting result as the second target stroke unit, where the preset order is the order of the appearance positions of the first strokes in the stroke units from front to back.

[0225] In some embodiments, the trie includes multiple nodes, each node includes a stroke, any node link in the trie includes strokes corresponding to a complete stroke sequence of a character in a dictionary, the node link includes nodes at different levels, and the query module 2333 is further configured to determine the position of at least one target stroke in the stroke unit to which it belongs; in the level corresponding to the position in the trie, query at least one node that matches the at least one target stroke, and read preset offsets and data lengths from the last node among the at least one node as the offsets and data lengths corresponding to the at least one target stroke.

[0226] In some embodiments, when querying for a target character corresponding to at least one target stroke from a character file according to an offset and a data length, the query module 2333 is further configured to, in response to not querying for a target character corresponding to at least one target stroke from the character file, replace any one stroke in the stroke unit to which the target stroke belongs with a wildcard, and transfer to the step of determining at least one stroke belonging to the same stroke unit as the target stroke.

[0227] In some embodiments, when querying for a target character corresponding to at least one target stroke from a character file according to an offset and a data length, the query module 2333 is further configured to, in response to not querying for a target character corresponding to at least one target stroke from the character file and other stroke units including strokes, use at least one stroke in the other stroke unit with the highest priority as a new target stroke, and transfer to the step of querying for the offset and data length corresponding to at least one target stroke from the trie tree based on the new target stroke.

[0228] In some embodiments, the index position of the word formation file is the first position of the included candidate words. The word formation file includes candidate words corresponding to multiple candidate characters when each of them is in the first position. The candidate character is any character in the dictionary. The query module 2333 is further configured to obtain multiple candidate words corresponding to the target character from the word formation file.

[0229] In some embodiments, the word formation file includes word formation blocks corresponding to multiple candidate characters respectively. Each word formation block includes at least one data block, and each data block stores multiple candidate words starting with the candidate character. When the word formation block includes multiple data blocks, the multiple data blocks are sorted in ascending order according to the length of the included candidate words. When the data block includes multiple candidate words, the multiple candidate words are sorted in descending order according to the word frequency.

[0230] In some embodiments, the number of word formation files is multiple. The index position of the word formation file is any one of the first, middle, and last positions of the included candidate words, and the index position of the same word formation file is fixed. The query module 2333 is further configured to determine the target position of the target stroke unit to which the target stroke belongs in the stroke sequence; determine the target word formation file, where the target word formation file uses the target position as the index position and includes the target character at the index position; and obtain multiple candidate words corresponding to the target character from the target word formation file.

[0231] In some embodiments, the query module 2333 is further configured to read a preset number of candidate words from the target word formation file in descending order of priority. The sorting rules for the priority include: the priority of a candidate word whose character at the target position exactly matches the target character is higher than that of a candidate word whose character at the target position does not exactly match the target character; among the candidate words whose characters at the target position exactly match the target character, the priority of a candidate word with a higher word frequency is higher than that of a candidate word with a lower word frequency; among the candidate words whose characters at the target position do not exactly match the target character, the priority of a candidate word with a higher word frequency is higher than that of a candidate word with a lower word frequency.

[0232] In some embodiments, the filtering module 2334 is further configured to use the sum of the number of word segmentation symbols and 1 as the word length of the stroke sequence; and filter out candidate words whose word lengths are different from the word length of the stroke sequence from multiple candidate words.

[0233] In some embodiments, the generating module 2335 is further configured to sort the remaining candidate words after filtering in descending order of word frequency; and select a preset number of candidate words starting from the first candidate word from the descending sorting result as the word query result.

[0234] In some embodiments, the generating module 2335 is further configured to use the stroke unit including the target stroke as the target stroke unit; when other stroke units include the target stroke, use any one stroke included in the other stroke units as an alternative stroke, where the other stroke units are any stroke units in the stroke sequence other than the target stroke unit; query the offset and data length corresponding to the alternative stroke in the trie tree; query at least one alternative character corresponding to the alternative stroke from the character file according to the offset and data length corresponding to the alternative stroke; and filter out candidate words that do not include the alternative character from the remaining candidate words after filtering again, and generate a word query result based on the remaining candidate words after filtering again.

[0235] Next, the implementation of the word query device 455 of the input method provided by the embodiments of the present application as a software module will be further described. In some embodiments, as Figure 2B shown, the software module in the word query device 455 of the input method stored in the memory 450 may include:

[0236] The first display module 4551 is configured to display an input area.

[0237] The second display module 4552 is configured to display a word query result in response to receiving a stroke sequence in the input area, where the word query result is obtained by the word query method of the input method described above.

[0238] An embodiment of the present application provides a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium, and the processor executes the computer-executable instructions, so that the electronic device executes the word query method of the input method in the above embodiments of the present application.

[0239] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, in which computer-executable instructions or a computer program are stored. When the computer-executable instructions or the computer program are executed by a processor, it will cause the processor to execute the word query method of the input method provided by the embodiment of the present application. For example, such as Figure 3A the word query method of the input method shown Figure 4 or the word query method of the input method shown.

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

[0241] In some embodiments, the computer-executable instructions may be in the form of a program, software, software module, script, or code, and may be 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 being deployed as an independent program or being deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0242] As an example, the computer-executable instructions may or may not correspond to a file in the file system, and may be stored as part of a file that stores other programs or data. For example, they may be stored in one or more scripts in a Hyper Text Markup Language (HTML) document, stored in a single file dedicated to the program being discussed, or stored in multiple cooperating files (for example, files that store one or more modules, subroutines, or code portions).

[0243] As an example, the computer-executable instructions may be deployed to execute on one electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected by a communication network.

[0244] In summary, through the use of delimiters in the embodiments of the present application, users can input multiple characters simultaneously for combined queries. At the same time, by using wildcards, the situation where users cannot retrieve due to forgetting some strokes is avoided, improving the user experience and facilitating fuzzy queries for users. The trie is used to query the offset and data length corresponding to the target stroke, and then according to the offset and data length, the target character corresponding to the target stroke is queried in the character file, and the candidate words corresponding to the target character are queried from the word combination file. Compared with the related technology of directly querying all words corresponding to strokes in the trie, only the offset and data length corresponding to the strokes are stored in the trie, and the word query steps are decomposed, with the query of the target character and the query of the candidate words including the target character being carried out separately, enabling each level of query to be quickly located based on the results obtained from the previous level of query, saving storage space, improving the query speed of candidate words, shortening the query time, and reducing the algorithm complexity of candidate word queries. According to the target position of the target stroke unit to which the target stroke belongs in the stroke sequence, different word combination files are associated, so that when querying candidate words for different situations, the corresponding word combination file can be determined first, and a corresponding word combination file is set for each situation, improving the query efficiency in multiple situations. At the same time, the storage order of characters and words is set in the character file and the word combination file respectively, also improving the query speed of characters and candidate words and shortening the query time. The candidate words are selected according to the priority, improving the diversity and selectivity of the candidate words. According to the word length and the strokes in other stroke units, the candidate words that do not meet the word length or do not contain the alternative characters are filtered to generate the word query result, enhancing the relevance between the word query result and the stroke sequence and improving the accuracy of word queries. Through the error correction strategy, the situation where candidate words cannot be searched due to incorrect stroke input is avoided, enhancing the applicability of the word query method.

[0245] The above is only the embodiments of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A word query method for an input method, characterized in that, The method includes: Obtain a stroke sequence to be queried, where the stroke sequence includes at least one stroke, at least one wildcard, and at least one word segmenter, and the word segmenter is used to divide the stroke sequence into multiple stroke units; Determine at least one of the strokes belonging to the same stroke unit as the target stroke; Query the offset and data length corresponding to at least one of the target strokes from the trie; Query the target word corresponding to at least one of the target strokes from the character file according to the offset and the data length; Query multiple candidate words corresponding to the target word from the word combination file; Determine the word length according to the number of word segmenters, and filter out the candidate words that do not meet the word length from the multiple candidate words; Generate a word query result based on the remaining candidate words after filtering; 2. The method according to claim 1, characterized in that, The step of determining at least one of the strokes belonging to the same stroke unit as the target stroke from the stroke sequence includes: Arrange the multiple stroke units in the writing order; Take the first stroke unit including the stroke as the first target stroke unit; Take at least one of the strokes in the first target stroke unit as the target stroke; 3. The method according to claim 1, characterized in that The step of determining at least one of the strokes belonging to the same stroke unit as the target stroke includes: Determine the number of strokes in each stroke unit; Take the stroke unit with the largest number of strokes as the second target stroke unit, where the largest number of strokes is the maximum value of the number of strokes; Take at least one of the strokes in the second target stroke unit as the target stroke; 4. The method according to claim 3, characterized in that, The step of taking the stroke unit including the largest number of strokes as the second target stroke unit includes: In response to the number of stroke units with the largest number of strokes being multiple, take the stroke unit with the largest number of strokes and whose first position does not include a wildcard as the second target stroke unit; 5. The method according to claim 3, wherein The step of taking the stroke unit including the largest number of strokes as the second target stroke unit includes: In response to the number of stroke units with the largest number of strokes being multiple and the first positions of all of them being wildcards, sort the multiple stroke units with the largest number of strokes in a preset order, and take the first stroke unit in the sorting result as the second target stroke unit, where the preset order is the order of the appearance positions of the first strokes in the stroke units from front to back; 6. The method according to claim 1, wherein: The index position of the word combination file is the first position of the included candidate words, and the word combination file includes the candidate words corresponding to multiple candidate characters when they are respectively in the first position, and the candidate characters are any characters in the dictionary; The step of querying multiple candidate words corresponding to the target word from the word combination file includes: Obtain multiple candidate words corresponding to the target word from the word combination file; 7. The method according to claim 6, wherein: The word combination file includes word combination blocks corresponding to multiple candidate characters, each word combination block includes at least one data block, and each data block stores multiple candidate words starting with the candidate character; When the word - forming block includes a plurality of the data blocks, the plurality of data blocks are sorted in ascending order of the length of the candidate words included; When the data block includes a plurality of the candidate words, the plurality of candidate words are sorted in descending order of word frequency.

8. The method according to claim 1, wherein, The number of the word - forming files is multiple, and the index position of the word - forming file is any one of the first, middle, and last positions of the candidate words included. The index position of the same word - forming file is fixed; The querying of a plurality of candidate words corresponding to the target character from the word - forming files includes: Determining a target position of the target stroke unit to which the target stroke belongs in the stroke sequence; Determining a target word - forming file, wherein the target word - forming file uses the target position as the index position and includes the target character at the index position; Obtaining a plurality of candidate words corresponding to the target character from the target word - forming file.

9. The method according to claim 6 or 8, characterized in that, The obtaining of a plurality of candidate words corresponding to the target character from the target word - forming file includes: Reading a preset number of candidate words from the target word - forming file in the order from the highest priority to the lowest priority, wherein the sorting rule of the priority includes: The priority of the candidate word whose character at the target position exactly matches the target character is higher than the priority of the candidate word whose character at the target position does not exactly match the target character; Among the candidate words whose characters at the target position exactly match the target character, the priority of the candidate word with a higher word frequency is higher than the priority of the candidate word with a lower word frequency; Among the candidate words whose characters at the target position do not exactly match the target character, the priority of the candidate word with a higher word frequency is higher than the priority of the candidate word with a lower word frequency.

10. The method according to any one of claims 1 to 8, characterized in that The determining of the word length according to the number of the word - splitting symbols and filtering out the candidate words that do not conform to the word length from the plurality of candidate words includes: Taking the sum of the number of the word - splitting symbols and 1 as the word length of the stroke sequence; Filtering out the candidate words whose word lengths are different from the word length of the stroke sequence from the plurality of candidate words.

11. The method according to any one of claims 1 to 8, characterized in that, The generating of a word query result based on the remaining candidate words after filtering includes: Sorting the remaining candidate words after filtering in descending order of word frequency; Selecting a preset number of candidate words starting from the first candidate word from the descending - order sorting result as the word query result.

12. The method according to any one of claims 1 to 8, characterized in that, The generating of a word query result based on the remaining candidate words after filtering includes: Taking the stroke unit including the target stroke as the target stroke unit; When another stroke unit includes the target stroke, taking any one of the strokes included in the other stroke unit as an alternative stroke, wherein the other stroke unit is any stroke unit other than the target stroke unit in the stroke sequence; Querying the offset and data length corresponding to the alternative stroke in the trie; Querying at least one alternative character corresponding to the alternative stroke from the character file according to the offset and data length corresponding to the alternative stroke; Filter out the candidate words that do not include the alternative characters from the remaining candidate words after filtering, and generate a word query result based on the remaining candidate words after the second filtering.

13. The method according to any one of claims 1 to 8, characterized in that When querying at least one target character corresponding to the target stroke from the character file according to the offset and the data length, the method further includes: In response to not querying at least one target character corresponding to the target stroke from the character file, replace any one stroke in the stroke unit to which the target stroke belongs with a wildcard, and transfer to the step of determining at least one stroke belonging to the same stroke unit as the target stroke.

14. The method according to any one of claims 1 to 8, characterized in that, When querying at least one target character corresponding to the target stroke from the character file according to the offset and the data length, the method further includes: In response to not querying at least one target character corresponding to the target stroke from the character file and other stroke units including the stroke, use at least one stroke in the other stroke unit with the highest priority as the new target stroke, and transfer to the step of querying the offset and data length corresponding to at least one target stroke from the trie based on the new target stroke.

15. The method according to any one of claims 1 to 8, wherein The trie includes a plurality of nodes, each node includes a stroke, and the strokes included in any node link in the trie correspond to a complete stroke sequence of a character in the dictionary. The node link includes nodes at different levels; Querying the offset and data length corresponding to at least one target stroke from the trie includes: Determine the position of at least one target stroke in the stroke unit to which it belongs; In the level corresponding to the position in the trie, query at least one node that matches at least one target stroke, and read the preset offset and data length from the last node among the at least one node as the offset and data length corresponding to at least one target stroke.

16. A word query device for an input method, characterized in that, The device includes: An acquisition module, configured to acquire a stroke sequence to be queried, where the stroke sequence includes at least one stroke, at least one wildcard, and at least one word segment separator, and the word segment separator is used to divide the stroke sequence into multiple stroke units; A determination module, configured to determine at least one stroke belonging to the same stroke unit as the target stroke; A query module, configured to query the offset and data length corresponding to at least one target stroke from the trie; query at least one target character corresponding to the target stroke from the character file according to the offset and the data length; query a plurality of candidate words corresponding to the target character from the word combination file; A filtering module, configured to determine the word length according to the number of word segment separators, and filter out candidate words that do not meet the word length from the plurality of candidate words; A generation module, configured to generate a word query result based on the remaining candidate words after filtering.

17. An electronic device, characterized in that, The electronic device includes: A memory, configured to store computer-executable instructions; A processor, when executing computer-executable instructions stored in the memory, implements the word query method of the input method according to any one of claims 1 to 15.

18. 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 query method of the input method according to any one of claims 1 to 15 is implemented.

19. 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 query method of the input method according to any one of claims 1 to 15 is implemented.