}
public static void train(String modelDirectory, ObjectStream<CorefSample> samples,
boolean useTreebank, boolean useDiscourseModel) throws IOException {
TrainSimilarityModel simTrain = SimilarityModel.trainModel(modelDirectory + "/coref/sim");
TrainSimilarityModel genTrain = GenderModel.trainModel(modelDirectory + "/coref/gen");
TrainSimilarityModel numTrain = NumberModel.trainModel(modelDirectory + "/coref/num");
useTreebank = true;
Linker simLinker;
if (useTreebank) {
simLinker = new TreebankLinker(modelDirectory + "/coref/", LinkerMode.SIM);
}
else {
simLinker = new DefaultLinker(modelDirectory + "/coref/" ,LinkerMode.SIM);
}
// TODO: Feed with training data ...
for (CorefSample sample = samples.read(); sample != null; sample = samples.read()) {
Mention[] mentions = getMentions(sample, simLinker.getMentionFinder());
MentionContext[] extentContexts = simLinker.constructMentionContexts(mentions);
simTrain.setExtents(extentContexts);
genTrain.setExtents(extentContexts);
numTrain.setExtents(extentContexts);
}
simTrain.trainModel();
genTrain.trainModel();
numTrain.trainModel();
MaxentResolver.setSimilarityModel(SimilarityModel.testModel(modelDirectory + "/coref"+"/sim"));
// Done with similarity training