我的程序有一些问题。第 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);