An input method, device, and device for input
By obtaining the original statements input by the user and applying the target statement acquisition method, the problem of low efficiency of user input statements in the prior art is solved, statement reorganization is realized, more accurate input results are provided, and user input efficiency is improved.
Patent Information
- Application Number
- CN202011291518.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-17
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2040-12-28
AI Technical Summary
Existing input method applications cannot effectively solve the sentence pattern problems in user input statements, resulting in low user input efficiency.
By obtaining the original statements entered by the user, determine their conversion requirements (such as scattered word sentence making requirements or word order adjustment requirements), and use the corresponding target statement acquisition method (such as based on the statement library or word order adjustment model) to obtain target statements with the same semantics and correct sentence patterns and display them to the user.
No need for user to manually modify the statement, directly provide more accurate statements, improving the efficiency of user input statements.
Smart Images

Figure CN114510154B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technologies, and particularly to an input method, an apparatus, and a device for inputting. Background Art
[0002] During the process of a user inputting a statement using an input method client, there are usually some expression problems in the input content. For example, users whose mother tongue is a language such as Korean or Japanese, when they want to express "He has gone to Harbin", usually due to the influence of their mother tongue expression habits, misinput it as "He Harbin has gone". Another example is that when some users want to express the complete statement "Have a dinner at XX tomorrow. Please reply if you receive this.", they only input individual keywords such as "tomorrow", "XX", and "reply".
[0003] Existing input method applications usually only support correcting the content input by users, and cannot solve the sentence pattern problems in the statements input by users. Users need to manually modify the statements, resulting in low efficiency of inputting statements by users. Summary of the Invention
[0004] The embodiments of the present application propose an input method, an apparatus, and a device for inputting to solve the technical problem of low efficiency of inputting statements by users in the prior art.
[0005] In a first aspect, the embodiments of the present application provide an input method, which includes: obtaining an original statement input by a user; when the original statement meets a preset condition, obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern; and displaying the target statement.
[0006] In some embodiments, the obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern includes: determining the conversion requirement of the original statement; and adopting a target statement obtaining method that matches the conversion requirement to obtain a target statement that has the same semantics as the original statement and has a correct sentence pattern.
[0007] In some embodiments, the conversion requirement includes at least one of the following: the requirement of constructing a sentence from scattered words, the requirement of adjusting word order; and the target statement obtaining method includes at least one of the following: the target statement obtaining method based on a statement library, the target statement obtaining method based on a word order adjustment model.
[0008] In some embodiments, obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method that matches the conversion requirement includes: when the conversion requirement is a requirement for constructing a sentence from scattered words, extracting keywords from the original statement and determining the types of the keywords; retrieving candidate statements from a preset statement library based on the keywords and the types of the keywords to obtain a candidate statement set; sorting the candidate statements in the candidate statement set based on the relevant information of the original statement to obtain a sorting result; and selecting a target statement from the candidate statement set based on the sorting result.
[0009] In some embodiments, obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method that matches the conversion requirement includes: when the conversion requirement is a requirement for adjusting word order, inputting the original statement into a pre-trained word order adjustment model to obtain a target statement with the word order of the original statement adjusted.
[0010] In some embodiments, the word order adjustment model is trained based on the following steps: obtaining a sample set, where the samples in the sample set are statement pairs, and the statement pairs include a first sample statement and a second sample statement, and the first sample statement and the second sample statement have different word orders; using the first sample statement in the sample set as the input of an end-to-end generation model, using the second sample statement corresponding to the input first sample statement as the output target of the end-to-end generation model, and training the end-to-end generation model by using a machine learning algorithm to obtain a word order adjustment model.
[0011] In some embodiments, the samples in the sample set are generated through the following steps: obtaining a correct statement without grammar errors; randomly swapping the positions of the words in the correct statement to obtain a scrambled statement; using the scrambled statement as the first sample statement, using the correct statement as the second sample statement, and aggregating the first sample statement and the second sample statement to obtain a sample.
[0012] In some embodiments, the samples in the sample set are generated through the following steps: obtaining the log of an input method application, where the log includes the historical behavior data of a user; searching in the historical behavior data for the statement before modification and the statement after modification corresponding to a backspace modification behavior; if the statement before modification and the statement after modification have the same semantics and the statement after modification has a correct sentence pattern, using the statement before modification as the first sample statement, using the statement after modification as the second sample statement, and aggregating the first sample statement and the second sample statement to obtain a sample.
[0013] In some embodiments, after presenting the target statement, the method further includes: when it is detected that the user selects the target statement, replacing the original statement with the target statement.
[0014] In a second aspect, an embodiment of the present application provides an input device, which includes: a first acquisition unit configured to acquire an original statement input by a user; a second acquisition unit configured to acquire a target statement having the same semantics as the original statement and having a correct sentence pattern when the original statement meets a preset condition; and a display unit configured to display the target statement.
[0015] In some embodiments, the second acquisition unit is further configured to: determine the conversion requirement of the original statement; and acquire a target statement having the same semantics as the original statement and having a correct sentence pattern by using a target statement acquisition method matching the conversion requirement.
[0016] In some embodiments, the conversion requirement includes at least one of the following: the requirement of constructing a sentence from scattered words, the requirement of adjusting word order; and the target statement acquisition method includes at least one of the following: the target statement acquisition method based on a statement library, the target statement acquisition method based on a word order adjustment model.
[0017] In some embodiments, the second acquisition unit is further configured to: when the conversion requirement is the requirement of constructing a sentence from scattered words, extract keywords from the original statement and determine the types of the keywords; retrieve candidate statements from a preset statement library based on the keywords and the types of the keywords to obtain a candidate statement set; sort the candidate statements in the candidate statement set based on the relevant information of the original statement to obtain a sorting result; and select a target statement from the candidate statement set based on the sorting result.
[0018] In some embodiments, the second acquisition unit is further configured to: when the conversion requirement is the requirement of adjusting word order, input the original statement into a pre-trained word order adjustment model to obtain a target statement after adjusting the word order of the original statement.
[0019] In some embodiments, the word order adjustment model is trained based on the following steps: acquiring a sample set, where the samples in the sample set are statement pairs, and the statement pair includes a first sample statement and a second sample statement, and the first sample statement and the second sample statement have different word orders; using the first sample statement in the sample set as the input of an end-to-end generation model, using the second sample statement corresponding to the input first sample statement as the output target of the end-to-end generation model, and training the end-to-end generation model by using a machine learning algorithm to obtain a word order adjustment model.
[0020] In some embodiments, the samples in the sample set are generated through the following steps: obtaining correct sentences without grammar errors; randomly swapping the positions of words in the correct sentences to obtain scrambled sentences; using the scrambled sentences as the first sample sentences, using the correct sentences as the second sample sentences, and aggregating the first sample sentences and the second sample sentences to obtain samples.
[0021] In some embodiments, the samples in the sample set are generated through the following steps: obtaining the logs of an input method application, where the logs include the historical behavior data of users; from the historical behavior data, searching for the sentences before modification and the sentences after modification corresponding to the backspace modification behavior; if the sentences before modification and the sentences after modification have the same semantics and the sentences after modification have correct sentence patterns, using the sentences before modification as the first sample sentences, using the sentences after modification as the second sample sentences, and aggregating the first sample sentences and the second sample sentences to obtain samples.
[0022] In some embodiments, the device further includes: a replacement unit configured to replace the original sentence with the target sentence when it is detected that the user selects the target sentence.
[0023] In a third aspect, an embodiment of the present application provides a device for input, including a memory, and one or more programs, where one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations: obtaining an original sentence input by a user; when the original sentence meets a preset condition, obtaining a target sentence that has the same semantics as the original sentence and has a correct sentence pattern; and displaying the target sentence.
[0024] In some embodiments, obtaining the target sentence that has the same semantics as the original sentence and has a correct sentence pattern includes: determining the conversion requirement of the original sentence; and using a target sentence obtaining method that matches the conversion requirement to obtain a target sentence that has the same semantics as the original sentence and has a correct sentence pattern.
[0025] In some embodiments, the conversion requirement includes at least one of the following: the requirement of forming sentences with scattered words, the requirement of adjusting word order; and the target sentence obtaining method includes at least one of the following: the target sentence obtaining method based on a sentence library, the target sentence obtaining method based on a word order adjustment model.
[0026] In some embodiments, obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method that matches the conversion requirement includes: when the conversion requirement is a requirement for constructing a sentence from scattered words, extracting keywords from the original statement and determining the types of the keywords; retrieving candidate statements from a preset statement library based on the keywords and the types of the keywords to obtain a candidate statement set; sorting the candidate statements in the candidate statement set based on the relevant information of the original statement to obtain a sorting result; and selecting a target statement from the candidate statement set based on the sorting result.
[0027] In some embodiments, obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method that matches the conversion requirement includes: when the conversion requirement is a requirement for adjusting word order, inputting the original statement into a pre-trained word order adjustment model to obtain a target statement after adjusting the word order of the original statement.
[0028] In some embodiments, the word order adjustment model is trained based on the following steps: obtaining a sample set, where the samples in the sample set are statement pairs, and the statement pairs include a first sample statement and a second sample statement, and the first sample statement and the second sample statement have different word orders; using the first sample statement in the sample set as the input of an end-to-end generation model, using the second sample statement corresponding to the input first sample statement as the output target of the end-to-end generation model, and training the end-to-end generation model by using a machine learning algorithm to obtain a word order adjustment model.
[0029] In some embodiments, the samples in the sample set are generated through the following steps: obtaining a correct statement without grammar errors; randomly swapping the positions of the words in the correct statement to obtain a scrambled statement; using the scrambled statement as the first sample statement, using the correct statement as the second sample statement, and aggregating the first sample statement and the second sample statement to obtain a sample.
[0030] In some embodiments, the samples in the sample set are generated through the following steps: obtaining the log of an input method application, where the log includes the historical behavior data of a user; searching in the historical behavior data for the statement before modification and the statement after modification corresponding to a backspace modification behavior; if the statement before modification and the statement after modification have the same semantics and the statement after modification has a correct sentence pattern, using the statement before modification as the first sample statement, using the statement after modification as the second sample statement, and aggregating the first sample statement and the second sample statement to obtain a sample.
[0031] In some embodiments, the device is configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations: when detecting that the user selects the target statement, replacing the original statement with the target statement.
[0032] In a fourth aspect, an embodiment of the present application provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, it implements the method described in the first aspect above.
[0033] The input method, device, and device for input provided by the embodiments of the present application obtain the original statement input by the user, and when the original statement meets the preset conditions, obtain the target statement with the same semantics as the original statement and a correct sentence pattern, so as to display the target statement. Thus, it is possible to perform statement restructuring on the original statement input by the user, provide a more accurate statement for the user without changing the semantics, and there is no need for the user to manually modify the statement, thereby improving the efficiency of the user input statement. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Other features, objects, and advantages of the present application will become more apparent by reading the detailed description of the non-limiting embodiments with reference to the following drawings:
[0035] Figure 1 is a flowchart of an embodiment of the input method according to the present application;
[0036] Figure 2 is a flowchart of a target statement acquisition method of the input method according to the present application;
[0037] Figure 3 is a schematic structural diagram of an embodiment of the input device according to the present application;
[0038] Figure 4 is a schematic structural diagram of a device for input according to the present application;
[0039] Figure 5 is a schematic structural diagram of a server in some embodiments according to the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0040] The present application will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only for explaining the related invention, rather than limiting the invention. Additionally, it should be noted that for the sake of description, only parts related to the related invention are shown in the drawings.
[0041] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The following will describe the present application in detail with reference to the drawings and in conjunction with the embodiments.
[0042] Please refer to Figure 1 , which shows a flow 100 of an embodiment of the input method according to the present application. The above input method can run on various electronic devices, including but not limited to: servers, smart phones, tablet computers, e-book readers, MP3 (Moving Picture Experts Group Audio Layer III) players, MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, in-vehicle computers, desktop computers, set-top boxes, smart televisions, wearable devices, and so on.
[0043] The input method application mentioned in the embodiments of the present application can support multiple input methods. Among them, an input method can be a coding method for inputting various symbols into electronic devices such as computers and mobile phones. Users can use the input method application to conveniently input the required characters or character strings into the electronic device. It should be noted that in the embodiments of the present application, in addition to supporting common Chinese input methods (such as pinyin input method, Wubi input method, phonetic input method, voice input method, handwriting input method, etc.), the input method can also support input methods in other languages (such as English input method, Japanese hiragana input method, Korean input method, etc.). No limitation is made on the input method and the language types of the input method here.
[0044] The input method in this embodiment may include the following steps:
[0045] Step 101, obtain the original statement input by the user.
[0046] In this embodiment, the execution subject of the input method (such as the above-mentioned electronic device) can obtain the statement input by the user and use this statement as the original statement. Among them, the above original statement can be input through the input method application. The user can use any input method to input the statement. For example, coding input methods such as pinyin, Wubi, and strokes can be used, or a voice input method can also be used, and no limitation is made here.
[0047] Step 102, when the original statement meets the preset conditions, obtain a target statement that has the same semantics as the original statement and has a correct sentence pattern.
[0048] In this embodiment, the above-mentioned execution entity can obtain a target sentence that has the same semantics as the original sentence and has a correct sentence pattern when the original sentence meets a preset condition. The preset condition can be used to trigger the operation of obtaining the target sentence, and the preset condition can be set in advance as needed. For example, it can be set to obtain a target sentence that has the same semantics as the original sentence and has a correct sentence pattern when there are grammar errors in the original sentence (such as incorrect sentence patterns, inability to form a complete sentence, disordered word order, etc.).
[0049] The target sentence and the original sentence can have the same semantics, and the target sentence can have a correct sentence pattern. The target sentence can be a sentence without grammar errors, with a complete sentence and correct word order. As an example, if the original sentence is "He went to Harbin", then the target sentence can be the sentence with adjusted word order "He went to Harbin". As another example, if the original sentence is "Tomorrow, XX Home Cooking Restaurant, Reply", then the target sentence can be the complete sentence "Have dinner at XX Home Cooking Restaurant tomorrow. Please reply if you receive this message."
[0050] In some alternative implementation manners of this embodiment, when the original sentence meets the preset condition, the above-mentioned execution entity can obtain a target sentence that has the same semantics as the original sentence and has a correct sentence pattern according to the following steps:
[0051] First step, determine the conversion requirement of the original sentence.
[0052] The conversion requirement can be determined according to the problems existing in the original sentence. For example, if the original sentence only contains scattered words and does not form a complete sentence, the conversion requirement can be the requirement of forming a sentence with scattered words. If the word order of the original sentence is disordered, the conversion requirement can be the requirement of adjusting the word order. It should be noted that the conversion requirements of the original sentence are not limited to the requirements of forming a sentence with scattered words and adjusting the word order, and other conversion requirements can also be determined according to other types of grammar errors in the original sentence.
[0053] Here, various methods can be used to detect the problems existing in the original sentence. The following are illustrated with two examples:
[0054] As an example, when there are multiple (such as at least two) delimiters (such as the comma "、", the comma ",", etc.) in the original sentence, and the content between each delimiter is mostly nouns (such as containing at least two nouns), it can be considered that there is a requirement of forming a sentence with scattered words. Such as "Today, clothes, how".
[0055] As another example, the parts of speech of the original sentence can be marked to determine the syntax of the original sentence. If the syntax of the original sentence matches the preset incorrect syntax (such as noun - noun - verb), it can be considered that the original sentence has a requirement of adjusting the word order. Such as "He went to Harbin".
[0056] In the second step, adopt a target statement acquisition method that matches the conversion requirement to obtain a target statement that has the same semantics as the original statement and has a correct sentence pattern.
[0057] Here, the target statement acquisition method may include, but is not limited to, at least one of the following: a target statement acquisition method based on a statement library, a target statement acquisition method based on a word order adjustment model. For different conversion requirements, different target statement acquisition methods can be preset in advance.
[0058] Optionally, in the case where the conversion requirement is a requirement for constructing sentences from scattered words, the above-mentioned execution entity can adopt a target statement acquisition method based on a statement library. Among them, the statement library can contain a large number of statements. The statements in the statement library can be pre-extracted from the user's input logs, Internet texts, and other corpora. The statement library also records the keywords of each statement and the type tags of each keyword. Among them, the types of keywords may include, but are not limited to, named entities (such as locations, people, institutions, etc.), verbs, times, etc.
[0059] In the case where the conversion requirement is a requirement for constructing sentences from scattered words, refer to Figure 2 the flowchart shown, the above-mentioned execution entity can obtain a target statement that has the same semantics as the original statement and has a correct sentence pattern according to the following sub-steps:
[0060] Sub-step S11, extract keywords from the original statement and determine the types of the keywords.
[0061] For example, if the original statement is "Xiaoming, take a taxi, Beijing", the keywords can be the words separated by the separator ",", specifically "Xiaoming", "take a taxi", "Beijing", and the types are person, verb, and location in sequence.
[0062] Sub-step S12, based on the keywords and the types of the keywords, retrieve candidate statements from the preset statement library to obtain a candidate statement set.
[0063] Specifically, first retrieve the statements that match the types of the keywords from the statement library; then, select the statements that contain the above keywords from the retrieved statements as candidate statements, so as to summarize them into a candidate statement set. Continuing the above example, the candidate statement set may include "Xiaoming took a taxi to Beijing", "Xiaoming took a taxi to Beijing", "Xiaoming took a taxi and came back from Beijing", etc.
[0064] Sub-step S13, based on the relevant information of the original statement, sort the candidate statements in the candidate statement set to obtain a sorting result.
[0065] Here, the relevant information of the original statement may include, but is not limited to, the above information, the following information, the user's historical input information, and the original statement. The above-mentioned execution entity can extract features from the relevant information of the original statement, input each candidate statement and the extracted features into a pre-trained ranking model respectively, and obtain the score of each candidate statement. Then, sort the candidate statements in the candidate statement set according to the score order to obtain the sorting result. The ranking model here can extract features from the candidate statements and match the features extracted from the candidate statements with the features extracted from the relevant information. The score it outputs can represent the matching degree.
[0066] In practice, the ranking model can adopt existing click-through rate prediction models, models based on Deep Interest Network (DIN), etc., and be pre-trained through machine learning methods (such as supervised learning methods).
[0067] Sub-step S14, based on the sorting result, select the target statement from the candidate statement set.
[0068] Here, the number of target statements is not limited. For example, the candidate statement ranked first can be selected as the target statement, so as to take the statement most needed by the user as the target statement. Or the first N (N is a positive integer) candidate statements can be used as the target statements, so as to provide more choices for the user.
[0069] In some optional implementation manners of this embodiment, when the conversion requirement is a word order adjustment requirement, the above-mentioned execution entity can input the original statement into a pre-trained word order adjustment model to obtain the target statement after adjusting the word order of the original statement. Among them, the word order adjustment model can be used to reorganize the input statement to obtain a new statement with correct word order. The word order adjustment model can be pre-trained based on machine learning methods (such as supervised learning methods).
[0070] In some optional implementation manners of this embodiment, the word order adjustment model is trained according to the following steps:
[0071] The first step is to obtain a sample set. Among them, the samples in the sample set are statement pairs. The statement pair can include a first sample statement and a second sample statement. The first sample statement and the second sample statement may have different word orders. Here, since the first sample statement and the second sample statement contain the same words and only the statements are different, they can be considered to have the same semantics.
[0072] Optionally, the samples in the sample set can be generated through the following steps: First, obtain correct sentences without grammar errors. Then, randomly swap the positions of the words in the correct sentences to obtain scrambled sentences. After that, use the scrambled sentences as the first sample sentences, use the correct sentences as the second sample sentences, and aggregate the first sample sentences and the second sample sentences to obtain samples.
[0073] Optionally, the samples in the sample set can also be generated through the following steps: First, obtain the logs of the input method application, which include the historical behavior data of the user. Then, from the historical behavior data, find the sentences before and after the backspace modification corresponding to the backspace modification behavior. If the sentence before modification and the sentence after modification have the same semantics and the sentence after modification has a correct sentence pattern, use the sentence before modification as the first sample sentence, use the sentence after modification as the second sample sentence, and aggregate the first sample sentence and the second sample sentence to obtain samples.
[0074] In the second step, use the first sample sentences in the sample set as the input of the end-to-end generation model, use the second sample sentences corresponding to the input first sample sentences as the output targets of the end-to-end generation model, and use machine learning algorithms to train the end-to-end generation model (Sequence to Sequence, Seq2Seq) to obtain a word order adjustment model.
[0075] Among them, the end-to-end generation model is a model with an Encoder-Deocder (encoder-decoder) structure. The input is a sequence, and the output is also a sequence. Thus, the samples in the sample set can be used to train this model to obtain a word order adjustment model.
[0076] Step 103, display the target sentence.
[0077] In this embodiment, the above execution subject can display the target sentence in various ways. For example, the target sentence can be displayed as a candidate item on the input method panel, or it can be displayed in a pop-up window. Here, the display position and display style of the target sentence are not specifically limited.
[0078] In some optional implementation manners of this embodiment, after the target sentence is displayed, if it is detected that the user selects the target sentence, the original sentence can be replaced with the target sentence, so as to input the target sentence.
[0079] The method provided by the above embodiments of the present application obtains the original statement input by the user, and when the original statement meets the preset conditions, obtains a target statement that has the same semantics as the original statement and has a correct sentence pattern, and then displays the target statement. Thereby, it can achieve sentence restructuring for the original statement input by the user, provide a more accurate statement for the user without changing the semantics, and eliminate the need for the user to manually modify the statement, thus improving the efficiency of the user's input statement.
[0080] Further referring to Figure 3 , as an implementation of the methods shown in the above figures, the present application provides an embodiment of an input device. This device embodiment corresponds to Figure 1 the method embodiment shown, and this device can be specifically applied to various electronic devices.
[0081] As Figure 3 shown, the input device 300 in the above embodiment includes: a first acquisition unit 301 configured to acquire the original statement input by the user; a second acquisition unit 302 configured to, when the above original statement meets the preset conditions, acquire a target statement that has the same semantics as the above original statement and has a correct sentence pattern; and a display unit 303 configured to display the above target statement.
[0082] In some optional implementation manners of this embodiment, the above second acquisition unit 302 is further configured to: determine the conversion requirement of the above original statement; and adopt a target statement acquisition method that matches the above conversion requirement to acquire a target statement that has the same semantics as the above original statement and has a correct sentence pattern.
[0083] In some optional implementation manners of this embodiment, the above conversion requirement includes at least one of the following: the requirement of constructing sentences from scattered words, the requirement of adjusting word order; and the above target statement acquisition method includes at least one of the following: the target statement acquisition method based on a statement library, the target statement acquisition method based on a word order adjustment model.
[0084] In some optional implementation manners of this embodiment, the above second acquisition unit 302 is further configured to: when the above conversion requirement is the requirement of constructing sentences from scattered words, extract keywords from the above original statement and determine the types of the above keywords; retrieve candidate statements from a preset statement library based on the above keywords and the types of the above keywords to obtain a candidate statement set; sort the candidate statements in the above candidate statement set based on the relevant information of the above original statement to obtain a sorting result; and select a target statement from the above candidate statement set based on the above sorting result.
[0085] In some alternative implementation manners of this embodiment, the above-mentioned second acquisition unit 302 is further configured to: when the conversion requirement is a word order adjustment requirement, input the above-mentioned original sentence into a pre-trained word order adjustment model to obtain a target sentence with the word order of the above-mentioned original sentence adjusted.
[0086] In some alternative implementation manners of this embodiment, the above-mentioned word order adjustment model is trained based on the following steps: obtaining a sample set, where the samples in the sample set are sentence pairs, and the sentence pairs include a first sample sentence and a second sample sentence with a different word order from the first sample sentence; using the first sample sentence in the sample set as the input of an end-to-end generation model, using the second sample sentence corresponding to the input first sample sentence as the output target of the end-to-end generation model, and training the end-to-end generation model using a machine learning algorithm to obtain a word order adjustment model.
[0087] In some alternative implementation manners of this embodiment, the samples in the sample set are generated through the following steps: obtaining a correct sentence without grammar errors; randomly swapping the positions of the words in the correct sentence to obtain a scrambled sentence; using the scrambled sentence as the first sample sentence, using the correct sentence as the second sample sentence, and summarizing the first sample sentence and the second sample sentence to obtain a sample.
[0088] In some alternative implementation manners of this embodiment, the samples in the sample set are generated through the following steps: obtaining the log of an input method application, where the log includes the historical behavior data of a user; from the historical behavior data, searching for the sentence before modification and the sentence after modification corresponding to a backspace modification behavior; if the sentence before modification and the sentence after modification have the same semantics and the sentence after modification has a correct sentence pattern, using the sentence before modification as the first sample sentence, using the sentence after modification as the second sample sentence, and summarizing the first sample sentence and the second sample sentence to obtain a sample.
[0089] In some alternative implementation manners of this embodiment, the above-mentioned device further includes: a replacement unit configured to replace the above-mentioned original sentence with the above-mentioned target sentence when it is detected that the user selects the above-mentioned target sentence.
[0090] The device provided in the above embodiment of this application obtains the original sentence input by the user, and when the original sentence meets a preset condition, obtains a target sentence with the same semantics as the original sentence and a correct sentence pattern, and thus displays the target sentence. Thereby, it is possible to perform sentence restructuring on the original sentence input by the user, provide a more accurate sentence for the user without changing the semantics, and eliminate the need for the user to manually modify the sentence, thereby improving the efficiency of the sentence input by the user.
[0091] Figure 4FIG. 0 is a block diagram of a device 400 for input according to an exemplary embodiment, and the device 400 may be a smart terminal or a server. For example, the device 400 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0092] Referring to Figure 4 , the device 400 may include one or more of the following components: a processing component 402, a memory 404, a power component 406, a multimedia component 408, an audio component 410, an input / output (I / O) interface 412, a sensor component 414, and a communication component 416.
[0093] The processing component 402 generally controls the overall operation of the device 400, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 402 may include one or more processors 420 to execute instructions to complete all or part of the steps of the above methods. In addition, the processing component 402 may include one or more modules to facilitate the interaction between the processing component 402 and other components. For example, the processing component 402 may include a multimedia module to facilitate the interaction between the multimedia component 408 and the processing component 402.
[0094] The memory 404 is configured to store various types of data to support the operation of the device 400. Examples of such data include instructions for any application or method operating on the device 400, contact data, phone book data, messages, pictures, videos, etc. The memory 404 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0095] The power component 406 provides power to the various components of the device 400. The power component 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 400.
[0096] The multimedia component 408 includes a screen that provides an output interface between the above-described device 400 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The above touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the above touch or swipe operations. In some embodiments, the multimedia component 408 includes a front camera and / or a rear camera. When the device 400 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0097] The audio component 410 is configured to output and / or input audio signals. For example, the audio component 410 includes a microphone (MIC) that is configured to receive external audio signals when the device 400 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 404 or transmitted via the communication component 416. In some embodiments, the audio component 410 further includes a speaker for outputting audio signals.
[0098] The I / O interface 412 provides an interface between the processing component 402 and a peripheral interface module, and the above peripheral interface module can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a power button, and a lock button.
[0099] The sensor component 414 includes one or more sensors for providing a status assessment of various aspects of the device 400. For example, the sensor component 414 can detect the on / off state of the device 400, the relative positioning of components, such as the above components being the display and keypad of the device 400. The sensor component 414 can also detect a change in the position of the device 400 or a component of the device 400, the presence or absence of user contact with the device 400, the orientation or acceleration / deceleration of the device 400, and the temperature change of the device 400. The sensor component 414 can include a proximity sensor that is configured to detect the presence of nearby objects without any physical contact. The sensor component 414 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 414 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0100] The communication component 416 is configured to facilitate communication between the device 400 and other devices in a wired or wireless manner. The device 400 can access a communication standard-based wireless network, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 416 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0101] In an exemplary embodiment, the device 400 can be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.
[0102] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as the memory 404 including instructions, and the instructions can be executed by the processor 420 of the device 400 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0103] Figure 5 It is a schematic structural diagram of a server in some embodiments of the present application. The server 500 can vary significantly due to configuration or performance differences and can include one or more central processing units (CPUs) 522 (e.g., one or more processors) and a memory 532, and one or more storage media 530 (e.g., one or more mass storage devices) for storing application programs 542 or data 544. Among them, the memory 532 and the storage media 530 can be transient storage or persistent storage. The programs stored in the storage media 530 can include one or more modules (not shown in the figure), and each module can include a series of instruction operations on the server. Further, the central processor 522 can be configured to communicate with the storage media 530 and execute a series of instruction operations in the storage media 530 on the server 500.
[0104] The server 500 may further include one or more power supplies 526, one or more wired or wireless network interfaces 550, one or more input / output interfaces 558, one or more keyboards 556, and / or one or more operating systems 541, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0105] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (intelligent terminal or server), enables the device to execute an input method, and the method includes: obtaining an original statement input by a user; when the original statement meets a preset condition, obtaining a target statement having the same semantics as the original statement and having a correct sentence pattern; and presenting the target statement.
[0106] Optionally, the obtaining a target statement having the same semantics as the original statement and having a correct sentence pattern includes: determining a conversion requirement of the original statement; and adopting a target statement obtaining method matching the conversion requirement to obtain a target statement having the same semantics as the original statement and having a correct sentence pattern.
[0107] Optionally, the conversion requirement includes at least one of the following: a requirement for constructing a sentence from scattered words, a requirement for adjusting word order; and the target statement obtaining method includes at least one of the following: a target statement obtaining method based on a statement library, a target statement obtaining method based on a word order adjustment model.
[0108] Optionally, the adopting a target statement obtaining method matching the conversion requirement to obtain a target statement having the same semantics as the original statement and having a correct sentence pattern includes: when the conversion requirement is a requirement for constructing a sentence from scattered words, extracting keywords from the original statement and determining the types of the keywords; retrieving candidate statements from a preset statement library based on the keywords and the types of the keywords to obtain a candidate statement set; sorting the candidate statements in the candidate statement set based on relevant information of the original statement to obtain a sorting result; and selecting a target statement from the candidate statement set based on the sorting result.
[0109] Optionally, the adopting a target statement obtaining method matching the conversion requirement to obtain a target statement having the same semantics as the original statement and having a correct sentence pattern includes: when the conversion requirement is a requirement for adjusting word order, inputting the original statement into a pre-trained word order adjustment model to obtain a target statement obtained by adjusting the word order of the original statement.
[0110] Optionally, the word order adjustment model is trained based on the following steps: Obtain a sample set, where the samples in the sample set are sentence pairs, and each sentence pair includes a first sample sentence and a second sample sentence, and the first sample sentence and the second sample sentence have different word orders; use the first sample sentence in the sample set as the input of an end-to-end generation model, use the second sample sentence corresponding to the input first sample sentence as the output target of the end-to-end generation model, and use a machine learning algorithm to train the end-to-end generation model to obtain a word order adjustment model.
[0111] Optionally, the samples in the sample set are generated through the following steps: Obtain a correct sentence without grammar errors; randomly swap the positions of the words in the correct sentence to obtain a scrambled sentence; use the scrambled sentence as the first sample sentence, use the correct sentence as the second sample sentence, and summarize the first sample sentence and the second sample sentence to obtain a sample.
[0112] Optionally, the samples in the sample set are generated through the following steps: Obtain the log of an input method application, where the log includes the historical behavior data of a user; from the historical behavior data, find the sentence before modification and the sentence after modification corresponding to a backspace modification behavior; if the sentence before modification and the sentence after modification have the same semantics and the sentence after modification has a correct sentence pattern, use the sentence before modification as the first sample sentence, use the sentence after modification as the second sample sentence, and summarize the first sample sentence and the second sample sentence to obtain a sample.
[0113] Optionally, the device is configured to execute the one or more programs by one or more processors and includes instructions for performing the following operations: When it is detected that the user selects the target sentence, replace the original sentence with the target sentence.
[0114] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and examples are only considered exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0115] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
[0116] The above are only the preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
[0117] The above has introduced in detail an input method, a device and a device for input provided by the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. An input method, characterized in that, The method includes: Obtaining an original statement input by a user; Determining a conversion requirement of the original statement when the original statement meets a preset condition; Obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method matching the conversion requirement; Displaying the target statement; Wherein, the conversion requirement includes at least one of the following: a requirement for constructing sentences from scattered words, a requirement for adjusting word order; and, the target statement obtaining method includes at least one of the following: a target statement obtaining method based on a statement library, a target statement obtaining method based on a word order adjustment model; The obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method matching the conversion requirement includes: When the conversion requirement is a requirement for constructing sentences from scattered words, extracting keywords from the original statement and determining the types of the keywords; Retrieving statements matching the types of the keywords from a preset statement library; selecting, from the statements matching the types of the keywords, statements containing the keywords as candidate statements to obtain a candidate statement set; Sorting the candidate statements in the candidate statement set based on relevant information of the original statement; the relevant information of the original statement includes upper context information, lower context information, the user's historical input information, and the original statement; Selecting a target statement from the candidate statement set based on the sorting result.
2. The method according to claim 1, wherein The obtaining a target statement that has the same semantics as the original statement and has a correct sentence pattern by using a target statement obtaining method matching the conversion requirement includes: When the conversion requirement is a requirement for adjusting word order, inputting the original statement into a pre-trained word order adjustment model to obtain a target statement after adjusting the word order of the original statement.
3. The method according to claim 2, wherein The word order adjustment model is trained based on the following steps: Obtaining a sample set, where the samples in the sample set are statement pairs, and the statement pair includes a first sample statement and a second sample statement, and the first sample statement and the second sample statement have different word orders; Using the first sample statement in the sample set as the input of an end-to-end generation model, using the second sample statement corresponding to the input first sample statement as the output target of the end-to-end generation model, and training the end-to-end generation model by using a machine learning algorithm to obtain a word order adjustment model.
4. The method according to claim 3, characterized in that, The samples in the sample set are generated through the following steps: Obtaining a correct statement without grammar errors; Randomly swapping the positions of the words in the correct statement to obtain a scrambled statement; Using the scrambled statement as the first sample statement, using the correct statement as the second sample statement, and summarizing the first sample statement and the second sample statement to obtain a sample.
5. An input device, characterized in that, The apparatus includes: A first obtaining unit configured to obtain an original statement input by a user; A second acquisition unit, configured to determine the conversion requirement of the original statement when the original statement meets a preset condition; and adopt a target statement acquisition method matching the conversion requirement to acquire a target statement that has the same semantics as the original statement and has a correct sentence pattern. A display unit, configured to display the target statement. Wherein, the conversion requirement includes at least one of the following: the requirement of forming sentences with scattered words, the requirement of adjusting word order; and the target statement acquisition method includes at least one of the following: the target statement acquisition method based on a statement library, the target statement acquisition method based on a word order adjustment model. The adopting a target statement acquisition method matching the conversion requirement to acquire a target statement that has the same semantics as the original statement and has a correct sentence pattern includes: When the conversion requirement is the requirement of forming sentences with scattered words, extracting keywords from the original statement and determining the types of the keywords. Retrieving statements matching the types of the keywords from a preset statement library; and selecting the statements containing the keywords from the statements matching the types of the keywords as candidate statements to obtain a candidate statement set. Sorting the candidate statements in the candidate statement set based on the relevant information of the original statement; the relevant information of the original statement includes the previous context information, the following context information, the user's historical input information, and the original statement. Selecting a target statement from the candidate statement set based on the sorting result.
6. A device for input, characterized in that, It includes a memory, and one or more programs, wherein one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations: Acquiring an original statement input by a user. Determining the conversion requirement of the original statement when the original statement meets a preset condition. Adopting a target statement acquisition method matching the conversion requirement to acquire a target statement that has the same semantics as the original statement and has a correct sentence pattern. Displaying the target statement. Wherein, the conversion requirement includes at least one of the following: the requirement of forming sentences with scattered words, the requirement of adjusting word order; and the target statement acquisition method includes at least one of the following: the target statement acquisition method based on a statement library, the target statement acquisition method based on a word order adjustment model. The adopting a target statement acquisition method matching the conversion requirement to acquire a target statement that has the same semantics as the original statement and has a correct sentence pattern includes: When the conversion requirement is the requirement of forming sentences with scattered words, extracting keywords from the original statement and determining the types of the keywords. Retrieving statements matching the types of the keywords from a preset statement library; and selecting the statements containing the keywords from the statements matching the types of the keywords as candidate statements to obtain a candidate statement set. Based on the relevant information of the original statement, sort the candidate statements in the candidate statement set to obtain a sorting result; the relevant information of the original statement includes the above information, the below information, the user's historical input information, and the original statement. Based on the sorting result, select a target statement from the candidate statement set.
7. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the method according to any one of claims 1-4.
Citation Information
Patent Citations
Corpus restoration method and device
CN109766556A
Text presentation apparatus, text presentation system and text presentation method
JP2011059933A