I’m about to create a "smart" dictionary that could generate similar words if the word from the user is not in the dictionary.
The dictionary starts with reading a file with words, the word should be added to the binary tree and a hash table. The hash table is used to determine if the word or similar word is in the dictionary, the hash Table will have a Boolean effect so we can fast look if the binary search tree contains the word. The hash Table has to be around ten times the length of our dictionary, because we also include similar words to the hash Table. As relatively new to Java, I would like tips and suggestions for how to make a hash function that would be ideal for my situation.
public String [] similarOne(String word) {
char [] word_array = word.toCharArray();
char [] tmp;
String [] words = new String[word_array.length-1];
for(int i = 0; i < word_array.length - 1; i++) {
tmp = word_array.clone();
words[i] = swap(i, i+1, tmp);
}
return words;
}
public String swap(int a, int b, char [] word) {
char tmp = word[a];
word[a] = word[b];
word[b] = tmp;
return new String(word);
}