句子生成器


 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 }

 

posted @ 2014-04-24 15:09  yiyi_xuechen  Views(2890)  Comments(0Edit  收藏  举报