プログラムに問題があります。行番号 93 にエラーがあります。これを解決するには?
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at first_JWNL.main(first_JWNL.java:93)
コード
for (int i=0;i<sentences.length;i++)
{
System.out.println(i);
System.out.println(sentences[i]);
int wcount = sentences[i].split("\\s+").length;
String[] word1 = sentences[i].split(" ");
for (int j=0;j<wcount;j++){
System.out.println(j);
System.out.println(word1[j]);
String sen="one";
IndexWordSet set = wordnet.lookupAllIndexWords(word1[j]);
IndexWord[] ws = set.getIndexWordArray();
**POS p = ws[0].getPOS();**///////Line no 93
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);