-1
거의 80,000 단어를 포함하는 파일을로드하고 있습니다. 기본 맞춤법 검사 사전으로 사용됩니다. 단어의 순서가 무작위로 지정되었습니다. 확인해야 할 철자가 틀린 단어가있는 다른 파일이 있습니다. 또한 맞춤법이 틀린 단어에 대한 제안을 제공합니다. Collections.binarySearch()의 문서에서사용자 지정 맞춤법 검사 오류 생성
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 줄은 어느 것입니까? –
ssibleCorrectSpellings = new 문서 (word, dictionary.get (-index + 1), dictionary.get (-index), dictionary.get (-index-1)); – V15720002000