Input method dictionary management method and device, equipment and storage medium
By setting process version numbers and public version numbers for the input method dictionary, the latest version of the dictionary can be directly compared and loaded, solving the problem of low dictionary update efficiency, improving the update efficiency of the input method and user experience, and saving development costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-08-05
- Publication Date
- 2026-07-14
AI Technical Summary
In existing technologies, updating the input method dictionary requires notifying each process to reload via communication, resulting in low update efficiency, input method lag, and impact on user experience.
By setting process version numbers and public version numbers for the dictionary, and comparing the consistency between the process version number and the public version number, the dictionary can be directly reloaded, avoiding the time-consuming message notification mechanism and improving update efficiency.
It improved the efficiency of dictionary updates, reduced input method lag, enhanced the user experience of input methods, and unified the dictionary memory management mechanism for different terminal devices, saving development and maintenance costs.
Smart Images

Figure CN117555908B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an input method dictionary management method, apparatus, device, and storage medium. Background Technology
[0002] The dictionary is the foundation of an input method, providing it with words and phrases. In a multi-process system, each process loads one input method, and multiple processes access the input method's dictionary. In this case, the dictionary memory is shared memory. So, when an application process enters a word, the input method records that word in the user dictionary. Because the dictionary uses shared memory, when other application processes use the input method, the newly recorded words in the user dictionary also take effect in real time.
[0003] In some cases, the input method's dictionary will be updated. Currently, when a dictionary update is detected, the dictionary memory management module (Memory Manager) sends a notification message to each process to inform them that the dictionary has been updated. After receiving the dictionary update message (Receipt), each process reloads the dictionary (Reload).
[0004] As can be seen from the above, currently, when the dictionary is updated, it needs to notify other processes to update the dictionary through communication, which takes time and makes the dictionary update inefficient, causing the input method to lag. Summary of the Invention
[0005] This application provides an input method dictionary management method, apparatus, device, and storage medium, which can improve the efficiency of dictionary updates, reduce input method lag, and enhance the user experience of the input method.
[0006] Firstly, this application provides an input method dictionary management method, including:
[0007] In response to an input method trigger operation in a first application process, the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary are obtained. The process version number is the dictionary version number corresponding to the first application process at the current time, and the public version number is the latest version number of the dictionary at the current time.
[0008] If the process version number corresponding to the first application process is inconsistent with the public version number, the dictionary is reloaded so that the process version number corresponding to the first application process is consistent with the public version number.
[0009] Secondly, this application provides an input method dictionary management device, comprising:
[0010] The acquisition unit is configured to respond to an input method trigger operation in a first application process to acquire the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary, wherein the process version number is the dictionary version number corresponding to the first application process at the current time, and the public version number is the latest version number of the dictionary at the current time;
[0011] The processing unit is configured to reload the dictionary if the process version number corresponding to the first application process is inconsistent with the public version number, so that the process version number corresponding to the first application process is consistent with the public version number.
[0012] In some embodiments, the processing unit is further configured to obtain the version number of the dictionary already loaded in memory; if the version number of the dictionary already loaded in memory is less than the public version number, the dictionary is reloaded so that the process version number corresponding to the first application process is consistent with the public version number.
[0013] In some embodiments, the processing unit is further configured to update the process version number corresponding to the first application process to the public version number if the version number of the dictionary already loaded in the memory is the public version number.
[0014] In some embodiments, the public version number is stored in the first memory, and the process version number corresponding to the first application process is stored in the memory corresponding to the first application process. The acquisition unit is further configured to, in response to an input method trigger operation on the first application process, acquire the public version number of the dictionary from the first memory, and acquire the process version number corresponding to the first application process from the memory corresponding to the first application process.
[0015] In some embodiments, if the dictionary is accessed by multiple processes, the public version number of the dictionary is stored in shared memory.
[0016] In some embodiments, the processing unit is further configured to update the public version number of the thesaurus when it is detected that the thesaurus has been updated.
[0017] In some embodiments, the processing unit is specifically configured to, when detecting that the dictionary has been updated, add a first value to the currently stored public version number of the dictionary to obtain the updated public version number of the dictionary.
[0018] In some embodiments, if the dictionary is accessed by multiple processes, the processing unit is specifically used to update the public version number of the dictionary sequentially through the N processes when it is detected that N processes have updated the dictionary, so as to obtain the updated public version number of the dictionary, where N is a positive integer.
[0019] In some embodiments, the processing unit is specifically configured to, upon detecting that all N processes have updated the dictionary, control the N processes to sequentially update the public version number based on a locking mechanism, thereby obtaining the updated public version number of the dictionary.
[0020] In some embodiments, the processing unit is specifically configured to determine the update operation order of the public version number for each of the N processes based on a competition mechanism; and according to the update operation order, control the N processes to update the public version number sequentially based on the locking mechanism to obtain the updated public version number of the dictionary.
[0021] In some embodiments, the public version number of the dictionary is stored in shared memory. The processing unit is specifically configured to, for the i-th process in the update order, lock the shared memory through the i-th process, and then add a first value to the latest public version number in the locked shared memory before unlocking it, to obtain the update of the public version number by the i-th process, where i is a positive integer less than or equal to N; control the (i+1)-th process in the update order to continue updating the public version number updated by the i-th process until all N processes have finished updating the public version number, to obtain the updated public version number of the dictionary.
[0022] In some embodiments, the processing unit is further configured to process the dictionary in response to the word display operation.
[0023] In some embodiments, the processing unit is specifically configured to add the word to the word library in response to the word loading operation, when it is detected that the word library is not full.
[0024] In some embodiments, the processing unit is specifically configured to, in response to the word display operation, when it detects that the dictionary is full, allocate new memory for the dictionary, and slim down or expand the dictionary in the new memory, and write the word into the slimmed down or expanded dictionary to obtain the updated dictionary, and write the updated dictionary to the disk; and update the public version number of the dictionary according to the updated dictionary.
[0025] In some embodiments, the processing unit is further configured to, after updating the public version number of the dictionary, when detecting an input method trigger operation of the second application process, in response to the input method trigger operation of the second application process, obtain the process version number of the dictionary currently corresponding to the second application process, and the updated public version number of the dictionary; if it is detected that the process version number corresponding to the second application process is inconsistent with the updated public version number of the dictionary, then load the updated dictionary from the disk into memory, so that the process version number corresponding to the second application process is consistent with the updated public version number of the dictionary.
[0026] Thirdly, an electronic device is provided, including a processor and a memory. The memory is used to store a computer program, and the processor is used to invoke and run the computer program stored in the memory to perform the methods of the first aspect or its implementations described above.
[0027] Fourthly, a chip is provided for implementing the methods of any one of the first to second aspects or their respective implementations. Specifically, the chip includes a processor for calling and running a computer program from a memory, causing a device on which the chip is installed to perform the methods of any one of the first aspects or their respective implementations.
[0028] Fifthly, a computer-readable storage medium is provided for storing a computer program that causes a computer to perform the methods of any of the first aspects or their implementations.
[0029] In a sixth aspect, a computer program product is provided, including computer program instructions that cause a computer to perform the methods in any of the first aspects or their implementations.
[0030] In a seventh aspect, a computer program is provided that, when run on a computer, causes the computer to perform the methods of any one of the first aspects or their implementations.
[0031] In summary, this application, in response to an input method trigger operation on a first application process, obtains the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary. The process version number is the version number of the dictionary maintained by the first application process at the current moment, and the public version number is the latest version number of the dictionary at that moment. Next, the process version number corresponding to the first application process is compared with the public version number. If the process version number and the public version number are inconsistent (usually the process version number of the first application process is less than the public version number of the dictionary), the dictionary is reloaded to update the dictionary corresponding to the first application process to the latest public version number. Thus, the first application process performs word input based on this updated dictionary, improving the input experience. In other words, in this embodiment of the application, a process version number and a public version number are set for the dictionary. Each time input occurs, the process version number of the dictionary currently maintained by the application process is compared with the public version number of the dictionary to determine whether the dictionary has been updated. When an update is detected (i.e., the process version number and the public version number of the dictionary are inconsistent), the dictionary is reloaded, replacing the previous time-consuming message notification mechanism. This improves the update efficiency of the dictionary, greatly reduces input method lag during dictionary updates, and enhances the input experience. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 Here is an example of an input diagram;
[0034] Figure 2 This is a schematic diagram of a system architecture according to an embodiment of this application;
[0035] Figure 3A This is a schematic diagram of a thesaurus management system;
[0036] Figure 3B This is a schematic diagram of another type of thesaurus management system;
[0037] Figure 4 A flowchart illustrating an input method dictionary management method provided in an embodiment of this application;
[0038] Figure 5 A flowchart illustrating an input method dictionary management method provided in an embodiment of this application;
[0039] Figure 6This is a schematic diagram of a kernel architecture according to an embodiment of this application;
[0040] Figure 7 This is a diagram illustrating how to handle a dictionary when it is not full.
[0041] Figure 8 This is a diagram illustrating the updating of the dictionary when it is full.
[0042] Figure 9 This is a schematic flowchart of an input method dictionary management method provided in an embodiment of this application;
[0043] Figure 10A This is an input diagram illustrating the application of the method described in this application to a computer.
[0044] Figure 10B This is an input diagram illustrating the application of the method of this embodiment to a mobile device;
[0045] Figure 11 This is a schematic block diagram of an input method dictionary management device provided in an embodiment of this application;
[0046] Figure 12 This is a schematic block diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0047] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0048] It should be understood that, in the embodiments of the present invention, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.
[0049] In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0050] Furthermore, to facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.
[0051] This application can be applied to platforms with various input methods, such as keyboard input methods and non-keyboard input methods. That is, information input through input methods includes keyboard strings, handwritten input, and voice input, etc., and all of these input methods require the use of a dictionary to sort candidate inputs.
[0052] First, the relevant concepts of the embodiments of this application will be introduced.
[0053] An input method can be understood as a way for an object to display characters on the screen through a certain input method.
[0054] The dictionary is the foundation of an input method, for example, for example Figure 1 As shown, when a user inputs the pinyin "zhongg" using the input method, the dictionary will search for words that have the same or similar pronunciation as "zhongg" and display them to the user for selection.
[0055] The dictionary includes a system dictionary and a user dictionary. The system dictionary can be understood as the dictionary that comes with the input method, and different input methods may have different system dictionaries. The system dictionary is used to provide basic words and phrases.
[0056] The user dictionary primarily contains a collection of words generated based on the words the user frequently inputs. For example, when the word learning function is enabled, the input method records the words the user has typed, and this collection of recorded words constitutes the user dictionary. Therefore, the user dictionary is personalized.
[0057] Based on the different content of the user thesaurus, it is further divided into: Chinese user thesaurus, English user thesaurus, website and email user thesaurus, etc.
[0058] In a narrow sense, a process is an instance of a computer program that is being executed. In a broader sense, it is a single instance of a program with a certain independent function running on a specific set of data. It is the basic unit of dynamic execution in an operating system; in traditional operating systems, a process is both the basic unit of allocation and the basic unit of execution.
[0059] Figure 2 This is a schematic diagram of a system architecture according to an embodiment of this application. The system includes: a terminal device 100.
[0060] Terminal device 100 can be a mobile phone, tablet computer, e-book reader, laptop computer, desktop computer, smart TV, in-vehicle equipment, wearable device, industrial equipment, etc.
[0061] The terminal device 100 includes a hardware system 110, an operating system 120, and an application layer 130. The hardware system 110 refers to the physical devices that constitute the terminal device 100, which can be physical components with computing, control, storage, and input / output functions, such as a CPU and a memory.
[0062] Operating system 120 is a computer program that manages hardware and software resources and provides a user interface for interaction between the user and the system.
[0063] Application layer 130 provides users with applications, including at least application 1 and input method program 2. Application 1 includes at least the function of detecting the input content entered by input method program 2 within application 1. Input method program 2 refers to the encoding method used to input various symbols into an electronic device. Application 1 has one or more functions. At least one program interface of application 1 provides controls for inputting text content. Application 1 can be any type of program, such as an instant messaging program, a text editing program, etc. Optionally, application layer 130 may also include other applications, such as application 3.
[0064] Currently, different types of terminal devices may have different methods for managing dictionary memory. There are mainly two types of clients:
[0065] For the first type of client, such as a Windows client, due to Windows system requirements, each application process must load an input method, meaning multiple processes will access the input method's dictionary. In this case, dictionary memory management is as follows: Figure 3A As shown, the dictionary memory must be shared memory. Shared memory means that two or more processes share a given storage area. When a user types a word in one application process, the input method records that word in the user's dictionary. Because the dictionary uses shared memory, newly recorded words in the user's dictionary also take effect in real time when other application processes use the input method. To prevent multiple processes from simultaneously accessing the same dictionary and causing dictionary errors, a locking mechanism is needed to synchronize access to shared memory. Simply put, when a process accesses the dictionary, it first checks if it is locked. If not, it locks it (Lock), and then unlocks it (Unlock) after the operation is complete. During this process, if other processes also want to access the dictionary and find it locked, they will wait until it is unlocked before attempting to access it. When the dictionary is updated, such as when the user dictionary is full and needs to be slimmed down by eliminating some useless words, or when the dictionary is synchronized by downloading words from other devices from the server and merging them into the local user dictionary, the dictionary memory management module (Memory Manager) needs to send a message to notify other processes after the dictionary is updated. When other processes receive the dictionary update message, they reload the dictionary.
[0066] For the second type of client, such as Linux, Mac, Android, and iOS clients, the input method is single-process, such as... Figure 3BAs shown, dictionary memory can be allocated in two ways: direct memory use, typically used for dictionaries that need modification, such as user dictionaries, and direct file mapping. Direct memory allocation is handled by the input method process, while direct file mapping allocates dictionary memory to the operating system; the input method process merely associates the two. In some embodiments, unchanging dictionaries, such as system dictionaries, use file mapping. In this second type of client, dictionary updates also occur. Since they occur within the same process, it's simply a matter of swapping the updated dictionary memory with the previous memory.
[0067] As mentioned above, for the first type of client, where multiple processes access the dictionary, when the dictionary is updated, it's necessary to notify each process to reload the dictionary by sending and receiving messages. This process is time-consuming and inefficient, leading to input method lag and a degraded user experience. Furthermore, as mentioned above... Figure 3A and Figure 3B It is known that different terminals use different dictionary memory management methods, which makes it impossible to unify the input method kernels of various terminal devices. In other words, at least two sets of input method kernels need to be maintained, which will waste manpower costs.
[0068] To address the aforementioned technical issues, this application embodiment sets two version numbers for the dictionary: one common to all processes, called the public version number, and the other process-specific, called the process version number. When a user triggers the input method, in response to the input method trigger operation, the process version number of the dictionary to be accessed by the first application process, as well as the public version number of that dictionary, are obtained. The public version number of the dictionary is the latest version number of the dictionary at that time. Next, the process version number of the first application process is compared with the public version number. If the process version number and the public version number are inconsistent, usually because the process version number corresponding to the first application process is lower than the public version number of the dictionary, the dictionary is reloaded to update the dictionary corresponding to the first application process to the latest public version number. In this way, the first application process performs word input based on the updated dictionary. In other words, this application embodiment determines whether the current dictionary has been updated by comparing the process version number of the current dictionary with the public version number. When an update is detected (i.e., the process version number of the current dictionary is inconsistent with the public version number), the dictionary is loaded directly, replacing the previous time-consuming message notification mechanism. This improves the update efficiency of the dictionary, greatly reduces input method lag during dictionary updates, and enhances the input experience.
[0069] Furthermore, the input method dictionary management method provided in this application can be applied to different terminal devices, such as single-process systems and multi-process systems, thereby unifying the dictionary memory management mechanism and the entire input method kernel. This not only greatly saves development and maintenance costs, but also maintains consistency of input method results across multiple devices for users, significantly improving the user input experience.
[0070] The technical solutions of the embodiments of this application will be described in detail below through some examples. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0071] Figure 4 This is a flowchart illustrating an embodiment of the input method dictionary management method provided in this application. The executing entity of this embodiment is a device with input method dictionary management functionality, such as an input method dictionary management device. This input method dictionary management device can be... Figure 2 The terminal device shown, or a part of the terminal device, such as the processor in the terminal device. Figure 2 The terminal device shown has an input function. For ease of description, the following explanation uses the terminal device as the executing entity.
[0072] like Figure 4 As shown, the method in this application embodiment includes:
[0073] S401. In response to the input method trigger operation on the first application process, obtain the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary.
[0074] Among them, the process version number is the dictionary version number corresponding to the first application process at the current moment, and the public version number is the latest version number of the dictionary at the current moment.
[0075] Multiple applications exist on the same terminal device, and users can open any of them to perform operations. When each application runs, its corresponding application process loads an input method, which includes a dictionary. When an application starts, the user can launch the input method within that application's process. Upon initial launch, the dictionary needs to be loaded into memory for the input method's use.
[0076] In this embodiment of the application, two version numbers are set for the dictionary: one process version number and the other public version number.
[0077] The public version number is shared by all processes and is usually the latest version number of the dictionary.
[0078] Each application process has its own unique process version number; that is, each application process that accesses the dictionary maintains its own process version number. The process version number of an application process can be understood as the version number of the dictionary maintained by that application process at the current moment.
[0079] For example, at the current moment, the latest version number of dictionary A is 0.3, meaning the public version number of dictionary A is 0.3. Application process 1 maintains dictionary A with version number 0.2, meaning the process version number corresponding to application process 1 is 0.2. Application process 2 maintains dictionary A with version number 0.1, meaning the process version number corresponding to application process 2 is 0.1. Dictionary version 0.1 is the predecessor to dictionary version 0.2, and dictionary version 0.2 is the predecessor to dictionary version 0.3.
[0080] In this embodiment, when a user launches an input method in a first application process, in response to the input method's trigger operation, the user obtains the process version number and public version number of the dictionary corresponding to the first application process. For example, at the current moment, the process version number of the dictionary maintained by the first application process is 0.2, while the public version of the dictionary is 0.3.
[0081] The embodiments of this application do not limit the specific type of the first application process.
[0082] In some embodiments, the first application process can be understood as the process corresponding to the application currently running on the terminal device, such as a chat tool, a Word document, etc.
[0083] The input method-triggered operation by the user in the first application process can be a key press on the keyboard or a key press on the soft keyboard using the mouse.
[0084] In one application scenario of this application embodiment, a terminal device runs application A. On an interface of application A, a user triggers an input method, for example, by clicking the keyboard. In response to the input method triggering operation on application A, the process version number and public version number corresponding to the first application process of application A are obtained.
[0085] This application embodiment does not limit the specific method for obtaining the process version number of the dictionary currently maintained by the first application process, as well as the public version number of the dictionary.
[0086] In some embodiments, the process version numbers corresponding to different application processes are stored in different locations. Each application process is allowed to read its own process version number, but other application processes are not allowed to read it. However, the public version number of the dictionary is allowed to be read by all application processes.
[0087] In some embodiments, at least one of the process version number and the public version number corresponding to the first application process is stored in memory.
[0088] In some embodiments, the public version number is stored in the first memory, and the process version number corresponding to the first application process is stored in the memory corresponding to the first application process. In this case, in response to an input method trigger operation on the first application process, the public version number of the dictionary is retrieved from the first memory, and the process version number corresponding to the first application process is retrieved from the memory corresponding to the first application process.
[0089] The aforementioned first memory region can be any memory area accessible to any process.
[0090] In some embodiments, if the dictionary is accessed by multiple processes, the public version number of the dictionary is stored in shared memory, i.e., the aforementioned first memory is shared memory. In this case, in response to an input method trigger operation on the first application process, the public version number of the dictionary is retrieved from the shared memory, and the process version number corresponding to the first application process is retrieved from the memory corresponding to the first application process.
[0091] According to the above method, after obtaining the process version number and public version number of the dictionary accessed by the first application process, the following step S402 is executed.
[0092] S402. If the process version number corresponding to the first application process is inconsistent with the public version number, reload the dictionary to make the process version number corresponding to the first application process consistent with the public version number.
[0093] Based on the above steps, obtain the process version number corresponding to the first application process and the public version number of the dictionary. If the process version number of the dictionary maintained by the first application process at the current moment is consistent with the public version number of the dictionary, it means that the dictionary has been updated to the latest version. At this time, there is no need to rebuild the dictionary, but to directly input words based on the current dictionary.
[0094] If the process version number of the dictionary maintained by the first application process at the current moment is inconsistent with the public version number of the dictionary, then the dictionary corresponding to the first application process needs to be updated. Specifically, the dictionary is reloaded to update the dictionary corresponding to the first application process to the dictionary corresponding to the public version number. After the update is completed, the version number of the dictionary corresponding to the first application process is the public version number, and the corresponding process version number of the first application process is updated to the public version number.
[0095] In some embodiments, for multi-process systems, the dictionary is reloaded in shared memory so that each process can read the updated dictionary from the shared memory.
[0096] In some embodiments, for a single-process system, the dictionary is reloaded into memory, and the single process reads the updated dictionary from that memory.
[0097] This application does not impose any restrictions on the method of rebuilding the loaded thesaurus.
[0098] In one possible implementation, if the process version number corresponding to the first application process is inconsistent with the public version number, instead of checking whether the current dictionary has been updated, the dictionary is directly reloaded and placed in memory, overwriting the existing dictionary in memory.
[0099] In some embodiments, before the first application process updates the dictionary, it is necessary to determine whether other processes have already updated the dictionary. In this case, before reloading the dictionary in S402, this embodiment further includes obtaining the version number of the dictionary already loaded in memory. That is, if the process version number corresponding to the first application process is inconsistent with the public version number, the dictionary is not immediately reloaded. Instead, the version number of the dictionary currently loaded in memory is obtained, and compared with the public version number of that dictionary. If the version number of the dictionary loaded in memory is less than the public version number, the dictionary is reloaded, and the process version number corresponding to the first application process is updated to the public version number, so that the process version number corresponding to the first application process is consistent with the public version number.
[0100] In some embodiments, if the process version number corresponding to the first application process is inconsistent with the public version number, and the version number of the dictionary loaded in memory at the current moment is the public version number, it means that the dictionary has been updated. In this case, the dictionary is not reloaded, but the process version number corresponding to the first application process is updated to the public version number of the dictionary.
[0101] The input method dictionary management method provided in this application embodiment, in response to an input method trigger operation on a first application process, obtains the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary. The process version number is the version number of the dictionary maintained by the first application process at the current moment, and the public version number is the latest version number of the dictionary at that moment. Next, the process version number corresponding to the first application process is compared with the public version number. If the process version number and the public version number are inconsistent (usually the process version number of the first application process is less than the public version number of the dictionary), the dictionary is reloaded to update the dictionary corresponding to the first application process to the dictionary corresponding to the latest public version number. In this way, the first application process performs word input based on the updated dictionary, improving the input experience. In other words, in this embodiment of the application, a process version number and a public version number are set for the dictionary. Each time input occurs, the process version number of the dictionary currently maintained by the process is compared with the public version number of the dictionary to determine whether the dictionary has been updated. When an update is detected (i.e., the process version number and the public version number of the dictionary are inconsistent), the dictionary is reloaded, replacing the previous time-consuming message notification mechanism. This improves the update efficiency of the dictionary, greatly reduces input method lag during dictionary updates, and enhances the input experience.
[0102] The above describes the process of reloading the dictionary when the process version number corresponding to the application process is inconsistent with the public version number of the dictionary. The following describes the dictionary update process.
[0103] In some embodiments, such as Figure 5 As shown, embodiments of this application also include:
[0104] S501. When an update to the thesaurus is detected, update the public version number of the thesaurus.
[0105] In some situations, dictionary updates may be triggered, such as when the user dictionary is full, triggering dictionary slimming to eliminate some useless words, or when the dictionary is synchronized, such as downloading words from other devices from the server and merging them into the local user dictionary. These situations lead to dictionary updates.
[0106] In this embodiment, since the public version is the latest version of the dictionary, when an update to the dictionary is detected, the public version number of the dictionary also needs to be updated. This allows the application process to compare its own maintained process version number with the updated public version number to determine if the dictionary has been updated. If an update is confirmed, the dictionary is reloaded promptly to maintain input reliability.
[0107] For example, the specific implementation methods of the public version number of the thesaurus in S501 above include, but are not limited to, the following:
[0108] Method 1: When an update to the dictionary is detected, the public version number 'a' of the currently saved dictionary is updated to the preset value 'b', meaning the public version number of the updated dictionary is 'b'.
[0109] Method 2, the above S501 includes the following S501-A:
[0110] S501-A: When an update to the dictionary is detected, the first value is added to the public version number of the currently saved dictionary to obtain the updated public version number of the dictionary.
[0111] For example, if the current public version number of the saved dictionary is 'a', and the first value is 'b', then the updated public version number of the dictionary will be 'a+b'.
[0112] The embodiments of this application do not impose restrictions on the specific values of a and b mentioned above.
[0113] In one example, assuming a is 7.1 and b is 0.1, the updated public version number of the thesaurus is 7.2.
[0114] In one possible implementation of Method 2, if the dictionary is accessed by multiple processes, the above S501-A includes the following S501-A:
[0115] S501-A: When it is detected that N processes have updated the dictionary, the public version number is updated sequentially by the N processes to obtain the updated public version number of the dictionary, where N is a positive integer.
[0116] In this implementation, if the dictionary can be accessed by multiple processes, there is a possibility that multiple processes will update the dictionary. For example, if N processes update the dictionary, and it is detected that all N processes have updated the dictionary, then the public version number of the dictionary will be updated sequentially by these N processes to obtain the updated public version number of the dictionary.
[0117] For example, suppose there are N processes, including process A and process B, and the first value is 1. Both process A and process B update dictionary 1; specifically, process A updates dictionary 1 to dictionary 2, and process B updates dictionary 1 to dictionary 3. If both process A and process B simultaneously increment the common version number of dictionary 1, the common version number of dictionary 1 might only increment by 1, resulting in an incorrect common version number.
[0118] To address this technical problem, this embodiment of the application, upon detecting that N processes have all updated the dictionary, updates the common version number sequentially through the N processes to obtain the updated common version number of the dictionary. For example, first, process A updates the common version number of dictionary 1, then process B updates the common version number updated by process A. Alternatively, process B updates the common version number of dictionary 1 first, then process A updates the common version number updated by process B, ultimately incrementing the common version number of dictionary 1 by 2.
[0119] In some embodiments, the dictionary 1 is updated simultaneously with the update of its public version number.
[0120] For example, the public version number of dictionary 1 is 7.1, and its first value is 1. Assume that process B first updates the public version number of dictionary 1 to 8.1, and then updates dictionary 1 based on dictionary 3 to obtain the updated dictionary 13. Next, process A updates the public version number 8.1 updated by process B to 9.1, and simultaneously updates dictionary 13 based on dictionary 2 to obtain the updated dictionary 132.
[0121] In one example, the dictionary 1 is updated based on the dictionary 3 to obtain the updated dictionary 13. This can be done by updating the dictionary 1 to the dictionary 3, or by merging the dictionary 1 and the dictionary 3 to obtain the updated dictionary 13.
[0122] In one example, the dictionary 13 is updated based on the dictionary 2 to obtain the updated dictionary 132. This can be done by updating the dictionary 13 to the dictionary 2, or by merging the dictionary 13 and the dictionary 2 to obtain the updated dictionary 132.
[0123] For example, the public version number of dictionary 1 is 7.1, and its first value is 1. Suppose that process A first updates the public version number of dictionary 1 to 8.1, and then updates dictionary 1 based on dictionary 2, resulting in the updated dictionary 12. Next, process B updates the public version number 8.1 from process A's update to 9.1, and simultaneously updates dictionary 12 based on dictionary 3, resulting in the updated dictionary 123.
[0124] In one example, the updated dictionary 1 is obtained by updating the dictionary 12 based on the dictionary 2. This can be done by updating the dictionary 1 to the dictionary 2, or by merging the dictionary 1 and the dictionary 2 to obtain the updated dictionary 12.
[0125] In one example, the dictionary 12 is updated based on the dictionary 3 to obtain the updated dictionary 123. This can be done by updating the dictionary 12 to the dictionary 3, or by merging the dictionary 12 and the dictionary 3 to obtain the updated dictionary 123.
[0126] In some embodiments, to prevent other processes from accessing the public version number of the dictionary during the update process, S501-A includes the following S501-A1:
[0127] S501-A1: When it is detected that N processes have updated the dictionary, control the N processes to update the common version number in sequence based on the locking mechanism, so as to obtain the common version number of the dictionary after the update.
[0128] Continuing with the example of N processes, including process A and process B, if process A updates the public version number of the dictionary first, process A locks the memory containing the public version number of the dictionary, updates the public version number in the locked memory, and then unlocks it after the update is complete. Next, process B locks the memory again, updates the public version number in the locked memory, and then unlocks it after the update is complete, thus improving the reliability of the public version number update.
[0129] Optionally, the memory where the public version number of the thesaurus is located is shared memory.
[0130] This application embodiment does not restrict the order in which N processes sequentially update the public version number.
[0131] In some embodiments, the above update order is preset.
[0132] In some embodiments, the update order is determined based on a competition mechanism. In this case, S501-A1 includes the following steps S501-A11 and S501-A12:
[0133] S501-A11. Based on a competition mechanism, determine the order of update operations for the common version number by each of the N processes.
[0134] S501-A12. Based on the update operation order, control N processes to update the public version number sequentially using a locking mechanism to obtain the updated public version number of the dictionary.
[0135] Figure 6 This is a schematic diagram of a kernel architecture according to an embodiment of this application, such as... Figure 6As shown, the system includes a dictionary memory, a memory management module, and a version management module. The dictionary memory includes direct memory, memory file mapping, and shared memory. The version management module includes a single-process version management unit and a multi-process version management unit. In a single process, the common version number of the dictionary is stored in direct memory; in a multi-process system, the common version number is stored in shared memory. In some embodiments, the system dictionary can be stored in a memory file. For multi-process systems, modifications to the common version number in shared memory are performed using a locking mechanism.
[0136] In other words, when N processes modify the dictionary, these N processes compete for lock resources based on a contention mechanism in order to update the public version number.
[0137] In one implementation of this embodiment, based on a competition mechanism, the order in which each of the N processes updates the common version number is first determined. Then, according to the update order, the N processes are controlled to update the common version number sequentially based on a locking mechanism, resulting in the updated common version number of the dictionary. For example, according to the competition mechanism, if process A updates first and process B updates later, then process A updates the common version number first, and then process B updates the common version number updated by process A.
[0138] In some embodiments, the public version number of the dictionary is stored in shared memory. In this case, the update process of S501-A12 above includes: for the i-th process in the update order, the i-th process locks the shared memory, and the latest public version number in the locked shared memory is incremented by a first value and then unlocked to obtain the update of the public version number by the i-th process, where i is a positive integer less than or equal to N; the i+1-th process in the update order continues to update the public version number updated by the i-th process until all N processes have finished updating the public version number, and the updated public version number of the dictionary is obtained.
[0139] For example, suppose there are N processes, including process A and process B, and the determined update order is that process A updates first, followed by process B. In this case, if... Figure 6 As shown, process A can first lock the shared memory and update the public version number in the shared memory, for example, by incrementing it by 1 and then unlocking it. Then, process B can lock the shared memory and update the already updated public version number in the shared memory again, for example, by incrementing it by 1 again and then unlocking it, thus sequentially updating the public version number of the dictionary.
[0140] In some embodiments, N processes determine the update order through multiple rounds of competition. For example, the N processes include process A, process B, and process C. First, processes A, B, and C compete for a unique lock resource based on a competition mechanism. Assuming process B wins in this round and acquires the lock resource, process B locks the shared memory, updates the updated public version number in the shared memory (e.g., increments by 1), and then unlocks it. Next, processes A and C compete for the lock resource again based on the competition mechanism. Assuming process C wins in this round and acquires the lock resource, process C locks the shared memory, updates the updated public version number in the shared memory (e.g., increments by 1), and then unlocks it. Finally, process A locks the shared memory, updates the updated public version number in the shared memory (e.g., increments by 1), and then unlocks it.
[0141] The following section describes the process of updating the thesaurus.
[0142] The dictionary update methods involved in the embodiments of this application include, but are not limited to, the following:
[0143] Method 1: Dictionary synchronization. For example, download the dictionary from other devices from the server and merge the downloaded dictionary into the local user dictionary to update the dictionary.
[0144] Method 2: If the dictionary is full, it needs to be slimmed down by eliminating some useless words, or the dictionary needs to be expanded to update the dictionary.
[0145] In one example of this method two, when the terminal device detects that the vocabulary in the dictionary has reached a certain number, it either reduces or expands the dictionary.
[0146] In another example of this method two, the user presses a key to input a word and inputs the word into the current display interface. This process is called the word input operation. In response to the word input operation, the dictionary is processed.
[0147] In this embodiment of the application, the processing of the dictionary in response to the word display operation includes the following two cases:
[0148] Case 1: In response to the word being added to the screen, if the current word library is not full, the word can be added directly to the word library.
[0149] In one example of scenario 1, the process of dictionary processing by each module in the terminal device is as follows: Figure 7 As shown, suppose the application in the business layer starts a word learning function. That is, when the user inputs a word in the application process, the input word is added to the user's vocabulary. Therefore, this word is called a learned word. Figure 7As shown, assuming the current vocabulary is not full, the learned word does not trigger a slimming operation. In this case, the data is organized and the vocabulary is modified through the application process (also known as the application instance). Specifically, the learned word is added to the vocabulary through the application process. In one example, if the vocabulary is stored in shared memory, the learned word is directly written to shared memory; if the vocabulary is stored in memory, the learned word is directly written to memory.
[0150] In some embodiments, after determining that the learned words have been successfully written to memory, the memory sends a response message to the application process, and the application process then sends a response message to the business layer.
[0151] In scenario 2, in response to the word loading operation, when the dictionary is detected to be full, new memory is allocated for the dictionary, and the dictionary is either reduced or expanded in the new memory. The words are then written to the reduced or expanded dictionary to obtain the updated dictionary, which is then written to the disk. Based on the updated dictionary, the public version number of the dictionary is updated.
[0152] In scenario 2, in response to the word being displayed, if the dictionary is detected to be full, it is updated. Specifically, new memory is allocated for the dictionary, and the dictionary is either reduced in size by removing useless words, or the dictionary is expanded to increase its capacity. Since the dictionary has been updated, its public version number also needs to be updated synchronously.
[0153] In one example of case 2, such as Figure 8 As shown, assuming the current dictionary is full, word learning triggers a slimming operation. At this time, the application process (also called the application instance) requests new memory and performs slimming or expansion operations on the new memory to obtain an updated dictionary. Next, the updated dictionary is written to disk or a file. After updating the dictionary, the application process sends a notification message to memory, also called dictionary memory, indicating that the dictionary has been updated. Dictionary memory sends this notification message to the version management module, so that the version management module updates the public version number of the dictionary based on the updated dictionary, for example, by adding 1 to the existing public version number to obtain the updated public version number.
[0154] In some embodiments, after updating the public version number of the dictionary, when an input method trigger operation of the second application process is detected, in response to the input method trigger operation of the second application process, the process version number of the dictionary currently corresponding to the second application process and the updated public version number of the dictionary are obtained; if it is detected that the process version number corresponding to the second application process is inconsistent with the updated public version number of the dictionary, the updated dictionary is loaded from the disk into memory so that the process version number corresponding to the second application process is consistent with the updated public version number of the dictionary.
[0155] The second application process can be any application process that accesses the dictionary. Optionally, the second application process can be the first application process mentioned above, or it can be another application process different from the first application process.
[0156] In this embodiment, according to the method in Case 2 above, after updating the dictionary and its public version number, upon detecting an input method trigger operation of the second application process, in response to the input method trigger operation of the second application process, the process version number of the dictionary currently corresponding to the second application process and the updated public version number of the dictionary are obtained, and the process version number corresponding to the second application process is compared with the updated public version number of the dictionary. If it is detected that the process version number corresponding to the second application process is inconsistent with the updated public version number of the dictionary, usually the process version number corresponding to the second application process is less than the updated public version number, then the updated dictionary is rebuilt and loaded from the disk into memory or shared memory so that the process version number corresponding to the second application process is consistent with the updated public version number of the dictionary, so that the input method of the second application process can read words from the updated dictionary.
[0157] The input method dictionary management method provided in this application not only updates the dictionary but also updates the public version number of the dictionary when an update is detected. This way, when other processes access the dictionary again, they can reload the dictionary when they determine that their current application process is inconsistent with the public version number of the dictionary, without having to send a separate dictionary update notification message. This improves the efficiency of dictionary updates, greatly reduces input method lag during dictionary updates, and enhances the input experience.
[0158] The preceding text described the process of updating and reloading the dictionary. The following section describes the entire process of input method dictionary management as described in this embodiment.
[0159] Figure 9 This is a schematic flowchart of an input method dictionary management method provided in an embodiment of this application. Figure 9 This can be understood as the above. Figure 4 and Figure 5 One specific embodiment.
[0160] like Figure 9 As shown, the embodiments of this application include:
[0161] S601. Update the dictionary.
[0162] In one example, dictionary synchronization involves downloading dictionaries from other devices from a server and merging the downloaded dictionaries into the local user dictionary to update the dictionary.
[0163] In another example, the dictionary is full and needs to be slimmed down by eliminating some useless words, or the dictionary needs to be expanded to update the dictionary.
[0164] It should be noted that, in addition to the two examples mentioned above, other thesaurus updates and distributions are also included, and this application embodiment does not limit these.
[0165] S602. Update the public version number of the dictionary.
[0166] For example, when an update to the dictionary is detected, a first value (e.g., 1) is added to the public version number of the currently saved dictionary to obtain the updated public version number of the dictionary.
[0167] For example, when it is detected that N processes have updated the dictionary, the updated public version number of the dictionary is obtained by updating the public version number of the dictionary in sequence through the N processes, where N is a positive integer.
[0168] The specific implementation process of S602 can be referred to the relevant description of S501 above, and will not be repeated here.
[0169] S603. In response to the input method trigger operation on the first application process, obtain the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary.
[0170] The dictionary accessed by the first application process is the updated dictionary mentioned above.
[0171] In some embodiments, the public version number of the dictionary is stored in shared memory, allowing the dictionary's public version number to be retrieved from shared memory. The process version number corresponding to the first application process is then retrieved from the memory corresponding to that first application process.
[0172] The specific implementation process of S603 can be referred to the specific implementation process of S401, and will not be repeated here.
[0173] S604. Determine whether the process version number is consistent with the public version number.
[0174] If it is determined that the process version number corresponding to the first application process is inconsistent with the public version number of the dictionary, then execute S606 as follows.
[0175] If it is determined that the process version number corresponding to the first application process is consistent with the public version number of the dictionary, then execute S606 as follows.
[0176] S605. Reload the dictionary and update the process version number.
[0177] If it is determined that the process version number corresponding to the first application process is inconsistent with the public version number of the dictionary, it means that the dictionary currently stored in memory is not the latest version, and the dictionary is reloaded into memory.
[0178] At the same time, after reloading the dictionary into memory, the process version number corresponding to the first application process is updated, that is, the process version number corresponding to the first application process is updated to the public version number of the current dictionary.
[0179] S606. Read words from the updated dictionary.
[0180] As described above, in this embodiment, after the dictionary is updated, there is no need to send notification messages to other processes for dictionary updates. Instead, the process determines whether the dictionary has been updated by comparing its process version number with the public version number of the dictionary. For example, if the process version number and the public version number are inconsistent, the dictionary is directly reloaded. Compared with existing message notification mechanisms, this embodiment improves the overall efficiency of dictionary updates on Windows by about 40%, greatly reducing input method lag during dictionary updates.
[0181] Furthermore, the method in this application embodiment can be applied to various types of terminals, supporting dictionary management for input methods on each terminal, thereby achieving a unified kernel for multi-terminal input methods. This not only significantly reduces development and maintenance costs but also ensures that input methods on different terminals use the same dictionary and kernel, resulting in more consistent candidate words provided by each terminal. This provides an excellent user experience for users of multi-terminal input methods. For example... Figure 10A and Figure 10B As shown, when you type "meinv" on both a computer and a mobile phone, the input options and their order are the same, ensuring that users will not feel unfamiliar with the input method regardless of which platform they are using.
[0182] It should be understood that Figures 4 to 10B This is merely an example of what is being done and should not be construed as limiting the scope of this application.
[0183] The preferred embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this application, various simple modifications can be made to the technical solutions of this application, and these simple modifications all fall within the protection scope of this application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this application will not describe the various possible combinations separately. Furthermore, various different embodiments of this application can also be arbitrarily combined, as long as they do not violate the spirit of this application, they should also be considered as the content disclosed in this application.
[0184] The above text combined Figures 4 to 10B The method embodiments of this application are described in detail below, in conjunction with... Figures 5 to 6 The following describes in detail the device embodiments of this application.
[0185] Figure 11 This is a schematic block diagram of an input method dictionary management device provided in an embodiment of this application.
[0186] like Figure 11 As shown, the input method dictionary management device 10 includes:
[0187] The acquisition unit 11 is used to respond to the input method triggering operation on the first application process to acquire the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary, wherein the process version number is the dictionary version number corresponding to the first application process at the current time, and the public version number is the latest version number of the dictionary at the current time;
[0188] Processing unit 12 is configured to reload the dictionary if the process version number corresponding to the first application process is inconsistent with the public version number, so that the process version number corresponding to the first application process is consistent with the public version number.
[0189] In some embodiments, the processing unit 12 is further configured to obtain the version number of the dictionary already loaded in memory; if the version number of the dictionary already loaded in memory is less than the public version number, the dictionary is reloaded so that the process version number corresponding to the first application process is consistent with the public version number.
[0190] In some embodiments, the processing unit 12 is further configured to update the process version number corresponding to the first application process to the public version number if the version number of the dictionary already loaded in the memory is the public version number.
[0191] In some embodiments, the public version number is stored in the first memory, and the process version number corresponding to the first application process is stored in the memory corresponding to the first application process. The acquisition unit 11 is also used to, in response to an input method triggering operation on the first application process, acquire the public version number of the dictionary from the first memory, and acquire the process version number corresponding to the first application process from the memory corresponding to the first application process.
[0192] In some embodiments, if the dictionary is accessed by multiple processes, the public version number of the dictionary is stored in shared memory.
[0193] In some embodiments, the processing unit 12 is further configured to update the public version number of the thesaurus when the thesaurus is detected to be updated.
[0194] In some embodiments, the processing unit 12 is specifically configured to, when detecting that the dictionary has been updated, add a first value to the currently stored public version number of the dictionary to obtain the updated public version number of the dictionary.
[0195] In some embodiments, if the dictionary is accessed by multiple processes, the processing unit 12 is specifically used to update the public version number of the dictionary sequentially by the N processes when it is detected that N processes have updated the dictionary, so as to obtain the updated public version number of the dictionary, where N is a positive integer.
[0196] In some embodiments, the processing unit 12 is specifically configured to, upon detecting that all N processes have updated the dictionary, control the N processes to update the public version number sequentially based on a locking mechanism, thereby obtaining the updated public version number of the dictionary.
[0197] In some embodiments, the processing unit 12 is specifically used to determine the update operation order of each of the N processes on the public version number based on a competition mechanism; and according to the update operation order, control the N processes to update the public version number sequentially based on the locking mechanism to obtain the updated public version number of the dictionary.
[0198] In some embodiments, the public version number of the dictionary is stored in shared memory. The processing unit 12 is specifically used to lock the shared memory for the i-th process in the update order, and then add a first value to the latest public version number in the locked shared memory before unlocking it, so as to obtain the update of the public version number by the i-th process, where i is a positive integer less than or equal to N; and to control the (i+1)-th process in the update order to continue updating the public version number after the update by the i-th process, until all N processes have finished updating the public version number, so as to obtain the updated public version number of the dictionary.
[0199] In some embodiments, the processing unit 12 is further configured to process the dictionary in response to the word display operation.
[0200] In some embodiments, the processing unit 12 is specifically configured to add the word to the word library in response to the word loading operation, when it is detected that the word library is not full.
[0201] In some embodiments, the processing unit 12 is specifically configured to respond to the word display operation, when the word library is detected to be full, allocate new memory for the word library, and slim down or expand the word library in the new memory, and write the word into the slimmed down or expanded word library to obtain the updated word library, and write the updated word library to the disk; and update the public version number of the word library according to the updated word library.
[0202] In some embodiments, the processing unit 12 is further configured to, after updating the public version number of the dictionary, when detecting an input method trigger operation of the second application process, in response to the input method trigger operation of the second application process, obtain the process version number of the dictionary currently corresponding to the second application process, and the updated public version number of the dictionary; if it is detected that the process version number corresponding to the second application process is inconsistent with the updated public version number of the dictionary, then load the updated dictionary from the disk into memory so that the process version number corresponding to the second application process is consistent with the updated public version number of the dictionary.
[0203] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, further details will not be provided here. Specifically, Figure 11 The apparatus shown can perform the embodiments of the above-described method, and the foregoing and other operations and / or functions of each module in the apparatus are for implementing the embodiments of the above-described method, which will not be described in detail here for the sake of brevity.
[0204] The apparatus of this application embodiment has been described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that this functional module can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method embodiments in this application can be completed by integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this application embodiment can be directly embodied as being executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. Optionally, the software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.
[0205] Figure 12 This is a schematic block diagram of an electronic device provided in an embodiment of this application. The electronic device can be... Figure 2 The terminal device shown is used to execute the above method embodiments.
[0206] like Figure 12 As shown, the robot 30 may include:
[0207] The system includes a memory 31 and a processor 32. The memory 31 stores a computer program 33 and transfers the program code 33 to the processor 32. In other words, the processor 32 can retrieve and run the computer program 33 from the memory 31 to implement the methods described in the embodiments of this application.
[0208] For example, the processor 32 can be used to execute the above method steps according to the instructions in the computer program 33.
[0209] In some embodiments of this application, the processor 32 may include, but is not limited to:
[0210] General-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0211] In some embodiments of this application, the memory 31 includes, but is not limited to:
[0212] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0213] In some embodiments of this application, the computer program 33 may be divided into one or more modules, which are stored in the memory 31 and executed by the processor 32 to complete the page recording method provided in this application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 33 in the robot.
[0214] like Figure 12 As shown, the robot 30 may also include:
[0215] Transceiver 34, which can be connected to processor 32 or memory 31.
[0216] The processor 32 can control the transceiver 34 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 34 may include a transmitter and a receiver. The transceiver 34 may further include antennas, and the number of antennas may be one or more.
[0217] It should be understood that the various components in the robot 30 are connected through a bus system, which includes a data bus, a power bus, a control bus, and a status signal bus.
[0218] According to one aspect of this application, a computer storage medium is provided that stores a computer program thereon, which, when executed by a computer, enables the computer to perform the methods described in the method embodiments.
[0219] This application also provides a computer program product containing instructions that, when executed by a computer, cause the computer to perform the method described in the above method embodiments.
[0220] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A robot's processor reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the robot to perform the method described in the above-described method embodiments.
[0221] In other words, when implemented using software, it can be implemented wholly or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0222] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0223] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0224] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. For example, the functional modules in the various embodiments of this application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0225] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An input method dictionary management method, characterized in that, include: In response to an input method trigger operation on a first application process, the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary are obtained. The process version number is the dictionary version number corresponding to the first application process at the current moment, and the public version number is the latest version number of the dictionary at the current moment. The public version number is stored in shared memory, and the process version number corresponding to the first application process is stored in the memory corresponding to the first application process. The step of obtaining the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary in response to an input method trigger operation on the first application process includes: in response to an input method trigger operation on the first application process, obtaining the public version number of the dictionary from the shared memory and obtaining the process version number corresponding to the first application process from the memory corresponding to the first application process. Obtain the version number of the dictionary already loaded in memory; If the process version number corresponding to the first application process is inconsistent with the public version number, the version number of the dictionary already loaded in memory is compared with the public version number. If the version number of the dictionary already loaded in the memory is less than the public version number, then the dictionary is reloaded so that the process version number corresponding to the first application process is consistent with the public version number; If the version number of the dictionary already loaded in the memory is the public version number, then the process version number corresponding to the first application process is updated to the public version number, and the dictionary is not reloaded. When it is detected that N processes have updated the dictionary, the update order of the public version number of each of the N processes is determined based on the competition mechanism. According to the update operation order, the N processes are controlled to update the public version number in sequence based on the locking mechanism to obtain the updated public version number of the dictionary, where N is a positive integer.
2. The method according to claim 1, characterized in that, If the dictionary is accessed by multiple processes, the public version number of the dictionary is stored in shared memory.
3. The method according to any one of claims 1-2, characterized in that, The method further includes: When an update to the thesaurus is detected, the public version number of the thesaurus is updated.
4. The method according to claim 3, characterized in that, The step of updating the public version number of the thesaurus when an update is detected includes: When an update to the dictionary is detected, a first value is added to the currently saved public version number of the dictionary to obtain the updated public version number of the dictionary.
5. The method according to claim 4, characterized in that, If the dictionary is accessed by multiple processes, when an update to the dictionary is detected, a first value is added to the currently stored public version number of the dictionary to obtain the updated public version number of the dictionary, including: When it is detected that N processes have updated the dictionary, the public version number is updated sequentially by the N processes to obtain the updated public version number of the dictionary, where N is a positive integer.
6. The method according to claim 1, characterized in that, The public version number of the dictionary is stored in shared memory. The step of controlling the N processes to update the public version number sequentially based on the locking mechanism, according to the update operation order, to obtain the updated public version number of the dictionary, includes: For the i-th process in the update order, the i-th process locks the shared memory, increments the latest public version number in the locked shared memory by a first value, and then unlocks it to obtain the update of the public version number by the i-th process, where i is a positive integer less than or equal to N; The (i+1)th process in the update sequence is controlled to continue updating the public version number after the i-th process has updated it, until all N processes have finished updating the public version number, thus obtaining the updated public version number of the dictionary.
7. The method according to claim 1, characterized in that, The method further includes: In response to the word being displayed on the screen, the dictionary is processed.
8. The method according to claim 7, characterized in that, The process of processing the dictionary database in response to the word display operation includes: In response to the word being added to the screen, if the word library is not full, the word is added to the word library.
9. The method according to claim 7, characterized in that, The process of processing the dictionary database in response to the word display operation includes: In response to the word being displayed on the screen, when the word library is detected to be full, new memory is allocated for the word library, and the word library is either reduced or expanded in the new memory. The word is then written into the reduced or expanded word library to obtain the updated word library, and the updated word library is written to the disk. Based on the updated thesaurus, the public version number of the thesaurus is updated.
10. The method according to claim 9, characterized in that, The method further includes: After updating the public version number of the dictionary, when an input method trigger operation of the second application process is detected, in response to the input method trigger operation of the second application process, the process version number of the dictionary currently corresponding to the second application process and the updated public version number of the dictionary are obtained. If it is detected that the process version number corresponding to the second application process is inconsistent with the updated public version number of the dictionary, the updated dictionary is loaded from the disk into memory so that the process version number corresponding to the second application process is consistent with the updated public version number of the dictionary.
11. An input method dictionary management device, characterized in that, include: The acquisition unit is configured to, in response to an input method triggering operation on a first application process, acquire the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary, wherein the process version number is the dictionary version number corresponding to the first application process at the current moment, and the public version number is the latest version number of the dictionary at the current moment, the public version number is stored in shared memory, and the process version number corresponding to the first application process is stored in the memory corresponding to the first application process. The step of acquiring the process version number of the dictionary corresponding to the first application process and the public version number of the dictionary in response to an input method triggering operation on the first application process includes: in response to an input method triggering operation on the first application process, acquiring the public version number of the dictionary from the shared memory and acquiring the process version number corresponding to the first application process from the memory corresponding to the first application process; The processing unit is configured to: obtain the version number of the dictionary already loaded in memory; if the process version number corresponding to the first application process is inconsistent with the public version number, compare the version number of the dictionary already loaded in memory with the public version number; if the version number of the dictionary already loaded in memory is less than the public version number, reload the dictionary to make the process version number corresponding to the first application process consistent with the public version number; if the version number of the dictionary already loaded in memory is the public version number, update the process version number corresponding to the first application process to the public version number without reloading the dictionary; when it is detected that N processes have updated the dictionary, determine the update operation order of each of the N processes on the public version number based on a competition mechanism, and control the N processes to update the public version number sequentially based on a locking mechanism according to the update operation order to obtain the updated public version number of the dictionary, where N is a positive integer.
12. The apparatus according to claim 11, characterized in that, The processing unit is also used to process the dictionary in response to the word display operation.
13. The apparatus according to claim 12, characterized in that, The public version number of the dictionary is stored in shared memory, and the processing unit is used for: For the i-th process in the update order, the i-th process locks the shared memory, increments the latest public version number in the locked shared memory by a first value, and then unlocks it to obtain the update of the public version number by the i-th process, where i is a positive integer less than or equal to N; The (i+1)th process in the update sequence is controlled to continue updating the public version number after the i-th process has updated it, until all N processes have finished updating the public version number, thus obtaining the updated public version number of the dictionary.
14. The apparatus according to claim 11, characterized in that, The processing unit is also used to process the dictionary in response to the word display operation.
15. The apparatus according to claim 14, characterized in that, The processing unit is configured to process the dictionary process in response to the word loading operation, including: in response to the word loading operation, when the dictionary is detected to be full, allocating new memory for the dictionary, slimming down or expanding the dictionary in the new memory, writing the word into the slimmed down or expanded dictionary to obtain the updated dictionary, and writing the updated dictionary to disk; and updating the public version number of the dictionary according to the updated dictionary.
16. The apparatus according to claim 15, characterized in that, The processing unit is further configured to: After updating the public version number of the dictionary, when an input method trigger operation of the second application process is detected, in response to the input method trigger operation of the second application process, the process version number of the dictionary currently corresponding to the second application process and the updated public version number of the dictionary are obtained. If it is detected that the process version number corresponding to the second application process is inconsistent with the updated public version number of the dictionary, the updated dictionary is loaded from the disk into memory so that the process version number corresponding to the second application process is consistent with the updated public version number of the dictionary.
17. An electronic device, characterized in that, Including processor and memory; The memory is used to store computer programs; The processor is configured to execute the computer program to implement the method as described in any one of claims 1 to 10.
18. A computer-readable storage medium, characterized in that, Used to store computer programs that cause a computer to perform the method as described in any one of claims 1 to 10.