1 Set<String> SentenceGerneration(String pattern, 2 ArrayList<String> cand) { 3 size = cand.size();// corpus sentences size 4 newSentenceSet = new HashSet<String>(); 5 for (i = 0; i < size; i++) { 6 for (j = 0; j < size; j++) { 7 if (i == j) 8 continue; 9 parentSentence = cand.get(i); 10 childSentence = cand.get(j); 11 prefix = getPrefix( 12 parentSentence, pattern); 13 suffix = getSuffix( 14 childSentence, pattern); 15 // Judge a new sentence composed by prefix, pattern and suffix 16 if (IsLegal(prefix, pattern, suffix)) 17 newSentenceSet.add(prefix + " " +pattern + " " + suffix); 18 } 19 } 20 return newSentenceSet; 21 }