Poetic walks
问题描述: 输入语料建立一个单词网络图,再对输入的语句,自动生成新的句子。
生成方法就是在单词网络图中寻找中间词,并插入生成新的句子
例如:
语料输入:
单词网络图:

输入:
Seek to explore new and exciting synergies!
输出:
Seek to explore strange new life and exciting synergies!
实现:
public class GraphPoet {
private final Graph<String> graph = Graph.empty(); //利用<String>替换<L>,意为建立一个节点类型为String的图
public GraphPoet(File corpus) throws IOException {
//利用corpus中的语料建立一个graph
}
public String poem(String input) {
//对于input的String,从graph中进行寻找并返回output String
}
}