public String expandTemplateTopic(String remark) {
String random_word = findKeyWord(remark);
String str=" ";
String kok2=" ";
int num1=0;
int num2=0;
int num3=0;
//find a random template
int number = generator.nextInt(sentenceList.size());
String argument=sentenceList.get(number).getTemplate();
//split it into words using space as delimiter
List ls=new LinkedList();
String[] array =argument.split (" ");
//find if there are %NOUN% words and if yes replace them with a synonym of the random_word
for (int i=0; i < array.length; i++) {
if (array[i].equals("%NOUN%")) {
System.out.println("Array["+i+"] is: "+array[i]);
[B] ls.addAll(word.getSynonyms(POS.NOUN,random_word) );[/B]
if (ls.size()>0) {
str=(String)ls.get(num1);
array[i]=str;
num1++;
for(int j=0;j<ls.size();j++)
System.out.println("ls "+j+" is:"+ls.get(j) );
} else array[i]=word.getNounAtRandom();
} ////find if there are %VERB% words and if yes replace them with a synonym of the random_word
else if (array[i].equals("%VERB%") ) {
System.out.println("Array["+i+"] is: "+array[i]);
[B] ls.addAll(word.getSynonyms(POS.VERB,random_word) );[/B]
if (ls.size()>0) {
str=(String)ls.get(num2);
array[i]=str;
num2++;
} else array[i]=word.getVerbAtRandom();
} //find if there are %ADJECTIVE% words and if yes replace them with a synonym of the random_word
else if (array[i].equals("%ADJECTIVE%")) {
System.out.println("Array["+i+"] is: "+array[i]);
[B]ls.addAll(word.getSynonyms(POS.ADJECTIVE,random_word) );[/B]
if (ls.size()>0) {
str=(String)ls.get(num3);
array[i]=str;
num3++;
} else array[i]=word.getAdjectiveAtRandom();
}//if
System.out.println("Array["+i+"] is: "+array[i]);
//clearing the List before the next loop
ls.clear();
}//for
//re-assemble the sentence with the replaced words
for (int k=1; k < array.length+1; k++) {
kok2=kok2.concat(" "+array[k-1]);
}
//and return it
return kok2;
}
Function compiles just fine but it pops warnings that i have unsafe or unchecked operations and with a little search i found that the problem is on the bold lines on my code when i use addAll()
Just to clarify, the function getSynonyms returns an arraylist with the synonyms of the word we give it and in the end all this is fed to addAll() as an argument.
Whats wrong with my code and the addAll?