-1
我正在加载一个包含近80,000个单词的文件。它将被用作主拼写检查字典。这些词的顺序已经被随机化了。还有另一个文件,我正在加载拼写错误的单词,我必须检查。它还提供拼写错误的单词的建议。自定义拼写检查生成错误
public void spellCheckDocument(ArrayList<String> dictionary){
long startCheck = System.currentTimeMillis();
for(String words: collectionOfParagraphs)
for(String word: words.split("[^a-zA-Z_0-9']+")){
int index = Collections.binarySearch(dictionary, word.toLowerCase());
if(index<0 && word.length()>0){
//collectionOfMisspelledWord.add(word+" Possible correct word: "+dictionary.get(-index+1)+" "+dictionary.get(-index)+" "+dictionary.get(-index-1));
//System.out.printf("%s Misspelled, possible correct words: %s, %s, %s\n", word, dictionary.get(-index+1),dictionary.get(-index),dictionary.get(-index-1));
possibleCorrectSpellings = new Document(word, dictionary.get(-index+1),dictionary.get(-index), dictionary.get(-index-1));
collectionOfMisspelledWord.add(possibleCorrectSpellings);
}
}
--------error----------
java.lang.IndexOutOfBoundsException: Index: 380, Size: 379
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at file.Document.spellCheckDocument(Document.java:82)
哪一行是82? – 2014-10-28 12:22:17
ssibleCorrectSpellings = new Document(word,dictionary.get(-index + 1),dictionary.get(-index),dictionary.get(-index-1)); – V15720002000 2014-10-28 12:23:54