|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.spell.KeyboardProximity
public class KeyboardProximity
Implementation of String
similarity measures with basis on
Keyboard proximity.
The keyboard is assumed to have a QWERTY layout, and we also make a distinction between keys on the same row of the keyboard (which therefore should be "more similar") and adjacent keys.
A large percentage of spelling mistakes are typographical errors, mainly due to keyboard typing slips (e.g. Jack becomes Hack since h and j are next to each other on the keyboard). Handling these errors is therefore of special importance.
Field Summary | |
---|---|
private static java.util.Map |
firstChars
Associates keys with a Map of adjacent keys in the same row of the keyboard. |
private static java.util.Map |
secondChars
Associates keys with a Map of adjacent keys but at diferent rows of the keyboard. |
private static KeyboardProximity |
theInstance
The single instance of this class. |
Constructor Summary | |
---|---|
private |
KeyboardProximity()
Sole constructor, private because this is a Singleton class. |
Method Summary | |
---|---|
static KeyboardProximity |
getInstance()
Return the single instance of this class. |
static boolean |
isNear(char ch1,
char ch2)
Check if two characters are adjacent in the keyboard. |
static boolean |
isSameRow(char ch1,
char ch2)
Check if two characters are adjacent in the same row of the keyboard. |
static int |
similarityStringsNear(java.lang.String s1,
java.lang.String s2)
Returns the similarity between two String objects in terms of the number of
different characters that are adjacent in the keyboard. |
static int |
similarityStringsSameRow(java.lang.String s1,
java.lang.String s2)
Returns the similarity between two String objects in terms of the number of
different characters that are adjacent in the same row of the keyboard. |
static boolean |
stringsNear(java.lang.String s1,
java.lang.String s2)
Check if two String objects differ in only one character adjacent in the keyboard. |
static boolean |
stringsNear(java.lang.String s1,
java.lang.String s2,
int n)
Check if two String objects differ in only a given number of characters adjacent in the keyboard. |
static boolean |
stringsSameRow(java.lang.String s1,
java.lang.String s2)
Check if two String objects differ in only one character adjacent in the same row of the keyboard. |
static boolean |
stringsSameRow(java.lang.String s1,
java.lang.String s2,
int n)
Check if two String objects differ in only a given number of characters adjacent in the same row of the keyboard. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.util.Map firstChars
Map
of adjacent keys in the same row of the keyboard.
private static java.util.Map secondChars
Map
of adjacent keys but at diferent rows of the keyboard.
private static final KeyboardProximity theInstance
Constructor Detail |
---|
private KeyboardProximity()
Method Detail |
---|
public static KeyboardProximity getInstance()
KeyboardProximity
.public static boolean isSameRow(char ch1, char ch2)
ch1
- A character.ch2
- Another character.
public static boolean isNear(char ch1, char ch2)
ch1
- A character.ch2
- Another character.
public static boolean stringsSameRow(java.lang.String s1, java.lang.String s2, int n)
String
objects differ in only a given number of characters adjacent in the same row of the keyboard.
s1
- A String
.s2
- Another String
.n
- the number of diferent characters.
public static boolean stringsSameRow(java.lang.String s1, java.lang.String s2)
String
objects differ in only one character adjacent in the same row of the keyboard.
s1
- A String
.s2
- Another String
.
public static boolean stringsNear(java.lang.String s1, java.lang.String s2, int n)
String
objects differ in only a given number of characters adjacent in the keyboard.
s1
- A String
.s2
- Another String
.n
- the maximum number of diferent characters.
public static boolean stringsNear(java.lang.String s1, java.lang.String s2)
String
objects differ in only one character adjacent in the keyboard.
s1
- A String
.s2
- Another String
.
public static int similarityStringsNear(java.lang.String s1, java.lang.String s2)
String
objects in terms of the number of
different characters that are adjacent in the keyboard.
s1
- A String
.s2
- Another String
.
public static int similarityStringsSameRow(java.lang.String s1, java.lang.String s2)
String
objects in terms of the number of
different characters that are adjacent in the same row of the keyboard.
s1
- A String
.s2
- Another String
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |