Created
February 14, 2012 22:11
-
-
Save graingert/1830956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Set<String> signatureToWords(String signature){ | |
Set<String> words = new HashSet<String>(); | |
int index = (Collections.binarySearch(dictionary, new WordSig("", signature))*-1-2); | |
//System.out.println("Index: "+index); | |
int x = index; | |
String currentSig = dictionary.get(x).getSig(); | |
String currentWord = dictionary.get(x).getWords(); | |
/** | |
if(PredictivePrototype.isValidWord(currentWord)){ | |
words.add(currentWord.toLowerCase()); | |
} | |
**/ | |
while(currentSig.equals(signature)){ | |
//System.out.println(x); | |
if(PredictivePrototype.isValidWord(currentWord.toLowerCase())&&PredictivePrototype.wordToSignature(currentWord).equals(signature)){ | |
words.add(currentWord.toLowerCase()); | |
} | |
currentSig = dictionary.get(x--).getSig(); | |
currentWord = dictionary.get(x).getWords(); | |
//System.out.println(dictionary.get(x).toString()); | |
} | |
while(currentSig.equals(signature)){ | |
if(PredictivePrototype.isValidWord(currentWord.toLowerCase())&&PredictivePrototype.wordToSignature(currentWord).equals(signature)){ | |
words.add(currentWord.toLowerCase()); | |
} | |
currentSig = dictionary.get(index++).getSig(); | |
currentWord = dictionary.get(index).getWords(); | |
//System.out.println(dictionary.get(x).toString()); | |
} | |
return words; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment