WO2024222525A1 - 输入法程序运行方法、装置、电子设备及存储介质 - Google Patents
输入法程序运行方法、装置、电子设备及存储介质 Download PDFInfo
- Publication number
- WO2024222525A1 WO2024222525A1 PCT/CN2024/088042 CN2024088042W WO2024222525A1 WO 2024222525 A1 WO2024222525 A1 WO 2024222525A1 CN 2024088042 W CN2024088042 W CN 2024088042W WO 2024222525 A1 WO2024222525 A1 WO 2024222525A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- file
- data
- vocabulary
- address
- input method
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/10—Address translation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/048—Interaction techniques based on graphical user interfaces [GUI]
- G06F3/0487—Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
- G06F3/0488—Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
- G06F3/04886—Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures by partitioning the display area of the touch-screen or the surface of the digitising tablet into independently controllable areas, e.g. virtual keyboards or menus
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the embodiments of the present disclosure relate to the field of computer technology, and in particular to an input method program running method, device, electronic device and storage medium.
- Input method programs are one of the commonly used programs used for human-computer interaction and information exchange between users.
- current input method programs are usually equipped with a large number of vocabulary data.
- input functions such as spelling, word formation, and error correction can be achieved.
- Embodiments of the present disclosure provide an input method program running method, device, electronic device, and storage medium.
- an input method program running method comprising:
- an input method program running device comprising:
- An acquisition module used for acquiring a virtual address corresponding to the word library data required to execute the input function before executing the input function of the input method program;
- a loading module used for loading the word library data into the kernel space corresponding to the virtual address
- the calling module is used to call the target word library data in the kernel space in response to the user instruction to execute the input function corresponding to the user instruction in the input method program.
- an electronic device including:
- a processor and a memory communicatively connected to the processor
- the memory stores computer-executable instructions
- the processor executes the computer-executable instructions stored in the memory to implement the input method program running method described in the first aspect and various possible designs of the first aspect.
- an embodiment of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer execution instructions.
- the input method program running method described in the first aspect and various possible designs of the first aspect is implemented.
- an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the input method program running method described in the first aspect and various possible designs of the first aspect.
- the input method program running method, device, electronic device and storage medium provided in this embodiment obtain a virtual address corresponding to the vocabulary data required to execute the input function before executing the input function of the input method program; load the vocabulary data into the kernel space corresponding to the virtual address; and call the target vocabulary data in the kernel space in response to the user instruction to execute the input function corresponding to the user instruction in the input method program.
- FIG1 is a schematic diagram of an execution process of an input method program provided by an embodiment of the present disclosure
- FIG2 is a flow chart of a method for running an input method program provided by an embodiment of the present disclosure
- FIG3 is a flow chart of a specific implementation of step S101 in the embodiment shown in FIG2 ;
- FIG4 is a schematic diagram of a process of obtaining a virtual address of vocabulary data provided by an embodiment of the present disclosure
- FIG5 is a flow chart of a specific implementation of step S102 in the embodiment shown in FIG2 ;
- FIG6 is a schematic diagram of a process of executing an input function provided by an embodiment of the present disclosure.
- FIG7 is a second flow chart of the input method program operation method provided by the embodiment of the present disclosure.
- FIG8 is a flow chart of a specific implementation method of step S202 in the embodiment shown in FIG7 ;
- FIG9 is a schematic diagram of a process for determining missing data provided by an embodiment of the present disclosure.
- FIG10 is a flowchart of a specific implementation method of step S204 in the embodiment shown in FIG7 ;
- FIG11 is a structural block diagram of an input method program running device provided by an embodiment of the present disclosure.
- FIG12 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure.
- FIG. 13 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure.
- user information including but not limited to user device information, user personal information, etc.
- data including but not limited to data used for analysis, stored data, displayed data, etc.
- user information including but not limited to user device information, user personal information, etc.
- data including but not limited to data used for analysis, stored data, displayed data, etc.
- FIG1 is a schematic diagram of the execution process of an input method program provided by the embodiment of the present disclosure.
- the disk space (hard disk) of the terminal device stores the vocabulary file of the input method program.
- the terminal device After starting the input method program, the terminal device will copy the vocabulary data in the vocabulary file on the disk to the kernel space in the memory. After that, a mapping relationship between the user space and the disk space is established.
- the vocabulary data corresponding to the vocabulary file is obtained from the kernel space through the page table, that is, the vocabulary data is loaded in the form of file mapping. Afterwards, in response to user instructions, the vocabulary data is used to complete the execution of the input function, such as spelling, composition, and error correction. Input function of input method programs such as .
- the kernel space can realize the data cache feature, so that the word library data can be quickly retrieved.
- the kernel space is shared by all processes, when the input method program is in the background idle state, the operating system will recycle the resources of the kernel space, resulting in the word library data stored in the kernel space (physical memory) being cleared.
- the input method program accesses the word library data on the physical page through the virtual address that has been mapped.
- the memory management unit of the central processing unit issues an interrupt instruction, that is, a page fault interrupt occurs.
- a page fault interrupt occurs, the operating system needs to re-read the word library file from the disk to obtain the word library data, and re-copy it to the kernel space, and then perform subsequent input functions based on the word library data in the kernel space. This process increases the time consumption of calling the word library data, thereby affecting the running fluency and stability of the input method program.
- the embodiment of the present disclosure provides an input method program running method to solve the above-mentioned problem.
- the vocabulary data usually needs to be pre-loaded into the memory for the input method program to call.
- the vocabulary data loaded into the memory will be cleared by the operating system when memory resources are tight, resulting in an increased time consumption for vocabulary calls, thereby affecting the running smoothness and stability of the input method program.
- FIG. 2 is a flow chart of an input method program operation method provided by an embodiment of the present disclosure.
- the method of this embodiment can be applied in a terminal device, and the input method program operation method includes:
- Step S101 before executing the input function of the input method program, obtaining the virtual address corresponding to the vocabulary data required to execute the input function.
- the virtual address corresponding to the vocabulary data is obtained, wherein the virtual address is information representing the data location of the vocabulary data.
- the input method program obtains the vocabulary data through the virtual address, and uses the vocabulary data to execute subsequent input functions, such as grouping words and correcting words using the vocabulary data.
- the virtual address is located in the virtual address space, which is also called the process address space. It is a data structure in the kernel of the operating system and is an address space composed of the virtual addresses of processes (such as the input method program process).
- the virtual address space and the process address space are technical concepts known to those skilled in the art.
- the virtual address corresponding to the vocabulary data is determined by the input method program.
- the virtual address corresponding to the vocabulary data can be obtained by calling a specific virtual address query function, which is a related technology known to those skilled in the art, and the above content will not be repeated one by one for this purpose.
- the input function of the input method program refers to the function of the input method program to generate content information such as text, numbers, and logos by receiving input information (such as keyboard information, voice information, etc.) input by the user, that is, the main function of the input method program.
- the input function is a foreground running function, that is, when executing the input method function, the input method program needs to run in the system foreground, that is, it is in a call-up state; in contrast, the input method program can also include non-main functions such as update functions and push functions that can run in the system background and can be executed without being called up. Among them, unlike the non-main functions such as update functions and push functions, the implementation of the input function requires the support of the word library data.
- the input method program needs to convert the input information input by the user into corresponding text and numbers based on the word library data, and display it as needed to realize the basic text input function. Therefore, in a possible implementation method, the timing of obtaining the virtual address corresponding to the word library data required to execute the input function can be when the input method program is called up to the foreground.
- the specific implementation method of step S101 includes:
- Step S1011 performing real-time detection on the input method program running in the background
- Step S1012 when it is detected that the input method program is called to the foreground to run, the virtual address corresponding to the word library data required to execute the input function is obtained.
- FIG4 is a schematic diagram of a process for obtaining a virtual address of vocabulary data provided by an embodiment of the present disclosure.
- a terminal device for example, a smart phone
- the input method program is called up, and the input interface of the input method program is displayed.
- the terminal device obtains the virtual address of the vocabulary data, and then, based on the virtual address of the vocabulary data, the vocabulary data is loaded into the kernel space.
- the user can further input keyboard information by operating the input interface of the input method program, such as clicking the "GHI" key, and the input method program uses the word library data to perform the input function (word combination function).
- the interface displays words containing the letter "h”, such as “hi”, “happy”, “http”, etc., as shown in the figure.
- the virtual address of the word library data is known preset information after the input method program is started, and the virtual address of the preset word library data can be directly read, and the specific process is not repeated.
- Step S102 Load the vocabulary data into the kernel space corresponding to the virtual address.
- the terminal device can directly obtain the above-mentioned word library data based on the virtual address, and then use the word library data to complete input functions such as word grouping and error correction.
- This possible situation is usually when the input method program is running in the foreground, the operating system will not clean up and recycle the memory data used by the application program in the call-up state, so the corresponding word library data can be directly obtained based on the virtual address.
- the terminal device cannot directly obtain the above-mentioned word library data in the kernel space based on the virtual address, which will cause a page fault interrupt (also called a hard page fault interrupt, hard interrupt, hard error).
- a page fault interrupt also called a hard page fault interrupt, hard interrupt, hard error
- the terminal device obtains the above-mentioned word library data from the disk and loads it into the kernel space corresponding to the virtual address.
- the input method program since the input method program has not started to execute the input function, that is, the word library data has not been called, it is equivalent to realizing the pre-loading of the word library data, thereby avoiding the page fault interrupt problem generated when the word library data needs to be called to execute the input function in the subsequent steps.
- the virtual address includes a virtual memory page address corresponding to at least one vocabulary file storing vocabulary data, and the virtual memory page address is mapped one-to-one with the disk address of the vocabulary file, as shown in FIG5 .
- the specific implementation of step S102 includes:
- Step S1021 traverse the virtual memory page address corresponding to at least one vocabulary file to determine missing data stored in the vocabulary file, wherein the missing data is vocabulary data that has not been copied to the kernel space.
- Step S1022 Load the missing data stored in the vocabulary file into the kernel space.
- the word library data required to perform the input function is stored in the disk in the form of a word library file. Then, based on the mapping relationship between the user space and the disk space, the input method program obtains the word library data required to perform the input function, that is, the word library data is loaded in the form of file mapping.
- the disk address of the word library file corresponds to the virtual memory page address.
- the virtual memory page address refers to the address of the virtual memory page corresponding to the virtual memory. Virtual memory is a related technology that uses hard disk space as memory, which will not be repeated here.
- the virtual memory page address is information used to describe the continuous address position of the above virtual memory page. Since the virtual memory page is virtualized, its corresponding virtual memory The page address is also virtual and is not consistent with the actual physical memory page address.
- the word library data stored in the word library file can be obtained from the corresponding position in the kernel space through the virtual memory page address. Therefore, the terminal device can determine whether the corresponding kernel space contains the corresponding word library data by traversing the virtual memory page address, that is, accessing each virtual memory page address in turn, according to the access result returned by the operating system.
- missing data is word library data that has not been copied to the kernel space.
- the disk address corresponding to the word library file (virtual memory page address) is obtained based on the preset page table, and the word library data is read from the disk address and copied to the kernel space to load the missing data stored in the word library file into the kernel space.
- the word library data required to execute the input function is loaded into the kernel space corresponding to the virtual address, avoiding the subsequent page missing interrupt problem.
- the method provided in this embodiment can be applied to the Linux system, or an operating system based on the Linux system.
- the file pre-reading mechanism of the Linux kernel is used to traverse the virtual memory page address corresponding to the file page to load the data in at least two consecutive file pages into the kernel space, wherein the vocabulary file is composed of at least two file pages, and each file page is used to store a part of the vocabulary data.
- the file pre-reading mechanism of the Linux kernel can be used to efficiently pre-read the file and improve the speed of loading the vocabulary data into the kernel space.
- Step S103 In response to the user instruction, the target word library data in the kernel space is called to execute the input function corresponding to the user instruction in the input method program.
- the target word library data for executing the input function triggered by the user instruction is called from the kernel space to implement the input function corresponding to the user instruction.
- the word library data may be a function model including specific functions, methods and data, which has a corresponding calling interface (API), and the calling interface is used to implement the calling of the word library data, thereby implementing the word library function of the word library data, and then according to one or more word library data, the word library data is called.
- API calling interface
- a collection of vocabulary functions is used to implement the corresponding input function.
- FIG6 is a schematic diagram of a process for executing an input function provided by an embodiment of the present disclosure.
- the user instruction comm_1 includes keyboard information letter "z” and letter “m” (shown as comm_1[z,m] in the figure), and the user instruction comm_1 is used to instruct the input method program to generate a corresponding phrase based on the above keyboard information.
- the terminal device calls the vocabulary data pack_1 and the vocabulary data pack_3 in the kernel space as the target vocabulary data to process the user instruction comm_1, wherein the vocabulary data pack_1 is used to use the keyboard information as the first letter to form a word to generate a Chinese character phrase; the vocabulary data pack_3 is used to correct the Chinese character phrase according to the keyboard information to obtain commonly used Chinese character phrases.
- the commonly used Chinese character phrases are displayed on the display interface of the terminal device, and the input function is executed.
- the virtual address corresponding to the word library data required to execute the input function is obtained; the word library data is loaded into the kernel space corresponding to the virtual address; in response to the user instruction, the target word library data in the kernel space is called to execute the input function corresponding to the user instruction in the input method program.
- the virtual address is obtained, and the word library data is preloaded based on the virtual address, so that when executing the input function in response to the user instruction, the corresponding target word library data can be directly obtained from the kernel space in the form of file mapping, avoiding the problem of hard page fault interrupt caused by memory clearing, reducing the overall time consumption of the input method program calling the word library data, reducing jamming, and improving the stability and running smoothness of the input function of the input method program.
- FIG. 7 is a second flow chart of the input method program operation method provided by the embodiment of the present disclosure. Based on the embodiment shown in FIG. 2 , this embodiment further refines step S102 , and the input method program operation method includes:
- Step S201 Before executing the input function of the input method program, obtain the virtual address corresponding to the vocabulary data required to execute the input function, the virtual address includes the virtual memory page address corresponding to at least one vocabulary file storing the vocabulary data, and the virtual memory page address is mapped one-to-one with the disk address of the vocabulary file.
- Step S202 Based on the virtual memory page address of the current vocabulary file, access the page cache area of the kernel space to obtain an access result.
- the page cache is an area in the memory used to store some disk data.
- the page cache it is possible to allow the operating system to keep some data that is usually stored on the disk in the kernel area of the memory, so that when the disk needs to be accessed, it can be obtained from the page cache.
- Corresponding data can be read from disk without reading data from disk, thereby improving the data reading and writing speed.
- each word library file corresponds to a virtual memory page address.
- the virtual memory page address has been introduced in detail in the embodiment shown in Figure 2 and will not be repeated here. A loop is traversed for each word library file, and the virtual memory page address of each word library file is obtained in turn.
- the address of the page cache area corresponding to the virtual memory page address can be obtained, that is, the address of the word library data corresponding to the virtual memory page address stored in the page cache area, and then the address of the page cache area corresponding to each virtual memory page address is accessed, and the access result obtained is the data at the address.
- the word library file corresponds to at least two physical pages located in the page cache area, and the physical pages are used to store word library data;
- the virtual memory page address includes at least two sub-memory page addresses, and the sub-memory page address represents the first address of the physical page.
- the specific implementation of step S202 includes:
- Step S2021 traverse the corresponding physical pages according to at least two sub-memory page addresses of the current vocabulary file.
- Step S2022 Read the first byte of each physical page in sequence to obtain an access result.
- the page cache area is composed of physical pages
- the virtual memory page address is composed of at least two sub-memory page addresses
- the position of the physical page corresponds to the sub-memory page address one by one, that is, the sub-memory page address is mapped to the physical page.
- the corresponding physical page is accessed based on the corresponding sub-memory page address, and the first byte of each physical page is read, and the access result is obtained according to the content of the read first byte.
- Step S203 Determine missing data corresponding to the current vocabulary file according to the access result, wherein the missing data is vocabulary data that has not been copied to the kernel space.
- step S203 includes: if the first byte of the first physical page corresponding to the vocabulary file is non-preset information, determining the data stored in the first physical page as missing data.
- FIG9 is a schematic diagram of a process for determining missing data provided by an embodiment of the present disclosure.
- the word library file File_1 corresponds to multiple physical pages, such as physical page p1, physical page p2, physical page p3, etc., as shown in the figure.
- the first byte of physical page p1, the first byte of physical page p2, and the first byte of physical page p3 are read respectively, and the content of the first byte of physical page p1 is [01000100]; the content of the first byte of physical page p2 is [01000100]; is [01100101]; the first byte of physical page p3 is [00000000]; where [00000000] is non-preset information, therefore, after reading the first byte of physical page p3, physical page p3 is determined as the first physical page, and the data stored in physical page p3 is determined as missing data. Afterwards, the vocabulary data (missing data) corresponding to the physical page p3 is obtained from the disk space and loaded into the kernel space to complete the vocabulary data required by the input method program.
- the word library data stored in the word library file is loaded in sections and quickly judged.
- the speed of determining missing data is effectively improved, thereby reducing the time required to traverse all word library files and improving the loading efficiency of word library data.
- Step S204 Based on the disk address of the current vocabulary file, the corresponding missing data is loaded into the page cache area.
- step S204 includes:
- Step S2041 Obtain the corresponding first disk address according to the sub-memory page address corresponding to the first physical page.
- Step S2042 read the data at the first disk address, obtain the missing data, and load the missing data into the first physical page.
- the first physical page is a physical page storing missing data.
- the corresponding first disk address is obtained according to the sub-memory page address corresponding to the first physical page, and the mapping relationship between the memory page address and the disk address is determined by a preset page table.
- the vocabulary file includes at least two file pages, the file page is used to store vocabulary data, and the first disk address is the first address of the file page of the vocabulary file. That is, the physical page in the cache page and the file page constituting the vocabulary file in the disk are in a one-to-one correspondence.
- the file page is the result of segmenting the vocabulary file
- the physical page is the data object after the file page is loaded into the memory
- the disk address is the address of the file page
- the first disk address is the address of the first file page corresponding to the first physical page. Therefore, after obtaining the first disk address corresponding to the memory page address, the data at the first disk address, that is, the first file page, is read, and the data retained in the first file page, that is, the missing data. Afterwards, the actual data in the first file page is loaded into the first physical page in the page cache area, completing the process of loading the missing data into the page cache area.
- Step S205 If the current word library file is the last word library file, execute step S206; otherwise, locate the next word library file and return to step S202.
- the current vocabulary file if the current vocabulary file is not the last vocabulary file of all vocabulary files configured for the input method program, continue to locate the next vocabulary file, and return to step S202 to loop and execute the above steps to process the vocabulary file, so that the missing data corresponding to the input function can be loaded into the memory for use; if the vocabulary file is the last vocabulary file of all vocabulary files configured for the input method program, it means that all vocabulary files have been processed. At this time, it can be guaranteed that the vocabulary data stored in all vocabulary files have been fully loaded into the memory for use. In this case, the problem of page fault interruption can be avoided, so the loop can be ended and the subsequent input function call steps can be executed.
- Step S206 In response to the user instruction, the target vocabulary data in the kernel space is called to execute the input function corresponding to the user instruction in the input method program.
- step S201 and step S206 are consistent with step S101 and step S103 in the embodiment shown in FIG. 2 .
- step S201 and step S206 are consistent with step S101 and step S103 in the embodiment shown in FIG. 2 .
- FIG11 is a structural block diagram of the input method program running device provided by the embodiment of the present disclosure. For the convenience of explanation, only the parts related to the embodiment of the present disclosure are shown.
- the input method program running device 3 includes:
- the acquisition module 31 is used to acquire the virtual address corresponding to the word library data required to execute the input function before executing the input function of the input method program;
- a loading module 32 used to load the word library data into the kernel space corresponding to the virtual address
- the calling module 33 is used to call the target word library data in the kernel space in response to the user instruction to execute the input function corresponding to the user instruction in the input method program.
- the virtual address includes a virtual memory page address corresponding to at least one vocabulary file storing vocabulary data, and the virtual memory page address is mapped one-to-one to the disk address of the vocabulary file; the loading module 32 is specifically used to: traverse the virtual memory page address corresponding to at least one vocabulary file, and load the missing data stored in the vocabulary file into the kernel space, wherein the missing data is the vocabulary data that has not been copied to the kernel space.
- the loading module 32 traverses the virtual memory page address corresponding to at least one word library file and loads the missing data stored in the word library file into the kernel space.
- the loading module 32 executes the following steps: based on the virtual memory page address of the current vocabulary file, accessing the page cache area of the kernel space to obtain the access result; according to the access result, determining the missing data corresponding to the current vocabulary file; based on the disk address of the current vocabulary file, loading the corresponding missing data into the page cache area.
- the vocabulary file corresponds to at least two physical pages located in the page cache area, and the physical pages are used to store vocabulary data;
- the virtual memory page address includes at least two sub-memory page addresses, and the sub-memory page address represents the first address of the physical page;
- the loading module 32 accesses the page cache area of the kernel space based on the virtual memory page address of the current vocabulary file, and when obtaining the access result, it is specifically used to: traverse the corresponding physical pages according to the at least two sub-memory page addresses of the current vocabulary file; read the first byte of each physical page in turn to obtain the access result.
- the loading module 32 determines the missing data corresponding to the current vocabulary file based on the access result, it is specifically used to: if the first byte of the first physical page corresponding to the vocabulary file is non-preset information, then the data stored in the first physical page is determined as missing data; the loading module 32 loads the corresponding missing data into the page cache area based on the disk address of the current vocabulary file, including: obtaining the corresponding first disk address according to the sub-memory page address corresponding to the first physical page; reading the data at the first disk address to obtain the missing data, and loading the missing data into the first physical page.
- the vocabulary file includes at least two file pages, which are used to store vocabulary data; when the loading module 32 traverses the virtual memory page address corresponding to at least one vocabulary file and loads the missing data stored in the vocabulary file into the kernel space, it is specifically used to: for each vocabulary file, use the file pre-reading mechanism of the Linux kernel to traverse the virtual memory page address corresponding to the file page to load the data in at least two consecutive file pages into the kernel space.
- the acquisition module 31 is specifically used to: perform real-time detection on the input method program running in the background; when it is detected that the input method program is called to the foreground to run, obtain the virtual address corresponding to the vocabulary data required to execute the input function.
- the acquisition module 31, loading module 32 and calling module 33 are connected in sequence.
- the input method program running device 3 provided in this embodiment can execute the technical solution of the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated in this embodiment.
- FIG12 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. As shown in FIG12 , the electronic device 7 includes:
- the memory 42 stores computer executable instructions
- the processor 41 executes the computer execution instructions stored in the memory 42 to implement the input method program running method in the embodiments shown in Figures 2 to 10.
- processor 41 and the memory 42 are connected via a bus 43 .
- An embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored.
- the computer execution instructions are executed by a processor, they are used to implement the input method program running method provided in any one of the embodiments corresponding to Figures 2 to 10 of the present disclosure.
- An embodiment of the present disclosure provides a computer program product, including a computer program.
- the computer program When the computer program is executed by a processor, the input method program running method in the embodiments shown in FIG. 2 to FIG. 10 is implemented.
- FIG13 it shows a schematic diagram of the structure of an electronic device 900 suitable for implementing the embodiment of the present disclosure
- the electronic device 900 may be a terminal device or a server.
- the terminal device may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (Portable Media Players, PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc.
- PDAs personal digital assistants
- PMPs portable multimedia players
- vehicle terminals such as vehicle navigation terminals
- fixed terminals such as digital TVs, desktop computers, etc.
- the electronic device shown in FIG13 is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
- the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 to a random access memory (RAM) 903.
- a processing device e.g., a central processing unit, a graphics processing unit, etc.
- RAM random access memory
- Various programs and data required for the operation of the electronic device 900 are also stored in the RAM 903.
- the processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904.
- An input/output (I/O) interface 905 is also connected to the bus 904.
- the following devices can be connected to the I/O interface 905: input devices 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; input devices 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc. Output device 907; Storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and Communication device 909. Communication device 909 may allow electronic device 900 to communicate with other devices wirelessly or by wire to exchange data.
- FIG. 13 shows electronic device 900 with various devices, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have alternatively.
- an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart.
- the computer program can be downloaded and installed from a network through a communication device 909, or installed from a storage device 908, or installed from a ROM 902.
- the processing device 901 the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
- the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two.
- the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above.
- Computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
- a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device.
- a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried.
- This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above.
- the computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device.
- the program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
- the computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
- the computer-readable medium carries one or more programs.
- the electronic device executes the method shown in the above embodiment.
- Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages.
- the program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server.
- the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
- LAN Local Area Network
- WAN Wide Area Network
- each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function.
- the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved.
- each square box in the block diagram and/or flow chart, and the combination of the square boxes in the block diagram and/or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
- the units involved in the embodiments described in the present disclosure may be implemented by software or hardware.
- the name of a unit does not limit the unit itself in some cases.
- the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
- FPGA Field Programmable Gate Array
- ASIC Application Specific Integrated Circuit
- ASSP Application Specific Standard Product
- SOC System on Chip
- CPLD Complex Programmable Logic Device
- a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment.
- a machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
- a machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing.
- a more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
- RAM random access memory
- ROM read-only memory
- EPROM or flash memory erasable programmable read-only memory
- CD-ROM portable compact disk read-only memory
- CD-ROM compact disk read-only memory
- magnetic storage device or any suitable combination of the foregoing.
- an input method program running method comprising:
- the virtual address includes a virtual memory page address corresponding to at least one vocabulary file storing vocabulary data, and the virtual memory page address is mapped one-to-one to the disk address of the vocabulary file; loading the vocabulary data into the kernel space corresponding to the virtual address includes: traversing the virtual memory page address corresponding to the at least one vocabulary file, and loading the missing data stored in the vocabulary file into the kernel space, wherein the missing data is the vocabulary data that has not been copied to the kernel space.
- the virtual memory page address corresponding to the at least one vocabulary file is traversed to load the missing data stored in the vocabulary file into the kernel space, including: for each of the vocabulary files, the following steps are performed: based on the virtual memory page address of the current vocabulary file, the page cache area of the kernel space is accessed to obtain an access result; based on the access result, the missing data corresponding to the current vocabulary file is determined; based on the disk address of the current vocabulary file, the corresponding missing data is loaded into the page cache area.
- the word library file corresponds to at least two A physical page of a page cache area, wherein the physical page is used to store vocabulary data;
- the virtual memory page address includes at least two sub-memory page addresses, wherein the sub-memory page address represents the first address of the physical page;
- the virtual memory page address based on the current vocabulary file accesses the page cache area of the kernel space to obtain an access result, including: traversing the corresponding physical pages according to at least two sub-memory page addresses of the current vocabulary file; and reading the first byte of each of the physical pages in turn to obtain the access result.
- determining the missing data corresponding to the current vocabulary file based on the access result includes: if the first byte of the first physical page corresponding to the vocabulary file is non-preset information, determining the data stored in the first physical page as missing data; loading the corresponding missing data into the page cache area based on the disk address of the current vocabulary file includes: obtaining the corresponding first disk address according to the sub-memory page address corresponding to the first physical page; reading the data at the first disk address to obtain the missing data, and loading the missing data into the first physical page.
- the vocabulary file includes at least two file pages, and the file pages are used to store vocabulary data; the virtual memory page address corresponding to the at least one vocabulary file is traversed to load the missing data stored in the vocabulary file into the kernel space, including: for each of the vocabulary files, the file pre-reading mechanism of the Linux kernel is used to traverse the virtual memory page address corresponding to the file page to load the data in at least two consecutive file pages into the kernel space.
- obtaining the virtual address corresponding to the vocabulary data required to execute the input function includes: performing real-time detection on the input method program running in the background; when it is detected that the input method program is called to the foreground to run, obtaining the virtual address corresponding to the vocabulary data required to execute the input function.
- an input method program running device comprising:
- An acquisition module used for acquiring a virtual address corresponding to the word library data required to execute the input function before executing the input function of the input method program;
- a loading module used for loading the word library data into the kernel space corresponding to the virtual address
- the calling module is used to call the target word library data in the kernel space in response to the user instruction to execute the input function corresponding to the user instruction in the input method program.
- the virtual address includes a There is one less virtual memory page address corresponding to the vocabulary file, and the virtual memory page address is mapped one-to-one with the disk address of the vocabulary file; the loading module is specifically used to: traverse the virtual memory page address corresponding to the at least one vocabulary file, and load the missing data stored in the vocabulary file into the kernel space, wherein the missing data is the vocabulary data that has not been copied to the kernel space.
- the loading module traverses the virtual memory page address corresponding to the at least one vocabulary file and loads the missing data stored in the vocabulary file into the kernel space, it is specifically used to: for each of the vocabulary files, perform the following steps: based on the virtual memory page address of the current vocabulary file, access the page cache area of the kernel space to obtain an access result; based on the access result, determine the missing data corresponding to the current vocabulary file; based on the disk address of the current vocabulary file, load the corresponding missing data into the page cache area.
- the vocabulary file corresponds to at least two physical pages located in the page cache area, and the physical pages are used to store vocabulary data;
- the virtual memory page address includes at least two sub-memory page addresses, and the sub-memory page address represents the first address of the physical page;
- the loading module 32 accesses the page cache area of the kernel space based on the virtual memory page address of the current vocabulary file, and when obtaining the access result, it is specifically used to: traverse the corresponding physical pages according to the at least two sub-memory page addresses of the current vocabulary file; read the first byte of each of the physical pages in turn to obtain the access result.
- the loading module determines the missing data corresponding to the current vocabulary file based on the access result, it is specifically used to: if the first byte of the first physical page corresponding to the vocabulary file is non-preset information, then the data stored in the first physical page is determined as missing data; the loading module loads the corresponding missing data into the page cache area based on the disk address of the current vocabulary file, including: obtaining the corresponding first disk address according to the sub-memory page address corresponding to the first physical page; reading the data at the first disk address to obtain the missing data, and loading the missing data into the first physical page.
- the word library file includes at least two file pages, and the file pages are used to store word library data; when the loading module traverses the virtual memory page address corresponding to the at least one word library file and loads the missing data stored in the word library file into the kernel space, it is specifically used to: for each word library file, use the file page of the Linux kernel to load the missing data stored in the word library file into the kernel space;
- the kernel space uses a pre-reading mechanism to traverse the virtual memory page addresses corresponding to the file pages to load data in at least two consecutive file pages into the kernel space.
- the acquisition module is specifically used to: perform real-time detection on the input method program running in the background; when it is detected that the input method program is called up to the foreground to run, acquire the virtual address corresponding to the vocabulary data required to execute the input function.
- an electronic device comprising: a processor, and a memory communicatively connected to the processor;
- the memory stores computer-executable instructions
- the processor executes the computer-executable instructions stored in the memory to implement the input method program running method described in the first aspect and various possible designs of the first aspect.
- a computer-readable storage medium stores computer execution instructions.
- the input method program running method described in the first aspect and various possible designs of the first aspect is implemented.
- an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the input method program running method described in the first aspect and various possible designs of the first aspect.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Document Processing Apparatus (AREA)
- Input From Keyboards Or The Like (AREA)
Abstract
本公开实施例提供一种输入法程序运行方法、装置、电子设备及存储介质,通过在执行输入法程序的输入功能前,获取执行输入功能所需的词库数据对应的虚拟地址;将词库数据加载至虚拟地址对应的内核空间;响应于用户指令,调用内核空间中的目标词库数据,以执行输入法程序中用户指令所对应的输入功能。
Description
相关申请的交叉引用
本申请是以中国申请号为2023104414908,申请日为2023年04月23日的申请为基础,并主张其优先权,该中国申请的公开内容在此作为整体引入本申请中。
本公开实施例涉及计算机技术领域,尤其涉及一种输入法程序运行方法、装置、电子设备及存储介质。
输入法程序是用于人机交互和用户间信息交流的常用程序之一,为了提高输入效率,当前的输入法程序通常配备有众多的词库数据,通过使用词库数据提供的字词信息,可以实现例如拼写、组词、纠错等输入功能。
发明内容
本公开实施例提供一种输入法程序运行方法、装置、电子设备及存储介质。
第一方面,本公开实施例提供一种输入法程序运行方法,包括:
在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;将所述词库数据加载至所述虚拟地址对应的内核空间;响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
第二方面,本公开实施例提供一种输入法程序运行装置,包括:
获取模块,用于在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;
加载模块,用于将所述词库数据加载至所述虚拟地址对应的内核空间;
调用模块,用于响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
第三方面,本公开实施例提供一种电子设备,包括:
处理器,以及与所述处理器通信连接的存储器;
所述存储器存储计算机执行指令;
所述处理器执行所述存储器存储的计算机执行指令,以实现如上第一方面以及第一方面各种可能的设计所述的输入法程序运行方法。
第四方面,本公开实施例提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的输入法程序运行方法。
第五方面,本公开实施例提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现如上第一方面以及第一方面各种可能的设计所述的输入法程序运行方法。
本实施例提供的输入法程序运行方法、装置、电子设备及存储介质,通过在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;将所述词库数据加载至所述虚拟地址对应的内核空间;响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
为了更清楚地说明本公开实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本公开实施例提供的一种输入法程序的执行过程示意图;
图2为本公开实施例提供的输入法程序运行方法的流程示意图一;
图3为图2所示实施例中步骤S101的具体实现方式的流程图;
图4为本公开实施例提供的一种获取词库数据的虚拟地址的过程示意图;
图5为图2所示实施例中步骤S102的具体实现方式的流程图;
图6为本公开实施例提供的一种执行输入功能的过程示意图;
图7为本公开实施例提供的输入法程序运行方法的流程示意图二;
图8为图7所示实施例中步骤S202的具体实现方式的流程图;
图9为本公开实施例提供的一种确定缺失数据的过程示意图;
图10为图7所示实施例中步骤S204的具体实现方式的流程图;
图11为本公开实施例提供的输入法程序运行装置的结构框图;
图12为本公开实施例提供的一种电子设备的结构示意图;
图13为本公开实施例提供的电子设备的硬件结构示意图。
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。
需要说明的是,本公开所涉及的用户信息(包括但不限于用户设备信息、用户个人信息等)和数据(包括但不限于用于分析的数据、存储的数据、展示的数据等),均为经用户授权或者经过各方充分授权的信息和数据,并且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准,并提供有相应的操作入口,供用户选择授权或者拒绝。
下面对本公开实施例的应用场景进行解释:
本公开实施例提供的输入法程序运行方法,可以应用于调用输入法程序进行信息输入的场景。具体地,本公开实施例提供的方法,可以应用于终端设备,图1为本公开实施例提供的一种输入法程序的执行过程示意图,如图1所示,终端设备的磁盘空间(硬盘)内存储有输入法程序的词库文件,终端设备在启动输入法程序后,会将磁盘中的词库文件中的词库数据拷贝至内存中的内核空间,之后,建立用户空间与磁盘空间的映射关系,当执行输入法程序的输入功能而需要使用词库数据时,通过页表从内核空间中获得与词库文件相对应的词库数据,即以文件映射的方式加载词库数据。之后响应于用户指令,利用词库数据完成输入功能的执行,例如实现拼写、组成、纠错
等输入法程序的输入功能。
相关技术中,针对上述以文件映射方式加载词库数据的技术方案,在词库数据被拷贝至内核空间后,利用内核空间能够实现数据高速缓存的特性,可以实现词库数据的快速调取,但另一方面,由于内核空间被所有进程所共享,当输入法程序处于后台闲置状态时,操作系统会对内核空间的资源进行回收,导致存储在内核空间(物理内存)中的词库数据被清楚。当输入法程序再次被调起而执行输入功能时,输入法程序(对应的线程)通过已建立映射的虚拟地址访问物理页上的词库数据,此时,由于虚拟地址访问对应物理页上缺少词库数据,导致中央处理器(CPU)的内存管理单元发出中断指令,即出现缺页中断。在出现缺页中断时,操作系统需要从磁盘上重新读取词库文件而获得词库数据,并重新拷贝至内核空间后,再基于内核空间中的词库数据,执行后续的输入功能,该过程导致词库数据的调用耗时增加,进而影响输入法程序的运行流畅度和稳定性。本公开实施例提供一种输入法程序运行方法以解决上述问题。
词库数据通常需要预先加载至内存中,以供输入法程序进行调用,然而,相关技术中加载至内存中的词库数据,会在内存资源紧张的情况下被操作系统清空,导致词库调用的耗时增加的问题,进而影响输入法程序的运行流畅度和稳定性。
参考图2,图2为本公开实施例提供的输入法程序运行方法的流程示意图一。本实施例的方法可以应用在终端设备中,该输入法程序运行方法包括:
步骤S101:在执行输入法程序的输入功能前,获取执行输入功能所需的词库数据对应的虚拟地址。
示例性地,参考图1所示的输入法程序的执行过程示意图,在输入法程序运行后、执行输入功能前,获取词库数据对应的虚拟地址,其中,虚拟地址是表征词库数据的数据位置的信息,输入法程序通过虚拟地址来获取到词库数据,并利用词库数据执行后续的输入功能,例如,例如词库数据进行组词、词语纠错等。其中,虚拟地址位于虚拟地址空间内,虚拟地址空间也称为进程地址空间,是操作系统内核中的一个数据结构,是由进程(例如输入法程序进程)的虚地址构成的地址空间,虚拟地址空间和进程地址空间为本领域技术人员知晓的技术概念,词库数据对应的虚拟地址,由输入法程序的
具体运行情况决定的,词库数据对应的虚拟地址可以通过调用具体的虚拟地址查询函数得到,为本领域技术人员知晓的相关技术,以上内容为此不再一一举例赘述。
进一步地,输入法程序的输入功能,是指输入法程序通过接收用户输入的输入信息(例如键盘信息、语音信息等),生成文字、数字、标识等内容信息的功能,即输入法程序的主体功能,输入功能是一种前台运行功能,即在执行输入法功能时,输入法程序需要运行于系统前台,即处于调起状态;与之相对的,输入法程序还可以包括更新功能、推送功能等可以运行于系统后台、无需调起即可执行的非主体功能,其中,与更新功能、推送功能等非主体功能不同的时,输入功能的实现需要词库数据的支持,输入法程序需要基于词库数据,将用户输入的输入信息转换成对应的文字、数字,并按需要进行显示,以实现基本的文字输入功能。因此,在一种可能的实现方式中,获取执行输入功能所需的词库数据对应的虚拟地址的时机,可以是输入法程序被调起至前台运行时。示例性地,如图3所示,步骤S101的具体实现方式包括:
步骤S1011:对处于后台运行的输入法程序进行实时检测;
步骤S1012:当检测到输入法程序被调起至前台运行时,获取执行输入功能所需的词库数据对应的虚拟地址。
示例性地,在输入法程序启动后,在不进行文字输入的情况下,输入法程序在系统后台运行,一种更具体地实现方式中,在操作系统运行后,输入法程序启动并常驻在系统后台运行,当需要进行文字输入时,例如用户点选可网页、软件中的编辑文本栏(edit_text),操作系统将输入法程序从后台调起至前台运行,并显示输入法程序的输入界面。图4为本公开实施例提供的一种获取词库数据的虚拟地址的过程示意图,参考图4所示,终端设备(例如为智能手机)运行浏览器程序时,当接收到用户针对地址栏的点选操作后,调起输入法程序,并显示输入法程序的输入界面,与此同时,终端设备(输入法程序)在检测到输入界面被调起并显示后,获取词库数据的虚拟地址,之后,之后基于词库数据的虚拟地址,将词库数据加载至内核空间。再之后,用户可进一步通过操作该输入法程序的输入界面,输入键盘信息,例如单击“GHI”键,输入法程序利用词库数据执行输入功能(组词功能),在输入法
界面内显示包含有“h”字母的词语,例如图中所示的“hi”、“happy”、“http”等。其中,该词库数据的虚拟地址在输入法程序启动后是已知的预设信息,可以直接读取该预设的词库数据的虚拟地址,具体过程不再赘述。
步骤S102:将词库数据加载至虚拟地址对应的内核空间。
示例性地,在得到词库数据对应的虚拟地址后,在一种可能的情况下,若内核空间中已存储有上述词库数据,则终端设备基于该虚拟地址,可以直接获得上述词库数据,之后利用词库数据完成组词、纠错等输入功能。此种可能的情况通常是在输入法程序处于前台运行的情况下,操作系统不会对处于调起状态的应用程序所使用的内存数据进行清理和回收,因此可以直接基于虚拟地址获得对应的词库数据。而在另一种可能的情况下,若内核空间中未存储有上述词库数据,则终端设备基于该虚拟地址,无法在内核空间中直接获得上述词库数据,进而会导致缺页中断(也称为硬缺页中断、硬中断、硬错误)。此种情况下,终端设备从磁盘中获取上述词库数据,并加载至虚拟地址对应的内核空间中,此时由于输入法程序还未开始执行输入功能,即未调用词库数据,相当于实现了对词库数据的预载入,从而避免在后续步骤中,当需要使用调用词库数据来执行输入功能时产生的缺页中断问题。
进一步地,示例性地,虚拟地址包括存储词库数据的至少一个词库文件所对应的虚拟内存页地址,虚拟内存页地址与词库文件的磁盘地址一一映射,如图5所示,示例性地,步骤S102的具体实现方式包括:
步骤S1021:针对至少一个词库文件对应的虚拟内存页地址进行遍历,确定词库文件中所存储的缺失数据,其中,缺失数据为未被拷贝至内核空间的词库数据。
步骤S1022:将词库文件中所存储的缺失数据加载至内核空间。
示例性地,执行输入功能所需要的词库数据,以词库文件的形式存储在磁盘中,之后基于用户空间与磁盘空间的映射关系,使输入法程序获得执行输入功能所需的词库数据,即以文件映射的方式加载词库数据。其中,词库文件的磁盘地址与虚拟内存页地址对应,虚拟内存页地址是指虚拟内存所对应的虚拟内存页的地址,虚拟内存是一种将硬盘空间作为内存来使用的相关技术,此处不再赘述,而虚拟内存页地址是用于描述上述虚拟内存页的连续地址位置的信息,由于虚拟内存页是被虚拟出来的,因此其对应的虚拟内存
页地址也是虚拟的,与实际的物理内存页的地址并不统一。
进一步地,正常情况下(内存数据未被操作系统清理),通过虚拟内存页地址可以从内核空间中的相应位置获得词库文件中存储的词库数据,因此,终端设备通过遍历虚拟内存页地址,即依次访问各虚拟内存页地址,根据操作系统返回的访问结果,可以确定对应的内核空间中,是否包含有响应的词库数据,例如,若操作系统返回的访问结果为大于0小于或等于127之间的整型,则确定该虚拟内存页地址对应的词库文件中存储的数据为正常的词库数据;若操作系统返回的访问结果为0,或者Null,则确定该虚拟内存页地址对应的词库文件中存储的数据为缺失数据。其中,缺失数据为未被拷贝至内核空间的词库数据。
进一步地,若词库文件中所存储的数据为缺失数据,则基于预设的页表获取该词库文件(虚拟内存页地址)对应的磁盘地址,并从磁盘地址读取词库数据,拷贝至内核空间,实现将词库文件中所存储的缺失数据加载至内核空间。最终,使执行输入功能所需的词库数据均加载至虚拟地址对应的内核空间,避免后续出现的缺页中断问题。
其中,示例性地,本实施例所提供的方法,可以应用于linux系统,或者基于linux系统的操作系统中,具体地,在针对每一词库文件对应的虚拟内存页地址进行遍历时,利用linux内核的文件预读取机制,对文件页对应的虚拟内存页地址进行遍历,以将至少两个连续的文件页中的数据加载至内核空间,其中,词库文件由至少两个文件页构成,每一文件页用于存储一部分词库数据,通过上述方式,利用linux内核的文件预读取机制可以高效的预读文件的优点,提高词库数据加载至内核空间的速度。
步骤S103:响应于用户指令,调用内核空间中的目标词库数据,以执行输入法程序中用户指令所对应的输入功能。
示例性地,进一步地,在将执行输入功能所需的词库数据均加载至虚拟地址对应的内核空间后,响应于用于触发输入功能的用户指令,从内核空间中调用用于执行用户指令所触发的输入功能的目标词库数据,来实现用户指令所对应的输入功能。其中,词库数据可以是包含有具体的函数、方法和数据的功能模型,其具有对应的调用接口(API),通过调用接口来实现对词库数据的调用,从而实现词库数据的词库功能,进而根据一个或多个词库数据
的词库功能的集合,实现对应的输入功能。图6为本公开实施例提供的一种执行输入功能的过程示意图,如图6所示,示例性地,用户指令comm_1中包括键盘信息字母“z”和字母“m”(图中示为comm_1[z,m]),用户指令comm_1用于指示输入法程序基于上述键盘信息来生成对应的词组。终端设备(输入法程序)根据上述用户指令comm_1,调用内核空间中的词库数据pack_1和词库数据pack_3作为目标词库数据,来对用户指令comm_1进行处理,其中,词库数据pack_1用于将键盘信息作为首字母进行组词,生成汉字词语;词库数据pack_3用于根据键盘信息对汉字词语进行纠错,得到常用汉字词语。最终将常用汉字词语显示在终端设备的显示界面上,输入功能执行完毕。
在本实施例中,通过在执行输入法程序的输入功能前,获取执行输入功能所需的词库数据对应的虚拟地址;将词库数据加载至虚拟地址对应的内核空间;响应于用户指令,调用内核空间中的目标词库数据,以执行输入法程序中用户指令所对应的输入功能。通过在执行输入法程序的输入功能前,获取虚拟地址,并基于虚拟地址预加载词库数据,从而在响应用户指令执行输入功能时,可以直接从内核空间以文件映射的方式获得对应的目标词库数据,避免了由于内存清空而引发的硬缺页中断的问题,降低输入法程序调用词库数据的整体耗时,减少卡顿,提高输入法程序的输入功能的稳定性和运行流畅度。
参考图7,图7为本公开实施例提供的输入法程序运行方法的流程示意图二。本实施例在图2所示实施例的基础上,对步骤S102进一步细化,该输入法程序运行方法包括:
步骤S201:在执行输入法程序的输入功能前,获取执行输入功能所需的词库数据对应的虚拟地址,虚拟地址包括存储词库数据的至少一个词库文件所对应的虚拟内存页地址,虚拟内存页地址与词库文件的磁盘地址一一映射。
步骤S202:基于当前的词库文件的虚拟内存页地址,访问内核空间的页高速缓存区,得到访问结果。
示例性地,页高速缓存区是内存中用于存储部分磁盘数据的区域,通过页高速缓存区,可以实现允许操作系统把通常存放在磁盘上的一些数据保留在内存的内核区域中,以便于在需要访问磁盘时,可以从页高速缓存区获取
相应的数据,而无需从磁盘读取数据,从而提高数据读写速度。使用文件映射的方式加载输入法程序所使用的词库文件的场景下,各词库文件均对应一个虚拟内存页地址,虚拟内存页地址在图2所示实施例中已进行详细介绍,此处不再赘述。针对每一词库文件进行循环遍历,依次获取每一词库文件的虚拟内存页地址,具体地,这一次具体的循环过程中,基于当前的词库文件的虚拟内存页地址,可以得到该虚拟内存页地址所对应的页高速缓存区的地址,也即页高速缓存区内存储虚拟内存页地址对应的词库数据的地址,进而对每一虚拟内存页地址所对应的页高速缓存区的地址进行访问,得到的访问结果即该地址处的数据。
其中,在一种可能的实现方式中,词库文件对应至少两个位于页高速缓存区的物理页,物理页用于存储词库数据;虚拟内存页地址包括至少两个子内存页地址,子内存页地址表征物理页的首地址。如图8所示,步骤S202的具体实现方式包括:
步骤S2021:根据当前的词库文件的至少两个子内存页地址,遍历对应的物理页。
步骤S2022:依次读取每一物理页的首字节,得到访问结果。
示例性地,页高速缓存区由物理页构成,虚拟内存页地址由至少两个子内存页地址构成,物理页的位置与子内存页地址一一对应,即通过子内存页地址映射至物理页。在遍历各词库文件的过程中,针对每一词库文件,分别基于对应的子内存页地址,访问对应的物理页,并读取每一物理页的首字节,并根据读取的首字节的内容,得到访问结果。
步骤S203:根据访问结果,确定当前的词库文件对应的缺失数据,其中,缺失数据为未被拷贝至内核空间的词库数据。
示例性地,步骤S203的具体实现方式包括:若词库文件对应的第一物理页的首字节为非预设信息,则将第一物理页所存储的数据,确定为缺失数据。
图9为本公开实施例提供的一种确定缺失数据的过程示意图,如图9所示,示例性地,针对词库文件File_1的过程,词库文件File_1对应多个物理页,例如图中所示的物理页p1、物理页p2、物理页p3等。根据子内存页地址,分别读取物理页p1的首字节、物理页p2的首字节、物理页p3的首字节,分别得到物理页p1的首字节的内容为[01000100];物理页p2的首字节的内容
为[01100101];物理页p3的首字节的内容为[00000000];其中,[00000000]为非预设信息,因此,在读取物理页p3的首字节后,将物理页p3确定为第一物理页,物理页p3所存储的数据,确定为缺失数据。之后,从磁盘空间中获取该物理页p3对应的词库数据(缺失数据),并加载至内核空间,完成输入法程序所需的词库数据的补全。
本实施例中,通过将词库文件映射为多个物理页,并基于对物理页的首字节的访问结果,确对应的物理页是否为缺失数据,实现了对词库文件中所保存的词库数据的分段加载、快速判断。有效提高了确定缺失数据的确定速度,从而降低了遍历全部词库文件所需的耗时,提高词库数据的加载效率。
步骤S204:基于当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区。
示例性地,在得到缺失数据后,从磁盘中获取缺失数据对应的物理页,并加载至内核空间,完成输入法程序所需的词库数据的补全。如图10所示,步骤S204的具体实现方式包括:
步骤S2041:根据第一物理页对应的子内存页地址,获得对应的第一磁盘地址。
步骤S2042:读取第一磁盘地址处的数据,得到缺失数据,并将缺失数据加载至第一物理页。
示例性地,第一物理页即存储缺失数据的物理页,基于上述步骤,在根据物理页的首字节确定出第一物理页后,根据第一物理页对应的子内存页地址,获得对应的第一磁盘地址,内存页地址和磁盘地址之间的映射关系通过预设的页表确定。其中,词库文件包括至少两个文件页,文件页用于存储词库数据,第一磁盘地址是词库文件的文件页的首地址。即高速缓存页中的物理页和磁盘中构成词库文件的文件页是一一对应的关系。文件页是对词库文件进行分割的结果,物理页是文件页加载至内存后的数据对象,磁盘地址是文件页的地址,第一磁盘地址即第一物理页对应的第一文件页的地址。因此,获得内存页地址对应的第一磁盘地址后,读取第一磁盘地址处的数据,即第一文件页,第一文件页中保持的数据,即缺失数据。之后,将第一文件页中的确实数据,加载至页高速缓存区中的第一物理页,完成将缺失数据加载至页高速缓存区的过程。
步骤S205:若当前的词库文件为最后一个词库文件,则执行步骤S206;否则,定位至下一个词库文件,并返回步骤S202。
进一步地,在处理完当前的词库文件后,若当前词库文件为输入法程序配置的所有词库文件的非最后一个词库文件,在继续定位至下一个词库文件,并返回步骤S202循环执行上述步骤对词库文件进行处理,以使输入功能对应的缺失数据能够被加载至内存中待用;若该词库文件为输入法程序配置的所有词库文件的最后一个词库文件,则说明所有词库文件均已处理完毕,此时,可以保证所有词库文件中存储的词库数据已被全部加载至内存中待用,此种情况下可以避免出现缺页中断的问题,因此可以结束循环,执行后续输入功能调用的步骤。
步骤S206:响应于用户指令,调用内核空间中的目标词库数据,以执行输入法程序中用户指令所对应的输入功能。
在本实施例中,步骤S201和步骤S206与图2所示实施例中的步骤S101、步骤S103的一致,详细论述请参考步骤图2所示实施例中内容,这里不再赘述。
对应于上文实施例的输入法程序运行方法,图11为本公开实施例提供的输入法程序运行装置的结构框图。为了便于说明,仅示出了与本公开实施例相关的部分。参照图11,输入法程序运行装置3包括:
获取模块31,用于在执行输入法程序的输入功能前,获取执行输入功能所需的词库数据对应的虚拟地址;
加载模块32,用于将词库数据加载至虚拟地址对应的内核空间;
调用模块33,用于响应于用户指令,调用内核空间中的目标词库数据,以执行输入法程序中用户指令所对应的输入功能。
在本公开的一个实施例中,虚拟地址包括存储词库数据的至少一个词库文件所对应的虚拟内存页地址,虚拟内存页地址与词库文件的磁盘地址一一映射;加载模块32,具体用于:针对至少一个词库文件对应的虚拟内存页地址进行遍历,将词库文件中所存储的缺失数据加载至内核空间,其中,缺失数据为未被拷贝至内核空间的词库数据。
在本公开的一个实施例中,加载模块32在针对至少一个词库文件对应的虚拟内存页地址进行遍历,将词库文件中所存储的缺失数据加载至内核空间
时,具体用于:针对每一词库文件,执行以下步骤:基于当前的词库文件的虚拟内存页地址,访问内核空间的页高速缓存区,得到访问结果;根据访问结果,确定当前的词库文件对应的缺失数据;基于当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区。
在本公开的一个实施例中,词库文件对应至少两个位于页高速缓存区的物理页,物理页用于存储词库数据;虚拟内存页地址包括至少两个子内存页地址,子内存页地址表征物理页的首地址;加载模块32在基于当前的词库文件的虚拟内存页地址,访问内核空间的页高速缓存区,得到访问结果时,具体用于:根据当前的词库文件的至少两个子内存页地址,遍历对应的物理页;依次读取每一物理页的首字节,得到访问结果。
在本公开的一个实施例中,加载模块32在根据访问结果,确定当前的词库文件对应的缺失数据时,具体用于:若词库文件对应的第一物理页的首字节为非预设信息,则将第一物理页所存储的数据,确定为缺失数据;加载模块32基于当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区,包括:根据第一物理页对应的子内存页地址,获得对应的第一磁盘地址;读取第一磁盘地址处的数据,得到缺失数据,并将缺失数据加载至第一物理页。
在本公开的一个实施例中,词库文件包括至少两个文件页,文件页用于存储词库数据;加载模块32在针对至少一个词库文件对应的虚拟内存页地址进行遍历,将词库文件中所存储的缺失数据加载至内核空间时,具体用于:针对每一词库文件,利用linux内核的文件预读取机制,对文件页对应的虚拟内存页地址进行遍历,以将至少两个连续的文件页中的数据加载至内核空间。
在本公开的一个实施例中,获取模块31,具体用于:对处于后台运行的输入法程序进行实时检测;当检测到输入法程序被调起至前台运行时,获取执行输入功能所需的词库数据对应的虚拟地址。
其中,获取模块31、加载模块32和调用模块33依次连接。本实施例提供的输入法程序运行装置3可以执行上述方法实施例的技术方案,其实现原理和技术效果类似,本实施例此处不再赘述。
图12为本公开实施例提供的一种电子设备的结构示意图,如图12所示,该电子设备7包括:
处理器41,以及与处理器41通信连接的存储器42;
存储器42存储计算机执行指令;
处理器41执行存储器42存储的计算机执行指令,以实现如图2-图10所示实施例中的输入法程序运行方法。
其中,可选地,处理器41和存储器42通过总线43连接。
相关说明可以对应参见图2-图10所对应的实施例中的步骤所对应的相关描述和效果进行理解,此处不做过多赘述。
本公开实施例提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,计算机执行指令被处理器执行时用于实现本公开图2-图10所对应的实施例中任一实施例提供的输入法程序运行方法。
本公开实施例提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现如图2-图10所示实施例中的输入法程序运行方法。
参考图13,其示出了适于用来实现本公开实施例的电子设备900的结构示意图,该电子设备900可以为终端设备或服务器。其中,终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、个人数字助理(Personal Digital Assistant,简称PDA)、平板电脑(Portable Android Device,简称PAD)、便携式多媒体播放器(Portable Media Player,简称PMP)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图13示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图13所示,电子设备900可以包括处理装置(例如中央处理器、图形处理器等)901,其可以根据存储在只读存储器(Read Only Memory,简称ROM)902中的程序或者从存储装置908加载到随机访问存储器(Random Access Memory,简称RAM)903中的程序而执行各种适当的动作和处理。在RAM 903中,还存储有电子设备900操作所需的各种程序和数据。处理装置901、ROM 902以及RAM 903通过总线904彼此相连。输入/输出(I/O)接口905也连接至总线904。
通常,以下装置可以连接至I/O接口905:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置906;包括例如液晶显示器(Liquid Crystal Display,简称LCD)、扬声器、振动器等的
输出装置907;包括例如磁带、硬盘等的存储装置908;以及通信装置909。通信装置909可以允许电子设备900与其他设备进行无线或有线通信以交换数据。虽然图13示出了具有各种装置的电子设备900,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置909从网络上被下载和安装,或者从存储装置908被安装,或者从ROM 902被安装。在该计算机程序被处理装置901执行时,执行本公开实施例的方法中限定的上述功能。
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备执行上述实施例所示的方法。
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(Local Area Network,简称LAN)或广域网(Wide Area Network,简称WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在某种情况下并不构成对该单元本身的限定,例如,第一获取单元还可以被描述为“获取至少两个网际协议地址的单元”。
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可
编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。
第一方面,根据本公开的一个或多个实施例,提供了一种输入法程序运行方法,包括:
在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;将所述词库数据加载至所述虚拟地址对应的内核空间;响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
根据本公开的一个或多个实施例,所述虚拟地址包括存储词库数据的至少一个词库文件所对应的虚拟内存页地址,所述虚拟内存页地址与所述词库文件的磁盘地址一一映射;所述将所述词库数据加载至所述虚拟地址对应的内核空间,包括:针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,其中,所述缺失数据为未被拷贝至内核空间的词库数据。
根据本公开的一个或多个实施例,所述针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,包括:针对每一所述词库文件,执行以下步骤:基于当前的词库文件的虚拟内存页地址,访问所述内核空间的页高速缓存区,得到访问结果;根据所述访问结果,确定所述当前的词库文件对应的缺失数据;基于所述当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区。
根据本公开的一个或多个实施例,所述词库文件对应至少两个位于所述
页高速缓存区的物理页,所述物理页用于存储词库数据;所述虚拟内存页地址包括至少两个子内存页地址,所述子内存页地址表征所述物理页的首地址;所述基于当前的词库文件的虚拟内存页地址,访问所述内核空间的页高速缓存区,得到访问结果,包括:根据当前的词库文件的至少两个子内存页地址,遍历对应的物理页;依次读取每一所述物理页的首字节,得到所述访问结果。
根据本公开的一个或多个实施例,所述根据所述访问结果,确定所述当前的词库文件对应的缺失数据,包括:若所述词库文件对应的第一物理页的首字节为非预设信息,则将所述第一物理页所存储的数据,确定为缺失数据;所述基于所述当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区,包括:根据所述第一物理页对应的子内存页地址,获得对应的第一磁盘地址;读取所述第一磁盘地址处的数据,得到所述缺失数据,并将所述缺失数据加载至所述第一物理页。
根据本公开的一个或多个实施例,所述词库文件包括至少两个文件页,所述文件页用于存储词库数据;所述针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,包括:针对每一所述词库文件,利用linux内核的文件预读取机制,对所述文件页对应的虚拟内存页地址进行遍历,以将至少两个连续的文件页中的数据加载至所述内核空间。
根据本公开的一个或多个实施例,所述在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址,包括:对处于后台运行的所述输入法程序进行实时检测;当检测到所述输入法程序被调起至前台运行时,获取执行所述输入功能所需的词库数据对应的虚拟地址。
第二方面,根据本公开的一个或多个实施例,提供了一种输入法程序运行装置,包括:
获取模块,用于在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;
加载模块,用于将所述词库数据加载至所述虚拟地址对应的内核空间;
调用模块,用于响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
根据本公开的一个或多个实施例,所述虚拟地址包括存储词库数据的至
少一个词库文件所对应的虚拟内存页地址,所述虚拟内存页地址与所述词库文件的磁盘地址一一映射;所述加载模块,具体用于:针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,其中,所述缺失数据为未被拷贝至内核空间的词库数据。
根据本公开的一个或多个实施例,所述加载模块在针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间时,具体用于:针对每一所述词库文件,执行以下步骤:基于当前的词库文件的虚拟内存页地址,访问所述内核空间的页高速缓存区,得到访问结果;根据所述访问结果,确定所述当前的词库文件对应的缺失数据;基于所述当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区。
根据本公开的一个或多个实施例,所述词库文件对应至少两个位于所述页高速缓存区的物理页,所述物理页用于存储词库数据;所述虚拟内存页地址包括至少两个子内存页地址,所述子内存页地址表征所述物理页的首地址;所述加载模块32在基于当前的词库文件的虚拟内存页地址,访问所述内核空间的页高速缓存区,得到访问结果时,具体用于:根据当前的词库文件的至少两个子内存页地址,遍历对应的物理页;依次读取每一所述物理页的首字节,得到所述访问结果。
根据本公开的一个或多个实施例,所述加载模块在根据访问结果,确定所述当前的词库文件对应的缺失数据时,具体用于:若所述词库文件对应的第一物理页的首字节为非预设信息,则将所述第一物理页所存储的数据,确定为缺失数据;所述加载模块基于所述当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区,包括:根据所述第一物理页对应的子内存页地址,获得对应的第一磁盘地址;读取所述第一磁盘地址处的数据,得到所述缺失数据,并将所述缺失数据加载至所述第一物理页。
根据本公开的一个或多个实施例,所述词库文件包括至少两个文件页,所述文件页用于存储词库数据;所述加载模块在针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间时,具体用于:针对每一所述词库文件,利用linux内核的文
件预读取机制,对所述文件页对应的虚拟内存页地址进行遍历,以将至少两个连续的文件页中的数据加载至所述内核空间。
根据本公开的一个或多个实施例,所述获取模块,具体用于:对处于后台运行的所述输入法程序进行实时检测;当检测到所述输入法程序被调起至前台运行时,获取执行所述输入功能所需的词库数据对应的虚拟地址。
第三方面,根据本公开的一个或多个实施例,提供了一种电子设备,包括:处理器,以及与所述处理器通信连接的存储器;
所述存储器存储计算机执行指令;
所述处理器执行所述存储器存储的计算机执行指令,以实现如上第一方面以及第一方面各种可能的设计所述的输入法程序运行方法。
第四方面,根据本公开的一个或多个实施例,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的输入法程序运行方法。
第五方面,本公开实施例提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现如上第一方面以及第一方面各种可能的设计所述的输入法程序运行方法。
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。
Claims (12)
- 一种输入法程序运行方法,包括:在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;将所述词库数据加载至所述虚拟地址对应的内核空间;响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
- 根据权利要求1所述的方法,其中所述虚拟地址包括存储词库数据的至少一个词库文件所对应的虚拟内存页地址,所述虚拟内存页地址与所述词库文件的磁盘地址一一映射;所述将所述词库数据加载至所述虚拟地址对应的内核空间,包括:针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,其中,所述缺失数据为未被拷贝至内核空间的词库数据。
- 根据权利要求2所述的方法,其中所述针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,包括:针对每一所述词库文件,执行以下步骤:基于当前的词库文件的虚拟内存页地址,访问所述内核空间的页高速缓存区,得到访问结果;根据所述访问结果,确定所述当前的词库文件对应的缺失数据;基于所述当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区。
- 根据权利要求3所述的方法,其中所述词库文件对应至少两个位于所述页高速缓存区的物理页,所述物理页用于存储词库数据;所述虚拟内存页地址包括至少两个子内存页地址,所述子内存页地址表征所述物理页的首地址;所述基于当前的词库文件的虚拟内存页地址,访问所述内核空间的页高速缓存区,得到访问结果,包括:根据当前的词库文件的至少两个子内存页地址,遍历对应的物理页;依次读取每一所述物理页的首字节,得到所述访问结果。
- 根据权利要求3或4所述的方法,其中所述根据所述访问结果,确定所述当前的词库文件对应的缺失数据,包括:若所述词库文件对应的第一物理页的首字节为非预设信息,则将所述第一物理页所存储的数据,确定为缺失数据;所述基于所述当前的词库文件的磁盘地址,将对应的缺失数据加载至页高速缓存区,包括:根据所述第一物理页对应的子内存页地址,获得对应的第一磁盘地址;读取所述第一磁盘地址处的数据,得到所述缺失数据,并将所述缺失数据加载至所述第一物理页。
- 根据权利要求2-5中的任一项所述的方法,其中所述词库文件包括至少两个文件页,所述文件页用于存储词库数据;所述针对所述至少一个词库文件对应的虚拟内存页地址进行遍历,将所述词库文件中所存储的缺失数据加载至所述内核空间,包括:针对每一所述词库文件,利用linux内核的文件预读取机制,对所述文件页对应的虚拟内存页地址进行遍历,以将至少两个连续的文件页中的数据加载至所述内核空间。
- 根据权利要求1-6中的任一项所述的方法,其中所述在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址,包括:对处于后台运行的所述输入法程序进行实时检测;当检测到所述输入法程序被调起至前台运行时,获取执行所述输入功能所需的词库数据对应的虚拟地址。
- 一种输入法程序运行装置,包括:获取模块,用于在执行输入法程序的输入功能前,获取执行所述输入功能所需的词库数据对应的虚拟地址;加载模块,用于将所述词库数据加载至所述虚拟地址对应的内核空间;调用模块,用于响应于用户指令,调用所述内核空间中的目标词库数据,以执行所述输入法程序中所述用户指令所对应的输入功能。
- 一种电子设备,包括:处理器,以及与所述处理器通信连接的存储器;所述存储器存储计算机执行指令;所述处理器执行所述存储器存储的计算机执行指令,以实现如权利要求1至7中任一项所述的输入法程序运行方法。
- 一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如权利要求1至7任一项所述的输入法程序运行方法。
- 一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现权利要求1至7中任一项所述的输入法程序运行方法。
- 一种计算机程序,该计算机程序被处理器执行时实现权利要求1至7中任一项所述的输入法程序运行方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310441490.8 | 2023-04-23 | ||
| CN202310441490.8A CN118838669A (zh) | 2023-04-23 | 2023-04-23 | 输入法程序运行方法、装置、电子设备及存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024222525A1 true WO2024222525A1 (zh) | 2024-10-31 |
Family
ID=93148790
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/088042 Ceased WO2024222525A1 (zh) | 2023-04-23 | 2024-04-16 | 输入法程序运行方法、装置、电子设备及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN118838669A (zh) |
| WO (1) | WO2024222525A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119292730A (zh) * | 2024-12-12 | 2025-01-10 | 厦门拓宝科技有限公司 | 多语言单片机的词库管理与切换方法 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103853665A (zh) * | 2012-12-03 | 2014-06-11 | 华为技术有限公司 | 存储空间分配方法及设备 |
| US10489302B1 (en) * | 2015-12-29 | 2019-11-26 | Amazon Technologies, Inc. | Emulated translation unit using a management processor |
| CN112445767A (zh) * | 2020-11-30 | 2021-03-05 | 平安科技(深圳)有限公司 | 内存管理方法及装置、电子设备、存储介质 |
| CN115687185A (zh) * | 2022-10-26 | 2023-02-03 | 青岛民航凯亚系统集成有限公司 | 基于mmap内存映射的手持端低功耗数据采集方法 |
| CN115858047A (zh) * | 2023-02-28 | 2023-03-28 | 荣耀终端有限公司 | 一种预加载文件页的方法、电子设备及芯片系统 |
-
2023
- 2023-04-23 CN CN202310441490.8A patent/CN118838669A/zh active Pending
-
2024
- 2024-04-16 WO PCT/CN2024/088042 patent/WO2024222525A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103853665A (zh) * | 2012-12-03 | 2014-06-11 | 华为技术有限公司 | 存储空间分配方法及设备 |
| US10489302B1 (en) * | 2015-12-29 | 2019-11-26 | Amazon Technologies, Inc. | Emulated translation unit using a management processor |
| CN112445767A (zh) * | 2020-11-30 | 2021-03-05 | 平安科技(深圳)有限公司 | 内存管理方法及装置、电子设备、存储介质 |
| CN115687185A (zh) * | 2022-10-26 | 2023-02-03 | 青岛民航凯亚系统集成有限公司 | 基于mmap内存映射的手持端低功耗数据采集方法 |
| CN115858047A (zh) * | 2023-02-28 | 2023-03-28 | 荣耀终端有限公司 | 一种预加载文件页的方法、电子设备及芯片系统 |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119292730A (zh) * | 2024-12-12 | 2025-01-10 | 厦门拓宝科技有限公司 | 多语言单片机的词库管理与切换方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN118838669A (zh) | 2024-10-25 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110489101B (zh) | 接口模拟方法、系统、介质和电子设备 | |
| US8856742B2 (en) | Distributed debugging | |
| CN114089920B (zh) | 数据存储方法、装置、可读介质及电子设备 | |
| EP4502801A1 (en) | Method, apparatus, device and storage medium for data request processing | |
| CN110502357A (zh) | 一种栈回溯方法、装置、介质和设备 | |
| EP4495794A1 (en) | Method, apparatus and device for data shuffling, computer-readable storage medium and product | |
| CN120596155A (zh) | 针对未对齐的存储器操作将存储器访问加宽至对齐的地址 | |
| WO2024222525A1 (zh) | 输入法程序运行方法、装置、电子设备及存储介质 | |
| US11385827B1 (en) | Creating virtual machine snapshots without interfering with active user sessions | |
| KR100532417B1 (ko) | 디지털 신호 처리장치의 저전력 소비형 캐시 메모리 장치및 이에 대한 제어방법 | |
| US20250181377A1 (en) | Request processing method and apparatus, electronic device, and storage medium | |
| WO2023071158A1 (zh) | 内存优化方法、装置、终端、存储介质 | |
| CN117891624B (zh) | 基于虚拟化设备的应用间通信方法、装置及电子设备 | |
| CN118573950A (zh) | 视频帧存储方法、视频播放器、终端及可读存储介质 | |
| CN114625433B (zh) | 应用程序启动方法和系统 | |
| CN111881212A (zh) | 执行检查点操作的方法、装置、设备及存储介质 | |
| CN117389831A (zh) | 内存错误检测方法、设备及存储介质 | |
| CN118069665A (zh) | 数据处理方法、设备、存储介质及程序产品 | |
| CN115242862A (zh) | 网络请求控制方法、装置、介质以及电子设备 | |
| CN114968535A (zh) | 一种数据传输方法、装置、电子设备及介质 | |
| KR100658918B1 (ko) | 블록 단위 입출력 명령어를 이용한 시스템 전역 변수초기화 장치 및 그 방법 | |
| JP2022539672A (ja) | 文書表示方法およびデバイス | |
| CN120406826B (zh) | 数据管理方法及相关设备 | |
| CN121301052B (zh) | 多核调试方法、装置、系统及存储介质 | |
| CN117974416A (zh) | 内容绘制方法、装置、设备、计算机可读存储介质及产品 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 24795906 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 24795906 Country of ref document: EP Kind code of ref document: A1 |