String processing method and device

By introducing a weight matrix based on the user's historical input behavior into the error correction model of the input method, the problem of insufficient error correction capabilities of the existing input method is solved and a more efficient error correction effect is achieved.

CN113849071BActive Publication Date: 2025-01-24VIVO MOBILE COMM CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111062426.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-10
Publication Date
2025-01-24
Estimated Expiration
2041-09-10

AI Technical Summary

Technical Problem

The existing input methods have poor error correction capabilities and cannot effectively adapt to the input habits of different users.

Method used

By introducing the user weight matrix in the error correction model, the matrix is ​​determined according to the user's historical input behavior, so as to calculate the string of the candidate string string score and increase the matching of the error correction result.

Benefits of technology

Improving the input method's error correction ability to make it more accurately match the input results of the user's expectations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113849071B_ABST
    Figure CN113849071B_ABST
Patent Text Reader

Abstract

The present application discloses a string processing method and device, which belongs to the field of communication technology. A first string input by a user through an input method is obtained; the string scores of M candidate strings are calculated through the error correction model of the input method, and the M candidate strings include: a first string, and (M-1) second strings obtained by error correction of the first string; M candidate words are output, and the M candidate words are candidate words corresponding to the M candidate strings; wherein the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of communication technology, and specifically relates to a string processing method and device. Background Art

[0002] When a user inputs characters using an electronic device, the user may enter the wrong character due to personal input habits or accidental touches. Currently, the input method can correct the character string input by the user. For example, the error correction model in the input method can calculate the error correction probability between characters based on factors such as the distance between the characters in the character string input by the user on the virtual keyboard, thereby calculating multiple character strings after the character string input by the user is corrected.

[0003] However, since the error correction model in the input method is trained by the input method developer based on a large number of user inputs, the error correction results obtained after different users enter the same pinyin string are the same, while the incorrect character strings entered by different users are different, resulting in poor error correction capabilities of the input method. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a method and device for processing a character string, which can solve the problem of poor error correction capability of an input method.

[0005] In a first aspect, an embodiment of the present application provides a string processing method, the method comprising: obtaining a first string input by a user through an input method; calculating string scores of M candidate strings through an error correction model of the input method, the M candidate strings comprising: the first string, and (M-1) second strings obtained by correcting the first string; outputting M candidate words, the M candidate words being candidate words corresponding to the M candidate strings; wherein the error correction model comprises a confusion matrix and a user weight matrix, the user weight matrix being determined based on the user's historical input behavior.

[0006] In a second aspect, an embodiment of the present application provides a string processing device, which includes an acquisition module, a calculation module and an output module; the acquisition module is used to acquire a first string input by a user through an input method; the calculation module is used to calculate the string scores of M candidate strings through an error correction model of the input method, and the M candidate strings include: a first string, and (M-1) second strings obtained by correcting the first string; the output module is used to output M candidate words, and the M candidate words are candidate words corresponding to the M candidate strings; wherein the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0010] In an embodiment of the present application, a first character string input by a user through an input method is obtained; the character string scores of M candidate character strings are calculated through an error correction model of the input method, and the M candidate character strings include: a first character string, and (M-1) second character strings obtained by error correction of the first character string; M candidate words are output, and the M candidate words are candidate words corresponding to the M candidate character strings; wherein the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior. Since the user weight matrix is ​​determined according to the user's historical input behavior, and the user's historical input behavior can reflect the user's input habits, when the error correction model includes the user weight matrix, the character string scores of the first character string and the (M-1) second character strings can be accurately calculated through the error correction model, thereby improving the matching degree of the output M candidate words with the candidate words that the user expects to input, and further improving the error correction ability of the input method. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 is a flowchart of a string processing method provided in an embodiment of the present application;

[0012] Figure 2A This is one of the interface schematic diagrams of the string processing method application provided in the embodiment of the present application;

[0013] Figure 2B This is the second interface schematic diagram of the application of the string processing method provided in the embodiment of the present application;

[0014] Figure 3 This is the third interface schematic diagram of the application of the string processing method provided in the embodiment of the present application;

[0015] Figure 4 is a structural diagram of a string processing device provided in an embodiment of the present application;

[0016] Figure 5 It is a hardware schematic diagram of a communication device provided in an embodiment of the present application;

[0017] Figure 6 It is a hardware schematic diagram of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0019] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0020] The character string processing provided by the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0021] like Figure 1 As shown, an embodiment of the present application provides a string processing method, which may include the following steps 201 to 203.

[0022] Step 201: The electronic device obtains a first character string input by a user through an input method.

[0023] Step 202: The electronic device calculates the string scores of the M candidate strings through the error correction model of the input method.

[0024] The M candidate character strings may include: a first character string, and (M-1) second character strings obtained by correcting the first character string, where M is an integer greater than 1. The error correction model may include a confusion matrix and a user weight matrix, and the user weight matrix may be determined according to the user's historical input behavior.

[0025] It can be understood that, for the above M candidate character strings, the first character string can be a normal candidate character string (a character string without error correction for the first character string), and the (M-1) second character strings can be error correction candidate character strings (character strings after error correction for the first character string).

[0026] In the embodiment of the present application, when a user inputs a first string through an input method of an electronic device, the electronic device can obtain the first string and calculate the string score of the first string and the string scores of (M-1) second strings obtained by correcting the first string through the error correction model of the input method. In this way, the electronic device can obtain the above-mentioned M candidate strings (including the first string and the (M-1) second strings).

[0027] Optionally, in the embodiment of the present application, the string score of the first string may be: the product of the sum of the logarithms of the uncorrected probability of each character in the first string and the first coefficient.

[0028] That is, assuming that the first string is "zifuchuan", the string score of the first string can be recorded as:

[0029] Among them, λ1 is the first coefficient, p c→c Indicates the probability that the character "c" is not corrected (ie, the probability of no error correction). That is, even if the first character string is not corrected, there is a mapping relationship from the first character string to the first character string in the confusion matrix.

[0030] It should be noted that the character "c" in the embodiment of the present application is used to represent any character in a character string.

[0031] Optionally, in the embodiment of the present application, the string score of a second string may be: the product of the logarithm of the probability of non-error correction of each character in the second string and the first coefficient, and the sum of the influence coefficient of the error correction content. The error correction content may be the content in the second string that is corrected relative to the first string.

[0032] Among them, the above-mentioned first coefficient can be the weight corresponding to the confusion matrix in the error correction model.

[0033] That is, assuming that the second string is "zifuchuai", the string score of the second string can be recorded as:

[0034] Among them, λ1 represents the first coefficient, p c→c Indicates the probability that the character "c" will not be corrected (i.e., the probability of no error correction). scoreIndicates the influence coefficient of the error correction content.

[0035] Optionally, in an embodiment of the present application, the influence coefficient of the error correction content may be the sum of the first product and the second product. The first product may be the product of the error correction probability (also referred to as transition probability or state transition probability) corresponding to the error correction content based on the logarithm of the confusion matrix and the first coefficient, and the second product may be the product of the error correction probability corresponding to the error correction content based on the logarithm of the user weight matrix and the second coefficient. The second coefficient may be the weight corresponding to the user weight matrix in the error correction model.

[0036] That is, error-correction score =λ1log(M)+λ2log(W). Among them, error-correction score is the influence coefficient of the error correction content, M is the confusion matrix, and W is the user weight matrix.

[0037] It should be noted that in the embodiment of the present application, the error correction probability refers to: after the user inputs a character (or string), the probability of the character (or string) being corrected calculated by the input method background, that is, the probability of correcting the character (or string).

[0038] Assuming that the second character string is "zifuchuai", the influence coefficient of the error correction content can be:

[0039]

[0040] Among them, λ1 is the first coefficient, λ2 is the second coefficient, M is the confusion matrix, W is the user weight matrix, represents the probability that character i is corrected to character n in the confusion matrix, The probability that character i is corrected to character n in the user weight matrix.

[0041] For example, assuming that the error correction content is to correct the character string "gn" to the character string "ng", the influence coefficient of the error correction content may be:

[0042]

[0043] Next, taking the first character string as "wennigewenhi", the above M candidate character strings may include: the normal candidate character string (i.e., the first character string) is "wennigewenhi", and the two error correction candidate character strings (i.e., the two second character strings) are "wennigewenti" and "wennigewenhu" as an example, the character string scores of the above first character string and the character string scores of the M second character strings are exemplarily explained.

[0044] Among them, the string score of the normal candidate string "wennigewenhi" (ie, the first string) can be: Among them, λ1 is the first coefficient, p c→c Indicates the probability that the character "c" is not corrected. That is, even if the first character string is not corrected, there is a mapping relationship from the first character string to the first character string in the confusion matrix.

[0045] The string score of the error correction candidate string "wennigewenti" (i.e., the second string) can be:

[0046]

[0047] The string score of the error correction candidate string "wennigewenhu" (i.e., the second string) can be:

[0048]

[0049] Step 203: The electronic device outputs M candidate words.

[0050] Among them, the above-mentioned M candidate words may be candidate words corresponding to the above-mentioned M candidate character strings.

[0051] In the embodiment of the present application, after the electronic device calculates the string scores of the M candidate strings, the electronic device can output the M candidate words according to the M candidate strings, so that the electronic device can display the M candidate words to the user. Then, the user can select the word he actually wants to input from the M candidate words, so that an input operation can be completed.

[0052] Optionally, in an embodiment of the present application, if the electronic device is a user device, the electronic device may directly display the M candidate words in the user interface of the user device to output the M candidate words. If the electronic device is a server, the server may send a candidate word list including the M candidate words to the user device to output the M candidate words. Of course, in actual implementation, the electronic device may also output the M candidate words in any other possible manner, which may be determined according to actual usage requirements, and is not limited in the embodiment of the present application.

[0053] Optionally, in an embodiment of the present application, the electronic device may output the M candidate words in a target order, for example, the M candidate words may be displayed in the target order. The target order may be determined based on the string scores of the M candidate strings, for example, the target order may be the order of the string scores of the M candidate strings from high to low.

[0054] In the embodiment of the present application, since the user weight matrix is ​​determined based on the user's historical input behavior, and the user's historical input behavior can reflect the user's input habits, when the error correction model includes the user weight matrix, the error correction model can be used to accurately calculate the string scores of the first character string and the (M-1) second character strings, thereby improving the matching degree between the output M candidate words and the candidate words that the user expects to input, thereby improving the error correction ability of the input method.

[0055] Optionally, in an embodiment of the present application, the electronic device can update the user weight matrix according to the user's historical error correction data, and then use the updated user weight matrix to train the error correction model, so that the various parameters in the error correction model can be more in line with the user's usage habits. In this way, the error correction accuracy of the error correction model can be further improved.

[0056] Based on this, before the above step 201, the string processing method provided in the embodiment of the present application may further include the following steps 204 to 206.

[0057] Step 204: The electronic device collects N pieces of historical error correction data of the user to obtain an error correction data set.

[0058] Each of the N pieces of historical error correction data may include an error correction type and error correction content, and N is a positive integer.

[0059] It should be noted that the error correction content may be the content modified by the error correction character string (also referred to as the character string before error correction) relative to the input character string (also referred to as the character string after error correction).

[0060] Optionally, in the embodiment of the present application, the error correction type may include at least one of the following: add, delete, alter, exchange or swap. Of course, in actual implementation, the error correction type may also be any other possible type, which may be determined according to actual use requirements and is not limited in the embodiment of the present application.

[0061] Example 1: Assuming that the string before error correction is "shagn" and the string after error correction is "shang", then a historical error correction data can be obtained: swap(gn), which means swapping the order of characters in the string "gn".

[0062] Example 2: Assuming that the string before error correction is "beujing" and the string after error correction is "beijing", then a historical error correction data can be obtained: alter(u, i), which means that the character "u" is changed to the character "i".

[0063] Example 3: Assume that the string before error correction is "beujign" and the string after error correction is "beujing". Then two error correction behaviors occurred in one input, and two historical error correction data can be obtained, namely: swap(gn) and alter(u, i).

[0064] Step 205: The electronic device updates the value of each matrix element in the user weight matrix according to the error correction data set.

[0065] The value of a matrix element may be the probability of changing from the first state to the second state (which may be called the state transition probability or error correction probability, denoted as P ij ), the first state may be the state before the string (which may be a complete string or a partial string in a string) is modified, and the second state may be the state after the string is modified.

[0066] In the embodiment of the present application, assuming that the user weight matrix is ​​W, after the electronic device obtains the above-mentioned error correction data set, the electronic device can calculate the value of each matrix element in the user weight matrix according to the error correction data set, and use the calculated value of the matrix element to replace the original value of the matrix element, so that the value of each matrix element can be updated. In this way, the electronic device can update the user weight matrix W.

[0067] The value of the user weight matrix element can be: W = {P ij} i=1,…n;i=1,…m , where P ij is the probability of state i (i.e., the first state) transferring to state j (i.e., the second state), that is, the probability of state i being modified to state j. The value range of i and j is the same as that of the confusion matrix M.

[0068] For example, assuming that the user's error correction behavior is to modify the string gn to the string ng, then the state i (i.e., the first state) can be gn, and the state j (i.e., the second state) can be ng, then the state transition probability P ij The calculation formula can be:

[0069]

[0070] Where K is the total number of error correction behaviors of the user, and count(swap(gn)) represents the number of times the string “gn” is swapped with the string “ng” in all error correction behaviors of the user.

[0071] It should be noted that as the number of error correction actions increases, the state transition probability of the error correction action becomes higher. In addition, the higher the state transition probability, the higher the corresponding error correction priority.

[0072] For example, assuming that the total number of user correction behaviors is 100, of which the error correction behavior of exchanging the string "gn" with the string "ng" is 50 times, the error correction behavior of exchanging the string "ni" with the string "in" is 30 times, and the error correction behavior of deleting the string "a" is 20 times, then in the user weight matrix, the state transition probabilities P corresponding to the three error correction behaviors are ij They are updated to P (gn→ng) =0.5 (indicates that the probability of changing gn to ng in a string is 0.5), P (ni→in) =0.3 (indicates that the probability of changing ni to in in a string is 0.3), (Indicates that the probability of deleting a in a string is 0.2).

[0073] Step 206: The electronic device uses the updated user weight matrix to train the first coefficient and the second coefficient in the error correction model.

[0074] The first coefficient (λ1) may be a coefficient of a confusion matrix, and the second coefficient (λ2) may be a coefficient of a user weight matrix.

[0075] In the embodiment of the present application, after the electronic device updates the user weight matrix, the electronic device can use the updated user weight matrix to train the first coefficient and the second coefficient in the error correction model, so that the error correction model is more in line with the user's usage habits, that is, an adaptive personalized error correction model can be constructed. In this way, the error correction accuracy of the error correction model is higher.

[0076] That is, the electronic device can adjust the confusion matrix M in the error correction model according to the error correction result increment selected by the user each time. n×m and the user weight matrix W n×m The proportion in the string score (which can be understood as the specific error correction score).

[0077] In an embodiment of the present application, since the first coefficient and the second coefficient in the error correction model are trained based on the updated user weight matrix, and the values ​​of the matrix elements in the user weight matrix are adjusted based on the user's historical error correction data, the trained error correction model can be made consistent with the user's usage habits, thereby improving the error correction accuracy of the error correction model.

[0078] Optionally, in the embodiment of the present application, before the above step 204, the string processing method provided in the embodiment of the present application may further include the following steps 207-209.

[0079] Step 207: The electronic device records N historical error correction logs of the user.

[0080] Each of the N historical error correction logs may include: a character string before error correction, a character string after error correction, and a candidate word selected by the user.

[0081] In the embodiment of the present application, after the user triggers the electronic device to run the input method, the user can input a string on the electronic device through the input method, so that the electronic device can record the user's error correction behavior. If the electronic device detects the user's error correction behavior, the electronic device can record an error correction log according to the user's error correction behavior.

[0082] Optionally, in the embodiment of the present application, the above error correction behavior may include at least one of the following:

[0083] A. The user modifies the edited string. For example, the user changes Figure 2A The string "wennigewenhi" shown is modified to the string "wennigewenti";

[0084] B. The user selects a candidate word corresponding to the corrected string. The candidate word may be referred to as an upper screen word. For example, the user selects Figure 2B The candidate word "Shanghai" is selected as the word on the screen.

[0085] Of course, in actual implementation, the user's error correction behavior may also include any other possible error correction behavior, which can be determined based on actual usage requirements and is not limited in the embodiments of the present application.

[0086] Step 208: The electronic device aligns the pre-correction character string and the post-correction character string in each historical error correction log, and determines the error correction type and error correction content corresponding to the N historical error correction logs.

[0087] Step 209: The electronic device generates N pieces of error correction data according to the error correction type and error correction content corresponding to each historical error correction log.

[0088] After the electronic device records N historical error correction logs of the user, for each historical error correction log, the electronic device can align the relationship between the character string before error correction and the character string after error correction, determine what content is modified in the character string after error correction relative to the character string before error correction, and how it is modified, so as to obtain the error correction content and error correction type corresponding to each historical error correction log; and record the error correction type and error correction content, so as to obtain N error correction data. For example, swap(gn) and alter(u, i).

[0089] Optionally, in the embodiment of the present application, before the above step 204, the embodiment of the present application may further include the following steps 210 and 211.

[0090] Step 210: The electronic device determines whether the user allows obtaining the user's historical error correction log.

[0091] In the embodiment of the present application, when the electronic device runs the input method, the electronic device may first determine whether the user allows the user's historical error correction log to be obtained. If the user does not allow the user's historical error correction log to be obtained, the electronic device may not perform steps 204-206 in the embodiment of the present application. If the user allows the electronic device to obtain the user's historical error correction log, the electronic device may perform the following step 211.

[0092] Step 211: The electronic device creates a user weight matrix.

[0093] The user weight matrix has the same dimension as the confusion matrix in the error correction model, and the value of each matrix element in the user weight matrix is ​​a preset value.

[0094] In the embodiment of the present application, when the user is in the input method setting interface of the electronic device (for example Figure 3 When the electronic device is triggered to enable the personalized error correction function in the interface shown in FIG. 1 ), the electronic device can determine that the user allows the electronic device to obtain the user's historical error correction data. Thus, the electronic device can create the above-mentioned user weight matrix. In this way, after the electronic device obtains the above-mentioned error correction data set, the electronic device can use the historical error correction data in the error correction data set to update the user weight matrix.

[0095] Optionally, in an embodiment of the present application, after the electronic device enables the above-mentioned personalized error correction function, the electronic device may restart the input method and create the above-mentioned user weight matrix.

[0096] It should be noted that the string processing method provided in the embodiment of the present application can be executed by a string processing device or a control module in the string processing device for executing the string processing method. In the embodiment of the present application, the string processing device provided in the embodiment of the present application is described by taking the string processing device executing the string processing method as an example.

[0097] like Figure 4As shown, the embodiment of the present application provides a string processing device 300, which includes an acquisition module 301, a calculation module 302 and an output module 303. The acquisition module 301 is used to acquire a first string input by a user through an input method; the calculation module 302 is used to calculate the string scores of M candidate strings through the error correction model of the input method, and the M candidate strings include: a first string, and (M-1) second strings obtained by correcting the first string; the output module 303 is used to output M candidate words, and the M candidate words are candidate words corresponding to the M candidate strings; wherein the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior.

[0098] Optionally, in an embodiment of the present application, the string processing device also includes a collection module, an update module and a training module; the collection module is used to collect N historical error correction data of the user to obtain an error correction data set, each of the N historical error correction data includes an error correction type and an error correction content, and N is a positive integer; the update module is used to update the value of each matrix element in the user weight matrix according to the error correction data set, the value of a matrix element is the probability of being changed from a first state to a second state, the first state is the state before the string is modified, and the second state is the state after the string is modified; the training module is used to use the updated user weight matrix to train the first coefficient and the second coefficient in the error correction model; wherein the first coefficient is the weight corresponding to the confusion matrix in the error correction model, and the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

[0099] Optionally, in an embodiment of the present application, the string processing device also includes a recording module, a determination module and a generation module; the recording module is used to record N historical error correction logs of the user, each historical error correction log includes: a pre-correction string, a post-correction string and a candidate word selected by the user; the determination module is used to align the pre-correction string and the post-correction string in each historical error correction log, and determine the error correction type and error correction content corresponding to the N historical error correction logs; the generation module is used to generate N error correction data according to the error correction type and error correction content corresponding to each historical error correction log.

[0100] Optionally, in the embodiment of the present application, the string score of the first string is: the product of the logarithm of the probability of non-error correction of each character in the first string and the first coefficient; the string score of the second string is: the product of the logarithm of the probability of non-error correction of each character in the second string and the first coefficient, and the sum of the influence coefficients of the error correction content, where the error correction content is the content in the second string that is corrected relative to the first string. The first coefficient is the weight corresponding to the confusion matrix in the error correction model.

[0101] Optionally, in an embodiment of the present application, the influence coefficient of the error correction content is the sum of the first product and the second product; the first product is the error correction probability corresponding to the error correction content based on the product of the logarithm of the confusion matrix and the first coefficient, and the second product is the error correction probability corresponding to the error correction content based on the product of the logarithm of the user weight matrix and the second coefficient; wherein the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

[0102] The embodiment of the present application provides a string processing device. Since the user weight matrix is ​​determined based on the user's historical input behavior, and the user's historical input behavior can reflect the user's input habits, when the error correction model includes the user weight matrix, the error correction model can be used to accurately calculate the string scores of the first string and (M-1) second strings, thereby improving the matching degree between the output M candidate words and the candidate words that the user expects to input, thereby improving the error correction capability of the input method.

[0103] The string processing device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in an electronic device. The electronic device can be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0104] The string processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0105] The string processing device provided in the embodiment of the present application can implement each process implemented in the above-mentioned string processing method embodiment, and will not be described again here to avoid repetition.

[0106] Alternatively, if Figure 5As shown, the embodiment of the present application also provides an electronic device 500, including a processor 501, a memory 502, and a program or instruction stored in the memory 502 and executable on the processor 501. When the program or instruction is executed by the processor 501, each process of the above-mentioned string processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0107] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0108] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0109] The electronic device 100 includes but is not limited to components such as a radio frequency unit 101, a network module 102, an audio output unit 103, an input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, and a processor 110.

[0110] Those skilled in the art will appreciate that the electronic device 100 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0111] The processor 110 can be used to obtain a first character string input by a user through an input method; and calculate the character string scores of M candidate character strings through an error correction model of the input method, wherein the M candidate character strings include the first character string and (M-1) second character strings obtained by error correction of the first character string. The display unit 106 is used to output M candidate words, wherein the M candidate words are candidate words corresponding to the M candidate character strings; and the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior.

[0112] Optionally, in an embodiment of the present application, the processor 110 is also used to collect N historical error correction data of the user to obtain an error correction data set, each of the N historical error correction data includes an error correction type and an error correction content, and N is a positive integer; and according to the error correction data set, update the value of each matrix element in the user weight matrix, the value of a matrix element is the probability of being changed from a first state to a second state, the first state is the state before the string is modified, and the second state is the state after the string is modified; and use the updated user weight matrix to train the first coefficient and the second coefficient in the error correction model; wherein the first coefficient is the weight corresponding to the confusion matrix in the error correction model, and the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

[0113] Optionally, in an embodiment of the present application, the processor 110 is also used to record N historical error correction logs of the user, each historical error correction log including: a pre-correction character string, a post-correction character string, and a candidate word selected by the user; and align the pre-correction character string and the post-correction character string in each historical error correction log to determine the error correction type and error correction content corresponding to the N historical error correction logs; and generate N error correction data according to the error correction type and error correction content corresponding to each historical error correction log.

[0114] Optionally, in an embodiment of the present application, the string score of the first string is: the product of the logarithm of the probability of non-error correction of each character in the first string and the first coefficient; the string score of the second string is: the product of the logarithm of the probability of non-error correction of each character in the second string and the first coefficient, and the sum of the influence coefficients of the error correction content, where the error correction content is the content in the second string that is corrected relative to the first string. Among them, the first coefficient is the weight corresponding to the confusion matrix in the error correction model, and the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

[0115] Optionally, in the embodiment of the present application, the influence coefficient of the error correction content is the sum of the first product and the second product; the first product is the product of the error correction probability corresponding to the error correction content based on the logarithm of the confusion matrix and the first coefficient, and the second product is the product of the error correction probability corresponding to the error correction content based on the logarithm of the user weight matrix and the second coefficient. The second coefficient is the weight corresponding to the user weight matrix in the error correction model.

[0116] An embodiment of the present invention provides an electronic device. Since a user weight matrix is ​​determined according to a user's historical input behavior, and the user's historical input behavior can reflect the user's input habits, when an error correction model includes the user weight matrix, the string scores of a first string and (M-1) second strings can be accurately calculated through the error correction model, thereby improving the accuracy of the output M candidate words with the user's expectations.

[0117] It should be understood that in the embodiment of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 107 includes a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. Other input devices 1072 may include but are not limited to a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here. The memory 109 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 110 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface, and the application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 110.

[0118] Optionally, an embodiment of the present invention further provides an electronic device, comprising Figure 6 The processor 110, memory 109, and a computer program stored in the memory 109 and executable on the processor 110 are shown. When the computer program is executed by the processor 110, the various processes of the above-mentioned method embodiment are implemented and the same technical effects can be achieved, which will not be described in detail here.

[0119] The embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned string processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0120] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0121] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned string processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0122] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0123] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0125] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for processing a character string, characterized in that: The method comprises: Get the first character string input by the user through the input method; Calculating string scores of M candidate strings by using the error correction model of the input method, wherein the M candidate strings include: the first string, and (M-1) second strings obtained by correcting the first string; Outputting M candidate words, wherein the M candidate words are candidate words corresponding to the M candidate character strings; Wherein, the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior; Before obtaining the first character string input by the user through the input method, the method further includes: Collecting N pieces of historical error correction data of the user to obtain an error correction data set, wherein each piece of historical error correction data of the N pieces of historical error correction data includes an error correction type and an error correction content, and N is a positive integer; According to the error correction data set, update the value of each matrix element in the user weight matrix, wherein the value of a matrix element is the probability of being changed from a first state to a second state, wherein the first state is a state before the character string is modified, and the second state is a state after the character string is modified; Using the updated user weight matrix to train the first coefficient and the second coefficient in the error correction model; Among them, the first coefficient is the weight corresponding to the confusion matrix in the error correction model, and the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

2. The method according to claim 1, characterized in that Before collecting N pieces of historical error correction data of the user, the method includes: Record the user's N historical error correction logs, each of which includes: the character string before error correction, the character string after error correction, and the candidate word selected by the user; Align the pre-correction string and the post-correction string in each historical error correction log to determine the error correction type and error correction content corresponding to the N historical error correction logs; N pieces of error correction data are generated according to the error correction type and error correction content corresponding to each historical error correction log.

3. The method according to claim 1, characterized in that The string score of the first string is: the product of the logarithm of the uncorrected probability of each character in the first string and the first coefficient; The string score of a second string is: the product of the logarithm of the probability of non-error correction of each character in the second string and the first coefficient, and the sum of the influence coefficients of the error correction content, where the error correction content is the content in the second string that is corrected relative to the first string; The first coefficient is the weight corresponding to the confusion matrix in the error correction model.

4. The method according to claim 3, characterized in that The influence coefficient of the error correction content is: the sum of the first product and the second product; the first product is the product of the error correction probability corresponding to the error correction content based on the logarithm of the confusion matrix and the first coefficient, and the second product is the product of the error correction probability corresponding to the error correction content based on the logarithm of the user weight matrix and the second coefficient; Among them, the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

5. A string processing device, characterized in that: The string processing device comprises an acquisition module, a calculation module and an output module; The acquisition module is used to acquire a first character string input by a user through an input method; The calculation module is used to calculate the string scores of M candidate strings by using the error correction model of the input method, wherein the M candidate strings include: the first string and (M-1) second strings obtained by correcting the first string; The output module is used to output M candidate words, where the M candidate words are candidate words corresponding to the M candidate character strings; Wherein, the error correction model includes a confusion matrix and a user weight matrix, and the user weight matrix is ​​determined according to the user's historical input behavior; The string processing device also includes a collection module, an update module and a training module; The collection module is used to collect N pieces of historical error correction data of the user to obtain an error correction data set, each piece of the N pieces of historical error correction data includes an error correction type and an error correction content, and N is a positive integer; The updating module is used to update the value of each matrix element in the user weight matrix according to the error correction data set, wherein the value of a matrix element is the probability of being changed from a first state to a second state, wherein the first state is the state before the character string is modified, and the second state is the state after the character string is modified; The training module is used to train the first coefficient and the second coefficient in the error correction model using the updated user weight matrix; Among them, the first coefficient is the weight corresponding to the confusion matrix in the error correction model, and the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

6. The device according to claim 5, characterized in that The string processing device also includes a recording module, a determination module and a generation module; The recording module is used to record N historical error correction logs of the user, each of which includes: a character string before error correction, a character string after error correction, and a candidate word selected by the user; The determination module is used to align the pre-correction character string and the post-correction character string in each historical error correction log, and determine the error correction type and error correction content corresponding to the N historical error correction logs; The generating module is used to generate N pieces of error correction data according to the error correction type and error correction content corresponding to each piece of historical error correction log.

7. The device according to claim 5, characterized in that The string score of the first string is: the product of the logarithm of the uncorrected probability of each character in the first string and the first coefficient; The string score of a second string is: the product of the logarithm of the probability of non-error correction of each character in the second string and the first coefficient, and the sum of the influence coefficients of the error correction content, where the error correction content is the content in the second string that is corrected relative to the first string; The first coefficient is the weight corresponding to the confusion matrix in the error correction model.

8. The device according to claim 7, characterized in that The influence coefficient of the error correction content is: the sum of the first product and the second product; the first product is the product of the error correction probability corresponding to the error correction content based on the logarithm of the confusion matrix and the first coefficient, and the second product is the product of the error correction probability corresponding to the error correction content based on the logarithm of the user weight matrix and the second coefficient; Among them, the second coefficient is the weight corresponding to the user weight matrix in the error correction model.

Citation Information

Patent Citations

  • Candidate character string processing method and device, electronic equipment and storage medium

    CN111665956A