List<String> words = Lists.newArrayList(Splitter.on(CharMatcher.WHITESPACE).trimResults().omitEmptyStrings()
.split(current));
List<String> tagged = tagger.tag(words);
IIndexWord idxWord;
List<IWordID> wordID;
IWord word;
StringBuilder outDef = new StringBuilder();
for (int i = 0; i < words.size(); i++) {
// System.out.println(i);
String definition = "";
if (table.containsKey(tagged.get(i))) {
if (nouns.containsKey(words.get(i))) {
words.set(i, nouns.get(words.get(i)));
}
try {
switch (table.get(tagged.get(i))) {
case (1):
idxWord = dict.getIndexWord(words.get(i), POS.NOUN);
if (idxWord == null)
break;
wordID = idxWord.getWordIDs();
word = dict.getWord(wordID.get(0));
definition = word.getSynset().getGloss();
break;
case (2):
tmpevent = port.createEventSet(words.get(i).toCharArray());
idxWord = dict.getIndexWord(tmpevent.eventAt(0).toString(), POS.VERB);
if (idxWord == null)
break;
wordID = idxWord.getWordIDs();
word = dict.getWord(wordID.get(0));
definition = word.getSynset().getGloss();
break;
case (3):
idxWord = dict.getIndexWord(words.get(i), POS.ADJECTIVE);
if (idxWord == null)
break;
wordID = idxWord.getWordIDs();
word = dict.getWord(wordID.get(0));
definition = word.getSynset().getGloss();
break;
case (4):
idxWord = dict.getIndexWord(words.get(i), POS.ADVERB);
if (idxWord == null)
break;
wordID = idxWord.getWordIDs();
word = dict.getWord(wordID.get(0));
definition = word.getSynset().getGloss();
break;
}