1
嗨,朋友,我正在做我的最後一年的項目語義相似性之間的句子。 所以我使用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);
OUTPUT: 只有sentences[o]
(第一句詞的只有鞋的含義......一切換句話說不是循環...) 它表明這個錯誤..
**java.lang.ArrayIndexOutOfBoundsException: 0
at first_JWNL.main(first_JWNL.java:102)**
你的問題似乎不完整。你能修改嗎?另外,你會得到哪些錯誤? – kufudo 2013-02-13 06:09:55