public GenericModelWriter(AbstractModel model, Jfile file) { string filename = file.Name; OutputStream os; // handle the zipped/not zipped distinction if (filename.EndsWith(".gz", StringComparison.Ordinal)) { os = new GZIPOutputStream(new FileOutputStream(file)); filename = filename.Substring(0, filename.Length - 3); } else { os = new FileOutputStream(file); } // handle the different formats if (filename.EndsWith(".bin", StringComparison.Ordinal)) { init(model, new DataOutputStream(os)); } else // filename ends with ".txt" { init(model, new BufferedWriter(new OutputStreamWriter(os))); } }
public QNModelWriter(AbstractModel model) { object[] data = model.DataStructures; cParameters = (Context[])data[0]; pmap = (IndexHashTable <string>)data[1]; outcomeNames = (string[])data[2]; QNModel qnModel = (QNModel)model; parameters = qnModel.Parameters; }
private void init(AbstractModel model, BufferedWriter bw) { if (model.ModelType == ModelType.Perceptron) { delegateWriter = new PlainTextPerceptronModelWriter(model, bw); } else if (model.ModelType == ModelType.Maxent) { delegateWriter = new PlainTextGISModelWriter(model, bw); } }
private void init(AbstractModel model, DataOutputStream dos) { if (model.ModelType == ModelType.Perceptron) { delegateWriter = new BinaryPerceptronModelWriter(model, dos); } else if (model.ModelType == ModelType.Maxent) { delegateWriter = new BinaryGISModelWriter(model, dos); } else if (model.ModelType == ModelType.MaxentQn) { delegateWriter = new BinaryQNModelWriter(model, dos); } }
public static void Main(string[] args) { AbstractModel m = (new GenericModelReader(new Jfile(args[0]))).Model; (new GenericModelWriter(m, new Jfile(args[1]))).persist(); }
public GenericModelWriter(AbstractModel model, DataOutputStream dos) { init(model, dos); }