IP Library Granted Patent US 12682165
Granted Patent B2
US 12682165 · App. 18/492,434 · Granted Jul 14, 2026

Method and system for character-to-character modeling for word suggestion and auto-correction

Inventors: Ankit Prasad (Jamshedpur, IN); Rahul Prasad (Gurugram, IN); Achyut Saxena (Hathras, IN); Siddharth Agarwal (Kolkata, IN)
Assignee: TALENT UNLIMITED ONLINE SERVICES PRIVATE LIMITED
G06F40/274G06F40/284G06N3/0442
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12682165
App. No.
18/492,434
Granted
Jul 14, 2026
Kind
B2
Abstract

A method and a system for character-to-character modeling for next-word prediction and auto correction are provided. The method is based on character-to-character modeling. The method envisages the use of an edit distance and a hash table for creating valid candidates based on the cleaned input text, for next-word prediction and auto-correction. The next-word creation is performed when the input text ends with a space character and the auto-correction is performed when the input text ends with a letter. The edit distance and the hash table are employed to identify valid candidates and to remove invalid candidates. Furthermore, an encoder-decoder model is used to process the valid candidates, generate completed words, and subsequently create word suggestions based on the completed words. The word suggestions are subsequently optimized into highly probable candidates using a language model and a scoring and ranking algorithm.

Claims (42)

1 . A computer-implemented method executed by a hardware processor in a computer system to perform a character-to-character modelling for a next-word prediction and an auto-correction, the method comprising the following steps of:

a. inputting text in a text field by a user through a keyboard and performing a text cleaning, and wherein the text cleaning removes invalid characters in the inputted text provided by the user which generates a cleaned input text, and subjecting characters in the cleaned input text to a tokenization;

b. ensuring a last character of the cleaned input text is a space character or a letter

c. invoking the auto-correction, if in an event the cleaned input text ends with the letter the invoking of the auto-correction comprises the following steps:

i. creating candidates with an edit distance, wherein the candidates include possible word suggestions, wherein said possible word suggestions include first auto-corrected candidates generated as the user types the input text in the text field;

ii. using the hash table to: remove invalid candidates and obtain valid candidates wherein the hash table contains a valid prefix list, and wherein the valid candidates comprise only an alphabet of a set language desired by the user;

iii. assigning a first score to each of the valid candidates;

iv. passing each of the valid candidates to an encoder and a decoder to obtain completed words;

v. generating first word suggestions by concatenating each of the completed words, assigning a second score to each of the generated first word suggestions, and ranking each of the generated first word suggestions according to their respective second score;

vi. displaying the first word suggestions on a suggestion strip;

d. invoking the next-word prediction, in an event the cleaned input text with a space character and the step of invoking the next-word prediction comprises the following steps:

i. fetching second auto-corrected candidates from second generated word suggestions;

ii. calculating a third score for each of the second auto-corrected candidates and selecting a auto-corrected candidate of second auto-corrected candidates having a highest third score among the calculated third scores;

iii. generating the next-word prediction by replacing a last word of the cleaned input text with a threshold candidate, in an event the highest third score is greater than the score of the threshold candidate;

iv. selecting the cleaned input text as the next-word prediction, in an event the highest third score is less than the threshold candidate; and

v. obtaining the next-word prediction and displaying the next word prediction on the suggestion strip.

2 . The method of claim 1 , wherein the invalid characters include special characters excluding the space character, numbers, and other characters, excluding alphabets, and wherein the tokenization is a number-based representation for each letter in the cleaned input text.

3 . The method of claim 1 , wherein the hash table is employed to remove the invalid candidates based on the valid prefix list and obtain the valid candidates, wherein the valid prefix list comprises at least a minimum of one letter as an input, said input comprising only the alphabet of the set language, and provided with a corresponding token number, and the token number is a number representation for each letter in the cleaned input text, and the next-word prediction is invoked when the valid prefix list ends with a the space character, and the auto-correction is invoked when the valid prefix list ends with a letter.

4 . The method of claim 1 , wherein the method further includes: passing the valid candidates, obtained based on the valid prefix list, as an input to the encoder and decoding the completed words generated by the encoder through the decoder, wherein the encoder is a deep learning model created with a cascade interconnection of convolutional blocks comprising multiple convolutional layers and a bidirectional LSTM (Long Short-Term Memory), and wherein the decoder is a LSTM (Long Short Term Memory) based model for predicting the first word suggestions, and wherein the first word suggestions are displayed to the user along with the auto-correction after the user types the input text, and after encountering the space character;

wherein the deep learning model is composed of first multiple layers, including an embedding layer, a convolutional block comprising the multiple convolutional layers, and batch normalization, to generate the completed words that are passed onto the decoder, and wherein the embedding layer transforms the cleaned input text into dense numerical vectors and captures semantic relationships and contextual data, and wherein the convolutional block identifies local patterns in the cleaned input text and pulls out pertinent information from words nearer to the cleaned input text to predict a next word relevant to the cleaned input text, and wherein the bidirectional LSTM processes the cleaned input text simultaneously in a forward direction and a backward direction, thereby enabling the encoder to extract context from both past and future data, and wherein the bidirectional LSTM is assigned with weights usable as initial weights for the decoder; and

wherein the first word suggestions obtained from the decoder are optimized based on a beam search, a language model, by assigning a penalty, and by assigning the ranking, and wherein the language model controls the score assigned to the valid candidates based on the valid prefix list and the first word suggestions obtained from the decoder, and wherein the penalty influences the first score by checking the edit distance between the last word of the cleaned input text and each of the word suggestions obtained from the decoder and by penalizing the first score according to the distance between the valid candidates and the first word suggestions, and wherein the first word suggestions are ranked according to the second scores, to generate top-k score candidates.

5 . The method of claim 4 , wherein the decoder is configured to receive the completed words from the encoder and process said completed words using second multiple layers, including a second embedding layer, an LSTM layer, and a dense layer to provide the word suggestions, and wherein the LSTM layer collects and retains long-term dependencies in the completed words, and wherein the dense layer carries out a final classification operation in a the language model by translating learned dependencies into a desired output format.

6 . A computer-implemented system ( 200 ) comprising a hardware processor configured to execute computer-readable instructions stored on anon-transitory computer-readable storage medium to perform character-to-character modelling for next-word prediction and auto-correction, the system further comprising:

a. a data preparation module ( 206 ), executed by the hardware processor, configured to obtain input text by a user and perform text cleaning to generate cleaned input text by removing invalid characters from the input text, and wherein the data preparation module ( 206 ), executed by the hardware processor, is configured to invoke the auto-correction in an event the cleaned input text ends with a letter, said data preparation module ( 206 ), executed by the hardware processor, configured to implement the auto-correction by:

creating candidates with an edit distance, and wherein the candidates include possible word suggestions, wherein said possible word suggestions further include auto-corrected candidates generated as the user types the input text;

removing the invalid candidates and obtaining valid candidates by using a hash table containing a valid prefix list, and wherein the valid candidates comprise only an alphabet of a set language desired by the user;

said data preparation module ( 206 ), executed by the hardware processor, further configured to implement the next-word prediction in an event the cleaned input text ends with a space character, said data preparation module ( 206 ), executed by the hardware processor, further configured to implement the next-word prediction by:

fetching the auto-corrected candidates from first word suggestions generated by a prediction module ( 208 );

b. the prediction module ( 208 ), executed by the hardware processor, configured to:

assign a first score to each of the valid candidates;

pass each of the valid candidates to an encoder and a decoder and obtain completed words from the encoder and the decoder;

calculate a third score for each of the auto-corrected candidates fetched by the data preparation module ( 206 );

select an auto-corrected candidate with a highest third score and replace a last word of the cleaned text input with a threshold candidate to generate a modified cleaned input text; and

wherein the prediction module ( 208 ), executed by the hardware processor, is configured to implement the next-word prediction based on the modified cleaned input text in an event the highest third score is greater than the score of the threshold candidate, and wherein the prediction module ( 208 ), executed by the hardware processor, is further configured to select the cleaned input text as the next-word prediction, in an event the highest third score is less than the score of threshold candidate;

c. a word suggestion module ( 210 ), executed by the hardware processor, configured to generate the first word suggestions by concatenating each of the completed words generated by the prediction module ( 208 ), and by assigning a second score to each of generated first word suggestions, and by ranking each of the generated first word suggestions according to their respective second score, said word suggestion module ( 210 ), executed by the hardware processor, further configured to displaying the generated first word suggestions on a suggestion strip; and

d. a word prediction module ( 210 a ), executed by the hardware processor, configured to obtain the next-word prediction from the prediction module ( 208 ) and displaying the next word prediction on the suggestion strip.

7 . The system ( 200 ) as claimed in claim 6 , wherein the data preparation module ( 206 ), executed by the hardware processor, subjects characters in the cleaned input text to tokenization, wherein the invalid characters include special characters excluding the space character, numbers, and other characters excluding alphabets, and wherein the tokenization is a number-based representation for each letter in the cleaned input text.

8 . The system ( 200 ) as claimed in claim 6 , wherein the hash table is used by the data preparation module ( 206 ), executed by the hardware processor, to remove the invalid candidates based on the valid prefix list and to obtain the valid candidates, wherein the valid prefix list comprises at least a minimum of one letter as an input, said input comprising only the alphabet of the set language, and provided with a corresponding token number, and wherein the token number is a number representation for each letter in the cleaned input text, and wherein the next-word prediction is invoked when the valid prefix list ends with the space character, and auto-correction is invoked when the valid prefix list ends with a letter.

9 . The system ( 200 ) as claimed in claim 6 , wherein the valid candidates obtained based on the valid prefix list are passed onto the encoder as an input, and wherein the encoder is a deep learning model created with a cascade interconnection of convolutional blocks comprising multiple convolutional layers and a bidirectional LSTM (Lonq Short-Term Memory), and wherein the decoder is a LSTM (Long Short Term Memory) based model for predicting the first word suggestions, and wherein the first word suggestions are displayed to the user along with the auto-correction the user types the input text, and after encountering the space character;

wherein the deep learning model is composed of first multiple layers, including an embedding layer, a convolutional block comprising the multiple convolutional layers, and batch normalization, to generate the completed words that are passed onto the decoder, and wherein the embedding layer transforms the cleaned input text into dense numerical vectors and captures semantic relationships and contextual data, and wherein the convolutional block identifies local patterns in the cleaned input text and pulls out pertinent information from words nearer to the cleaned input text to predict a next word relevant to the cleaned input text, and wherein the bidirectional LSTM processes the cleaned input text simultaneously in a forward direction and a backward direction, thereby enabling the encoder to extract context from both past and future data, and wherein the bidirectional LSTM is assigned with weights usable as initial weights for the decoder; and

wherein the first word suggestions obtained from the decoder are optimized based on a beam search, a language model, by assigning a penalty, and by assigning the ranking, and wherein the language model controls the score assigned to the valid candidates based on the valid prefix list and the first word suggestions obtained from the decoder, and wherein the penalty influences the first score by checking the edit distance between the last word of the cleaned input text and each of the word suggestions obtained from the decoder and by penalizing the first score according to the distance between the valid candidates and the first word suggestions, and wherein the first word suggestions are ranked according to the second scores, to generate top-k score candidates.

10 . The system ( 200 ) as claimed in claim 9 , wherein the decoder is configured to receive the completed words from the encoder and process said completed words using second multiple layers, including a second embedding layer, an LSTM layer, and a dense layer to provide the word suggestions, and wherein the LSTM layer collects and retains long term dependencies in the completed words, and wherein the dense layer carries out a final classification operation in a the language model by translating learned dependencies into a desired output format.