subject

KeyboardDistance is similar to LevenshteinDistance, it houses a single method, distance(x, y). It is very often the case that, when users are typing on a keyboard, they don't make random errors but they mistakenly press adjacent keys. Searching for all potential combinations of this type of mispellings would require programming techniques that we haven't yet covered, therefore, we're going to implement an oversimplified version of this concept. So, we will make the following assumptions:. ā€¢ A mispelled word will have the same length with the respective correct word (i. e. mispellings do not add/remove characters, they only alter the existing ones).
ā€¢ There won't be more than one mispellings in a single word.
ā€¢ For a misspelling to count as a misspelling, the user must have pressed the adjacent key that is either to the left or to the right of the intended key (1.e. not the key above below or any other key that is not adjacent).
ā€¢ The distance of a mispelled word from a correct word depends on the location of the mispelling: if the mispelling is in the first character, the distance is 1, if it's in the second character, the distance is 2. and so forth. If the two words are the same, the distance is 0. If the two words cannot count as a misspelling of each other, the distance is infinite (i. e. assign the maximum value that corresponds to the type of variable you declared). It goes without saying that this is a naive formula for a string distance but our goal here is different.
ā€¢ We will only consider one keyboard layout, the one depicted in this link. A mistyping can occur only in the 26 characters of the alphabet (i. e. not in numbers, special characters, etc.)
ā€¢ Characters A and z have one mistyping only: the characters 5 and X respectively i. e. disregard the caps lock and the shift keys). So, for example:
ā€¢ A mistyping of 'U' will become either an 'Y' or an 'I'
ā€¢ A mistyping of 'S' will become either an 'A' or a 'D'
ā€¢ A mistyping of 'A' can only become 'S' . Words unn and univerdity have a distance of 7
ā€¢ Words mason and mason have a distance of 0
ā€¢ Words Mason and MASON have an infinite distance Unit Testing We haven't provided JUnit tests for this class. You must write your own tests and put them in keyboardDistanceTests. java

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:00
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
question
Computers and Technology, 22.06.2019 17:00
Your company has 1,500 desktop computers running windows 7. you want to upgrade them to windows 10. which type of microsoft license would be best suited in this situation?
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
Which of the following statements is false? a. a class can directly inherit from class object. b. if the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. c. a class's instance variables are normally declared private to enforce good software engineering. d. it's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires.
Answers: 3
You know the right answer?
KeyboardDistance is similar to LevenshteinDistance, it houses a single method, distance(x, y). It is...
Questions
question
Mathematics, 05.05.2020 18:46