A computer implemented method for correcting a mistyped word resulting from at least one of an inaccurate keyboard input and a wrong keyboard layout, the method executable by a server, the method comprising, at a training phase:
- acquiring a first word from a corpus of text;
- selecting a first n-characters of the first word;
- selecting a first set of candidate characters for the first n-characters, each candidate character of the first set of candidate characters being a possible subsequent character to the first n-characters;
- assigning a candidate score value for each candidate character of the first set of candidate characters, the candidate score value being representative of a likelihood of a given candidate character of the first set of candidate characters to be a subsequent character to the first n-characters, the likelihood being determined based at least on a co-occurrence of the first n-characters and the given candidate character in the corpus of text;
- selecting a first top n-th candidate characters based on their respective candidate score value, the top n-th candidate characters forming a first subset of the first set of candidate characters;
- selecting a second subset of the first set of candidate characters, the second subset comprising candidate characters not included in the first subset of candidate characters;
- generating, for each of the candidate characters within the first subset of the first set, a respective positive reformulated word, the positive reformulated word corresponding to the first word having replaced at least the n+1 character with the respective candidate character from the first subset, each of the positive reformulated words and the first word forming a positive training pair with a first label value;
- generating, for each of the candidate characters within the second subset of the first set, a respective negative reformulated word, the negative reformulated word corresponding to the first word having replaced at least the n+1 character with the respective candidate character from the second subset, each of the negative reformulated words and the first word forming a negative training pair with a second label value,
- the positive training pairs and the negative training pairs forming training pairs, and each of the negative and positive reformulated words being a training word;
- training a machine learning algorithm (MLA), the training comprising:
- determining, for each training pairs, a set of features representative of a property of the training pairs;
- and
- based on the set of features associated with each training pairs, ranking the training pairs, a top ranked training pair being indicative of an absence of a mistype within the associated training word.