안녕하세요, 저는 문장 사이의 의미 상 유사성에 대한 마지막 해의 프로젝트를하고 있습니다. 그래서 나는 의미를 검색하기 위해 word-net 2.1 데이터베이스를 사용하고 있습니다. 각 줄마다 단어를 나눌 필요가 없습니다. 각 단어에서 나는 의미를 얻고 배열에 저장합니다. 그러나 그것은 첫 번째 문장의 의미만을 얻을 수 있습니다.처리 문제 해결 java.lang.ArrayIndexOutOfBoundsException
String[] sentences = result.split("[\\.\\!\\?]");
for (int i=0;i<sentences.length;i++)
{
System.out.println(i);
System.out.println(sentences[i]);
int wcount1 = sentences[i].split("\\s+").length;
System.out.println(wcount1);int wcount1=wordCount(w2);
System.out.println(wcount1);
String[] word1 = sentences[i].split(" ");
for (int j=0;j<wcount1;j++){
System.out.println(j);
System.out.println(word1[j]);
}
}
IndexWordSet set = wordnet.lookupAllIndexWords(word1[j]);
System.out.println(set);
IndexWord[] ws = set.getIndexWordArray();
**POS p = ws[0].getPOS();///line no 103**
Set<String> synonyms = new HashSet<String>();
IndexWord indexWord = wordnet.lookupIndexWord(p, word1[j]);
Synset[] synSets = indexWord.getSenses();
for (Synset synset : synSets)
{
Word[] words = synset.getWords();
for (Word word : words)
{
synonyms.add(word.getLemma());
}
}
System.out.println(synonyms);
출력 : 에만 sentences[o]
(첫 문장의 단어 유일의 신발 의미 ... 다른 모든 단어가 반복되지 않습니다 ...) 는이 오류를 보여 ..
**java.lang.ArrayIndexOutOfBoundsException: 0
at first_JWNL.main(first_JWNL.java:102)**
질문이 불완전한 것 같습니다. 너는 개정 할 수 있니? 또한, 어떤 라인에서 오류가 발생합니까? – kufudo