我正在使用wearet3.0 来获取同义词和每个单词的光泽度......我已经附上了一段我的代码(一个搜索词方法),我有 2 个数组列表......我需要返回 2 个数组列表以供剩余操作....我该怎么做?我尝试使用 map ......但我仍然没有任何唯一的键来这样做......任何人都给我一些想法,我怎样才能获得数组列表(nums 和 nums1)的内容
public ArrayList<String> searchWord(String key)
{
nums.clear();
/* A word is having a different WordId in different synsets. Each Word is having a
* unique Index.
*/
//Get the index associated with the word, 'book' with Parts of Speech NOUN.
IIndexWord idxWord = idict.getIndexWord(key, POS.NOUN);
if(idxWord==null)
{
return nums;
}
System.out.println("Word ->"+key);
System.out.println("-------------");
System.out.println("-------------");
int i=1;
/*getWordIDs() returns all the WordID associated with a index
*
*/
IWord word;
ISynset wordSynset = null;
//if(StringUtils.isNotEmpty(idxWord.getWordIDs()))
for(IWordID wordID : idxWord.getWordIDs())
{
//Construct an IWord object representing word associated with wordID
word = idict.getWord(wordID);
//System.out.println("SENSE->"+i);
//System.out.println("---------");
wordSynset = word.getSynset();
System.out.print("Synset "+i+" {");
//Returns all the words present in the synset wordSynset
for(IWord synonym : wordSynset.getWords())
{
System.out.print(synonym.getLemma()+", ");
nums1.add(synonym.getLemma());
}
System.out.print("}"+"\n");
nums.add(wordSynset.getGloss());
for(String s:nums)
// {
// System.out.print(s);
// }
//Returns the gloss associated with the synset.
System.out.println("GLOSS -> "+wordSynset.getGloss());
System.out.println();
i++;
}
return nums;
// WordNetDatabase database=WordNetDatabase.getFileInstance();
}